📄 pay.frm
字号:
VERSION 5.00
Begin VB.Form pay
Caption = "收银业务"
ClientHeight = 2385
ClientLeft = 5040
ClientTop = 4125
ClientWidth = 4230
LinkTopic = "pay"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2385
ScaleWidth = 4230
Begin VB.CommandButton Command2
Caption = "下一笔交易"
Height = 375
Left = 2640
TabIndex = 8
Top = 1920
Width = 1095
End
Begin VB.TextBox Text2
Alignment = 2 'Center
Height = 375
Left = 1680
TabIndex = 4
Top = 840
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 600
TabIndex = 0
Top = 1920
Width = 855
End
Begin VB.Label Label8
Alignment = 2 'Center
Height = 375
Left = 1680
TabIndex = 10
Top = 1440
Width = 1095
End
Begin VB.Label Label7
Alignment = 2 'Center
Height = 375
Left = 1680
TabIndex = 9
Top = 240
Width = 1095
End
Begin VB.Label Label6
Caption = "元"
Height = 375
Left = 3000
TabIndex = 7
Top = 1440
Width = 615
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Caption = "应找:"
Height = 375
Left = 360
TabIndex = 6
Top = 1440
Width = 975
End
Begin VB.Label Label4
Caption = "元"
Height = 375
Left = 3000
TabIndex = 5
Top = 840
Width = 735
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Caption = "实收:"
Height = 375
Left = 480
TabIndex = 3
Top = 840
Width = 855
End
Begin VB.Label Label2
Caption = "元"
Height = 375
Left = 3000
TabIndex = 2
Top = 240
Width = 615
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "应收:"
Height = 375
Left = 480
TabIndex = 1
Top = 240
Width = 855
End
End
Attribute VB_Name = "pay"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'Dim Mcon As ADODB.Connection
'Set Mcon = New ADODB.Connection
Dim rsSale As New ADODB.Recordset
Dim rsMerchInfo As New ADODB.Recordset
Dim d As String
Dim j As Currency
Dim k As String
Dim mid As String
Dim Sdate As String
Dim Snum As Integer
Dim Sprice As Currency
Dim mcode As String
Dim today As String
Dim bool2 As Boolean
Dim tp As String
Dim mp As Currency
Dim lp As Integer
d = menu.Label3.Caption
j = Label7.Caption
k = menu.Text1.Text
'Mcon.ConnectionString = "Provider=sqloledb;Data Source=172.26.10.5;Initial Catalog=SuperMarketdb;User Id=sa;Password=kof;"
'Mcon.Open
If Val(Label7.Caption) > Val(Text2.Text) Then
MsgBox "输入错误,所买货物价格高于所输入的数目,请检查!", , "提示:"
Text2.SetFocus
Exit Sub
ElseIf Text2.Text = "" Then
MsgBox "没有输入数字,请检查!", , "提示:"
Else
Label8.Caption = str(Val(Text2.Text) - Val(Label7.Caption))
End If
For m = 1 To i
temp1 = menu.MSHFlexGrid1.TextMatrix(m, 0)
temp3 = Val(menu.MSHFlexGrid1.TextMatrix(m, 3))
'temp3 = mnum - Val(Text2.Text)
Mcon.Execute ("update MerchInfo set MerchNum = Merchnum - " & temp3 & " where MerchID =" & temp1 & "")
Next m
If menu.Chkmem.value = 1 Then
Mcon.Execute ("update Member set TotalCost= " & temp2 & " where MemberCard=" & memID & "")
End If
If menu.Chkmem.value = 1 Then
Mcon.Execute ("insert into Dealing values ('" & d & "'," & j & ", '" & sid & "'," & k & ")")
Else: Mcon.Execute ("insert into Dealing values ('" & d & "'," & j & " ,'" & sid & "', Null )")
End If
For j = 1 To i
If rsSale.State = 1 Then
rsSale.Close
End If
rsSale.Open "SELECT MerchID,SaleDate,SaleNum,SalePrice FROM Sale ", Mcon, adOpenStatic, adLockBatchOptimistic
Do While Not rsSale.EOF
mid = rsSale!MerchID
Sdate = rsSale!SaleDate
Snum = rsSale!Salenum
Sprice = rsSale!SalePrice
today = menu.Label3.Caption
tp = menu.MSHFlexGrid1.TextMatrix(j, 0)
'MsgBox "i:j:g" & i & j & mid
If mid = tp Then
If Sdate = today Then
bool2 = True
'rsSale.MoveFirst
Exit Do
Else
bool2 = False
'Exit Do
End If
End If
'MsgBox bool2
rsSale.MoveNext
Loop
' MsgBox tp
If bool2 = True Then
mp = (Sprice * Snum + Val(menu.MSHFlexGrid1.TextMatrix(j, 2)) * Val(menu.MSHFlexGrid1.TextMatrix(j, 3))) / (Snum + Val(menu.MSHFlexGrid1.TextMatrix(j, 3)))
lp = Snum + Val(menu.MSHFlexGrid1.TextMatrix(j, 3))
''MsgBox mp
'MsgBox lp
'MsgBox mid
Mcon.Execute ("update Sale set SaleNum=" & lp & ",SalePrice=" & mp & " where MerchID =" & mid & "")
Else
Mcon.Execute ("insert into Sale values('" & tp & "','" & today & "'," & menu.MSHFlexGrid1.TextMatrix(j, 3) & " ," & menu.MSHFlexGrid1.TextMatrix(j, 2) & ")")
End If
Next j
'Mcon.Close
End Sub
Private Sub Command2_Click()
menu.MSHFlexGrid1.ClearStructure
menu.MSHFlexGrid1.Rows = 2
menu.MSHFlexGrid1.TextMatrix(0, 0) = "商品编号"
menu.MSHFlexGrid1.TextMatrix(0, 1) = "商品名称"
menu.MSHFlexGrid1.TextMatrix(0, 2) = "单价(元)"
menu.MSHFlexGrid1.TextMatrix(0, 3) = "商品数量"
i = 0
total = 0
menu.Chkmem.value = 0
menu.Text1.Text = ""
menu.Label10.Caption = 0
temp3 = 0
temp2 = 0
snumber = snumber + 1
menu.Label6.Caption = temp & CStr(snumber)
Unload Me
End Sub
Private Sub Form_Load()
Label7.Caption = menu.Label10.Caption
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call Command1_Click
End If
If KeyAscii < 57 And KeyAscii > 47 Or KeyAscii = 8 Or KeyAscii = 46 Then
Else: MsgBox "请输入数字!", , "提示:"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -