近几天一直在看米老师语录,其中有一条是:“技术永远是第二 ;思想永远是第一”。在机房收费系统结账的方面体现的真是很淋漓尽致。在结账这部分中汇总了任何人员的操作记录(购卡、充值、退卡、临时用户),最后结账可以将一日的账单展示在日结账单上,同理周结账单也可以展示。
结账的目的:管理员进行一些统计,看看每天的收益怎么样,看看有没有操作员违纪,开小车。最后计算自己一天能挣多少,并导入日结和周结账单中,可以说结账是机房最重要的一部分之一,如果帐不好,就会影响收益。
结账要达到的程度:对一个操作员或管理员结账,在SSTAB控件中依次显示此人所进行的一系列操作,在汇总中显示操作人员售卡、退卡、充值、临时以及总退卡、总金额等,点击结账后,再次点击将不再显示。
重点部分解释及代码:
购卡:
'将购卡信息显示在控件中
txtSQL = "select studentNo,cardno,date,time from student_Info where Ischeck='未结账' and UserID='" & CmdUserId.Text & "'" Set mrcSD = ExecuteSQL(txtSQL, MsgText)
myflexgrid1.Rows = mrcSD.RecordCount + 1
With myflexgrid1 .Row = 0 While mrcSD.EOF = False .Row = .Row + 1 .TextMatrix(.Row, 0) = " " & mrcSD.Fields(0) .TextMatrix(.Row, 1) = " " & mrcSD.Fields(1) .TextMatrix(.Row, 2) = " " & mrcSD.Fields(2) .TextMatrix(.Row, 3) = " " & mrcSD.Fields(3) mrcSD.MoveNext Wend End With
充值记录计算总和
'把该操作员的所有未结账的充值信息汇总到表格,一个注册信息对应一个充值信息 txtSQL = "select studentNo,cardno,addmoney,date,time from ReCharge_Info where status='未结账' and UserID='" & CmdUserId.Text & "'" Set mrcRC = ExecuteSQL(txtSQL, MsgText)
myflexgrid2.Rows = mrcRC.RecordCount + 1 If IsNull(mrcRC.Fields(2)) Then mrcRC.Fields(2) = 0 End If With myflexgrid2 .Row = 0 While Not mrcRC.EOF .Row = .Row + 1 .TextMatrix(.Row, 0) = " " & Trim(mrcRC.Fields(0)) .TextMatrix(.Row, 1) = " " & mrcRC.Fields(1) .TextMatrix(.Row, 2) = " " & mrcRC.Fields(2) .TextMatrix(.Row, 3) = " " & mrcRC.Fields(3) .TextMatrix(.Row, 4) = " " & mrcRC.Fields(4) RechargeCash = Val(mrcRC.Fields(2)) + RechargeCash '计算充值总和 mrcRC.MoveNext Wend RechargeCash = RechargeCash + Val(zhuce) '计算总的收入 End With
退卡
'把所有信息汇总到表格 txtSQL = "select studentNo,cardNo,date,time,cancelcash from CancelCard_Info where UserID='" & CmdUserId.Text & "'" Set mrcCC = ExecuteSQL(txtSQL, MsgText)
myflexgrid3.Rows = mrcCC.RecordCount + 1
With myflexgrid3 .Row = 0
While mrcCC.EOF = False .Row = .Row + 1 .TextMatrix(.Row, 0) = " " & Trim(mrcCC.Fields(0)) .TextMatrix(.Row, 1) = " " & mrcCC.Fields(1) .TextMatrix(.Row, 2) = " " & mrcCC.Fields(2) .TextMatrix(.Row, 3) = " " & mrcCC.Fields(3) .TextMatrix(.Row, 4) = " " & mrcCC.Fields(4) cancelCash = cancelCash + mrcCC.Fields(4) mrcCC.MoveNext Wend End With
临时用户'临时用户显示信息并计算费用 txtSQL = "select studentNo,cardNo,date,time ,cash from student_Info where type='" & "临时用户" & "'" Set mrc = ExecuteSQL(txtSQL, MsgText) myflexgrid4.Rows = mrc.RecordCount + 1 With myflexgrid4 .Row = 0 While mrc.EOF = False .Row = .Row + 1 .TextMatrix(.Row, 0) = " " & mrc.Fields(0) .TextMatrix(.Row, 1) = " " & mrc.Fields(1) .TextMatrix(.Row, 2) = " " & mrc.Fields(2) .TextMatrix(.Row, 3) = " " & mrc.Fields(3) LinshiCash = LinshiCash + mrc.Fields(4)
mrc.MoveNext Wend End With
结账Private Sub cmdCheckOut_Click() '把该操作员 有关的 未结账信息 修改成 已结账
Dim txtSQL As String Dim MsgText As String Dim mrcSD As ADODB.Recordset Dim mrcRC As ADODB.Recordset Dim mrcCC As ADODB.Recordset On Error GoTo a txtSQL = "select Ischeck from student_Info where Ischeck='未结账' and UserID='" & CmdUserId.Text & "'" Set mrcSD = ExecuteSQL(txtSQL, MsgText)
txtSQL = "select status from Recharge_Info where status='未结账' and UserID='" & CmdUserId.Text & "'" Set mrcRC = ExecuteSQL(txtSQL, MsgText)
txtSQL = "select Ischeck from CancelCard_Info where Ischeck='未结账' and UserId='" & CmdUserId.Text & "'" Set mrcCC = ExecuteSQL(txtSQL, MsgText)
While mrcSD.EOF = False '修改数据库 并且 更新 mrcSD.Fields(0) = "已结账" mrcSD.Update '更新数据库 mrcSD.MoveNext Wend mrcSD.Close '关闭释放空间 While mrcRC.EOF = False mrcRC.Fields(0) = "已结帐" mrcRC.Update mrcRC.MoveNext
Wend mrcRC.Close
While mrcCC.EOF = False mrcCC.Fields(0) = "已结帐"
mrcCC.Update mrcCC.MoveNext Wend mrcCC.Close a: '将数据清空 txtSaleCard.Text = 0 txtCancelCard.Text = 0 txtRechargeCash.Text = 0 txtlinshi.Text = 0 txtCancelCash.Text = 0 txtSumCard.Text = 0 txtSumCash.Text = 0 MsgBox "结账成功", vbOKOnly + vbInformation, "提示" Call viewdate '更新 汇总信息
End Sub
三、总结篇
通过学习结账,真心可以锻炼自己的逻辑思维,什么时候要更改数据,什么时候要提取数据,对数据库有了一部分的理解。同时,觉得数据库已经不再像一开始那么难了。总之呢!敲系统不是目的,重要的是思想的锻炼。技术永远是第二 ;思想永远是第一。