📄 frmsell.frm
字号:
VERSION 5.00
Begin VB.Form frmSell
BorderStyle = 1 'Fixed Single
Caption = "销售登记"
ClientHeight = 4755
ClientLeft = 45
ClientTop = 330
ClientWidth = 6645
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4755
ScaleWidth = 6645
Begin VB.CommandButton cmdReset
Caption = "清空重填"
Height = 375
Left = 4080
TabIndex = 11
Top = 4080
Width = 1215
End
Begin VB.TextBox txtmoney
Height = 375
Left = 4320
TabIndex = 9
Top = 3480
Width = 1575
End
Begin VB.TextBox txtday
Height = 375
Left = 3720
TabIndex = 7
Top = 2760
Width = 615
End
Begin VB.TextBox txtmon
Height = 375
Left = 2400
TabIndex = 6
Top = 2760
Width = 615
End
Begin VB.TextBox txtyear
Height = 375
Left = 1200
TabIndex = 5
Top = 2760
Width = 615
End
Begin VB.TextBox txtem
Height = 375
Left = 1200
TabIndex = 8
Top = 3480
Width = 1335
End
Begin VB.TextBox txtGoodsNo
Enabled = 0 'False
Height = 375
Left = 1200
TabIndex = 12
Text = "编号自动添加"
Top = 240
Width = 1455
End
Begin VB.TextBox txtName
Height = 375
Left = 4320
TabIndex = 0
Top = 240
Width = 1575
End
Begin VB.TextBox txtFc
Height = 375
Left = 1200
TabIndex = 1
Top = 1080
Width = 1455
End
Begin VB.TextBox txtType
Height = 375
Left = 4320
TabIndex = 2
Top = 1080
Width = 1575
End
Begin VB.TextBox txtPrice
Height = 375
Left = 1200
TabIndex = 3
Top = 1920
Width = 1455
End
Begin VB.TextBox txtQuantity
Height = 375
Left = 4320
TabIndex = 4
Top = 1920
Width = 1575
End
Begin VB.CommandButton cmdSell
Caption = "销 售"
Height = 375
Left = 1680
TabIndex = 10
Top = 4080
Width = 1335
End
Begin VB.Label Label4
Caption = "总金额:"
Height = 375
Left = 3240
TabIndex = 24
Top = 3600
Width = 855
End
Begin VB.Label Label3
Caption = "日"
Height = 375
Left = 4560
TabIndex = 23
Top = 2880
Width = 375
End
Begin VB.Label Label2
Caption = "月"
Height = 255
Left = 3240
TabIndex = 22
Top = 2880
Width = 375
End
Begin VB.Label Label1
Caption = "年"
Height = 255
Left = 2040
TabIndex = 21
Top = 2880
Width = 255
End
Begin VB.Label lblem
Caption = "业务员编号:"
Height = 375
Left = 120
TabIndex = 20
Top = 3600
Width = 1335
End
Begin VB.Label lblgoodsno
Caption = "商品编号:"
Height = 375
Left = 120
TabIndex = 19
Top = 360
Width = 975
End
Begin VB.Label lblgoodsname
Caption = "商品名称:"
Height = 375
Left = 3240
TabIndex = 18
Top = 360
Width = 975
End
Begin VB.Label lblfcname
Caption = "生产厂商:"
Height = 375
Left = 120
TabIndex = 17
Top = 1200
Width = 975
End
Begin VB.Label lbltype
Caption = "型号:"
Height = 375
Left = 3240
TabIndex = 16
Top = 1200
Width = 855
End
Begin VB.Label lblprice
Caption = "单价:"
Height = 375
Left = 120
TabIndex = 15
Top = 2040
Width = 975
End
Begin VB.Label lblquantity
Caption = "数量:"
Height = 495
Left = 3240
TabIndex = 14
Top = 1920
Width = 975
End
Begin VB.Label lblselltime
Caption = "销售日期:"
Height = 375
Left = 120
TabIndex = 13
Top = 2880
Width = 975
End
End
Attribute VB_Name = "frmSell"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_add As New ADODB.Recordset
Dim rs_check As New ADODB.Recordset
Private Sub cmdReset_Click()
txtName.Text = ""
txtFc.Text = ""
txtType.Text = ""
txtPrice.Text = ""
txtQuantity.Text = ""
txtyear.Text = ""
txtmon.Text = ""
txtday.Text = ""
txtem.Text = ""
txtmoney.Text = ""
End Sub
Private Sub cmdSell_Click()
txtGoodsNo.Enabled = False
If txtFc.Text = "" Then
MsgBox "请填写厂商名称!", vbOKOnly + vbInformation, "注意"
txtFc.SetFocus
Exit Sub
ElseIf txtName.Text = "" Then
MsgBox "请填写商品名称!", vbOKOnly + vbInformation, "注意"
txtName.SetFocus
Exit Sub
ElseIf txtType.Text = "" Then
MsgBox "请填写商品型号!", vbOKOnly + vbInformation, "注意"
txtType.SetFocus
Exit Sub
ElseIf txtPrice.Text = "" Then
MsgBox "请填写商品价格!", vbOKOnly + vbInformation, "注意"
txtPrice.SetFocus
Exit Sub
ElseIf txtQuantity.Text = "" Then
MsgBox "请填写商品数量!", vbOKOnly + vbInformation, "注意"
txtQuantity.SetFocus
Exit Sub
ElseIf txtyear.Text = "" Then
MsgBox "请填写销售年份!", vbOKOnly + vbInformation, "注意"
txtyear.SetFocus
Exit Sub
ElseIf txtmon.Text = "" Then
MsgBox "请填写销售月份!", vbOKOnly + vbInformation, "注意"
txtmon.SetFocus
Exit Sub
ElseIf txtday.Text = "" Then
MsgBox "请填写销售日!", vbOKOnly + vbInformation, "注意"
txtday.SetFocus
Exit Sub
ElseIf txtem.Text = "" Then
MsgBox "请填写业务员姓名!", vbOKOnly + vbInformation, "注意"
txtem.SetFocus
Exit Sub
ElseIf txtmoney.Text = "" Then
MsgBox "请填写总金额!", vbOKOnly + vbInformation, "注意"
txtmoney.SetFocus
Exit Sub
End If
Dim sqlcheck As String
sqlcheck = "select * from goods where 商品名='" & txtName.Text & _
"'and 生产厂商='" & txtFc.Text & "'and 型号='" & txtType.Text & "'"
rs_check.CursorLocation = adUseClient '设定游标类型
rs_check.Open sqlcheck, conn, adOpenKeyset, adLockPessimistic
If rs_check.EOF = True Then
MsgBox "对不起,此商品型号已无货!请选择其他型!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
ElseIf rs_check.Fields(5) < Val(txtQuantity.Text) Then
MsgBox "此型号商品不足!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
End If
Dim sqlsell As String
sqlsell = "select * from sell"
rs_add.Open sqlsell, conn, adOpenKeyset, adLockPessimistic
'添加入销售表
rs_add.AddNew
rs_add.Fields(1) = txtFc.Text
rs_add.Fields(2) = txtName.Text
rs_add.Fields(3) = txtType.Text
rs_add.Fields(4) = txtPrice.Text
rs_add.Fields(5) = Val(txtQuantity.Text)
rs_add.Fields(6) = Val(txtmoney.Text)
rs_add.Fields(7) = txtyear.Text
rs_add.Fields(8) = txtmon.Text
rs_add.Fields(9) = txtday.Text
rs_add.Fields(10) = txtem.Text
rs_add.Update
'从现存商品表中减去
Dim oldquantity As Long '用于存放goods表中原来的此商品数量
Dim oldmoney As Long '用于存放goods表中原来的此商品进货总额
oldquantity = rs_check.Fields(5)
oldmoney = rs_check.Fields(6)
rs_check.Fields(5) = oldquantity - Val(txtQuantity.Text)
rs_check.Fields(6) = oldmoney - (rs_check.Fields(4)) * Val(txtQuantity.Text)
rs_check.Update
rs_check.Close
rs_add.Close
MsgBox "销售成功!", vbOKOnly + vbExclamation, "注意"
End Sub
Private Sub Form_Load()
'让窗体居中
Call MakeCenter(Me)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -