📄 frmretreattable.vb
字号:
Me.bunSearch.TabIndex = 96
Me.bunSearch.Text = "搜索"
'
'bunAdd
'
Me.bunAdd.Location = New System.Drawing.Point(48, 152)
Me.bunAdd.Name = "bunAdd"
Me.bunAdd.Size = New System.Drawing.Size(40, 24)
Me.bunAdd.TabIndex = 94
Me.bunAdd.Text = "添加"
'
'bunUpdate
'
Me.bunUpdate.Location = New System.Drawing.Point(336, 152)
Me.bunUpdate.Name = "bunUpdate"
Me.bunUpdate.Size = New System.Drawing.Size(88, 24)
Me.bunUpdate.TabIndex = 100
Me.bunUpdate.Text = "更新到数据库"
'
'bunNext
'
Me.bunNext.Location = New System.Drawing.Point(288, 152)
Me.bunNext.Name = "bunNext"
Me.bunNext.Size = New System.Drawing.Size(32, 24)
Me.bunNext.TabIndex = 99
Me.bunNext.Text = ">>"
'
'bunCancel
'
Me.bunCancel.Location = New System.Drawing.Point(240, 152)
Me.bunCancel.Name = "bunCancel"
Me.bunCancel.Size = New System.Drawing.Size(40, 24)
Me.bunCancel.TabIndex = 98
Me.bunCancel.Text = "取消"
'
'frmRetreatTable
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(432, 190)
Me.Controls.Add(Me.bunPrevious)
Me.Controls.Add(Me.bunDelete)
Me.Controls.Add(Me.bunSave)
Me.Controls.Add(Me.bunSearch)
Me.Controls.Add(Me.bunAdd)
Me.Controls.Add(Me.bunUpdate)
Me.Controls.Add(Me.bunNext)
Me.Controls.Add(Me.bunCancel)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.txtDay)
Me.Controls.Add(Me.txtMonth)
Me.Controls.Add(Me.txtYear)
Me.Controls.Add(Me.txtRCount)
Me.Controls.Add(Me.txtOId)
Me.Controls.Add(Me.txtRId)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label2)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmRetreatTable"
Me.Text = "退货数据表"
Me.ResumeLayout(False)
End Sub
#End Region
Private myDataAdapter As New SqlClient.SqlDataAdapter
Private myDataReader As SqlClient.SqlDataReader
Private myDataSet As DataSet = New DataSet("retreat")
Private TableName As String
Private myIndex As Integer = 0
Private RowsMax As Integer
Private Sub Rshowfield()
If myIndex >= 0 Then
Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
Dim myRow As DataRow = currRows(myIndex)
txtRId.Text = myRow(0)
txtOId.Text = myRow(1)
txtRCount.Text = myRow(2)
txtYear.Text = Microsoft.VisualBasic.DateAndTime.Year(myRow(3))
txtMonth.Text = Microsoft.VisualBasic.DateAndTime.Month(myRow(3))
txtDay.Text = Microsoft.VisualBasic.DateAndTime.Day(myRow(3))
End If
End Sub
Private Sub bunCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunCancel.Click
On Error GoTo ErrorHandle
If RowsMax < 0 Then
txtOId.Text = ""
txtRId.Text = ""
txtRCount.Text = ""
txtYear.Text = ""
txtMonth.Text = ""
txtDay.Text = ""
Exit Sub
End If
Rshowfield()
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub bunDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunDelete.Click
On Error GoTo ErrorHandle
If RowsMax < 0 Then
MsgBox("库中没有可删除的记录!", , "退货数据表")
Exit Sub
End If
If MsgBox("是否删除?", 36, "提示") = vbYes Then
Dim myRow As DataRow = myDataSet.Tables(0).Rows(myIndex)
Dim strsql As String = "delete from retreat where r_id='" & myRow("r_id") & "'"
Dim mycommand As New SqlClient.SqlCommand(strsql, db)
db.Open()
mycommand.ExecuteNonQuery()
db.Close()
myRow.Delete()
myDataSet.AcceptChanges()
RowsMax = RowsMax - 1
If RowsMax >= 0 Then
myIndex = myIndex - 1
Rshowfield()
Exit Sub
Else
txtOId.Text = ""
txtRId.Text = ""
txtRCount.Text = ""
txtYear.Text = ""
txtMonth.Text = ""
txtDay.Text = ""
bunPrevious.Enabled = False
bunDelete.Enabled = False
bunSearch.Enabled = False
bunSave.Enabled = False
bunNext.Enabled = False
Exit Sub
End If
Else
Exit Sub
End If
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub bunNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunNext.Click
On Error Resume Next
If myIndex < RowsMax Then
myIndex = myIndex + 1
End If
Rshowfield()
End Sub
Private Sub bunPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunPrevious.Click
On Error Resume Next
If myIndex > 0 Then
myIndex = myIndex - 1
End If
Rshowfield()
End Sub
Private Sub bunSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunSave.Click
On Error GoTo ErrorHandle
Dim myRow As DataRow = myDataSet.Tables(0).Rows(myIndex)
myRow("r_count") = txtRCount.Text
myRow("r_date") = CDate(txtYear.Text & "/" & txtMonth.Text & "/" & txtDay.Text)
myDataSet.AcceptChanges()
Dim strsql As String = "update retreat set r_count='" & myRow("r_count") & "', r_date='" & myRow("r_date") & "' where r_id='" & myRow("r_id") & "'"
Dim mycommand As New SqlClient.SqlCommand(strsql, db)
db.Open()
mycommand.ExecuteNonQuery()
db.Close()
MsgBox("已经保存修改", , "退货数据表")
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub bunSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunSearch.Click
On Error GoTo ErrorHandle
Dim IDQuery As String
Dim myRow As DataRow
myIndex = 0
IDQuery = InputBox("输入要搜索的退货编号", "按退货编号搜索")
Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow In currRows
If myRow("r_id") Like "*" & LCase(IDQuery) & "*" Then
Rshowfield()
Exit Sub
Else
myIndex = myIndex + 1
End If
Next
MsgBox("没有找到符合条件的记录", , "退货数据表")
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub frmFactory_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
ShowStatus("数据管理--", "退货数据表")
End Sub
Private Sub frmFactory_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Me.Dispose()
Me.Close()
ShowStatus("", "")
RetreatTableOpened = False
TableMenuEnable()
End Sub
Private Sub bunUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunUpdate.Click
db.Open()
myDataAdapter.Update(myDataSet)
db.Close()
MsgBox("已经更新到数据库", , "退货数据表")
End Sub
Private Sub frmProduct_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
TableName = CurrentTable
Dim strSelectRetreat As String = "select * from Retreat"
Dim cmdSelectRetreat As New SqlClient.SqlCommand(strSelectRetreat, db)
myDataAdapter.SelectCommand = cmdSelectRetreat
Dim xx As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapter)
db.Open()
myDataAdapter.Fill(myDataSet)
db.Close()
bunAdd.Enabled = False
Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMax = currRows.Length - 1
If RowsMax < 0 Then
myIndex = -1
MsgBox("数据库中没有记录", , "退货数据表")
bunPrevious.Enabled = False
bunDelete.Enabled = False
bunSearch.Enabled = False
bunSave.Enabled = False
bunNext.Enabled = False
Else
Rshowfield()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -