📄 登记销售单.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form 登记销售单
Caption = "登记销售单"
ClientHeight = 8490
ClientLeft = 2115
ClientTop = 1965
ClientWidth = 11880
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 8490
ScaleWidth = 11880
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 4575
Left = 240
TabIndex = 10
Top = 2520
Width = 11415
_ExtentX = 20135
_ExtentY = 8070
_Version = 393216
Rows = 500
Cols = 10
End
Begin VB.CommandButton Command2
Caption = "退 出"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 7200
TabIndex = 6
Top = 7440
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "销售确认"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3480
TabIndex = 1
Top = 7440
Width = 1215
End
Begin VB.Frame Frame2
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1815
Left = 240
TabIndex = 0
Top = 480
Width = 11415
Begin VB.ListBox List1
Height = 1140
ItemData = "登记销售单.frx":0000
Left = 1680
List = "登记销售单.frx":0002
TabIndex = 11
Top = 360
Width = 2175
End
Begin VB.TextBox Text3
Height = 270
Left = 9240
TabIndex = 9
Top = 360
Width = 975
End
Begin VB.TextBox Text2
Height = 270
Left = 5880
TabIndex = 7
Top = 1200
Width = 1215
End
Begin VB.TextBox Text1
Height = 270
Left = 5760
TabIndex = 5
Top = 360
Width = 1335
End
Begin VB.Label Label3
Caption = "单位"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 8400
TabIndex = 8
Top = 360
Width = 855
End
Begin VB.Label Label4
Caption = "销售数量"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4440
TabIndex = 4
Top = 1200
Width = 1215
End
Begin VB.Label Label2
Caption = "商品编号"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4440
TabIndex = 3
Top = 360
Width = 1095
End
Begin VB.Label Label1
Caption = "商品名称"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 2
Top = 360
Width = 975
End
End
Begin VB.Image Image1
Height = 8505
Left = 0
Picture = "登记销售单.frx":0004
Top = 0
Width = 12750
End
End
Attribute VB_Name = "登记销售单"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub list1_click()
Dim rs As ADODB.Recordset
Dim sql As String
sql = "select * from spxxb where spmc='" & Trim(List1.Text) & "'"
Set rs = exesql(sql)
If rs.RecordCount > 0 Then '将选中的商品对应的商品编号和单位加到文本框中
Text1.Text = Trim(rs.Fields("spbh"))
Text3.Text = Trim(rs.Fields("dw"))
End If
Set rs = Nothing
End Sub
Private Sub Command1_Click()
Dim sql As String
Dim i As Integer
Dim k As Integer
Dim rs As ADODB.Recordset
Dim cn As ADODB.Recordset
On Error Resume Next
If Trim(List1.Text) <> "" Then '检查是否输入商品名称
If Trim(Text2) <> "" Then '检查是否输入数量
i = MsgBox("确定后不能修改,确定商品出售吗?", vbYesNo, "销售确认")
If i = 6 Then '检查是否有该商品名称,若没有,给出提示,有则进行下一步判断
sql = "select * from spxxb where spmc='" & Trim(List1.Text) & "'"
Set rs = exesql(sql)
If rs.RecordCount > 0 Then '检查库存数量是否大于要出售数量,若否则给出提示,是则进行销售
sql = "select * from spxxb where spmc='" & Trim(List1.Text) & "'and sl > " & Trim(Text2.Text)
Set rs = exesql(sql)
If rs.RecordCount > 0 Then '计算销售数量、库存、销售总额、成本总额、当日销售数量等
rs.Fields("zxssl") = rs.Fields("zxssl") + Val(Trim(Text2.Text))
rs.Fields("sl") = rs.Fields("sl") - Val(Trim(Text2.Text))
rs.Fields("xsze") = rs.Fields("xsze") + rs.Fields("sj") * Val(Trim(Text2.Text))
rs.Fields("cbze") = rs.Fields("cbze") + rs.Fields("cbj") * Val(Trim(Text2.Text))
rs.Update
Set rs = Nothing
sql = "select * from spxxb where spmc='" & Trim(List1.Text) & "'"
Set rs = exesql(sql)
rs.Fields("lrze") = rs.Fields("xsze") - rs.Fields("cbze")
rs.Update
sql = "select * from xsxxb where spbh=" & Trim(Text1.Text)
Set cn = exesql(sql)
cn.AddNew '将销售信息加到销售信息表中
cn.Fields("xsrq") = Date
cn.Fields("spbh") = Trim(Text1.Text)
cn.Fields("drxssl") = Trim(Text2.Text)
cn.Update
MsgBox ("销售成功!")
sql = "select * from spxxb where spmc='" & Trim(List1.Text) & "'"
Set rs = exesql(sql)
Dim m As Integer
Dim n As Integer
m = rs.Fields("sl")
n = rs.Fields("kcxx")
If m < n Then '若m小于n,给出报警
MsgBox "库存报警:库存低于下限,请尽快进货!"
End If
Set rs = Nothing '查询当日销售信息,并刷新网格
sql = "select * from spxxb,xsxxb where spxxb.spbh=xsxxb.spbh and xsxxb.xsrq= # " & Date & " # "
Call gridshow(sql, 登记销售单.MSFlexGrid1, "djxsd")
Set cn = Nothing
Else: MsgBox ("库存量不足!")
Text2.Text = ""
Text2.SetFocus
End If
Else: MsgBox ("该商品不存在!")
List1.Text = ""
List1.SetFocus
End If
End If
Else: MsgBox ("销售数量不能为空!")
Text2.SetFocus
End If
Else: MsgBox ("商品不能为空!")
List1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Unload 登记销售单
End Sub
Private Sub Form_Load()
Call listinitial("spmc", List1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -