📄 frmsellgoods.frm
字号:
VERSION 5.00
Begin VB.Form frmSellgoods
BackColor = &H00FFFFFF&
BorderStyle = 3 'Fixed Dialog
Caption = "添加销货信息"
ClientHeight = 5955
ClientLeft = 45
ClientTop = 435
ClientWidth = 7425
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "frmSellgoods.frx":0000
ScaleHeight = 5955
ScaleWidth = 7425
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text15
Height = 375
Left = 3720
TabIndex = 31
Top = 4440
Width = 735
End
Begin VB.TextBox Text14
Height = 375
Left = 2640
TabIndex = 29
Top = 4440
Width = 735
End
Begin VB.TextBox Text13
Height = 375
Left = 1560
TabIndex = 27
Top = 4440
Width = 735
End
Begin VB.TextBox Text12
Height = 375
Left = 1560
TabIndex = 10
Top = 3840
Width = 1695
End
Begin VB.CommandButton Command2
Caption = "清空重添"
Height = 495
Left = 4320
TabIndex = 5
Top = 5040
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "销售"
Height = 495
Left = 1920
TabIndex = 4
Top = 5040
Width = 1215
End
Begin VB.TextBox Text11
Height = 375
Left = 5040
TabIndex = 3
Top = 3240
Width = 2055
End
Begin VB.TextBox Text10
Height = 375
Left = 1560
TabIndex = 25
Top = 3240
Width = 1815
End
Begin VB.TextBox Text9
Height = 375
Left = 3720
TabIndex = 24
Top = 2520
Width = 735
End
Begin VB.TextBox Text8
Height = 375
Left = 2640
TabIndex = 23
Top = 2520
Width = 735
End
Begin VB.TextBox Text7
Height = 375
Left = 1560
TabIndex = 22
Top = 2520
Width = 735
End
Begin VB.TextBox Text6
Height = 375
Left = 5160
TabIndex = 8
Top = 1800
Width = 1815
End
Begin VB.TextBox Text5
Height = 375
Left = 1560
TabIndex = 6
Top = 1800
Width = 1815
End
Begin VB.TextBox Text4
Height = 375
Left = 5160
TabIndex = 7
Top = 1080
Width = 1815
End
Begin VB.TextBox Text3
Height = 375
Left = 1560
TabIndex = 0
Top = 1080
Width = 1815
End
Begin VB.TextBox Text2
Height = 375
Left = 5160
TabIndex = 2
Top = 360
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Left = 1560
TabIndex = 1
Top = 360
Width = 1815
End
Begin VB.Label Label17
BackStyle = 0 'Transparent
Caption = "销售时间:"
Height = 255
Left = 480
TabIndex = 33
Top = 4560
Width = 975
End
Begin VB.Label Label16
BackStyle = 0 'Transparent
Caption = "秒"
Height = 255
Left = 4560
TabIndex = 32
Top = 4560
Width = 255
End
Begin VB.Label Label15
BackStyle = 0 'Transparent
Caption = "分"
Height = 255
Left = 3480
TabIndex = 30
Top = 4560
Width = 255
End
Begin VB.Label Label14
BackStyle = 0 'Transparent
Caption = "时"
Height = 255
Left = 2400
TabIndex = 28
Top = 4560
Width = 255
End
Begin VB.Label Label13
BackStyle = 0 'Transparent
Caption = "数量:"
Height = 255
Left = 4200
TabIndex = 26
Top = 3360
Width = 975
End
Begin VB.Label Label12
BackStyle = 0 'Transparent
Caption = "总金额:"
Height = 255
Left = 480
TabIndex = 21
Top = 3960
Width = 855
End
Begin VB.Label Label11
BackStyle = 0 'Transparent
Caption = "业务员编号:"
Height = 255
Left = 480
TabIndex = 20
Top = 3360
Width = 1215
End
Begin VB.Label Label10
BackStyle = 0 'Transparent
Caption = "日"
Height = 255
Left = 4560
TabIndex = 19
Top = 2640
Width = 255
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "月"
Height = 255
Left = 3480
TabIndex = 18
Top = 2640
Width = 255
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "年"
Height = 375
Left = 2400
TabIndex = 17
Top = 2640
Width = 255
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "销售日期"
Height = 495
Left = 480
TabIndex = 16
Top = 2640
Width = 1215
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "单价:"
Height = 495
Left = 4080
TabIndex = 15
Top = 1920
Width = 1215
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "型号:"
Height = 255
Left = 480
TabIndex = 14
Top = 1920
Width = 735
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "生产厂商:"
Height = 495
Left = 4080
TabIndex = 13
Top = 1200
Width = 1215
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "商品名称:"
Height = 255
Left = 480
TabIndex = 12
Top = 1200
Width = 975
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "商品编号:"
Height = 495
Left = 4080
TabIndex = 11
Top = 480
Width = 1215
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "销货编号:"
Height = 255
Left = 480
TabIndex = 9
Top = 480
Width = 975
End
End
Attribute VB_Name = "frmSellgoods"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_goods As New ADODB.Recordset
Dim rs_sell As New ADODB.Recordset
Dim str_goods As String
Dim str_sell As String
Dim numgoods As Integer
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请填写销货编号!", vbOKOnly + vbInformation, "注意"
Text1.SetFocus
Exit Sub
ElseIf Text2.Text = "" Then
MsgBox "请填写商品编号!", vbOKOnly + vbInformation, "注意"
Text2.SetFocus
Exit Sub
End If
str_goods = "select * from goods where 商品编号='" & Text2.Text & "'"
rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic
If rs_goods.EOF = True Then
MsgBox "对不起,此商品型号已无货!请选择其他型!", vbOKOnly + vbInformation, "注意"
rs_goods.Close
Exit Sub
End If
rs_goods.Close
If Text11.Text = "" Then
MsgBox "请填写销货数量!", vbOKOnly + vbInformation, "注意"
Text11.SetFocus
Exit Sub
End If
Text12.Text = Val(Text6.Text) * Val(Text11.Text)
'下面是对销售表进行入库操作!
str_sell = "select * from sell where 销货编号='" & Text1.Text & "'"
rs_sell.Open str_sell, cnn, adOpenStatic, adLockOptimistic
If rs_sell.EOF = True Then
rs_sell.AddNew
rs_sell.Fields("销货编号") = Text1.Text
rs_sell.Fields("商品编号") = Text2.Text
rs_sell.Fields("商品名称") = Text3.Text
rs_sell.Fields("生产厂商") = Text4.Text
rs_sell.Fields("型号") = Text5.Text
rs_sell.Fields("单价") = Text6.Text
rs_sell.Fields("销售年") = Text7.Text
rs_sell.Fields("销售月") = Text8.Text
rs_sell.Fields("销售日") = Text9.Text
rs_sell.Fields("业务员编号") = Text10.Text
rs_sell.Fields("数量") = Val(Text11.Text)
rs_sell.Fields("总金额") = Val(Text12.Text)
rs_sell.Fields("销售时") = Text13.Text
rs_sell.Fields("销售分") = Text14.Text
rs_sell.Fields("销售秒") = Text15.Text
rs_sell.Update
rs_sell.Close
Else
MsgBox "此销货编号已存在,请重添!", vbOKOnly + vbInformation, "注意"
Text1.Text = ""
Text1.SetFocus
rs_sell.Close
Exit Sub
End If
'下面是对商品库存表的减货操作!
str_goods = "select * from goods where 商品编号='" & Text2.Text & "'"
rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic
numgoods = rs_goods.Fields("数量")
rs_goods.Fields("数量") = numgoods - Val(Text11.Text)
rs_goods.Update
rs_goods.Close
MsgBox "销售成功!", vbOKOnly + vbExclamation, "注意"
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""
End Sub
Private Sub Form_Load()
Text7.Text = Year(Date)
Text8.Text = Month(Date)
Text9.Text = Day(Date)
Text10.Text = strs
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text6.Enabled = False
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text10.Enabled = False
Text12.Enabled = False
Text13.Enabled = False
Text14.Enabled = False
Text15.Enabled = False
End Sub
Private Sub Text11_Change()
If Text6.Text <> "" Then
Text12.Text = Val(Text6.Text) * Val(Text11.Text)
End If
End Sub
Private Sub Text12_Change()
Text13.Text = Val(Hour(Time))
Text14.Text = Val(Minute(Time))
Text15.Text = Val(Second(Time))
End Sub
Private Sub Text2_Change()
str_goods = "select * from goods where 商品编号='" & Text2.Text & "'"
rs_goods.Open str_goods, cnn, adOpenStatic, adLockOptimistic
Text3.Text = rs_goods.Fields("商品名称")
Text4.Text = rs_goods.Fields("生产厂商")
Text5.Text = rs_goods.Fields("型号")
Text6.Text = rs_goods.Fields("销货价")
rs_goods.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -