结账窗体在机房收费系统里占了重要的位置,比如一个网吧,每天的账算不清,那岂不是要天天亏钱,那还不得倒闭破产了。要做一个完美的结账,首先要有一个完整的流程图。
紧接着按着自己的流程图写代码
Dim mrc As ADODB.Recordset
Dim mrcc As ADODB.Recordset
Dim mrccc As ADODB.Recordset
Dim mrcccc As ADODB.Recordset
Dim txtsql As String
Dim msgtext As String
txtsql = "select * from student_info where userid= '" & comboOpUserID.Text & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
With MSFlexGrid4
.Rows = 1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
Do While Not mrc.EOF
.ColAlignment(1) = flexAlignCenterCenter
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(0))
.TextMatrix(.Rows - 1, 2) = mrc.Fields(12)
.TextMatrix(.Rows - 1, 3) = mrc.Fields(13)
mrc.MoveNext
Loop
End With
txtsql = "select * from recharge_info where userid= '" & comboOpUserID.Text & "'"
Set mrcc = ExecuteSQL(txtsql, msgtext)
With MSFlexGrid3
.Rows = 1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While Not mrcc.EOF
.ColAlignment(1) = flexAlignCenterCenter
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = Trim(mrcc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcc.Fields(2))
.TextMatrix(.Rows - 1, 2) = mrcc.Fields(3)
.TextMatrix(.Rows - 1, 3) = mrcc.Fields(4)
.TextMatrix(.Rows - 1, 4) = mrcc.Fields(5)
mrcc.MoveNext
Loop
End With
txtsql = "select * from cancelcard_info where userid= '" & comboOpUserID.Text & "'"
Set mrccc = ExecuteSQL(txtsql, msgtext)
With MSFlexGrid2
.Rows = 1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.TextMatrix(0, 4) = "退卡金额"
Do While Not mrccc.EOF
.ColAlignment(1) = flexAlignCenterCenter
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = Trim(mrccc.Fields(0))
.TextMatrix(.Rows - 1, 1) = Trim(mrccc.Fields(1))
.TextMatrix(.Rows - 1, 2) = mrccc.Fields(3)
.TextMatrix(.Rows - 1, 3) = mrccc.Fields(4)
.TextMatrix(.Rows - 1, 4) = mrccc.Fields(2)
mrccc.MoveNext
Loop
End With
txtsql = "select * from student_info where userid= '" & comboOpUserID.Text & "'"
Set mrcccc = ExecuteSQL(txtsql, msgtext)
With MSFlexGrid1
.Rows = 1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.TextMatrix(0, 4) = "充值金额"
Do While Not mrcccc.EOF
.ColAlignment(1) = flexAlignCenterCenter
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = Trim(mrcccc.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcccc.Fields(0))
.TextMatrix(.Rows - 1, 2) = mrcccc.Fields(12)
.TextMatrix(.Rows - 1, 3) = mrcccc.Fields(13)
.TextMatrix(.Rows - 1, 4) = mrcccc.Fields(7)
mrcccc.MoveNext
Loop
End With
txtSellCardSum = ""
txtBackCardSum = ""
txtRecharge = ""
txtBackCardMoney = ""
txtSellCardActua = ""
txtCollectMoney = ""
txtTemRecharge = ""
txtSellCardSum = Int(MSFlexGrid4.Rows - 1) '售卡张数
txtBackCardSum = Int(MSFlexGrid2.Rows - 1) '退卡张数
If MSFlexGrid3.Rows = 1 Then
txtRecharge = "0"
Else
For i = 1 To MSFlexGrid3.Rows - 1 '充值金额
CSum = CSum + Val(MSFlexGrid3.TextMatrix(i, 2))
Next i
txtRecharge = CSum
End If
If MSFlexGrid2.Rows = 1 Then
txtBackCardMoney = "0"
Else
For i = 1 To MSFlexGrid2.Rows - 1 '退卡金额
TSum = TSum + Val(MSFlexGrid2.TextMatrix(i, 4))
Next i
txtBackCardMoney = TSum
End If
If MSFlexGrid1.Rows = 1 Then
txtTemRecharge = "0"
Else
For i = 1 To MSFlexGrid1.Rows - 1 '临时收费金额
LSum = LSum + Val(MSFlexGrid1.TextMatrix(i, 4))
Next i
txtTemRecharge = LSum
End If
txtSellCardActua = Val(txtSellCardSum) - Val(txtBackCardSum) '总售卡数
txtCollectMoney = Val(txtTemRecharge.Text) + CSum - TSum '应收金额
mrc.Close
mrcc.Close
mrccc.Close
mrcccc.Close