机房收费—日结报表

日结账单说之前先说一下与报表设计器连接的日结账单表中的数据是怎么来的。我是在结账中写的代码。 请看下边:

    Dim RemainCash As Double   '上期余额,就是昨天的金额总和。
    Dim RechargeCash As Double   '今天结账的充值金额。
    Dim ConsumeCash As Double    ' 今天结账的消费金额。
    Dim CancelCash As Double    '今天结账的退卡金额。
    Dim AllCash As Double       '今天结账的金额总和。


    Dim txtSQL As String
    Dim mrc As ADODB.Recordset
     '先删除今天的结账的记录。
    txtSQL = "delete from CheckDay_Info where date='" & Date & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)


    '算出上期余额,是从日结表中昨天的金额总和得来的。
    Dim txtSQLCheckDay As String
    Dim mrcCheckDay As ADODB.Recordset

    txtSQLCheckDay = "select AllCash from CheckDay_Info where date='" & Date - 1 & "'"
    Set mrcCheckDay = ExecuteSQL(txtSQLCheckDay, MsgText)
    If mrcCheckDay.RecordCount = 0 Then
        RemainCash = 0
    Else

        If IsNull(mrcCheckDay.Fields(0)) Then
            RemainCash = 0
        Else
            RemainCash = mrcCheckDay.Fields(0)

        End If

    End If

    '充值金额,是从充值表中整出今天的充值金额。
    Dim txtSQLReCharg As String
    Dim mrcReCharg As ADODB.Recordset

    txtSQLReCharg = "select sum(addmoney) from ReCharge_Info where date='" & Date & "'and status='结账'"
    Set mrcReCharg = ExecuteSQL(txtSQLReCharg, MsgText)

    If mrcReCharg.RecordCount = 0 Then
        RechargeCash = 0
    Else

        If IsNull(mrcReCharg.Fields(0)) Then
            RechargeCash = 0
        Else
            RechargeCash = mrcReCharg.Fields(0)
        End If
    End If


    '消费金额,从Line表中今天消费金额的总和。
    Dim txtSQLLine As String
    Dim mrcLine As ADODB.Recordset

    txtSQLLine = "select sum(consume) from Line_Info where offdate='" & Date & "'"
    Set mrcLine = ExecuteSQL(txtSQLLine, MsgText)

    If mrcLine.RecordCount = 0 Then
        ConsumeCash = 0
    Else

        If IsNull(mrcLine.Fields(0)) Then
            ConsumeCash = 0
        Else
            ConsumeCash = mrcLine.Fields(0)
        End If
    End If


    '退卡金额,在退卡表中得今天退卡金额的总和
    Dim txtSQLCancel As String
    Dim mrcCancel As ADODB.Recordset

    txtSQLCancel = "select sum(CancelCash) from CancelCard_Info where Date='" & Date & "'and status='结账'"
    Set mrcCancel = ExecuteSQL(txtSQLCancel, MsgText)

    If mrcCancel.RecordCount = 0 Then
        CancelCash = 0
    Else

        If IsNull(mrcCancel.Fields(0)) Then
            CancelCash = 0
        Else
            CancelCash = mrcCancel.Fields(0)
        End If
    End If


    '金额总和,上期余额加充值金额减退卡金额。
    AllCash = RemainCash + RechargeCash - CancelCash





    Dim txtSQLCheck As String
    Dim mrcCheck As ADODB.Recordset

    txtSQLCheck = "select * from CheckDay_Info"
    Set mrcCheck = ExecuteSQL(txtSQLCheck, MsgText)
    '将对应的数据写入日结表中。
    mrcCheck.AddNew
    mrcCheck.Fields(0) = RemainCash
    mrcCheck.Fields(1) = RechargeCash
    mrcCheck.Fields(2) = ConsumeCash
    mrcCheck.Fields(3) = CancelCash
    mrcCheck.Fields(4) = AllCash
    mrcCheck.Fields(5) = Date
    mrcCheck.Update

这是日结表的数据是要显示在日结账单中的数据。 下边看怎么将数据库的表与报表设计器连接的: 首先新建一个,在文件—新建向导。再连接:
这里写图片描述 这里写图片描述 这里写图片描述 这里写图片描述 这里直接过了!!!!

将列名与标题行一一对应好这里写图片描述
下边这样的:
这里写图片描述

这是与数据库的链接。

下边是与vb的链接代码:

    Dim strSQL As String, strMsg As String
    strSQL = "select * from CheckDay_info"
    Set Report = New grproLibCtl.GridppReport                      '实例化模版

    Report.LoadFromFile (App.Path & "\报表.grf")               '加载模版
    Report.DetailGrid.Recordset.ConnectionString = ConnectString() '连接数据源
    Report.DetailGrid.Recordset.QuerySQL = strSQL                  '通过SELECT查询创建记录集
    GRDisplayViewer1.Report = Report
    GRDisplayViewer1.Start                          '开始打印

注意要提前声明一下。

评论 26
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值