frmHw.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:10k
- Public Class frmHw
- 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 tbnHw As System.Windows.Forms.ToolBar
- Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
- Friend WithEvents tbnAdd As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbnSave As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbnExit As System.Windows.Forms.ToolBarButton
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents Label2 As System.Windows.Forms.Label
- Friend WithEvents txtnumber As System.Windows.Forms.TextBox
- Friend WithEvents txtname As System.Windows.Forms.TextBox
- Friend WithEvents dgview As System.Windows.Forms.DataGrid
- Friend WithEvents tbndelete As System.Windows.Forms.ToolBarButton
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.tbnHw = 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.txtname = New System.Windows.Forms.TextBox
- Me.txtnumber = New System.Windows.Forms.TextBox
- Me.Label2 = New System.Windows.Forms.Label
- Me.Label1 = New System.Windows.Forms.Label
- Me.dgview = New System.Windows.Forms.DataGrid
- Me.GroupBox1.SuspendLayout()
- CType(Me.dgview, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'tbnHw
- '
- Me.tbnHw.Appearance = System.Windows.Forms.ToolBarAppearance.Flat
- Me.tbnHw.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbnAdd, Me.tbnSave, Me.tbndelete, Me.tbnExit})
- Me.tbnHw.DropDownArrows = True
- Me.tbnHw.Location = New System.Drawing.Point(0, 0)
- Me.tbnHw.Name = "tbnHw"
- Me.tbnHw.ShowToolTips = True
- Me.tbnHw.Size = New System.Drawing.Size(200, 41)
- Me.tbnHw.TabIndex = 0
- '
- 'tbnAdd
- '
- Me.tbnAdd.Text = "添加"
- '
- 'tbnSave
- '
- Me.tbnSave.Text = "保存"
- '
- 'tbndelete
- '
- Me.tbndelete.Text = "删除"
- '
- 'tbnExit
- '
- Me.tbnExit.Text = "退出"
- '
- 'GroupBox1
- '
- Me.GroupBox1.Controls.Add(Me.txtname)
- Me.GroupBox1.Controls.Add(Me.txtnumber)
- 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, 41)
- Me.GroupBox1.Name = "GroupBox1"
- Me.GroupBox1.Size = New System.Drawing.Size(200, 80)
- Me.GroupBox1.TabIndex = 1
- Me.GroupBox1.TabStop = False
- '
- 'txtname
- '
- Me.txtname.Location = New System.Drawing.Point(80, 48)
- Me.txtname.Name = "txtname"
- Me.txtname.TabIndex = 3
- Me.txtname.Text = ""
- '
- 'txtnumber
- '
- Me.txtnumber.Location = New System.Drawing.Point(80, 16)
- Me.txtnumber.Name = "txtnumber"
- Me.txtnumber.TabIndex = 2
- Me.txtnumber.Text = ""
- '
- 'Label2
- '
- Me.Label2.AutoSize = True
- Me.Label2.Location = New System.Drawing.Point(24, 56)
- Me.Label2.Name = "Label2"
- Me.Label2.Size = New System.Drawing.Size(60, 17)
- Me.Label2.TabIndex = 1
- Me.Label2.Text = "货位名称:"
- '
- 'Label1
- '
- Me.Label1.AutoSize = True
- Me.Label1.Location = New System.Drawing.Point(24, 24)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(60, 17)
- 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, 121)
- Me.dgview.Name = "dgview"
- Me.dgview.Size = New System.Drawing.Size(200, 116)
- Me.dgview.TabIndex = 2
- '
- 'frmHw
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
- Me.ClientSize = New System.Drawing.Size(200, 237)
- Me.Controls.Add(Me.dgview)
- Me.Controls.Add(Me.GroupBox1)
- Me.Controls.Add(Me.tbnHw)
- Me.Name = "frmHw"
- 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
- Private Sub frmHw_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- dslocals = lsweb.returndataset("select * from wz_hw", "wz_hw")
- dgview.DataSource = dslocals.Tables("wz_hw").DefaultView
- End Sub
- Private Sub save()
- dslocals = lsweb.returndataset("select * from wz_hw", "wz_hw")
- Dim dr As DataRow = dslocals.Tables(0).NewRow()
- dr("货位编号") = txtnumber.Text.Trim
- dr("货位") = txtname.Text.Trim
-
- dslocals.Tables(0).Rows.Add(dr)
- If lsweb.updatedataset("select * from wz_hw", "wz_hw", dslocals, DataRowState.Added) = True Then
- MessageBox.Show("信息成功保存!", "提示", MessageBoxButtons.OK)
- Else
- MessageBox.Show("信息保存失败!", "提示", MessageBoxButtons.AbortRetryIgnore)
- End If
- End Sub
- Private Sub add()
- txtnumber.Text = "".Trim()
- txtname.Text = "".Trim()
- txtnumber.Focus()
- 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 wz_hw 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("货位"))
-
- End Sub
- 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 dgview_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dgview.Navigate
- 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 tbnHw_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbnHw.ButtonClick
- Select Case e.Button.Text
- Case "添加"
- add()
- tbnEnable("tbnAdd.Enabled = False", tbnHw)
- dslocals.Clear()
- Case "保存"
- If txtnumber.Text = "" Then
- MessageBox.Show("信息不完整,保存失败!", "提示", MessageBoxButtons.OK)
- Else
- save()
- tbnEnable("tbnSave.Enabled = False", tbnHw)
- End If
- Case "删除"
- delete()
- tbnEnable("tbnDelete.Enabled = False", tbnHw)
- Case "退出"
- Me.Close()
- End Select
- End Sub
- Private Sub txtnumber_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnumber.TextChanged
- End Sub
- End Class