📄 frmsslog.frm
字号:
Private Sub CmdInput_Click()
Dim intindex As Integer
If txtID.Text <> "" And txtAmount.Text <> "" Then
If txtAmount > 0 Then
Do While Not rct.EOF
If rct.Fields.Item(0).Value = txtID.Text Then
n = n + 1
MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
For intindex = 0 To 4
MSFlexGrid1.Col = intindex
MSFlexGrid1.CellAlignment = 4
Next intindex
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = n
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = txtID.Text
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = rct.Fields.Item(1).Value
MSFlexGrid1.Col = 3
If rct.Fields.Item(4) Like "*N*" Then '判断销售数量是否可以是小数
If Val(txtAmount.Text) < 1 Then
MsgBox "进货数量输入合法,请重新输入!", vbInformation + vbOKOnly, "错误提示!"
txtAmount.Text = ""
txtAmount.SetFocus
If MSFlexGrid1.Rows > 2 Then '删除该记录
MSFlexGrid1.RemoveItem (MSFlexGrid1.Rows - 1)
MSFlexGrid1.AddItem (Empty)
n = n - 1
Exit Sub
Else
Call CmdClear_Click
Exit Sub
End If
Else
MSFlexGrid1.Text = Int(Val(txtAmount.Text))
End If
Else
If Val(txtAmount.Text) >= 1 Then
MSFlexGrid1.Text = Val(txtAmount.Text)
Else
MSFlexGrid1.Text = "0" & Val(txtAmount.Text)
End If
End If
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = rct.Fields.Item(5).Value
rct.MoveFirst
txtID.Text = ""
txtAmount.Text = ""
txtID.SetFocus
MSFlexGrid1.AddItem (Empty)
CmdClear.Enabled = True
CmdSave.Enabled = True
Exit Sub
End If
rct.MoveNext
Loop
MsgBox "数据库中无此商品记录,请重新核对!", vbInformation + vbOKOnly, "输入提示!"
txtID.Text = ""
txtAmount.Text = ""
txtID.SetFocus
rct.MoveFirst
Else
MsgBox "进货数量不能为零!", vbInformation + vbOKOnly, "输入提示!"
txtAmount.Text = ""
txtAmount.SetFocus
End If
Else
MsgBox "请输入商品编号及进货数量!", vbInformation + vbOKOnly, "输入提示!"
txtID.Text = ""
txtAmount.Text = ""
txtID.SetFocus
End If
End Sub
Private Sub CmdSave_Click()
On Error GoTo error2
Dim str1 As String
Dim intindex As Integer
Dim Id1 As Integer
str1 = "select * from stock"
Set rct1 = QueryXFInfo(str1)
If rct1.EOF = True Then '进货表中如果没有记录,则表中序号从0计数,否则顺延上条记录的序号
Id1 = 0
Else
rct1.MoveLast
Id1 = rct1.Fields.Item(0).Value
End If
If MSFlexGrid1.TextMatrix(1, 0) <> "" Then
For intindex = 1 To MSFlexGrid1.Rows - 2
rct1.AddNew
rct1.Fields.Item(0).Value = Id1 + 1
rct1.Fields.Item(1).Value = MSFlexGrid1.TextMatrix(intindex, 1)
rct1.Fields.Item(2).Value = MSFlexGrid1.TextMatrix(intindex, 3)
rct1.Fields.Item(3).Value = txtDate.Text
rct1.Fields.Item(4).Value = MSFlexGrid1.TextMatrix(intindex, 4)
rct1.Fields.Item(5).Value = txtNumber.Text
Id1 = Id1 + 1
rct1.UpdateBatch
rct.MoveFirst
Do While Not rct.EOF
If rct.Fields.Item(0).Value = MSFlexGrid1.TextMatrix(intindex, 1) Then
'库存表中各商品库存量随进货数量变动
rct.Fields.Item(3).Value = rct.Fields.Item(3).Value + Val(MSFlexGrid1.TextMatrix(intindex, 3))
rct.UpdateBatch
rct.MoveLast
End If
rct.MoveNext
Loop
Next intindex
rct2.AddNew
rct2.Fields.Item(0) = txtNumber.Text
rct2.Fields.Item(1) = txtDate.Text
rct2.UpdateBatch
MsgBox "成功保存到数据库!", vbInformation + vbOKOnly, "保存成功!"
Else
MsgBox "无记录可保存!", vbInformation + vbOKOnly, "错误提示!"
End If
Call CmdClear_Click
txtNumber.Text = "J" & Year(Date) & Month(Date) & Day(Date) & "N" & (Val(Right(txtNumber.Text, (Len(txtNumber.Text) - Len(Year(Date) & Month(Date) & Day(Date)) - 2))) + 1)
CmdSave.Enabled = False
rct.MoveFirst
Exit Sub
error2:
MsgBox "错误代码:" & Err.Number & vbCrLf & _
"错误描述:" & Err.Description, vbCritical + vbOKOnly, "错误!"
End Sub
Private Sub Form_Load()
Dim str1 As String
Dim str2 As String
Dim str3 As String
str3 = "J" & Year(Date) & Month(Date) & Day(Date)
CmdSave.Enabled = False
CmdClear.Enabled = False
Call flexView
str1 = "select * from storage"
Set rct = QueryXFInfo(str1)
txtDate.Text = Date
str2 = "select * from stockInvoice"
Set rct2 = QueryXFInfo(str2)
If rct2.EOF = False Then '进货序号表中无记录时,进货序号从0开始计数,否则按照日期进行依次排序
rct2.MoveLast
If Left((rct2.Fields.Item(0).Value), Len(str3)) = str3 Then
txtNumber = "J" & Year(Date) & Month(Date) & Day(Date) & "N" & Val(Right((rct2.Fields.Item(0).Value), (Len(rct2.Fields.Item(0).Value) - Len(str3) - 1))) + 1
Else
txtNumber = "J" & Year(Date) & Month(Date) & Day(Date) & "N" & "1"
End If
Else
txtNumber = "J" & Year(Date) & Month(Date) & Day(Date) & "N" & "1"
End If
End Sub
Private Sub flexView()
Dim intindex As Integer
MSFlexGrid1.ColWidth(0) = 12 * 25 * 4
MSFlexGrid1.ColWidth(1) = 12 * 25 * 6
MSFlexGrid1.ColWidth(2) = 12 * 25 * 9
MSFlexGrid1.ColWidth(3) = 12 * 25 * 5
MSFlexGrid1.ColWidth(4) = 12 * 25 * 7
MSFlexGrid1.Row = 0
For intindex = 0 To 4
MSFlexGrid1.Col = intindex
MSFlexGrid1.CellAlignment = 4
MSFlexGrid1.CellFontBold = True
Next intindex
MSFlexGrid1.TextMatrix(0, 0) = "序号"
MSFlexGrid1.TextMatrix(0, 1) = "商品编号"
MSFlexGrid1.TextMatrix(0, 2) = "商品名称"
MSFlexGrid1.TextMatrix(0, 3) = "数量"
MSFlexGrid1.TextMatrix(0, 4) = "厂商编号"
End Sub
'判断个文本框的输入合法性
Private Sub TxtAmount_LostFocus()
If txtAmount.Text <> "" Then
If IsNumber(txtAmount.Text) = False Then
MsgBox "进货数量输入不合法!", vbInformation + vbOKOnly, "输入提示!"
txtAmount.Text = ""
txtAmount.SetFocus
End If
End If
End Sub
Private Sub txtID_LostFocus()
If IsNumber(txtID.Text) = False Then
MsgBox "商品编号输入不合法!", vbInformation + vbOKOnly, "输入提示!"
txtID.Text = ""
txtID.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -