📄 frmretraet.frm
字号:
VERSION 5.00
Begin VB.Form frmretreat
Caption = "退货登记"
ClientHeight = 4785
ClientLeft = 60
ClientTop = 450
ClientWidth = 6375
LinkTopic = "Form1"
ScaleHeight = 4785
ScaleWidth = 6375
StartUpPosition = 3 'Windows Default
Begin VB.Frame Fraaddgoods
Caption = "添加商品"
Height = 3615
Left = 0
TabIndex = 0
Top = 0
Width = 6015
Begin VB.TextBox txtname
Height = 375
Left = 4200
TabIndex = 25
Top = 360
Width = 1335
End
Begin VB.TextBox txtfc
Height = 375
Left = 1320
TabIndex = 24
Top = 840
Width = 1575
End
Begin VB.TextBox txtgoodsno
Enabled = 0 'False
Height = 285
Left = 1320
TabIndex = 11
Text = "编号自动添加"
Top = 360
Width = 1455
End
Begin VB.TextBox txttype
Height = 285
Left = 4200
TabIndex = 10
Top = 840
Width = 1335
End
Begin VB.TextBox txtprice
Height = 285
Left = 1320
TabIndex = 9
Top = 1320
Width = 1455
End
Begin VB.TextBox txtquantity
Height = 285
Left = 4200
TabIndex = 8
Top = 1320
Width = 1335
End
Begin VB.TextBox txtyear
Height = 285
Left = 1320
TabIndex = 7
Top = 1920
Width = 615
End
Begin VB.TextBox txtmon
Height = 285
Left = 2640
TabIndex = 6
Top = 1920
Width = 615
End
Begin VB.TextBox txtday
Height = 285
Left = 4080
TabIndex = 5
Top = 1920
Width = 735
End
Begin VB.TextBox txtem
Height = 285
Left = 1320
TabIndex = 4
Top = 2370
Width = 1215
End
Begin VB.TextBox txtmoney
Height = 285
Left = 3960
TabIndex = 3
Top = 2400
Width = 1335
End
Begin VB.CommandButton cmdretreat
Caption = "退货"
Height = 375
Left = 1200
TabIndex = 2
Top = 3000
Width = 1215
End
Begin VB.CommandButton cmdReset
Caption = "清空重填"
Height = 375
Left = 3480
TabIndex = 1
Top = 3000
Width = 1095
End
Begin VB.Label Label1
Caption = "产品编号:"
Height = 255
Left = 360
TabIndex = 23
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "商品名称:"
Height = 255
Left = 3240
TabIndex = 22
Top = 360
Width = 1095
End
Begin VB.Label Label3
Caption = "生产厂商:"
Height = 255
Left = 360
TabIndex = 21
Top = 840
Width = 975
End
Begin VB.Label Label4
Caption = "型号"
Height = 375
Left = 3360
TabIndex = 20
Top = 840
Width = 615
End
Begin VB.Label Label5
Caption = "单价"
Height = 255
Left = 360
TabIndex = 19
Top = 1320
Width = 615
End
Begin VB.Label Label6
Caption = "数量"
Height = 255
Left = 3360
TabIndex = 18
Top = 1320
Width = 615
End
Begin VB.Label Label7
Caption = "销售日期"
Height = 255
Left = 360
TabIndex = 17
Top = 1920
Width = 735
End
Begin VB.Label Label8
Caption = "年"
Height = 255
Left = 2160
TabIndex = 16
Top = 1920
Width = 495
End
Begin VB.Label Label9
Caption = "月"
Height = 255
Left = 3600
TabIndex = 15
Top = 1920
Width = 495
End
Begin VB.Label Label10
Caption = "日"
Height = 255
Left = 5040
TabIndex = 14
Top = 1920
Width = 495
End
Begin VB.Label Label11
Caption = "业务员编号"
Height = 255
Left = 360
TabIndex = 13
Top = 2400
Width = 975
End
Begin VB.Label Label12
Caption = "退货总金额"
Height = 255
Left = 3000
TabIndex = 12
Top = 2400
Width = 735
End
End
End
Attribute VB_Name = "frmretreat"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_back As New ADODB.Recordset
Dim rs_check As New ADODB.Recordset
Dim rs_buy As New ADODB.Recordset
Private Sub cmdretreat_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 sqlback As String
sqlback = "select * from sell"
rs_back.Open sqlback, conn, adopenkyset, adLockPessimistic
rs_back.AddNew
rs_back.Fields(1) = txtfc.Text
rs_back.Fields(2) = txtname.Text
rs_back.Fields(3) = txttype.Text
rs_back.Fields(4) = txtprice.Text
rs_back.Fields(5) = Val(txtquantity.Text)
rs_back.Fields(6) = Val(txtmoney.Text)
rs_back.Fields(7) = txtyear.Text
rs_back.Fields(8) = txtmon.Text
rs_back.Fields(9) = txtday.Text
rs_back.Fields(10) = txtem.Text
rs_back.Update
rs_back.Close
Dim sqlbuy As String
Dim oldquantity As Long
Dim oldmoney As Long
oldmoney = rs_check.Fields(5)
oldquantity = rs_check.Fields(6)
rs_check.Fields(5) = oldquantity - Val(txtquantity.Text)
rs_check.Fields(6) = oldmoney - Val(txtmoney.Text)
rs_check.Update
rs_check.Close
sqlbuy = "select * from goods"
rs_buy.Open sqlbuy, conn, adOpenKeyset, adLockPessimistic
rs_buy.AddNew
rs_buy.Fields(1) = txtfc.Text
rs_buy.Fields(2) = txtname.Text
rs_buy.Fields(3) = txttype.Text
rs_buy.Fields(4) = txtprice.Text
rs_buy.Fields(5) = Val(txtquantity.Text)
rs_buy.Fields(6) = Val(txtmoney.Text)
rs_buy.Fields(7) = txtyear.Text
rs_buy.Fields(8) = txtmon.Text
rs_buy.Fields(9) = txtday.Text
rs_buy.Fields(10) = txtem.Text
rs_buy.Update
rs_buy.Close
MsgBox "退货成功!", vbOKOnly + vbInformation, "注意"
End Sub
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 Form_Load()
'让窗体居中
Call MakeCenter(Me)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -