📄 frminput.vb
字号:
'
Me.bunAddFactory.Location = New System.Drawing.Point(336, 120)
Me.bunAddFactory.Name = "bunAddFactory"
Me.bunAddFactory.Size = New System.Drawing.Size(40, 24)
Me.bunAddFactory.TabIndex = 105
Me.bunAddFactory.Text = "添加"
'
'txtFId
'
Me.txtFId.BackColor = System.Drawing.SystemColors.Window
Me.txtFId.Enabled = False
Me.txtFId.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtFId.Location = New System.Drawing.Point(96, 16)
Me.txtFId.Name = "txtFId"
Me.txtFId.Size = New System.Drawing.Size(152, 21)
Me.txtFId.TabIndex = 105
Me.txtFId.Text = ""
'
'txtFName
'
Me.txtFName.BackColor = System.Drawing.SystemColors.Window
Me.txtFName.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtFName.Location = New System.Drawing.Point(328, 16)
Me.txtFName.Name = "txtFName"
Me.txtFName.Size = New System.Drawing.Size(208, 21)
Me.txtFName.TabIndex = 105
Me.txtFName.Text = ""
'
'Label8
'
Me.Label8.ForeColor = System.Drawing.Color.Red
Me.Label8.Location = New System.Drawing.Point(16, 528)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(400, 24)
Me.Label8.TabIndex = 23
Me.Label8.Text = "前面带※的必须填写!"
'
'frmInput
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(584, 558)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.GBLog)
Me.Controls.Add(Me.GBAddProduct)
Me.Controls.Add(Me.GBAddFactory)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmInput"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "进货登记"
Me.GBLog.ResumeLayout(False)
Me.GBAddProduct.ResumeLayout(False)
Me.GBAddFactory.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private i As Integer
Private LastTable As String
Private InComboBox As Boolean
Private CanAddFactory As Boolean
Private CanAddProduct As Boolean
Private myDataAdapterInput As New SqlClient.SqlDataAdapter
Private myDataSetInput As DataSet = New DataSet("Input")
Private myDataAdapterProduct As New SqlClient.SqlDataAdapter
Private myDataSetProduct As DataSet = New DataSet("Product")
Private myDataAdapterFactory As SqlDataAdapter = New SqlDataAdapter
Private myDataSetFactory As DataSet = New DataSet("Factory")
Private myDataAdapterStore As New SqlClient.SqlDataAdapter
Private myDataSetStore As DataSet = New DataSet("store")
Private myIndexInput As Integer = 0
Private myIndexProduct As Integer = 0
Private myIndexFactory As Integer = 0
Private myIndexstore As Integer = 0
Private RowsMaxInput As Integer
Private RowsMaxProduct As Integer
Private RowsMaxFactory As Integer
Private RowsMaxStore As Integer
Private IID As String
Private FID As String
Private PID As String
Private SID As String
Private Sub SetInputID()
Dim CountInTable As Integer
If RowsMaxInput >= 0 Then
CountInTable = RowsMaxInput + 2
IID = "i" & Format(CountInTable, "000000000")
Else
IID = "i000000001"
End If
txtInputId.Text = IID
End Sub
Public Sub InitAddLog()
txtInputId.Text = ""
txtCount.Text = ""
txtPrice.Text = ""
cobFactory.Text = ""
cobProduct.Text = ""
txtYear.Text = CStr(Microsoft.VisualBasic.DateAndTime.Year(Now))
txtMonth.Text = CStr(Microsoft.VisualBasic.DateAndTime.Month(Now))
txtDay.Text = CStr(Microsoft.VisualBasic.DateAndTime.Day(Now))
End Sub
Public Sub InitAddFactory()
txtFId.Text = ""
txtFName.Text = ""
txtFManager.Text = ""
txtFAddr.Text = ""
txtFPhone.Text = ""
End Sub
Public Sub InitAddProduct()
txtPId.Text = ""
txtPName.Text = ""
cobPFactory.Text = ""
txtPModel.Text = ""
End Sub
Public Sub FillCobProduct(ByVal Constraint As Boolean)
Dim found As Boolean
FID = "NULL"
found = False
If Constraint Then
Dim myRow As DataRow
myIndexFactory = 0
Dim currRows() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow In currRows
If myRow("f_name") = cobFactory.Text Then
found = True
FID = myRow("f_id")
Exit For
Else
myIndexFactory = myIndexFactory + 1
End If
Next
End If
cobProduct.Items.Clear()
cobProduct.Items.Add("<new>")
If Constraint Then
InComboBox = False
Dim i As Integer = 0
Dim myRow As DataRow
myIndexProduct = 0
i = 1
Dim currRows() As DataRow = myDataSetProduct.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myrow In currRows
If myrow("f_id") = FID Then
While (i <= cobProduct.Items.Count) And (InComboBox = False)
If LCase(myrow("p_name")) & " " & myrow("p_model") = LCase(cobProduct.Items(i - 1)) Then
InComboBox = True
Else
i = i + 1
End If
End While
If Not InComboBox Then
cobProduct.Items.Add(myrow("p_name") & " " & myrow("p_model"))
End If
InComboBox = False
End If
Next
End If
End Sub
Public Sub fillcobfactory()
cobFactory.Items.Clear()
cobFactory.Items.Add("<new>")
Dim myRow As DataRow
myIndexFactory = 0
Dim currRows() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow In currRows
cobFactory.Items.Add(myRow("f_name"))
Next
End Sub
Public Sub FillCobPFactory()
cobPFactory.Items.Clear()
cobPFactory.Items.Add("<new>")
Dim myRow As DataRow
myIndexFactory = 0
Dim currRows() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myRow In currRows
cobPFactory.Items.Add(myRow("f_name"))
Next
End Sub
Public Sub IfCanAddfactory()
CanAddFactory = (txtFId.Text <> "") And (txtFName.Text <> "")
If CanAddFactory Then
bunAddFactory.Enabled = True
Else
bunAddFactory.Enabled = False
End If
End Sub
Public Sub IfCanAddProduct()
CanAddProduct = (txtPId.Text <> "") And (txtPName.Text <> "") And (cobPFactory.Text <> "")
If CanAddProduct Then
bunAddProduct.Enabled = True
Else
bunAddProduct.Enabled = False
End If
End Sub
Private Sub IfCanAddLog()
Dim CanAddLog As Boolean
CanAddLog = (cobProduct.Text <> "") And (cobFactory.Text <> "") And (txtPrice.Text <> "") And (txtCount.Text <> "") And (txtYear.Text <> "") And (txtMonth.Text <> "") And (txtDay.Text <> "") And (txtInputId.Text <> "")
If CanAddLog Then
bunAddLog.Enabled = True
Else
bunAddLog.Enabled = False
End If
End Sub
Private Sub frmInput_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtYear.Text = CStr(Microsoft.VisualBasic.DateAndTime.Year(Now))
txtMonth.Text = CStr(Microsoft.VisualBasic.DateAndTime.Month(Now))
txtDay.Text = CStr(Microsoft.VisualBasic.DateAndTime.Day(Now))
ShowStatus("进货登记", "")
On Error GoTo ErrorHandle
Dim strSelectInput As String = "select * from Input"
Dim cmdSelectInput As New SqlClient.SqlCommand(strSelectInput, db)
myDataAdapterInput.SelectCommand = cmdSelectInput
Dim xxInput As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapterInput)
Dim strSelectProduct As String = "select * from Product"
Dim cmdSelectProduct As New SqlClient.SqlCommand(strSelectProduct, db)
myDataAdapterProduct.SelectCommand = cmdSelectProduct
Dim xxProduct As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapterProduct)
Dim strSelectFactory As String = "select * from Factory"
Dim cmdSelectFactory As New SqlClient.SqlCommand(strSelectFactory, db)
myDataAdapterFactory.SelectCommand = cmdSelectFactory
Dim xxFactory As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapterFactory)
Dim strSelectstore As String = "select * from Store"
Dim cmdSelectstore As New SqlClient.SqlCommand(strSelectstore, db)
myDataAdapterStore.SelectCommand = cmdSelectstore
Dim xxStore As SqlCommandBuilder = New SqlCommandBuilder(myDataAdapterStore)
db.Open()
myDataAdapterInput.Fill(myDataSetInput)
myDataAdapterProduct.Fill(myDataSetProduct)
myDataAdapterFactory.Fill(myDataSetFactory)
myDataAdapterStore.Fill(myDataSetStore)
db.Close()
Dim currRows() As DataRow = myDataSetInput.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxInput = currRows.Length - 1
Dim currRows2() As DataRow = myDataSetProduct.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxProduct = currRows2.Length - 1
Dim currRows3() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxFactory = currRows3.Length - 1
Dim currRows4() As DataRow = myDataSetStore.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
RowsMaxStore = currRows4.Length - 1
SetInputID()
fillcobfactory()
FillCobProduct(True)
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub frmInput_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Me.Dispose()
ShowStatus("", "")
frmMain1.mnuTrade.MenuItems(0).Enabled = True
End Sub
Private Sub bunAddFactory_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddFactory.Click
Dim found As Boolean
On Error GoTo ErrorHandle
myIndexFactory = 0
Dim myrow2 As DataRow
Dim currRows() As DataRow = myDataSetFactory.Tables(0).Select(Nothing, Nothing, DataViewRowState.CurrentRows)
For Each myrow2 In currRows
If myrow2("f_name") = txtFName.Text Then
found = True
MsgBox("已经有该厂家", , "错误提示")
Exit Sub
End If
Next
Dim myRow As DataRow = myDataSetFactory.Tables(0).NewRow
myRow("f_id") = txtFId.Text
myRow("f_name") = txtFName.Text
myRow("f_manager") = txtFManager.Text
myRow("f_addr") = txtFAddr.Text
myRow("f_phone") = txtFPhone.Text
myDataSetFactory.Tables(0).Rows.Add(myRow)
MsgBox(txtFName.Text & " 已经添加到厂商数据表", , "添加厂商")
RowsMaxFactory = RowsMaxFactory + 1
myIndexFactory = RowsMaxFactory
Exit Sub
ErrorHandle:
ShowErr()
End Sub
Private Sub bunAddFactoryCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bunAddFactoryCancel.Click
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -