机房收费系统之结账
2018-02-27 21:17
183 查看
流程图
部分代码
Private Sub SSTab1_Click(PreviousTab As Integer) Dim mrcCan As ADODB.Recordset Dim MsgText As String Dim txtSQL As String Dim mrcReC As ADODB.Recordset Dim mrcStu As ADODB.Recordset Dim mrc As ADODB.Recordset Select Case SSTab1.Tab Case 0 myFlexgrid1.Clear myFlexgrid1.Rows = 2 '表格的首行 With myFlexgrid1 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" End With '连接数据库 txtSQL = "select *from student_Info where userID='" & Trim(cmbUserId.Text) & "'" Set mrcStu = ExecuteSQL(txtSQL, MsgText) myFlexgrid1.Rows = myFlexgrid1.Rows - 1 Do While Not mrcStu.EOF With myFlexgrid1 .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrcStu.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrcStu.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrcStu.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrcStu.Fields(13)) mrcStu.MoveNext End With Loop 'mrcStu.Update mrcStu.Close Case 1 myFlexgrid2.Clear myFlexgrid2.Rows = 2 '表格的首行 With myFlexgrid2 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "充值金额" .TextMatrix(0, 3) = "日期" .TextMatrix(0, 4) = "时间" End With '连接数据库 txtSQL = "select *from ReCharge_Info where userID='" & Trim(cmbUserId.Text) & "'" Set mrcReC = ExecuteSQL(txtSQL, MsgText) myFlexgrid2.Rows = myFlexgrid2.Rows - 1 Do While Not mrcReC.EOF With myFlexgrid2 .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrcReC.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrcReC.Fields(2)) .TextMatrix(.Rows - 1, 2) = Trim(mrcReC.Fields(3)) .TextMatrix(.Rows - 1, 3) = Trim(mrcReC.Fields(4)) .TextMatrix(.Rows - 1, 4) = Trim(mrcReC.Fields(5)) mrcReC.MoveNext End With Loop mrcReC.Close Case 2 myFlexgrid3.Clear myFlexgrid3.Rows = 2 '表格的首行 With myFlexgrid3 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" .TextMatrix(0, 4) = "退卡金额" End With '连接数据库 txtSQL = "select *from CancelCard_Info where userID='" & Trim(cmbUserId.Text) & "'" Set mrcCan = ExecuteSQL(txtSQL, MsgText) myFlexgrid3.Rows = myFlexgrid3.Rows - 1 Do While Not mrcCan.EOF With myFlexgrid3 .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrcCan.Fields(0)) .TextMatrix(.Rows - 1, 1) = Trim(mrcCan.Fields(1)) .TextMatrix(.Rows - 1, 2) = Trim(mrcCan.Fields(2)) .TextMatrix(.Rows - 1, 3) = Trim(mrcCan.Fields(3)) .TextMatrix(.Rows - 1, 4) = Trim(mrcCan.Fields(4)) mrcCan.MoveNext End With Loop mrcCan.Close Case 3 myFlexgrid4.Clear myFlexgrid4.Rows = 2 '表格的首行 With myFlexgrid4 .CellAlignment = 4 .TextMatrix(0, 0) = "学号" .TextMatrix(0, 1) = "卡号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "时间" End With '连接数据库 txtSQL = "select *from student_Info where userID='" & Trim(cmbUserId.Text) & "'and type='" & "临时用户" & "'" Set mrcStu = ExecuteSQL(txtSQL, MsgText) myFlexgrid4.Rows = myFlexgrid4.Rows - 1 Do While Not mrcStu.EOF With myFlexgrid4 .Rows = .Rows + 1 .CellAlignment = 4 .TextMatrix(.Rows - 1, 0) = Trim(mrcStu.Fields(1)) .TextMatrix(.Rows - 1, 1) = Trim(mrcStu.Fields(0)) .TextMatrix(.Rows - 1, 2) = Trim(mrcStu.Fields(12)) .TextMatrix(.Rows - 1, 3) = Trim(mrcStu.Fields(13)) mrcStu.MoveNext End With Loop mrcStu.Close Case 4 '计算售卡张数 txtSQL = "select count(*) from student_Info where userID='" & Trim(cmbUserId.Text) & "'and Ischeck='" & "未结账" & "'" Set mrcStu = ExecuteSQL(txtSQL, MsgText) txtSellCardCount.Text = Trim(mrcStu.Fields(0)) '计算退卡张数 txtSQL = "select count(*) from CancelCard_Info where userID='" & Trim(cmbUserId.Text) & "'and status='" & "未结账" & "'" Set mrcCan = ExecuteSQL(txtSQL, MsgText) txtQuitCardcount.Text = Val(mrcCan.Fields(0)) '计算充值金额(不区分固定还是临时用户) txtSQL = "select sum(addmoney) from ReCharge_Info where userID='" & Trim(cmbUserId.Text) & "'and status = '" & "未结账" & "'" Set mrcReC = ExecuteSQL(txtSQL, MsgText) If IsNull(mrcReC.Fields(0)) Then '无记录 txtRechargeMoney.Text = "0" Else txtRechargeMoney.Text = mrcReC.Fields(0) End If '计算退卡金额 txtSQL = "select sum(CancelCash) from CancelCard_Info where userID = '" & Trim(cmbUserId.Text) & "'and status = '" & "未结账" & "'" Set mrcCan = ExecuteSQL(txtSQL, MsgText) If IsNull(mrcCan.Fields(0)) Then '无记录 txtQuitCardMoney.Text = "0" Else txtQuitCardMoney.Text = mrcCan.Fields(0) End If '计算临时收费金额 txtSQL = "select sum(addmoney)as sum from student_info ,ReCharge_Info where student_info.cardno=recharge_info.cardno and student_info.cardno = '" & Trim(cmbUserId.Text) & "' and ischeck = '未结账' and type = '临时用户'" Set mrc = ExecuteSQL(txtSQL, MsgText) If IsNull(mrc.Fields(0)) Then '无记录 txtTemReceiveMoney.Text = "0" Else txtTemReceiveMoney.Text = mrc.Fields(0) End If '计算应收金额 txtShouldGainMoney.Text = Val(txtRechargeMoney.Text) - Val(txtQuitCardMoney.Text) '计算总售卡数 txtAllCardCount.Text = Val(txtSellCardCount) - Val(txtQuitCardcount) Case 5 Unload Me End Select End Sub
ps:在这个地方我使用了select语句,其实也可以用if语句
总结
结账中的购卡、充值、退卡,以及临时用户是简单的数据库的调用,表格的显示;但是汇总的部分就涉及了一些逻辑计算,以及逻辑关系,因此要好好注意这部分,会让自己对数据库有更多的了解。感谢大家的支持,若是有需要修改的地方欢迎大家指出~~相关文章推荐
- 机房收费系统之结账窗体理解
- 机房收费系统——结账
- VB.net版机房收费系统——结账功能实现(调错与优化)
- 【机房收费系统】结账
- 【机房收费系统】——结账
- 机房收费系统之结账
- 机房收费系统--结账(一)
- 机房收费系统关于结账和账单生成的计算问题
- 机房收费系统—结账
- 第一次机房收费系统——结账
- 机房收费系统—结账
- 职责链模式——机房收费系统下机结账
- 机房收费系统——结账
- 机房收费系统之结账
- 机房收费系统(1)之结账
- 机房收费系统之结账与报表(二)周报表制作《一学就会傻瓜版》
- 机房收费系统之结账与报表(三)VB与报表代码《一学就会傻瓜版》
- 机房收费系统-结账
- 机房收费系统之日结账单表
- 【机房收费系统】日结账单报表实现