frmCardDj.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:15k
- Public Class frmCardDj
- Inherits System.Windows.Forms.Form
- #Region " Windows 窗体设计器生成的代码 "
- Public Sub New()
- MyBase.New()
- '该调用是 Windows 窗体设计器所必需的。
- InitializeComponent()
- '在 InitializeComponent() 调用之后添加任何初始化
- End Sub
- '窗体重写 dispose 以清理组件列表。
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- 'Windows 窗体设计器所必需的
- Private components As System.ComponentModel.IContainer
- '注意: 以下过程是 Windows 窗体设计器所必需的
- '可以使用 Windows 窗体设计器修改此过程。
- '不要使用代码编辑器修改它。
- Friend WithEvents tbncard As System.Windows.Forms.ToolBar
- Friend WithEvents tbnAdd As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbnSave As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbndelete As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbnExit As System.Windows.Forms.ToolBarButton
- Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents Label2 As System.Windows.Forms.Label
- Friend WithEvents Label3 As System.Windows.Forms.Label
- Friend WithEvents Label4 As System.Windows.Forms.Label
- Friend WithEvents txtnumber As System.Windows.Forms.TextBox
- Friend WithEvents txtname As System.Windows.Forms.TextBox
- Friend WithEvents txttype As System.Windows.Forms.TextBox
- Friend WithEvents txtZk As System.Windows.Forms.TextBox
- Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
- Friend WithEvents dgview As System.Windows.Forms.DataGrid
- Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.components = New System.ComponentModel.Container
- Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmCardDj))
- Me.tbncard = New System.Windows.Forms.ToolBar
- Me.tbnAdd = New System.Windows.Forms.ToolBarButton
- Me.tbnSave = New System.Windows.Forms.ToolBarButton
- Me.tbndelete = New System.Windows.Forms.ToolBarButton
- Me.tbnExit = New System.Windows.Forms.ToolBarButton
- Me.GroupBox1 = New System.Windows.Forms.GroupBox
- Me.txtZk = New System.Windows.Forms.TextBox
- Me.txttype = New System.Windows.Forms.TextBox
- Me.txtname = New System.Windows.Forms.TextBox
- Me.txtnumber = New System.Windows.Forms.TextBox
- Me.Label4 = New System.Windows.Forms.Label
- Me.Label3 = New System.Windows.Forms.Label
- Me.Label2 = New System.Windows.Forms.Label
- Me.Label1 = New System.Windows.Forms.Label
- Me.dgview = New System.Windows.Forms.DataGrid
- Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
- Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
- Me.GroupBox1.SuspendLayout()
- CType(Me.dgview, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'tbncard
- '
- Me.tbncard.Appearance = System.Windows.Forms.ToolBarAppearance.Flat
- Me.tbncard.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbnAdd, Me.tbnSave, Me.tbndelete, Me.tbnExit})
- Me.tbncard.DropDownArrows = True
- Me.tbncard.ImageList = Me.ImageList1
- Me.tbncard.Location = New System.Drawing.Point(0, 0)
- Me.tbncard.Name = "tbncard"
- Me.tbncard.ShowToolTips = True
- Me.tbncard.Size = New System.Drawing.Size(682, 44)
- Me.tbncard.TabIndex = 1
- '
- 'tbnAdd
- '
- Me.tbnAdd.ImageIndex = 7
- Me.tbnAdd.Text = "添加"
- '
- 'tbnSave
- '
- Me.tbnSave.ImageIndex = 4
- Me.tbnSave.Text = "保存"
- '
- 'tbndelete
- '
- Me.tbndelete.ImageIndex = 6
- Me.tbndelete.Text = "删除"
- '
- 'tbnExit
- '
- Me.tbnExit.ImageIndex = 11
- Me.tbnExit.Text = "退出"
- '
- 'GroupBox1
- '
- Me.GroupBox1.Controls.Add(Me.txtZk)
- Me.GroupBox1.Controls.Add(Me.txttype)
- Me.GroupBox1.Controls.Add(Me.txtname)
- Me.GroupBox1.Controls.Add(Me.txtnumber)
- Me.GroupBox1.Controls.Add(Me.Label4)
- Me.GroupBox1.Controls.Add(Me.Label3)
- Me.GroupBox1.Controls.Add(Me.Label2)
- Me.GroupBox1.Controls.Add(Me.Label1)
- Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Top
- Me.GroupBox1.Location = New System.Drawing.Point(0, 44)
- Me.GroupBox1.Name = "GroupBox1"
- Me.GroupBox1.Size = New System.Drawing.Size(682, 184)
- Me.GroupBox1.TabIndex = 2
- Me.GroupBox1.TabStop = False
- '
- 'txtZk
- '
- Me.txtZk.Location = New System.Drawing.Point(107, 144)
- Me.txtZk.Name = "txtZk"
- Me.txtZk.Size = New System.Drawing.Size(133, 25)
- Me.txtZk.TabIndex = 7
- Me.txtZk.Text = ""
- '
- 'txttype
- '
- Me.txttype.Location = New System.Drawing.Point(107, 103)
- Me.txttype.Name = "txttype"
- Me.txttype.Size = New System.Drawing.Size(133, 25)
- Me.txttype.TabIndex = 6
- Me.txttype.Text = ""
- '
- 'txtname
- '
- Me.txtname.Location = New System.Drawing.Point(107, 62)
- Me.txtname.Name = "txtname"
- Me.txtname.Size = New System.Drawing.Size(133, 25)
- Me.txtname.TabIndex = 5
- Me.txtname.Text = ""
- '
- 'txtnumber
- '
- Me.txtnumber.Location = New System.Drawing.Point(107, 21)
- Me.txtnumber.Name = "txtnumber"
- Me.txtnumber.Size = New System.Drawing.Size(133, 25)
- Me.txtnumber.TabIndex = 4
- Me.txtnumber.Text = ""
- '
- 'Label4
- '
- Me.Label4.AutoSize = True
- Me.Label4.Location = New System.Drawing.Point(32, 154)
- Me.Label4.Name = "Label4"
- Me.Label4.Size = New System.Drawing.Size(75, 21)
- Me.Label4.TabIndex = 3
- Me.Label4.Text = "会员折扣:"
- '
- 'Label3
- '
- Me.Label3.AutoSize = True
- Me.Label3.Location = New System.Drawing.Point(32, 113)
- Me.Label3.Name = "Label3"
- Me.Label3.Size = New System.Drawing.Size(75, 21)
- Me.Label3.TabIndex = 2
- Me.Label3.Text = "会员类型:"
- '
- 'Label2
- '
- Me.Label2.AutoSize = True
- Me.Label2.Location = New System.Drawing.Point(32, 72)
- Me.Label2.Name = "Label2"
- Me.Label2.Size = New System.Drawing.Size(75, 21)
- Me.Label2.TabIndex = 1
- Me.Label2.Text = "会员名称:"
- '
- 'Label1
- '
- Me.Label1.AutoSize = True
- Me.Label1.Location = New System.Drawing.Point(32, 31)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(75, 21)
- Me.Label1.TabIndex = 0
- Me.Label1.Text = "会员编号:"
- '
- 'dgview
- '
- Me.dgview.DataMember = ""
- Me.dgview.Dock = System.Windows.Forms.DockStyle.Fill
- Me.dgview.HeaderForeColor = System.Drawing.SystemColors.ControlText
- Me.dgview.Location = New System.Drawing.Point(0, 228)
- Me.dgview.Name = "dgview"
- Me.dgview.Size = New System.Drawing.Size(682, 241)
- Me.dgview.TabIndex = 3
- '
- 'ErrorProvider1
- '
- Me.ErrorProvider1.ContainerControl = Me
- '
- 'ImageList1
- '
- Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
- Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
- Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
- '
- 'frmCardDj
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(8, 18)
- Me.ClientSize = New System.Drawing.Size(682, 469)
- Me.Controls.Add(Me.dgview)
- Me.Controls.Add(Me.GroupBox1)
- Me.Controls.Add(Me.tbncard)
- Me.Name = "frmCardDj"
- Me.Text = "会员登记"
- Me.GroupBox1.ResumeLayout(False)
- CType(Me.dgview, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public lsweb As New jxcmanage
- Public dslocals As New DataSet
- Public Sub tbnEnable(ByVal strboolean As String, ByVal tbr As ToolBar)
- If strboolean = "tbnAdd.Enabled = True" Then
- tbnSave.Enabled = False
- tbndelete.Enabled = False
- tbnExit.Enabled = True
- ElseIf strboolean = "tbnAdd.Enabled = False" Then
- tbnAdd.Enabled = False
- tbnSave.Enabled = True
- tbndelete.Enabled = False
- tbnExit.Enabled = True
- ElseIf strboolean = "tbnSave.Enabled = True" Then
- tbnAdd.Enabled = False
- tbndelete.Enabled = False
- tbnExit.Enabled = True
- ElseIf strboolean = "tbnSave.Enabled = False" Then
- tbnSave.Enabled = False
- tbnAdd.Enabled = True
- tbndelete.Enabled = True
- tbnExit.Enabled = True
- ElseIf strboolean = "tbnDelete.Enabled = True" Then
- tbnAdd.Enabled = False
- tbnSave.Enabled = True
- tbnExit.Enabled = True
- ElseIf strboolean = "tbnDelete.Enabled = False" Then
- tbndelete.Enabled = False
- tbnAdd.Enabled = False
- tbnSave.Enabled = True
- tbnExit.Enabled = True
- End If
- End Sub
- Private Sub txtnumber_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtnumber.KeyDown
- If e.KeyCode = Keys.Enter Then
- txtname.Focus()
- End If
- End Sub
-
- Private Sub txtname_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtname.KeyDown
- If e.KeyCode = Keys.Enter Then
- txttype.Focus()
- End If
- End Sub
-
- Private Sub txttype_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txttype.KeyDown
- If e.KeyCode = Keys.Enter Then
- txtZk.Focus()
- End If
- End Sub
- Private Sub add()
- txtnumber.Text = "".Trim()
- txtname.Text = "".Trim()
- txttype.Text = ""
- txtZk.Text = ""
- txtnumber.Focus()
- End Sub
- Private Sub save()
- dslocals = lsweb.returndataset("select * from mdcard", "mdcard")
- Dim dr As DataRow = dslocals.Tables(0).NewRow()
- dr("会员编号") = txtnumber.Text.Trim
- dr("会员名称") = txtname.Text.Trim
- dr("会员类型") = txttype.Text.Trim
- dr("会员折扣") = txtZk.Text.Trim
- dslocals.Tables(0).Rows.Add(dr)
- If lsweb.updatedataset("select * from mdcard", "mdcard", dslocals, DataRowState.Added) = True Then
- MessageBox.Show("信息成功保存!", "提示", MessageBoxButtons.OK)
- Else
- MessageBox.Show("信息保存失败!", "提示", MessageBoxButtons.AbortRetryIgnore)
- End If
- End Sub
- Private Sub delete()
- Dim drv As DataRowView = BindingContext(Me.dgview.DataSource).Current
- If drv(1) Is System.DBNull.Value Then
- MessageBox.Show("没有要删除的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim strquery As String = drv(1)
- lsweb.runSql("delete from mdcard where 会员名称='" & strquery & "'")
- MessageBox.Show("已经删除记录啦!", "提示", MessageBoxButtons.OK)
- End If
- End Sub
- Private Sub view()
- Dim drv As DataRowView = BindingContext(Me.dgview.DataSource).Current
- Dim dr As DataRow
- dr = drv.Row
- txtnumber.Text = IIf(dr("会员编号") Is System.DBNull.Value, "", dr("会员编号"))
- txtname.Text = IIf(dr("会员名称") Is System.DBNull.Value, "", dr("会员名称"))
- txttype.Text = IIf(dr("会员类型") Is System.DBNull.Value, "", dr("会员类型"))
- txtZk.Text = IIf(dr("会员折扣") Is System.DBNull.Value, "", dr("会员折扣"))
- End Sub
- Private Sub frmCardDj_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- dslocals = lsweb.returndataset("select * from mdcard", "mdcard")
- dgview.DataSource = dslocals.Tables("mdcard").DefaultView
- End Sub
-
- Private Sub dgview_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgview.CurrentCellChanged
- view()
- tbndelete.Enabled = True
- tbnExit.Enabled = True
- End Sub
- Private Sub tbncard_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbncard.ButtonClick
- Select Case e.Button.Text
- Case "添加"
- add()
- tbnEnable("tbnAdd.Enabled = False", tbncard)
- dslocals.Clear()
- Case "保存"
- If txtnumber.Text = "" Or txtname.Text = "" Then
- MessageBox.Show("信息不完整,保存失败!", "提示", MessageBoxButtons.OK)
- Else
- save()
- tbnEnable("tbnSave.Enabled = False", tbncard)
- End If
-
- Case "删除"
- delete()
- tbnEnable("tbnDelete.Enabled = False", tbncard)
- Case "退出"
- Me.Close()
- End Select
- End Sub
-
- Private Sub txtnumber_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtnumber.Validating
- If txtnumber.Text = String.Empty Then
- ErrorProvider1.SetError(txtnumber, "不能为空!")
- txtnumber.Focus()
- Else
- ErrorProvider1.SetError(txtnumber, "")
- End If
- End Sub
- Private Sub txtname_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtname.Validating
- If txtname.Text = String.Empty Then
- ErrorProvider1.SetError(txtname, "不能为空!")
- txtname.Focus()
- Else
- ErrorProvider1.SetError(txtname, "")
- End If
- End Sub
- Private Sub txttype_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txttype.Validating
- If txttype.Text = String.Empty Then
- ErrorProvider1.SetError(txttype, "不能为空!")
- txttype.Focus()
- Else
- ErrorProvider1.SetError(txttype, "")
- End If
- End Sub
-
- Private Sub txtZk_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtZk.Validating
- If Not IsNumeric(txtZk.Text) Or txtZk.Text = String.Empty Then
- ErrorProvider1.SetError(txtZk, "不是数值类型且不能为空。")
- txtZk.Focus()
- Else
- ErrorProvider1.SetError(txtZk, "")
- End If
- End Sub
- End Class