周所周知,结账在日常生活中非常的常见,可以更加结账的消费额。来判断对于以后的改革和创新。在机房收费系统中,我认为结账是最难的。既要考虑表之间的操作。而且还要练习实际情况对于收费金额进行计算。生活中处处皆是学问。在这里体现的尤其明显。
实现思路:1、选择操作员(包括操作员和管理员),在此操作员的前提下进行下列操作。
2、以购卡为例。找到对于表选择此操作员未结账的所购卡。
3、汇总对于此操作员的各种操作。
4、单击结账,改变表状态,数据写入日结账单。
对于所涉及的表梳理。
'对于购卡表的操作。状态未结账,操作员还要一致 txtsql = "select * from student_info where userid = '" & Trim(CmbUserID.Text) & "' And Ischeck = '" & "未结账" & "'" Set mrc = ExecuteSQL(txtsql, msgtext) With MSHFlexGrid1 .Rows = 1 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" Do While Not mrc.EOF .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(13)) mrc.MoveNext Loop End With mrc.Close
对于汇总窗口的实现。
'对于售卡张数的实现。查询学生表中有几条记录 txtsql = "select count(cardno) from student_info where userid = '" & Trim(CmbUserID.Text) & "' and Ischeck = '" & "未结账" & "'" Set mrc = ExecuteSQL(txtsql, msgtext) txtSaleCard.Text = Val(mrc.Fields(0)) '对于退卡张数的实现。 txtsql = "select count(cardno) from cancelcard_info where userid = '" & Trim(CmbUserID.Text) & "' And status = '" & "未结账" & "'" Set mrcc = ExecuteSQL(txtsql, msgtext) txtCancelCard.Text = Val(mrcc.Fields(0)) txtCard.Text = Val(txtSaleCard.Text) - Val(txtCancelCard.Text) '对应充值金额的实现,为recharge表中的金额 txtsql = "select * from recharge_info where userid = '" & Trim(CmbUserID.Text) & "' and status = '" & "未结账" & "'" Set mrb = ExecuteSQL(txtsql, msgtext) i = 0 Do While Not mrb.EOF i = i + Val(mrb.Fields(3)) mrb.MoveNext Loop txtRecharge.Text = Trim(i) mrb.Close '对于临时收费金额的实现,为recharge表中的金额临时用户的充值加上注册。 txtsql = "select * from recharge_info where userid = '" & Trim(CmbUserID.Text) & "' and status = '" & "未结账" & "' and type = '" & "临时用户" & "'" Set mrbb = ExecuteSQL(txtsql, msgtext) Set mrbb = ExecuteSQL(txtsql, msgtext) j = 0 Do While Not mrbb.EOF j = j + Val(mrbb.Fields(3)) mrbb.MoveNext Loop txtTmpRecharge.Text = Trim(Val(j)) mrbb.Close '对于退卡金额的实现,cancelcard表中的金额。临时用户下机等于退卡。 txtsql = "select * from cancelcard_info where userid = '" & Trim(CmbUserID.Text) & "' and status = '" & "未结账" & "'" Set mrd = ExecuteSQL(txtsql, msgtext) k = 0 Do While Not mrd.EOF k = k + Val(mrd.Fields(2)) mrd.MoveNext Loop txtCancelCash.Text = Trim(k) '应收金额的实现。充值金额减去退卡金额。 txtCash.Text = Val(i) - Val(k)在单击结账之后需要对三个表中的记录状态进行修改。以防二次结账。
Dim txtsql As String Dim msgtext As String Dim mrc As ADODB.Recordset Dim mrcc As ADODB.Recordset Dim mrb As ADODB.Recordset Dim mrbb As ADODB.Recordset Dim mrd As ADODB.Recordset Dim mrdd As ADODB.Recordset Dim lastmoney As String Dim nowmoney As String '结账需要更改数据库中用户的结账状态。 '对于student表中状态的修改。 txtsql = "select * from student_info where userid = '" & Trim(CmbUserID.Text) & "' And Ischeck = '" & "未结账" & "'" Set mrc = ExecuteSQL(txtsql, msgtext) Do While Not mrc.EOF mrc.Fields(11) = Trim("结账") mrc.MoveNext Loop mrc.Close '对cancelcard表中状态的改变。 txtsql = "select * from cancelcard_info where userid = '" & Trim(CmbUserID.Text) & "' and status = '" & "未结账" & "'" Set mrcc = ExecuteSQL(txtsql, msgtext) Do While Not mrcc.EOF mrcc.Fields(6) = Trim("结账") mrcc.MoveNext Loop mrcc.Close '对recharge表中状态的修改。 txtsql = "select * from recharge_info where userid = '" & Trim(CmbUserID.Text) & "' and status = '" & "未结账" & "'" Set mrbb = ExecuteSQL(txtsql, msgtext) Do While Not mrbb.EOF mrbb.Fields(7) = Trim("结账") mrbb.MoveNext Loop mrbb.Close '需要向日结账单表中添加数据。上期剩余金额,充值金额,消费金额,退卡金额,汇总金额,日期, '上期剩余金额。 txtsql = "select * from checkday_info " Set mrb = ExecuteSQL(txtsql, msgtext) mrb.MoveLast lastmoney = mrb.Fields(4) mrb.MoveFirst txtsql = "select sum(consume) from Line_Info where offdate='" & date & "'" '本期消费金额当天 Set mrd = ExecuteSQL(txtsql, msgtext) '汇总金额,充值减去退卡加上上期剩余余额 nowmoney = Val(txtCash.Text) + Val(lastmoney) '往checkday中添加一条记录 mrb.AddNew mrb.Fields(0) = lastmoney mrb.Fields(1) = Trim(txtRecharge.Text) '本期充值金额 mrb.Fields(2) = Trim(mrd.Fields(0)) '消费金额为line表中的所有记录的消费额的总和。 mrb.Fields(3) = Trim(txtCancelCard.Text) '本期退卡金额 mrb.Fields(4) = Trim(nowmoney) mrb.Fields(5) = Format(Now, "yyyy-mm-dd") mrb.Update mrb.Close MsgBox "结账成功", vbOKOnly + vbExclamation, "提示"