本文主要是介绍第一次机房收费系统之结账,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前言:
机房收费系统的结账窗体主要是先想清楚功能的逻辑思路。
1.结账是结谁的帐?
结账是管理员的权限,是管理员给操作员结账,操作员工作期间售卡以及充值的金额还有退卡时应退给学生的金额。所以结账是操作员工作期间机房的收入。
2.怎么结账?
在SSTab控件中有购卡,充值,退卡,临时用户几个选项卡,临时用户和购卡的收费金额已经结算到充值中,所以现在清楚结账就是:应收金额=充值金额-退卡金额
部分代码:
单击选项卡:
Private Sub SSTab_Click(PreviousTab As Integer)Dim Smrc As ADODB.RecordsetDim Rmrc As ADODB.RecordsetDim Cmrc As ADODB.RecordsetDim SLmrc As ADODB.RecordsetDim StxtSQL As StringDim RtxtSQL As StringDim CtxtSQL As StringDim SLtxtSQL As StringDim Smsgtext As StringDim Rmsgtext As StringDim Cmsgtext As StringDim SLmsgtext As StringDim i As IntegerDim ReChargeSum As Single '定义充值金额Dim j As IntegerDim BackCardMoneySum As Single '定义退卡金额'连接student_info表StxtSQL = "select * from student_info where userid ='" & Trim(cboOpUserID.Text) & "' and ischeck='未结账'"Set Smrc = ExecuteSQL(StxtSQL, Smsgtext)'连接recharge_info表RtxtSQL = "select * from recharge_info where userid='" & Trim(cboOpUserID.Text) & "' and status='未结账'"Set Rmrc = ExecuteSQL(RtxtSQL, Rmsgtext)'连接cancelcard_info表CtxtSQL = "select * from cancelcard_info where userid='" & Trim(cboOpUserID.Text) & "' and status='未结账' "Set Cmrc = ExecuteSQL(CtxtSQL, Cmsgtext)'连接student_info表SLtxtSQL = "select * from student_info where userid ='" & Trim(cboOpUserID.Text) & "' and ischeck='未结账' and type='临时用户'"Set SLmrc = ExecuteSQL(SLtxtSQL, SLmsgtext)Select Case SSTab.Tab'选择购卡Case 0'显示数据With MSHFlexGrid1.rows = 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"Do While Not Smrc.EOF.rows = .rows + 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(.rows - 1, 0) = Smrc.Fields(1).TextMatrix(.rows - 1, 1) = Smrc.Fields(0).TextMatrix(.rows - 1, 2) = Smrc.Fields(12).TextMatrix(.rows - 1, 3) = Smrc.Fields(13)Smrc.MoveNextLoopAdjustColWidth Me, MSHFlexGrid1End With'选择充值Case 1'显示数据With MSHFlexGrid2.rows = 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "充值金额".TextMatrix(0, 3) = "日期".TextMatrix(0, 4) = "时间"Do While Not Rmrc.EOF.rows = .rows + 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(.rows - 1, 0) = Rmrc.Fields(1).TextMatrix(.rows - 1, 1) = Rmrc.Fields(2).TextMatrix(.rows - 1, 2) = Rmrc.Fields(3).TextMatrix(.rows - 1, 3) = Rmrc.Fields(4).TextMatrix(.rows - 1, 4) = Rmrc.Fields(5)Rmrc.MoveNextLoopAdjustColWidth Me, MSHFlexGrid1End With'选择退卡Case 2'显示数据With MSHFlexGrid3.rows = 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间".TextMatrix(0, 4) = "退卡金额"Do While Not Cmrc.EOF.rows = .rows + 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(.rows - 1, 0) = Cmrc.Fields(0).TextMatrix(.rows - 1, 1) = Cmrc.Fields(1).TextMatrix(.rows - 1, 2) = Cmrc.Fields(3).TextMatrix(.rows - 1, 3) = Cmrc.Fields(4).TextMatrix(.rows - 1, 4) = Cmrc.Fields(2)Cmrc.MoveNextLoopAdjustColWidth Me, MSHFlexGrid1End With'选择临时用户Case 3'显示数据With MSHFlexGrid4.rows = 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(0, 0) = "学号".TextMatrix(0, 1) = "卡号".TextMatrix(0, 2) = "日期".TextMatrix(0, 3) = "时间"Do While Not SLmrc.EOF.rows = .rows + 1.CellAlignment = 4.ColAlignment = 4.TextMatrix(.rows - 1, 0) = SLmrc.Fields(1).TextMatrix(.rows - 1, 1) = SLmrc.Fields(0).TextMatrix(.rows - 1, 2) = SLmrc.Fields(12).TextMatrix(.rows - 1, 3) = Trim(SLmrc.Fields(13))SLmrc.MoveNextLoopAdjustColWidth Me, MSHFlexGrid1End With'选择汇总Case 4'计算售卡张数txtSellCardSum.Text = Smrc.RecordCount'计算退卡张数txtBackCardSum.Text = Cmrc.RecordCount'计算总售卡张数txtSellCardActual.Text = Smrc.RecordCount - Cmrc.RecordCount'计算充值金额For i = 0 To Rmrc.RecordCount - 1ReChargeSum = ReChargeSum + Val(Rmrc.Fields(3))Rmrc.MoveNextNext itxtRecharge.Text = ReChargeSum'计算退卡金额For j = 0 To Cmrc.RecordCount - 1BackCardMoneySum = BackCardMoneySum + Val(Cmrc.Fields(2))Cmrc.MoveNextNext jtxtBackCardMoney.Text = BackCardMoneySum'计算应收金额txtCollectMoney.Text = txtRecharge.Text - txtBackCardMoney.TextCase 5Unload MeEnd SelectSmrc.CloseRmrc.CloseCmrc.CloseSLmrc.Close
End Sub
结账:
Private Sub cmdAccount_Click()Dim Smrc, Rmrc, Cmrc As ADODB.RecordsetDim StxtSQL, RtxtSQL, CtxtSQL As StringDim Smsgtext, Cmsgtext, Rmsgtext As StringIf Not Testtxt(cboOpUserID.Text) ThenMsgBox "请先选择操作员后结账!", vbOKOnly + vbExclamation, "提示"Exit SubEnd If'更新student_Info表的更新状态StxtSQL = "update student_Info set Ischeck ='已结账' where userid= '" & cboOpUserID & "'"Call ExecuteSQL(StxtSQL, Smsgtext)'更新recharge_Info表的更新状态RtxtSQL = "update recharge_Info set status ='已结账' where userid= '" & cboOpUserID & "'"Call ExecuteSQL(RtxtSQL, Rmsgtext)'更新cancelcard_Info表的更新状态CtxtSQL = "update cancelcard_Info set status ='已结账' where userid= '" & cboOpUserID & "'"Call ExecuteSQL(CtxtSQL, Cmsgtext)MsgBox "结账成功!", vbOKOnly + vbExclamation, "提示"End Sub
这篇关于第一次机房收费系统之结账的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!