VB机房收费系统08——结账

前端之家收集整理的这篇文章主要介绍了VB机房收费系统08——结账前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

前言

结账对于笔者也是一块新知识,首先是这个控件,他显示信息是什么原理,我就看了好多博客......

正文


如图,中间的控件叫做SSTab。 SSTab控件提供了一组选项卡,每个都充当一个容器,包含了其他的控件。

本窗体的运行原理是当我们选择操作员用户名后,显示操作员真实姓名。显示此人的工作记录在下面五个栏目中:购卡、充值、退卡、临时用户、汇总。

这里有个重点,计算总的售卡数,总的收款金额。我们计算时需要用到Val函数,把字符串型的代码转换成数值型。

代码实现全过程如下:

Private Sub comboid_Click()
'购卡
    Dim txtsql As String
    Dim msgtext As String
    Dim mrc As ADODB.Recordset

'查找管理员

    txtsql = "select * from User_Info where userID='" & comboid.Text & "'"
    Set mrc = Executesql(txtsql,msgtext)

    comboname.Text = mrc.Fields(3)
    mrc.Close

    txtsql = "select * from student_Info where UserID='" & comboid.Text & "'"
    Set mrc1 = Executesql(txtsql,msgtext)


 '显示购卡信息
    With MSFlexGrid1
        .Rows = 1
        .CellAlignment = 4
        .TextMatrix(0,0) = "学号"
        .TextMatrix(0,1) = "卡号"
        .TextMatrix(0,2) = "日期"
        .TextMatrix(0,3) = "时间"




    Do While Not mrc1.EOF
        .Rows = .Rows + 1
        .CellAlignment = 4
        .TextMatrix(.Rows - 1,0) = Trim(mrc1.Fields(1))
        .TextMatrix(.Rows - 1,1) = Trim(mrc1.Fields(0))
        .TextMatrix(.Rows - 1,2) = Trim(mrc1.Fields(12))
        .TextMatrix(.Rows - 1,3) = Trim(mrc1.Fields(13))
        
        mrc1.MoveNext
    Loop
        
        .Rows = .Rows - 1
        Text1.Text = Int(.Rows - 1)       '汇总:售卡张数
        
    End With
    mrc1.Close








'充值

    Dim mrcrecharge As ADODB.Recordset
    

'查找管理员

    txtsql = "select * from ReCharge_Info where userID='" & comboid.Text & "'"
    Set mrcrecharge = Executesql(txtsql,msgtext)


 '显示购卡信息
    With MSFlexGrid2
        .Rows = 1
        .CellAlignment = 4
        .TextMatrix(0,2) = "充值金额"
        .TextMatrix(0,3) = "日期"
        .TextMatrix(0,4) = "时间"


      Do While Not mrcrecharge.EOF
        .Rows = .Rows + 1
        .CellAlignment = 4
        .TextMatrix(.Rows - 1,0) = Trim(mrcrecharge.Fields(1))
        .TextMatrix(.Rows - 1,1) = Trim(mrcrecharge.Fields(2))
        .TextMatrix(.Rows - 1,2) = Trim(mrcrecharge.Fields(3))
        .TextMatrix(.Rows - 1,3) = Trim(mrcrecharge.Fields(4))
        .TextMatrix(.Rows - 1,4) = Trim(mrcrecharge.Fields(5))
        
        Text3.Text = Val(.TextMatrix(.Rows - 1,2)) + Val(Text3.Text)  '汇总:充值金额
        
        mrcrecharge.MoveNext
    Loop
        
    End With
    mrcrecharge.Close
    
    
    
    
    
    
    
    
'退卡

    Dim mrccancelcard As ADODB.Recordset

'查找管理员

    txtsql = "select * from CancelCard_Info where userID='" & comboid.Text & "'"
    Set mrccancelcard = Executesql(txtsql,msgtext)


 '显示购卡信息
    With MSFlexGrid3
        .Rows = 1
        .CellAlignment = 4
        .TextMatrix(0,3) = "时间"
        .TextMatrix(0,4) = "退卡金额"


    Do While Not mrccancelcard.EOF
        .Rows = .Rows + 1
        .CellAlignment = 4
        .TextMatrix(.Rows - 1,0) = Trim(mrccancelcard.Fields(0))
        .TextMatrix(.Rows - 1,1) = Trim(mrccancelcard.Fields(1))
        .TextMatrix(.Rows - 1,2) = Trim(mrccancelcard.Fields(3))
        .TextMatrix(.Rows - 1,3) = Trim(mrccancelcard.Fields(4))
        .TextMatrix(.Rows - 1,4) = Trim(mrccancelcard.Fields(2))
        Text5.Text = Val(mrccancelcard.Fields(2)) + Val(Text5.Text) '汇总:退卡金额
        mrccancelcard.MoveNext
        
    Loop
        .Rows = .Rows - 1
        Text2.Text = Int(.Rows - 1)       '汇总:退卡张数
    End With
    mrccancelcard.Close









'临时用户

    txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" & " " & "and type ='" & "临时用户" & "'"
    Set mrc1 = Executesql(txtsql,msgtext)


 '显示购卡信息
    With MSFlexGrid4
        .Rows = 1
        .CellAlignment = 4
        .TextMatrix(0,3) = "时间"
        


    Do While Not mrc1.EOF
        .Rows = .Rows + 1
        .CellAlignment = 4
        .TextMatrix(.Rows - 1,3) = Trim(mrc1.Fields(13))
        
    
        Text4.Text = Val(mrc1.Fields(7)) + Val(Text4.Text) '汇总:临时收费金额
        mrc1.MoveNext
    Loop
    End With
    mrc1.Close



Text6.Text = Val(Text1.Text) - Val(Text2.Text)   '汇总:总售卡数
Text7.Text = Val(Text3.Text) - Val(Text5.Text)   '汇总: 应收金额
End Sub


Private Sub Command1_Click()
'结账


    Dim txtsql As String
    Dim msgtext As String
    Dim mrc As ADODB.Recordset

    txtsql = "select * from student_Info where UserID='" & comboid.Text & "'" & " " & "and Ischeck ='" & "未结账" & "'"
    Set mrc = Executesql(txtsql,msgtext)



        mrc.Fields(11) = "结账"

        mrc.Update
        mrc.Close
    MsgBox "结账成功!",vbonly + vbExclamation,"提示"
    
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
End Sub

Private Sub Form_Load()
    comboid.AddItem "12"
End Sub

'退出
Private Sub SSTab1_Click(PrevIoUsTab As Integer)
    Select Case SSTab1.Tab
           Case 5
                Unload Me
    End Select
End Sub
原文链接:https://www.f2er.com/vb/256204.html

猜你在找的VB相关文章