📄 frmoutputtable.vb
字号:
Me.Label12.Location = New System.Drawing.Point(8, 184)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(80, 24)
Me.Label12.TabIndex = 83
Me.Label12.Text = " 退货数量:"
'
'bunPrevious
'
Me.bunPrevious.Location = New System.Drawing.Point(8, 288)
Me.bunPrevious.Name = "bunPrevious"
Me.bunPrevious.Size = New System.Drawing.Size(32, 24)
Me.bunPrevious.TabIndex = 85
Me.bunPrevious.Text = "<<"
'
'bunDelete
'
Me.bunDelete.Location = New System.Drawing.Point(96, 288)
Me.bunDelete.Name = "bunDelete"
Me.bunDelete.Size = New System.Drawing.Size(40, 24)
Me.bunDelete.TabIndex = 87
Me.bunDelete.Text = "删除"
'
'bunSave
'
Me.bunSave.Location = New System.Drawing.Point(192, 288)
Me.bunSave.Name = "bunSave"
Me.bunSave.Size = New System.Drawing.Size(40, 24)
Me.bunSave.TabIndex = 89
Me.bunSave.Text = "保存"
'
'bunSearch
'
Me.bunSearch.Location = New System.Drawing.Point(144, 288)
Me.bunSearch.Name = "bunSearch"
Me.bunSearch.Size = New System.Drawing.Size(40, 24)
Me.bunSearch.TabIndex = 88
Me.bunSearch.Text = "搜索"
'
'bunAdd
'
Me.bunAdd.Location = New System.Drawing.Point(48, 288)
Me.bunAdd.Name = "bunAdd"
Me.bunAdd.Size = New System.Drawing.Size(40, 24)
Me.bunAdd.TabIndex = 86
Me.bunAdd.Text = "添加"
'
'bunUpdate
'
Me.bunUpdate.Location = New System.Drawing.Point(336, 288)
Me.bunUpdate.Name = "bunUpdate"
Me.bunUpdate.Size = New System.Drawing.Size(88, 24)
Me.bunUpdate.TabIndex = 92
Me.bunUpdate.Text = "更新到数据库"
'
'bunNext
'
Me.bunNext.Location = New System.Drawing.Point(288, 288)
Me.bunNext.Name = "bunNext"
Me.bunNext.Size = New System.Drawing.Size(32, 24)
Me.bunNext.TabIndex = 91
Me.bunNext.Text = ">>"
'
'bunCancel
'
Me.bunCancel.Location = New System.Drawing.Point(240, 288)
Me.bunCancel.Name = "bunCancel"
Me.bunCancel.Size = New System.Drawing.Size(40, 24)
Me.bunCancel.TabIndex = 90
Me.bunCancel.Text = "取消"
'
'frmOutputTable
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(432, 326)
Me.Controls.Add(Me.txtRCount)
Me.Controls.Add(Me.txtBId)
Me.Controls.Add(Me.txtPId)
Me.Controls.Add(Me.txtDay)
Me.Controls.Add(Me.txtMonth)
Me.Controls.Add(Me.txtYear)
Me.Controls.Add(Me.txtOPrice)
Me.Controls.Add(Me.txtOCount)
Me.Controls.Add(Me.txtCId)
Me.Controls.Add(Me.txtOId)
Me.Controls.Add(Me.Label12)
Me.Controls.Add(Me.Label11)
Me.Controls.Add(Me.Label10)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label2)
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.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmOutputTable"
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("output")
Private TableName As String
Private myIndex As Integer = 0
Private RowsMax As Integer
Private Sub Oshowfield()
If myIndex >= 0 Then
Dim currRows() As DataRow = myDataSet.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
Dim myRow As DataRow = currRows(myIndex)
txtOId.Text = myRow(0)
txtCId.Text = myRow(1)
txtPId.Text = myRow(2)
txtBId.Text = myRow(3)
txtOCount.Text = myRow(4)
txtRCount.Text = myRow(5)
txtOPrice.Text = myRow(6)
txtYear.Text = Microsoft.VisualBasic.DateAndTime.Year(myRow(7))
txtMonth.Text = Microsoft.VisualBasic.DateAndTime.Month(myRow(7))
txtDay.Text = Microsoft.VisualBasic.DateAndTime.Day(myRow(7))
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 = ""
txtCId.Text = ""
txtPId.Text = ""
txtBId.Text = ""
txtOCount.Text = ""
txtRCount.Text = ""
txtOPrice.Text = ""
txtYear.Text = ""
txtMonth.Text = ""
txtDay.Text = ""
Exit Sub
End If
Oshowfield()
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 output where o_id='" & myRow("o_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
Oshowfield()
Exit Sub
Else
txtOId.Text = ""
txtCId.Text = ""
txtPId.Text = ""
txtBId.Text = ""
txtOCount.Text = ""
txtRCount.Text = ""
txtOPrice.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
Oshowfield()
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
Oshowfield()
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("o_count") = CLng(txtOCount.Text)
myRow("r_count") = CLng(txtRCount.Text)
myRow("o_price") = CSng(txtOPrice.Text)
myRow("o_date") = CDate(txtYear.Text & "/" & txtMonth.Text & "/" & txtDay.Text)
myDataSet.AcceptChanges()
Dim strsql As String = "update output set o_count=" & myRow("o_count") & ", r_count=" & myRow("r_count") & ", o_price=" & myRow("o_price") & ", o_date='" & myRow("o_date") & "' where o_id='" & myRow("o_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("o_id") Like "*" & LCase(IDQuery) & "*" Then
Oshowfield()
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("", "")
OutputTableOpened = 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 strSelectoutput As String = "select * from Output"
Dim cmdSelectoutput As New SqlClient.SqlCommand(strSelectoutput, db)
myDataAdapter.SelectCommand = cmdSelectoutput
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
Oshowfield()
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -