您的位置:首页 > 其它

【机房收费系统】结账

2016-09-09 20:57 288 查看
我在进行结账窗体的时候,真的是被困了很长时间,好多逻辑性的东西以及一些常识性的东西都没有考虑到,花了整整1天时间才算是初步整理清楚,下面就将一些我遇到的问题以及应该考虑到的问题写下来,希望可以帮助到有需要的读者。

首先,在窗体加载的时候应该让它自动查询管理员和操作员的信息并且在下拉控件中显示;其次,当选中用户的时候应该显示用户真实姓名;然后,在SSTab控件中显示该用户的相应操作信息;最后,结账的时候应该修改相应的数据库信息(将结账的所有账户信息改为“已结账”),并且在checkWeek_Info和checkDay_Info中添加数据,方便在报表中调用,完成之后将窗体的所有信息清0。注意:既然这里将所有信息都改为了“已结账”,那么这些用户下次登录的记录将不再收集,但是确实消费了,所以在下次登录的时候应该将余额大于0的用户统一改回“未结账”

对了,我在Recharge_Info表中添加了一个新的列Type,用来显示用户的类型。下面是在SSTab控件中用来显示信息的代码,至于放在什么事件中,个人有个人的想法,我就不展示了。

'根据已经选择好的人员信息来修改SSTab里面的汇总信息
Dim txtSQL1 As String
Dim txtSQL2 As String
Dim txtSQL3 As String
Dim txtSQL4 As String
Dim txtSQL5 As String
Dim txtSQL6 As String
Dim MsgText As String
Dim Smsgtext As String
Dim mrc1 As ADODB.Recordset
Dim mrc2 As ADODB.Recordset
Dim mrcSD As ADODB.Recordset
Dim mrcRC As ADODB.Recordset
Dim mrcCC As ADODB.Recordset
Dim mrcS As ADODB.Recordset

Select Case SSTab1.Tab
Case 0
'把操作员的所有信息,未结账的显示出来 学生表
txtSQL1 = "select * from student_Info where ischeck='未结账' and userid='" & Trim(cboUser.Text) & "'"
Set mrcSD = ExecuteSQL(txtSQL1, MsgText)

MSHFlexGrid1.Rows = mrcSD.RecordCount + 1

With MSHFlexGrid1
.CellAlignment = 4
.Rows = 1                                              '初始化,每次开始都是一列
.TextMatrix(0, 0) = "学号"                             '将学号等信息填入作为开头属性
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
Do While mrcSD.EOF = False
.CellAlignment = 4
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = " " & mrcSD.Fields(1)
.TextMatrix(.Rows - 1, 1) = " " & mrcSD.Fields(0)
.TextMatrix(.Rows - 1, 2) = " " & mrcSD.Fields(12)
.TextMatrix(.Rows - 1, 3) = " " & mrcSD.Fields(13)
mrcSD.MoveNext
Loop
End With

Case 1
'把该操作员的所有未结账的充值信息汇总到表格,一个注册信息对应一个充值信息
txtSQL2 = "select * from recharge_Info where status='未结账' and userid='" & Trim(cboUser.Text) & "'"
Set mrcRC = ExecuteSQL(txtSQL2, MsgText)

MSHFlexGrid2.Rows = mrcRC.RecordCount + 1

If mrcRC.EOF Then
txtRechargeMoney.Text = "0"
Else
With MSHFlexGrid2
.CellAlignment = 4
.Rows = 1                                              '初始化,每次开始都是一列
.TextMatrix(0, 0) = "学号"                             '将学号等信息填入作为开头属性
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While mrcRC.EOF = False
.CellAlignment = 4
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = " " & mrcRC.Fields(1)
.TextMatrix(.Rows - 1, 1) = " " & mrcRC.Fields(2)
.TextMatrix(.Rows - 1, 2) = " " & mrcRC.Fields(3)
.TextMatrix(.Rows - 1, 3) = " " & mrcRC.Fields(4)
.TextMatrix(.Rows - 1, 4) = " " & mrcRC.Fields(5)
mrcRC.MoveNext
Loop
End With
End If

Case 2
'把操作员所有的退卡信息汇总到表格
txtSQL3 = "select * from cancelcard_Info where status='未结账' and userid='" & Trim(cboUser.Text) & "'"
Set mrcCC = ExecuteSQL(txtSQL3, MsgText)

If mrcCC.EOF Then
txtExitCardMoney.Text = "0"
Else
MSHFlexGrid3.Rows = mrcCC.RecordCount + 1
With MSHFlexGrid3
.CellAlignment = 4
.Rows = 1                                              '初始化,每次开始都是一列
.TextMatrix(0, 0) = "学号"                             '将学号等信息填入作为开头属性
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.TextMatrix(0, 4) = "退卡金额"
Do While mrcCC.EOF = False
.CellAlignment = 4
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = " " & mrcCC.Fields(0)
.TextMatrix(.Rows - 1, 1) = " " & 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
End If

Case 3
'把操作员的临时用户信息汇总到表格
txtSQL4 = "select * from student_Info where type='临时用户' and userid='" & Trim(cboUser.Text) & "'and ischeck='未结账'"
Set mrcS = ExecuteSQL(txtSQL4, MsgText)

If mrcS.EOF Then
txtTemporaryCharge.Text = "0"
Else
MSHFlexGrid4.Rows = mrcS.RecordCount + 1
With MSHFlexGrid4
.CellAlignment = 4
.Rows = 1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
.TextMatrix(0, 4) = "金额"

Do While mrcS.EOF = False
.CellAlignment = 4
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = Trim(mrcS.Fields(1))
.TextMatrix(.Rows - 1, 1) = Trim(mrcS.Fields(0))
.TextMatrix(.Rows - 1, 2) = Trim(mrcS.Fields(12))
.TextMatrix(.Rows - 1, 3) = Trim(mrcS.Fields(13))
.TextMatrix(.Rows - 1, 4) = Trim(mrcS.Fields(7))
mrcS.MoveNext
Loop
End With
End If

Case 4
txtSQL6 = "select * from recharge_Info where status='未结账' and userid='" & Trim(cboUser.Text) & " ' and type='临时用户'"
Set mrc2 = ExecuteSQL(txtSQL, MsgText)
If mrc2.EOF Then
Label1.Caption = 0
Else
'直接查询临时用户的充值金额
txtSQL5 = "select sum(addmoney) from recharge_Info where status='未结账' and userid='" & Trim(cboUser.Text) & " ' and type='临时用户'"
Set mrc1 = ExecuteSQL(txtSQL5, MsgText)

Label1.Caption = mrc.Fields(0)   '临时用户的总充值金额
End If
mrc2.Close

If mrc.EOF Then
mrc.Close

End If
'然后,把操作员的所有统计信息汇总到汇总列表
txtMarketCardNumber.Text = Int(MSHFlexGrid1.Rows - 1)  '售卡张数

txtExitCardNumber.Text = Int(MSHFlexGrid3.Rows - 1)     '退卡张数

For i = 1 To MSHFlexGrid2.Rows - 1                     '充值金额
Sum = Sum + Val(MSHFlexGrid2.TextMatrix(i, 2))
Next
txtRechargeMoney.Text = Sum

For i = 1 To MSHFlexGrid3.Rows - 1                      '退卡金额
sum1 = sum1 + Val(MSHFlexGrid3.TextMatrix(i, 4))
Next
txtExitCardMoney.Text = Int(sum1)

txtMarketCardNum.Text = Val(txtMarketCardNumber.Text) - Val(txtExitCardNumber.Text)  '总售卡张数
txtShouldMoney.Text = Sum - sum1                     '应收金额

For i = 1 To MSHFlexGrid4.Rows - 1                   '临时用户金额
sum2 = sum2 + Val(MSHFlexGrid4.TextMatrix(i, 4))
Next
txtTemporaryCharge.Text = Val(Label1.Caption) - Val(sum2)

Case 5
Unload Me
End Select


以上就是汇总信息的代码了,至于怎么算的金额,这里就不写了,代码写的还算清楚,大家自己看吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: