📄 frmretreat.vb
字号:
Me.txtCName.TabIndex = 152
Me.txtCName.Text = ""
'
'Label15
'
Me.Label15.ForeColor = System.Drawing.Color.Red
Me.Label15.Location = New System.Drawing.Point(24, 80)
Me.Label15.Name = "Label15"
Me.Label15.Size = New System.Drawing.Size(80, 24)
Me.Label15.TabIndex = 151
Me.Label15.Text = "※客户名称:"
'
'txtODay
'
Me.txtODay.BackColor = System.Drawing.SystemColors.Window
Me.txtODay.Enabled = False
Me.txtODay.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtODay.Location = New System.Drawing.Point(496, 40)
Me.txtODay.Name = "txtODay"
Me.txtODay.Size = New System.Drawing.Size(40, 21)
Me.txtODay.TabIndex = 158
Me.txtODay.Text = ""
'
'txtOMonth
'
Me.txtOMonth.BackColor = System.Drawing.SystemColors.Window
Me.txtOMonth.Enabled = False
Me.txtOMonth.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtOMonth.Location = New System.Drawing.Point(440, 40)
Me.txtOMonth.Name = "txtOMonth"
Me.txtOMonth.Size = New System.Drawing.Size(40, 21)
Me.txtOMonth.TabIndex = 157
Me.txtOMonth.Text = ""
'
'txtOYear
'
Me.txtOYear.BackColor = System.Drawing.SystemColors.Window
Me.txtOYear.Enabled = False
Me.txtOYear.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtOYear.Location = New System.Drawing.Point(360, 40)
Me.txtOYear.Name = "txtOYear"
Me.txtOYear.Size = New System.Drawing.Size(64, 21)
Me.txtOYear.TabIndex = 153
Me.txtOYear.Text = ""
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(536, 48)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(16, 16)
Me.Label7.TabIndex = 156
Me.Label7.Text = "日"
'
'Label12
'
Me.Label12.Location = New System.Drawing.Point(480, 48)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(16, 16)
Me.Label12.TabIndex = 155
Me.Label12.Text = "月"
'
'Label13
'
Me.Label13.Location = New System.Drawing.Point(424, 48)
Me.Label13.Name = "Label13"
Me.Label13.Size = New System.Drawing.Size(16, 16)
Me.Label13.TabIndex = 154
Me.Label13.Text = "年"
'
'bunSearch
'
Me.bunSearch.Location = New System.Drawing.Point(24, 168)
Me.bunSearch.Name = "bunSearch"
Me.bunSearch.Size = New System.Drawing.Size(40, 24)
Me.bunSearch.TabIndex = 159
Me.bunSearch.Text = "查询"
'
'frmRetreat
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(560, 206)
Me.Controls.Add(Me.bunSearch)
Me.Controls.Add(Me.txtODay)
Me.Controls.Add(Me.txtOMonth)
Me.Controls.Add(Me.txtOYear)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label12)
Me.Controls.Add(Me.Label13)
Me.Controls.Add(Me.txtRCount)
Me.Controls.Add(Me.txtCName)
Me.Controls.Add(Me.Label15)
Me.Controls.Add(Me.Label14)
Me.Controls.Add(Me.txtOId)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.txtProduct)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.bunAddRetreatCanel)
Me.Controls.Add(Me.bunUpdate)
Me.Controls.Add(Me.bunAddRetreat)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtDay)
Me.Controls.Add(Me.txtMonth)
Me.Controls.Add(Me.txtYear)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.Label10)
Me.Controls.Add(Me.Label11)
Me.Controls.Add(Me.txtOCount)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.txtRId)
Me.Controls.Add(Me.Label2)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmRetreat"
Me.Text = "退货登记"
Me.ResumeLayout(False)
End Sub
#End Region
Dim OCount As Long
Dim RCount As Long
Private myDataAdapterRetreat As New SqlClient.SqlDataAdapter
Private myDataSetRetreat As DataSet = New DataSet("retreat")
Private RowsMaxRetreat As Integer
Private RID As String
Private myDataAdapterOutput As New SqlClient.SqlDataAdapter
Private myDataSetOutput As DataSet = New DataSet("Output")
Private myDataAdapterBusinessman As New SqlClient.SqlDataAdapter
Private myDataSetBusinessman As DataSet = New DataSet("Businessmand")
Private myDataSetProduct As DataSet = New DataSet("Product")
Private myDataAdapterProduct As New SqlClient.SqlDataAdapter
Private myDataSetStore As DataSet = New DataSet("Store")
Private myDataAdapterStore As New SqlClient.SqlDataAdapter
Private myDataSetCustomer As DataSet = New DataSet("Customer")
Private mydataadapterCustomer As New SqlClient.SqlDataAdapter
Private OID As String
Private SID As String
Private CID As String
Private PID As String
Private BID As String
Private Price As Single
Private Sub SetRetreatID()
Dim CountInTable As Integer
If RowsMaxRetreat >= 0 Then
CountInTable = RowsMaxRetreat + 2
RID = "r" & Format(CountInTable, "000000000")
Else
RID = "r000000001"
End If
txtRId.Text = RID
End Sub
Public Sub IfCanAddRetreat()
If (txtRCount.Text <> "") And (txtYear.Text <> "") And (txtMonth.Text <> "") And (txtDay.Text <> "") Then
bunAddRetreat.Enabled = True
Else
bunAddRetreat.Enabled = False
End If
End Sub
Private Sub frmRetreat_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtYear.Text = Microsoft.VisualBasic.DateAndTime.Year(Now)
txtMonth.Text = Microsoft.VisualBasic.DateAndTime.Month(Now)
txtDay.Text = Microsoft.VisualBasic.DateAndTime.Day(Now)
ShowStatus("退货登记", "")
Dim strSelectOutput As String = "select * from output"
Dim cmdSelectOutput As New SqlClient.SqlCommand(strSelectOutput, db)
myDataAdapterOutput.SelectCommand = cmdSelectOutput
Dim strSelectRetreat As String = "select * from retreat"
Dim cmdSelectRetreat As New SqlClient.SqlCommand(strSelectRetreat, db)
myDataAdapterRetreat.SelectCommand = cmdSelectRetreat
Dim xxRetreat As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapterRetreat)
Dim strSelectBusinessman As String = "select * from businessman"
Dim cmdSelectBusinessman As New SqlClient.SqlCommand(strSelectBusinessman, db)
myDataAdapterBusinessman.SelectCommand = cmdSelectBusinessman
Dim strSelectCustomer As String = "select * from customer"
Dim cmdSelectCustomer As New SqlClient.SqlCommand(strSelectCustomer, db)
mydataadapterCustomer.SelectCommand = cmdSelectCustomer
Dim strSelectStore As String = "select * from store"
Dim cmdselectstore As New SqlClient.SqlCommand(strSelectStore, db)
myDataAdapterStore.SelectCommand = cmdselectstore
Dim strSelectProduct As String = "select * from product"
Dim cmdSelectProduct As New SqlClient.SqlCommand(strSelectProduct, db)
myDataAdapterProduct.SelectCommand = cmdSelectProduct
db.Open()
myDataAdapterRetreat.Fill(myDataSetRetreat)
myDataAdapterOutput.Fill(myDataSetOutput)
myDataAdapterProduct.Fill(myDataSetProduct)
myDataAdapterBusinessman.Fill(myDataSetBusinessman)
myDataAdapterStore.Fill(myDataSetStore)
mydataadapterCustomer.Fill(myDataSetCustomer)
db.Close()
Dim currRows() As DataRow = myDataSetRetreat.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxRetreat = currRows.Length - 1
IfCanAddRetreat()
On Error GoTo ErrorHandle
SetRetreatID()
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub frmRetreat_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
ShowStatus("", "")
frmMain1.mnuTrade.MenuItems(2).Enabled = True
End Sub
Private Sub bunAddRetreat_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddRetreat.Click
On Error GoTo ErrorHandle
Dim myRow As DataRow = myDataSetRetreat.Tables(0).NewRow
myRow("r_id") = txtRId.Text
myRow("o_id") = OID
myRow("r_count") = CLng(txtRCount.Text)
myRow("r_date") = CDate(txtYear.Text & "/" & txtMonth.Text & "/" & txtDay.Text)
myDataSetRetreat.Tables(0).Rows.Add(myRow)
RCount = RCount + CLng(txtRCount.Text)
OCount = OCount - CLng(txtRCount.Text)
Dim strsqlOutput As String = "update output set r_count='" & RCount & "', o_count='" & OCount & "' where o_id='" & OID & "'"
Dim mycommandOutput As New SqlClient.SqlCommand(strsqlOutput, db)
Dim strsqlBusinessman As String = "update businessman set b_trades=b_trades-" & Price * CSng(txtRCount.Text) & " where b_id='" & BID & "'"
Dim mycommandBusinessman As New SqlClient.SqlCommand(strsqlBusinessman, db)
Dim strsqlStore As String = "update store set s_count=s_count+" & CLng(txtRCount.Text) & " where p_id='" & PID & "'"
Dim mycommandStore As New SqlClient.SqlCommand(strsqlStore, db)
db.Open()
mycommandOutput.ExecuteNonQuery()
mycommandBusinessman.ExecuteNonQuery()
mycommandStore.ExecuteNonQuery()
db.Close()
MsgBox("已添加到数据库", , "退货登记")
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub txtDay_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDay.TextChanged
IfCanAddRetreat()
End Sub
Private Sub txtMonth_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMonth.TextChanged
IfCanAddRetreat()
End Sub
Private Sub txtYear_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtYear.TextChanged
IfCanAddRetreat()
End Sub
Private Sub bunUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunUpdate.Click
db.Open()
myDataAdapterRetreat.Update(myDataSetRetreat)
myDataAdapterStore.Update(myDataSetStore)
myDataAdapterBusinessman.Update(myDataSetBusinessman)
myDataAdapterOutput.Update(myDataSetOutput)
db.Close()
MsgBox("已更新到数据库", , "退货登记")
End Sub
Private Sub bunAddRetreatCanel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddRetreatCanel.Click
Me.Close()
frmMain1.mnuTrade.MenuItems(2).Enabled = True
End Sub
Private Sub bunSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bunSearch.Click
OID = txtOId.Text
Dim myRow1 As DataRow
Dim currRows1() As DataRow = myDataSetOutput.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow1 In currRows1
If myRow1("o_id") = OID Then
txtOYear.Text = Microsoft.VisualBasic.DateAndTime.Year(myRow1("o_date"))
txtOMonth.Text = Microsoft.VisualBasic.DateAndTime.Month(myRow1("o_date"))
txtODay.Text = Microsoft.VisualBasic.DateAndTime.Day(myRow1("o_date"))
txtOCount.Text = myRow1("o_count")
Price = CSng(myRow1("o_price"))
OCount = CLng(myRow1("o_count"))
RCount = CLng(myRow1("r_count"))
BID = myRow1("b_id")
PID = myRow1("p_id")
CID = myRow1("c_id")
End If
Next
Dim myRow2 As DataRow
Dim currRows2() As DataRow = myDataSetProduct.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow2 In currRows2
If myRow2("p_id") = PID Then
txtProduct.Text = myRow2("p_name") & " " & myRow2("p_model")
End If
Next
Dim myRow3 As DataRow
Dim currRows3() As DataRow = myDataSetCustomer.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow3 In currRows3
If myRow3("c_id") = CID Then
txtCName.Text = myRow3("c_name")
End If
Next
IfCanAddRetreat()
End Sub
Private Sub txtRCount_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtRCount.TextChanged
If (txtRCount.Text <> "") Then
If (txtRCount.Text > OCount) Then
MsgBox("退货量不能大于销售量!", , "退货登记")
txtRCount.Text = ""
Else
IfCanAddRetreat()
End If
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -