📄 frminput.vb
字号:
If LastTable = "Input" Then
GBLog.Enabled = True
cobFactory.Text = ""
bunAddLog.Enabled = True
Else
GBAddProduct.Enabled = True
cobPFactory.Text = ""
bunAddProduct.Enabled = True
End If
FillCobProduct(True)
End Sub
Private Sub bunAddLog_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddLog.Click
Dim found As Boolean
Dim P As String
Dim M As String
Dim i As Integer
Dim Sameprice As Boolean
Dim Price As Single
found = False
On Error GoTo ErrorHandle
Price = CSng(txtPrice.Text)
i = InStr(cobProduct.Text, " ")
P = Mid(cobProduct.Text, 1, i - 1)
M = Mid(cobProduct.Text, i + 1)
Dim myrow As DataRow
Dim currRows() As DataRow = myDataSetProduct.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myrow In currRows
If myrow("p_name") = P And myrow("p_model") = M Then
found = True
PID = myrow("p_id")
Exit For
End If
Next
Dim myRow2 As DataRow = myDataSetInput.Tables(0).NewRow
myRow2("i_id") = txtInputId.Text
myRow2("p_id") = PID
myRow2("i_count") = CLng(txtCount.Text)
myRow2("i_inprice") = Price
myRow2("i_date") = CDate(txtYear.Text & "/" & txtMonth.Text & "/" & txtDay.Text)
myDataSetInput.Tables(0).Rows.Add(myRow2)
RowsMaxInput = RowsMaxInput + 1
myIndexInput = RowsMaxInput
found = False
Sameprice = False
SID = "NULL"
Dim myrow3 As DataRow
Dim currRows2() As DataRow = myDataSetStore.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myrow3 In currRows2
If PID = myrow3("p_id") Then
If myrow3("s_inprice") = Price Then
found = True
Sameprice = True
SID = myrow3("s_id")
myrow3("s_count") = myrow3("s_count") + CLng(txtCount.Text)
Exit For
End If
End If
Next
If Not found Then
RowsMaxStore = currRows2.Length - 1
If RowsMaxStore >= 0 Then
Dim countintable As Integer
countintable = RowsMaxStore + 2
SID = "s" & Format(countintable, "000000000")
Else
SID = "s000000001"
End If
Dim myrow4 As DataRow = myDataSetStore.Tables(0).NewRow
myrow4("s_id") = SID
myrow4("p_id") = PID
myrow4("s_inprice") = Price
myrow4("s_count") = CLng(txtCount.Text)
myDataSetStore.Tables(0).Rows.Add(myrow4)
End If
MsgBox("进货数据已经添加但还未更新到数据库", vbInformation, "进货登记")
InitAddLog()
SetInputID()
Exit Sub
ErrorHandle:
MsgBox("错误:要添加新内容,请选择下拉框中的<new>;" & "输入的内容格式要符合要求", , "错误提示")
End Sub
Private Sub bunAddProduct_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddProduct.Click
Dim found As Boolean
On Error GoTo ErrorHandle
Dim myRow As DataRow
Dim currRows() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow In currRows
If myRow("f_name") = cobPFactory.Text Then
found = True
FID = myRow("f_id")
Exit For
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_name") = txtPName.Text And myRow2("p_model") = txtPModel.Text Then
found = True
MsgBox("已经存在该产品", , "错误提示")
Exit Sub
End If
Next
Dim myRow3 As DataRow = myDataSetProduct.Tables(0).NewRow
myRow3("p_id") = txtPId.Text
myRow3("f_id") = FID
myRow3("p_name") = txtPName.Text
myRow3("p_model") = txtPModel.Text
myDataSetProduct.Tables(0).Rows.Add(myRow3)
RowsMaxProduct = RowsMaxProduct + 1
myIndexProduct = RowsMaxProduct
MsgBox(txtPName.Text & " 一添加到商品数据表", vbInformation, "添加商品")
GBLog.Enabled = True
FillCobProduct(True)
bunAddLog.Enabled = True
Exit Sub
ErrorHandle:
MsgBox("错误:要添加新内容,请选择下拉框中的<new>;" & "输入的内容格式要符合要求", , "错误提示")
End Sub
Private Sub bunAddProductCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddProductCancel.Click
GBLog.Enabled = True
FillCobProduct(True)
cobProduct.Text = ""
bunAddLog.Enabled = True
End Sub
Private Sub bunLogCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunLogCancel.Click
Me.Close()
frmMain1.mnuTrade.MenuItems(0).Enabled = True
End Sub
Private Sub cobFactory_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cobFactory.Click
IfCanAddLog()
If cobFactory.Text = "<new>" Then
cobFactory.Text = ""
GBLog.Enabled = False
GBAddFactory.Enabled = True
LastTable = "Input"
InitAddFactory()
Dim myRow As DataRow
Dim currrows() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxFactory = currrows.Length - 1
If RowsMaxFactory >= 0 Then
RowsInTable = RowsMaxFactory + 2
txtFId.Text = "f" & Format(RowsInTable, "000000000")
Else
txtFId.Text = "f000000001"
End If
bunAddFactory.Enabled = True
Else
FillCobProduct(True)
End If
End Sub
Private Sub cobPFactory_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cobPFactory.TextChanged
IfCanAddProduct()
End Sub
Private Sub cobFactory_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cobFactory.TextChanged
IfCanAddLog()
End Sub
Private Sub cobProduct_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cobProduct.TextChanged
IfCanAddLog()
End Sub
Private Sub txtCount_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCount.TextChanged
IfCanAddLog()
End Sub
Private Sub txtDay_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDay.TextChanged
IfCanAddLog()
End Sub
Private Sub txtFId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFId.TextChanged
IfCanAddfactory()
End Sub
Private Sub txtFName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFName.TextChanged
IfCanAddfactory()
End Sub
Private Sub txtPModel_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPModel.TextChanged
IfCanAddProduct()
End Sub
Private Sub txtInputId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtInputId.TextChanged
IfCanAddLog()
End Sub
Private Sub txtMonth_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMonth.TextChanged
IfCanAddLog()
End Sub
Private Sub txtPId_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPId.TextChanged
IfCanAddProduct()
End Sub
Private Sub txtPName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPName.TextChanged
IfCanAddProduct()
End Sub
Private Sub txtPrice_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPrice.TextChanged
IfCanAddLog()
End Sub
Private Sub txtYear_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtYear.TextChanged
IfCanAddLog()
End Sub
Private Sub txtFAddr_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFAddr.TextChanged
IfCanAddfactory()
End Sub
Private Sub txtFManager_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFManager.TextChanged
IfCanAddfactory()
End Sub
Private Sub txtFPhone_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFPhone.TextChanged
IfCanAddfactory()
End Sub
Private Sub bunFactoryUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunFactoryUpdate.Click
db.Open()
myDataAdapterFactory.Update(myDataSetFactory)
db.Close()
MsgBox("已经更新到数据库", , "添加厂商")
If LastTable = "Input" Then
GBLog.Enabled = True
cobFactory.Text = txtFName.Text
bunAddLog.Enabled = True
fillcobfactory()
Else
FillCobPFactory()
GBAddProduct.Enabled = True
cobPFactory.Text = txtFName.Text
bunAddProduct.Enabled = True
End If
End Sub
Private Sub bunInputUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunInputUpdate.Click
db.Open()
myDataAdapterInput.Update(myDataSetInput)
myDataAdapterStore.Update(myDataSetStore)
db.Close()
MsgBox("已经更新到数据库", , "进货登记")
End Sub
Private Sub bunProductUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunProductUpdate.Click
db.Open()
myDataAdapterProduct.Update(myDataSetProduct)
db.Close()
MsgBox("已经更新到数据库", , "添加商品")
GBLog.Enabled = True
FillCobProduct(True)
bunAddLog.Enabled = True
End Sub
Private Sub cobProduct_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cobProduct.Click
IfCanAddLog()
If cobProduct.Text = "<new>" Then
cobProduct.Text = ""
GBLog.Enabled = False
GBAddProduct.Enabled = True
LastTable = "Input"
InitAddProduct()
Dim myRow As DataRow
Dim currRows() As DataRow = myDataSetProduct.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxProduct = currRows.Length - 1
If RowsMaxProduct >= 0 Then
RowsInTable = RowsMaxProduct + 2
txtPId.Text = "p" & Format(RowsInTable, "000000000")
Else
txtPId.Text = "f000000001"
End If
bunAddProduct.Enabled = True
Else
FillCobProduct(True)
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -