机房收费系统之周结账单

         在做系统的过程中,应该说报表这块儿,尤其是周结账和日结账这块是最繁琐的了,我用了3、4天吧,拿下了这块儿。

         首先看一下这个周结账单

        

           这个窗体的控件我也找了很长时间才找到,显示时间的是DTpicker,日历是monthview。

          首先实例化报表       

     Dim WithEvents report As grproLibCtl.GridppReport '实例化报表

         在报表中初始化日期、用户名

      

Private Sub report_initialize() '初始化数据
    report.ParameterByName("username").AsString = username
    report.ParameterByName("datestart").AsString = Format(startDate.Value, "yyyy-mm-dd")
    report.ParameterByName("dateend").AsString = Format(endDate.Value, "yyyy-mm-dd")

End Sub

 

          下面看一下我的周结账单是如何计算的

Private Sub cmdUpdate_Click()
    Dim strMsg As String
    Dim strSqlRe As String
    Dim mrcRe As ADODB.Recordset
    Dim strSqlCan As String
    Dim mrcCan As ADODB.Recordset
    Dim strSqlWeek As String
    Dim mrcWeek  As ADODB.Recordset
    Dim strSQLL As String
    Dim mrcL As ADODB.Recordset
    Dim Toconsume As Long
    Dim consume As Long
    Dim dateIndex As Date
    Dim datestart As Date
    Dim dateend As Date
    Dim Toremain As Integer
    Dim Torecharge As Integer
    Dim Tocancel As Integer
    Dim remain As Integer
    Dim charge As Integer
    Dim cancel As Integer
    Dim all As Long
    'GRDisplayViewer1.Refresh

    datestart = Format(startDate.Value, "yyyy-mm-dd")
    dateend = Format(endDate.Value, "yyyy-mm-dd")

                 '删除周表中的数据
    strSqlWeek = "delete from checkweek_info "
    Set mrcWeek = executeSQL(strSqlWeek, strMsg)

    For dateIndex = datestart To dateend
        remain = 0
        Recharge = 0
        consume = 0
        cancel = 0
        all = 0
        '上期充值卡余额计算
        If dateIndex = datestart Then
            remain = 0
            Call Form_Load
        Else

            '先算总的recharge
            strSqlRe = "select sum(addmoney) as rechargecash from recharge_info where date<='" & Format(dateIndex - 1, "yyyy-mm-dd") & "'"
            Set mrcRe = executeSQL(strSqlRe, strMsg)
            If Not IsNull(mrcRe!rechargecash) Then
                Recharge = mrcRe!rechargecash
                mrcRe.Close
            End If

            '总的cancelcard
            strSqlCan = "select sum(cancelcash) as cancel from cancelcard_info where date<='" & Format(dateIndex - 1, "yyyy-mm-dd") & "'"
            Set mrcCan = executeSQL(strSqlCan, strMsg)
            If Not IsNull(mrcCan!cancel) Then
               cancel = mrcCan!cancel
               mrcCan.Close
            End If
            '总的consume
            strSQLL = "select sum(consume) as consumecash from line_info where offdate<= '" & Format(dateIndex - 1, "yyyy-mm-dd") & "'"
            Set mrcL = executeSQL(strSQLL, strMsg)
            If Not IsNull(mrcL!consumeCash) Then
                consume = mrcL!consumeCash
                mrcL.Close
            End If
            '上期充值卡余额
            remain = Recharge - consume - cancel
            '本期充值金额
            strSqlRe = "select sum(addmoney) as rechargecash from recharge_info where date='" & Format(dateIndex, "yyyy-mm-dd") & "'"
            Set mrcRe = executeSQL(strSqlRe, strMsg)
            If Not IsNull(mrcRe!rechargecash) Then
                Torecharge = mrcRe!rechargecash
                mrcRe.Close
            End If
            '本期退卡
            strSqlCan = "select sum(cancelcash) as cancel from cancelcard_info where date='" & Format(dateIndex, "yyyy-mm-dd") & "'"
            Set mrcCan = executeSQL(strSqlCan, strMsg)
            If Not IsNull(mrcCan!cancel) Then
                Tocancel = mrcCan!cancel
                mrcCan.Close
            End If
            '本期消费
            strSQLL = "select sum(consume) as consumecash from line_info where offdate= '" & Format(dateIndex, "yyyy-mm-dd") & "'"
            Set mrcL = executeSQL(strSQLL, strMsg)
            If Not IsNull(mrcL!consumeCash) Then
                Toconsume = mrcL!consumeCash
                mrcL.Close
            End If
            '本期充值卡余额
            all = remain + Torecharge - Toconsume - Tocancel
            strSqlWeek = "select * from checkweek_info "
            Set mrcWeek = executeSQL(strSqlWeek, strMsg)
            mrcWeek.AddNew
            mrcWeek.Fields("remaincash") = remain
            mrcWeek.Fields("rechargecash") = Torecharge
            mrcWeek.Fields("consumecash") = Toconsume
            mrcWeek.Fields("cancelcash") = Tocancel
            mrcWeek.Fields("allcash") = all
            mrcWeek.Fields("date") = Format(dateIndex, "yyyy-mm-dd")
            mrcWeek.Update
            mrcWeek.Close
        End If
    Next
    Call Form_Load
    End Sub

Private Sub Form_Load()
    Dim strSQL As String
    Dim strMsg As String
    Dim mrc As ADODB.Recordset
    Dim strSqlRe As String
    Dim mrcRe As ADODB.Recordset
    Dim strSqlCan As String
    Dim mrcCan As ADODB.Recordset
    Dim strSqlWeek As String
    Dim mrcWeek  As ADODB.Recordset
    Dim strSQLL As String
    Dim mrcL As ADODB.Recordset
    Dim Toconsume As Long
    Dim consume As Long
    Dim remain As Integer
    Dim Recharge As Integer
    Dim cancel As Integer
    Dim all As Integer
    Dim Toremain As Integer
    Dim Torecharge As Integer
    Dim Tocancel As Integer

    MonthViewStart.Visible = False
    MonthViewEnd.Visible = False

    strSQL = "select * from checkweek_info where date between '" & Format(startDate.Value, "yyyy-mm-dd") & "' and '" & Format(endDate.Value, "yyyy-mm-dd") & "'"
    Set mrc = executeSQL(strSQL, strMsg)
    strSQL = strSQL & "order by date"
    Set report = New grproLibCtl.GridppReport
    GRDisplayViewer1.Stop
    report.LoadFromFile (App.Path & "\周结账单.grf")

    report.DetailGrid.Recordset.ConnectionString = connectstring()
    report.DetailGrid.Recordset.QuerySQL = strSQL
    GRDisplayViewer1.report = report
    GRDisplayViewer1.Start

    strSqlRe = "select sum(addmoney) as rechargecash from recharge_info where date<='" & Format(startDate.Value - 1, "yyyy-mm-dd") & "'"
    Set mrcRe = executeSQL(strSqlRe, strMsg)
    If Not IsNull(mrcRe!rechargecash) Then
        Recharge = mrcRe!rechargecash
        mrcRe.Close
    End If

    '总的cancelcard
    strSqlCan = "select sum(cancelcash) as cancel from cancelcard_info where date<='" & Format(startDate.Value - 1, "yyyy-mm-dd") & "'"
    Set mrcCan = executeSQL(strSqlCan, strMsg)
    If Not IsNull(mrcCan!cancel) Then
       cancel = mrcCan!cancel
       mrcCan.Close
    End If
    '总的consume
    strSQLL = "select sum(consume) as consumecash from line_info where offdate<= '" & Format(startDate.Value - 1, "yyyy-mm-dd") & "'"
    Set mrcL = executeSQL(strSQLL, strMsg)
    If Not IsNull(mrcL!consumeCash) Then
        consume = mrcL!consumeCash
        mrcL.Close
    End If
    '上期充值卡余额
    remain = Recharge - consume - cancel
    '本期充值金额
    strSqlRe = "select sum(addmoney) as rechargecash from recharge_info where date='" & Format(startDate.Value, "yyyy-mm-dd") & "'"
    Set mrcRe = executeSQL(strSqlRe, strMsg)
    If Not IsNull(mrcRe!rechargecash) Then
        Torecharge = mrcRe!rechargecash
        mrcRe.Close
    End If
    '本期退卡
    strSqlCan = "select sum(cancelcash) as cancel from cancelcard_info where date='" & Format(startDate.Value, "yyyy-mm-dd") & "'"
    Set mrcCan = executeSQL(strSqlCan, strMsg)
    If Not IsNull(mrcCan!cancel) Then
        Tocancel = mrcCan!cancel
        mrcCan.Close
    End If
    '本期消费
    strSQLL = "select sum(consume) as consumecash from line_info where offdate= '" & Format(startDate.Value, "yyyy-mm-dd") & "'"
    Set mrcL = executeSQL(strSQLL, strMsg)
    If Not IsNull(mrcL!consumeCash) Then
        Toconsume = mrcL!consumeCash
        mrcL.Close
    End If
    '本期充值卡余额
    all = remain + Torecharge - Toconsume - Tocancel
    strSqlWeek = "select * from checkweek_info "
    Set mrcWeek = executeSQL(strSqlWeek, strMsg)
    mrcWeek.AddNew
    mrcWeek.Fields("remaincash") = remain
    mrcWeek.Fields("rechargecash") = Torecharge
    mrcWeek.Fields("consumecash") = Toconsume
    mrcWeek.Fields("cancelcash") = Tocancel
    mrcWeek.Fields("allcash") = all
    mrcWeek.Fields("date") = Format(startDate.Value, "yyyy-mm-dd")
    mrcWeek.Update

End Sub

         我的方法很麻烦,这是我使劲想出来的,大家有好的方法可以给我一个连接哦,让我借鉴一下。 

         

时间: 2024-09-20 13:27:21

机房收费系统之周结账单的相关文章

软工文档-机房收费系统:详细设计说明书

详细设计说明书   1引言   1.1编写目的 详细设计说明书是在概要设计的基础上进一步明确系统结构,表示出软件结构的图表,完成算法设计.数据结构设计.物理设计等,详细地描述的逐个模块,包括算法和逻辑流程,为下一步系统的实现和测试做准备. 本文档的预期读者是程序开发人员和程序测试人员. 1.2背景 A.待开发软件名称:机房收费系统 B.项目提出者:米新江教授   开发者:吴士龙   用户:廊坊师范学院全体教职工和学生   实现该软件的计算中心或计算机网络:廊坊师范学院局域网 C.该软件系统同其他

机房收费系统之结尾

       机房收费系统在这个冬月告一个不完美的结局,刚开始接触他的时候,各种纠结,各种逃避,各种不想做,接触一个新的事物,内心充满了恐惧与排斥,机房收费系统与学生管理系统不一样,没有源码,这个时候,需要自己不断的给予自己鼓励,七八九期的师哥师姐都做出来了,你完全有理由相信,自己也能做出来.        机房收费系统来来回回验收了三次,这期间,很谢谢陈金阁师哥耐心的指导,一次又一次,不厌烦的告诉我做系统的思路以及要注意哪些细节问题.现在,就机房收费系统,做个简单的总结.         结账

机房收费系统之表

         机房收费系统,主要是用于对学生在机房上机的收费问题,首先要建立的是数据库,数据库中有三个角色,一般用户.管理员.操作员,管理员对操作员进行设置,然后由操作员员对一般用户的信息进行设置,注册.       首先管理员员登陆这个系统,管理员的用户名,密码,姓名,然后将机房的收费标准录入到数据库中.然后将登陆密码交给操作员,让操作员管理的上机.用户进入机房进行上网,此时开始计费,一直到学生出机房,再次刷卡下机.做系统之前,一定要理清楚表之间的关系,以及这张表有什么用,在系统的那块儿用

软工文档-机房收费系统:概要设计说明书

概要设计说明书             1引言 1.1编写目的         本阶段的主要任务是在用户的需求分析阶段的基础上,对机房收费系统做概要设计,为在需求分析阶段得到的目标系统的物理模型确定一个合理的软件系统的体系结构.包括合理地划分组成系统的模块.模块间的调用关系及模块间的接口,并且为软件系统提供所用的数据结构或者数据库结构.同时为下一阶段的详细设计做参考. 本文档的读者是项目设计和项目编码人员. 1.2背景  A.待开发软件名称:机房收费系统 B.项目提出者:米新江教授  开发者:吴

机房收费系统之结账与报表

机房收费系统在几天前终于告一个段落了,这篇是关于最后阶段结账与报表的总结. 结账,首先清楚该窗体的作用是:管理员对每个操作员工作情况的查看.其中包括售卡数量,充值金额以及退还金额. 知道全局后,操作上就会简单不少了.我们需要做的就是将遍历学生信息表.充值信息表和退卡信息表后的该操作员和结账状态为"未结账"的所有金额总计.然后在单击结账后,将汇总后的信息写入结账表,将前面三个表中的结账状态标记为"已结账". 结账流程: Part One:将所有操作员ID和Name提取

VB.NET版机房收费系统---报表

       报表,即报告情况的表格,简单的说:报表就是用表格.图表等格式来动态显示数据,可以用公式表示为:"报表 = 多样的格式 + 动态的数据". 在没有计算机以前,人们利用纸和笔来记录数据.       比如:民间常常说的豆腐帐,就是卖豆腐的每天将自己的卖出的豆腐记在一个本子上,然后每月都要汇总算算,这种情况下,报表数据和报表格式是紧密结合在一起的,都在同一个本子上.数据也只能有一种几乎只有记帐的人才能理解的表现形式,且这种形式难于修改.      VB版机房收费系统的报表采用的

机房收费系统之技术总结

机房收费系统,从最初的迷茫到现在的明朗,这一路,总算是到站了. 看到完工后的系统,自己都惊呆了.总共有27个窗体,一个模块,代码的多少可想而知,那么多那么多,都是自己敲上去的,和学生信息管理系统相比,真的算得上是一次飞跃了吧.前前后后,历时二十多天,不管是技术上还是思想上,自己的收获很大. 从头到尾,自己都是尽心尽力,从新建数据库到新建各个表,从各个窗体设计到各个窗体代码,一个也不容小觑. 先从自己的数据库说起:一共九张表,这个过程很漫长,不是一开始就照着原来的模板建,而是在敲代码的过程中,用到

VB.NET机房收费系统总结

     又一次机房收费系统,有一次总结,第一次是vb6,这次则采用VB.NET+设计模式+三层.     vb6的机房收费系统是面向过程开发,代码量大,不易维护,而这次的VB.NET则是面向对象的开发,代码量虽然没有减少反而增多,但是系统的结构变得灵活的多,可维护性增强了不少,采用了分层和设计模式,对象化了各个模块,复用率也大大提高了.     具体来说一下吧.在网上查了资料,简单了解了三层后,开始了我的三层之旅.先用EA画了3层的登录例子.下面是我的系统架构(包图):     当时一开始只有

机房收费系统重构中的一些感受

        在正式写文章之前反省一下,好久没有到CSDN上来写博客了,也就是说自己已经有一段时间学习劲头不足了.今天写这篇文章一方面是总结一下自己这半个月敲机房收费系统的一点点小的体会,另一方面就是写写刚刚实现的"运用简单工厂实现登陆权限选择"的实例.         其实重构机房收费系统这各项目已经建立两个月了,只是前一个半月由于一些未知的原因导致自己心里例假而什么都没有干.半个月前,借着家长过来的机会,米老师顺便把我的情况提了一下,顿时感觉愧疚难当,同时一股强烈的查克拉在我体内