机房之结账

来源:互联网 发布:蜘蛛软件下载 编辑:程序博客网 时间:2024/03/29 09:15

结账窗体不是日结账单,也不是周结账单,他更像是一个账单的分类汇总,显示了每个操作员或者管理员的使用情况。下面是整个的窗体。


1.首先介绍两个关于名字的控件,这两个第一个是只能选择,不能输入,从数据库中users表将用户名全部添加到这个选项,而真是姓名是在单机用户名后,自动将操作员的真实姓名赋值。代码如下:

    Dim mrc1 As ADODB.Recordset    ComboRealname.Clear                       '清空用户上次输入内容    txtSQL = "select*from user_info where userid='" & ComboOperator.Text & "'"      '查询用户名    Set mrc1 = ExecuteSQL(txtSQL, Msgtext)    If mrc1.EOF = False Then                  '判断用户是否存在        ComboRealname.Text = mrc1.Fields(3)       '将查询到的用户名在文本框中显示        mrc1.MoveNext        mrc1.Close    End If
2.购卡,充值,退卡,临时用户都是一样的,都是点击这些字样,然后通过查表(条件是上边已经选中的用户)在表中显示数据。这里不一个一个的具体说了,就有一个购卡的代码示例。
    txtSQL = "select *from student_info where userid='" & ComboOperator.Text & "'" '查询输入的用户的信息"    Set nrc = ExecuteSQL(txtSQL, Msgtext)    zs = nrc.RecordCount                      '查询到的信息记录数,总共的卡数    With MSHFlexGrid1        .CellAlignment = 4        .Rows = 1       '初始化,每次开始都是一列        .TextMatrix(0, 0) = "学号"    '将学号等信息填入作为开头属性        .TextMatrix(0, 1) = "卡号"        .TextMatrix(0, 2) = "日期"        .TextMatrix(0, 3) = "时间"        Do While Not nrc.EOF     '循环,每查询到一条信息就增加一列,填入其中,直到查询不到信息。            .CellAlignment = 4            .Rows = .Rows + 1            .TextMatrix(.Rows - 1, 0) = Trim(nrc.Fields(1))            .TextMatrix(.Rows - 1, 1) = Trim(nrc.Fields(0))            .TextMatrix(.Rows - 1, 2) = Trim(nrc.Fields(12))            .TextMatrix(.Rows - 1, 3) = Trim(nrc.Fields(13))            nrc.MoveNext        Loop    End With    nrc.Close        With MSHFlexGrid1        .CellAlignment = 4        .Rows = 1       '初始化,每次开始都是一列        .TextMatrix(0, 0) = "学号"    '将学号等信息填入作为开头属性        .TextMatrix(0, 1) = "卡号"        .TextMatrix(0, 2) = "日期"        .TextMatrix(0, 3) = "时间"        Do While Not nrc.EOF     '循环,每查询到一条信息就增加一列,填入其中,直到查询不到信息。            .CellAlignment = 4            .Rows = .Rows + 1            .TextMatrix(.Rows - 1, 0) = Trim(nrc.Fields(1))            .TextMatrix(.Rows - 1, 1) = Trim(nrc.Fields(0))            .TextMatrix(.Rows - 1, 2) = Trim(nrc.Fields(12))            .TextMatrix(.Rows - 1, 3) = Trim(nrc.Fields(13))            nrc.MoveNext        Loop    End With    nrc.Close    
3.汇总是每个情况的一个汇总,统计每个数量,注意,在以下代码,记录各个记录的数量。

 zs = nrc.RecordCount                      '查询到的信息记录数,总共的卡数
汇总的代码如下: 
    txtSQL = "select sum(cash) from student_info where userid='" & ComboOperator.Text & "'"     '求办卡的金额总和    Set nrc7 = ExecuteSQL(txtSQL, Msgtext)    If nrc7.RecordCount <> 0 Then        If Not IsNull(nrc7.Fields(0)) Then            zj = Val(nrc7.Fields(0))            ys = zj - tkj             '求应收余额        End If    End If    nrc7.Close        txtCardNu.Text = sk                   '将查询计算的值添加到文本框中    txtBackCardNu.Text = tk    txtAmountOfCharge.Text = cz    txtTemporarycharge.Text = ls    txtBlackCardCharge.Text = tkj    txtTotalCard.Text = zs    txtReceivable.Text = ys    

有别的好的建议,可以交流一下。


原创粉丝点击