第一次机房收费系统之结账

机房收费系统终于快弄完了,在结账的时候会有选择用户名,而选择了用户名操作员的真实姓名就会随着出现。

那么就需要的form_load中添加用户名,在用户名点击事件中加载真实姓名。

Private Sub Form_Load()
    Dim txtSQL As String
    Dim MsgText As String
    Dim user As ADODB.Recordset
    Dim user1 As ADODB.Recordset

    txtSQL = "select * from User_info where Level='管理员'" '设置用户名下拉框
    Set user = ExecuteSQL(txtSQL, MsgText)
    Do While Not user.EOF
        Combo1.AddItem user.Fields(0)
        user.MoveNext
    Loop

End Sub

 在选择用户名之后,随之文本框中会出现zhen

Private Sub Combo1_Click()
    Dim txtSQL As String
    Dim MsgText As String
    Dim user1 As ADODB.Recordset

    txtSQL = "select * from User_info where userID='" & Trim(Combo1.Text) & "'"
    Set user1 = ExecuteSQL(txtSQL, MsgText)
    Text1.Text = Trim(user1.Fields(3))
End Sub

购卡

If SSTab1.Tab = 0 Then ‘购卡
        If Combo1.Text = "" Then
            MsgBox "请选择操作员姓名", vbOKOnly + vbExclamation, "提示"
            Exit Sub
        End If
        
        MSFlexGrid1.Clear
        txtSQL = "select * from student_info where userID='" & Combo1.Text & "'"
        Set GK = ExecuteSQL(txtSQL, MsgText)
        With MSFlexGrid1
        .Rows = 1
        .CellAlignment = 4
        .TextMatrix(0, 0) = "学号"
        .TextMatrix(0, 1) = "卡号"
        .TextMatrix(0, 2) = "日期"
        .TextMatrix(0, 3) = "时间"

        Do While Not GK.EOF
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 0) = Trim(GK.Fields(1))
            .TextMatrix(.Rows - 1, 1) = Trim(GK.Fields(0))
            .TextMatrix(.Rows - 1, 2) = Trim(GK.Fields(12))
            .TextMatrix(.Rows - 1, 3) = Trim(GK.Fields(13))
            GK.MoveNext
            
        Loop
        GK.Close
        End With

    End If

充值、退卡、临时用户和购卡基本相似,在这里可以参考以上代码

在汇总的时候,需要展示加载出来的有售卡张数以及退卡张数、退卡金额,这三项是指今天的售卡、退卡,而不是累加的,这一点要区分清楚。

 售卡数:

txtSQL = "select * from student_info where userID='" & Combo1.Text & "'and Ischeck='未结账 'and date='" & Date & "'"  '售卡数
        Set HZ = ExecuteSQL(txtSQL, MsgText)
        Sellcard.Text = HZ.RecordCount
        HZ.Close

退卡数

txtSQL = "select * from CancelCard_info where userID='" & Combo1.Text & "'and date='" & Date & "'" '退卡数
        Set TK = ExecuteSQL(txtSQL, MsgText)
        Cancelcard.Text = TK.RecordCount
        TK.Close

充值

txtSQL = "select * from ReCharge_info where userID='" & Combo1.Text & "'" '充值
        Set CZ = ExecuteSQL(txtSQL, MsgText)
        t = 0 '定义总金额
        For i = 1 To CZ.RecordCount
            t = t + Val(CZ.Fields(3))
            charge.Text = Val(t)
            CZ.MoveNext
        Next i

临时收费

txtSQL = "select * from student_info where userID='" & Combo1.Text & "'and type='临时用户' and Ischeck='未结账' and status='使用'" '临时收费
         Set HZ = ExecuteSQL(txtSQL, MsgText)
         j = 0
         If Not HZ.EOF Then
            For i = 1 To HZ.RecordCount
                j = j + Val(HZ.Fields(7))
                lscharge.Text = Val(j)
                HZ.MoveNext
            Next i
         End If

退卡总金额

txtSQL = "select * from CancelCard_info where userID='" & Combo1.Text & "'" '退卡总金额
         Set TK = ExecuteSQL(txtSQL, MsgText)
         j = 0
         If Not HZ.EOF Then
            For i = 1 To TK.RecordCount
                j = j + Val(TK.Fields(2))
                CancelcardMoney.Text = Val(j)
                HZ.MoveNext
            Next i
         End If

退卡总数

txtSQL = "select * from student_info where userID='" & Combo1.Text & "'" '退卡总数
        Set HZ = ExecuteSQL(txtSQL, MsgText)
        sumreturncard.Text = HZ.RecordCount
        HZ.MoveNext
        '应收金额=充值金额+临时收费金额-退卡金额
        money.Text = Val(charge.Text) + Val(lscharge.Text) - Val(CancelcardMoney.Text)

猜你喜欢

转载自blog.csdn.net/weixin_45309155/article/details/106437218
今日推荐