机房收费系统——结账

来源:互联网 发布:免费的cms 编辑:程序博客网 时间:2024/06/04 19:42
    结账,上下机,还有组合窗体,是机房的三个难点。之所以难更多的是因为内容多,相对的就变得复杂了,思路就会混乱,然后脑袋就大了。静下来细细分析后将每一块分开,单独实现某一功能,然后汇总,那基本上就完成了。结账涉及到了财务方面的问题,用了很长时间才弄清各部分的关系。

结账是什么:

    结账是相当于财务部门每天对各部门工作的一个汇总,卖了多少卡,退了多少卡,收了多少钱,退了多少钱,将各部分明细制成表格做以记录。给老板一个简单明了的结果就完成了,这就是我们的任务了。

结账中的具体思路:

    在购卡、充值、退卡、临时用户这四项中的内容是比较好实现的,根据基本表的查询然后显示数据即可。
    在汇总这一块就比较复杂了。结账中所有的信息是查找“未结账”的数据,如果每天都结账那就是结算每天的工作。每天结账
    销售卡数= 每天注册的新卡
    退卡张数=每天有多少人退卡了
    退卡金额= 每个人退卡时,柜台将卡内的余额退给使用者
    充值金额= 每天充值的金额
    临时收费金额=临时用户卡内的钱
    应收金额=充值金额+每次售卡时一次冲进去的金额(我这里在注册时冲进去的钱没有放在充值的表中)-退卡金额
    总售卡数=销售卡数-退卡张数

具体实现:

    (1)点击一个控件时让操作员用户名 与 操作员真实姓名 一同显示
 
Private Sub comboOpUserID_click()                                '点击账号时,使姓名自动显示出来    Dim txtSQL As String    Dim MsgText As String    Dim mrc As ADODB.Recordset            txtSQL = "select userName from user_Info where userID='" & Trim(comboOpUserID.Text) & "'"    Set mrc = ExecuteSQL(txtSQL, MsgText)        comboOpName.Text = mrc.Fields(0)    mrc.Close        Call viewdateEnd Sub
    点击姓名同理可得出。
    (2)选中用户后让SStab自动显示结果这里用到了 viewdate 来反复调用此过程,将数据显示出来。
Private Sub viewdate()    Dim mrc1 As ADODB.Recordset    Dim mrc2 As ADODB.Recordset    Dim mrc3 As ADODB.Recordset    Dim mrc As ADODB.Recordset    Dim txtSQL As String    Dim MsgText As String    Dim txtsql1 As String    Dim msgtext1 As String    Dim txtsql2 As String    Dim msgtext2 As String    Dim txtsql3 As String    Dim msgtext3 As String    Dim RegisterCash As String                     '注册时的金额    Dim RechargeCash As String                     '充值的金额    Dim CancelcardCash As String                   '退卡的金额    Dim tmpCash As String                          '临时用户的金额                                                     'sstab显示信息        txtSQL = "select * from student_info where ischeck='未结账' and userid='" & Trim(comboOpUserID.Text) & "'"                      '显示购卡信息    Set mrc = ExecuteSQL(txtSQL, MsgText)    txtSellCardSum.Text = mrc.RecordCount                                    '购卡总数        With MSFlexGrid1        .Rows = 1        .CellAlignment = 4        .TextMatrix(0, 0) = "学号"        .TextMatrix(0, 1) = "卡号"        .TextMatrix(0, 2) = "注册金额"        .TextMatrix(0, 3) = "日期"        .TextMatrix(0, 4) = "时间"        .ColWidth(3) = 2500        .ColWidth(4) = 2500            Do While mrc.EOF = False            .CellAlignment = 4            .Rows = .Rows + 1            .TextMatrix(.Rows - 1, 0) = Trim(mrc.Fields(1))            .TextMatrix(.Rows - 1, 1) = Trim(mrc.Fields(0))            .TextMatrix(.Rows - 1, 2) = Trim(mrc.Fields(7))            .TextMatrix(.Rows - 1, 3) = Trim(mrc.Fields(12))            .TextMatrix(.Rows - 1, 4) = Trim(mrc.Fields(13))            .ColWidth(3) = 2500            .ColWidth(4) = 2500            RegisterCash = Val(RegisterCash) + Val(Trim(mrc.Fields(7)))                  '注册时总额            mrc.MoveNext        Loop    End With            txtsql1 = "select * from recharge_info where status='未结账' and userid='" & Trim(comboOpUserID.Text) & "'"                  '显示充值信息    Set mrc1 = ExecuteSQL(txtsql1, msgtext1)    With MSFlexGrid2        .Rows = 1        .CellAlignment = 4        .TextMatrix(0, 0) = "学号"        .TextMatrix(0, 1) = "卡号"        .TextMatrix(0, 2) = "充值金额"        .TextMatrix(0, 3) = "日期"        .TextMatrix(0, 4) = "时间"        .ColWidth(3) = 2500        .ColWidth(4) = 2500            Do While mrc1.EOF = False            .CellAlignment = 4            .Rows = .Rows + 1            .TextMatrix(.Rows - 1, 0) = Trim(mrc1.Fields(1))            .TextMatrix(.Rows - 1, 1) = Trim(mrc1.Fields(2))            .TextMatrix(.Rows - 1, 2) = Trim(mrc1.Fields(3))            .TextMatrix(.Rows - 1, 3) = Trim(mrc1.Fields(4))            .TextMatrix(.Rows - 1, 4) = Trim(mrc1.Fields(5))            .ColWidth(3) = 2500            .ColWidth(4) = 2500            RechargeCash = Val(RechargeCash) + Val(Trim(mrc1.Fields(3)))                            '充值总额            mrc1.MoveNext        Loop    End With        txtsql2 = "select * from cancelcard_info where status='未结账' and userid='" & Trim(comboOpUserID.Text) & "'"                  '显示退卡信息    Set mrc2 = ExecuteSQL(txtsql2, msgtext2)    txtBackCardSum.Text = mrc2.RecordCount                                                         '退卡总数    With MSFlexGrid3        .Rows = 1        .CellAlignment = 4        .TextMatrix(0, 0) = "学号"        .TextMatrix(0, 1) = "卡号"        .TextMatrix(0, 2) = "退卡金额"        .TextMatrix(0, 3) = "日期"        .TextMatrix(0, 4) = "时间"        .ColWidth(3) = 2500        .ColWidth(4) = 2500            Do While mrc2.EOF = False            .CellAlignment = 4            .Rows = .Rows + 1            .TextMatrix(.Rows - 1, 0) = Trim(mrc2.Fields(0))            .TextMatrix(.Rows - 1, 1) = Trim(mrc2.Fields(1))            .TextMatrix(.Rows - 1, 2) = Trim(mrc2.Fields(2))            .TextMatrix(.Rows - 1, 3) = Trim(mrc2.Fields(3))            .TextMatrix(.Rows - 1, 4) = Trim(mrc2.Fields(4))            .ColWidth(3) = 2500            .ColWidth(4) = 2500            CancelcardCash = Val(CancelcardCash) + Val(Trim(mrc2.Fields(2)))                          '退卡总额            mrc2.MoveNext        Loop    End With        txtsql3 = "select * from student_info where ischeck='未结账'and status ='使用' and type ='临时用户' and userid='" & Trim(comboOpUserID.Text) & "'"                      '显示临时用户信息    Set mrc3 = ExecuteSQL(txtsql3, msgtext3)    With MSFlexGrid4        .Rows = 1        .CellAlignment = 4        .TextMatrix(0, 0) = "学号"        .TextMatrix(0, 1) = "卡号"        .TextMatrix(0, 2) = "日期"        .TextMatrix(0, 3) = "时间"        .ColWidth(2) = 2500        .ColWidth(3) = 2500            Do While mrc3.EOF = False            .CellAlignment = 4            .Rows = .Rows + 1            .TextMatrix(.Rows - 1, 0) = Trim(mrc3.Fields(1))            .TextMatrix(.Rows - 1, 1) = Trim(mrc3.Fields(0))            .TextMatrix(.Rows - 1, 2) = Trim(mrc3.Fields(12))            .TextMatrix(.Rows - 1, 3) = Trim(mrc3.Fields(13))            .ColWidth(2) = 2500            .ColWidth(3) = 2500            tmpCash = Val(tmpCash) + Val(Trim(mrc3.Fields(7)))                                    '临时用户的总额            mrc3.MoveNext        Loop    End With                                                                            '将数据汇总    txtBackCardMoney.Text = Val(CancelcardCash)    txtRecharge.Text = Val(RechargeCash)    txtTemRecharge.Text = Val(tmpCash)    txtSellCardActual.Text = Val(txtSellCardSum.Text) - Val(txtBackCardSum.Text)    txtCollectMoney.Text = Val(RegisterCash) + Val(RechargeCash) - Val(CancelcardCash)        mrc.Close    mrc1.Close    mrc2.Close    mrc3.Close   
End Sub

结账:

    最后结账时需要将每一项的钱数的总和更新到checkday_info 表中。
    
    RemainCash——本期金额即student_info表中状态为使用的金额的总和
    RechargeCash——今日充值金额
    ConsumeCash——今日消费金额
    CancelCash——今日退卡金额
    AllCash=本期金额+今日消费+今日退卡-今日充值

总结:

    整个结账窗体涉及到的数据特别多,需要认真详细的整理好,学会使用定义变量会有很大的帮助,现在虽然实现了要求,但是还是感觉思路有些乱,所以一定要先把握好思路再开始往下走!
</pre>
0 0
原创粉丝点击