机房收费系统之结账

机房结账的时候首先得明白几个点

应收金额是收的哪几部分的金额

临时收费金额收的是哪的金额(临时用户可不可以退卡)

想明白了那就开始吧

代码实现:

Dim txtSQL As String
Dim MsgText As String
Private Sub Command1_Click()
Dim mrc1 As ADODB.Recordset

txtSQL = "select * from student_info where userid='" & comboUserId.Text & "'"
Set mrc1 = ExecuteSQL(txtSQL, MsgText)

    Do While Not mrc1.EOF
        mrc1!ischeck = "结账"
        mrc1.Update
        mrc1.MoveNext
    Loop
mrc1.Close

txtSQL = "select * from recharge_info where userid='" & comboUserId.Text & "'"
Set mrc2 = ExecuteSQL(txtSQL, MsgText)
    
    Do While Not mrc2.EOF
        mrc2!Status = "结账"
        mrc2.Update
        mrc2.MoveNext
    Loop
mrc2.Close

MsgBox "结账成功!", vbOKOnly + vbInformation, "提示"


End Sub

Private Sub Form_Load()
Dim mrc As ADODB.Recordset
txtSQL = "select * from user_info "

Set mrc = ExecuteSQL(txtSQL, MsgText)

Do While mrc.EOF = False
    comboUserId.AddItem mrc!UserId
    mrc.MoveNext
Loop


End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)

Text3.Text = "0"
Text5.Text = "0"
Text4.Text = "0"
Select Case SSTab1.Tab

    Case 0
    
        MSHFlexGrid2.Visible = True
    
        Dim mrc2 As ADODB.Recordset
        txtSQL = "select * from student_info where userid='" & comboUserId.Text & "'"
        Set mrc2 = ExecuteSQL(txtSQL, MsgText)
        If mrc2.EOF Then
        MsgBox "没有记录", vbOKOnly + vbExclamation, "提示"
        Else
        With MSHFlexGrid2
          .Rows = 2
          .CellAlignment = 4
          .TextMatrix(1, 0) = "学号"
          .TextMatrix(1, 1) = "卡号"
          .TextMatrix(1, 2) = "日期"
          .TextMatrix(1, 3) = "时间"
       Do While Not mrc2.EOF
          .Rows = .Rows + 1
          .CellAlignment = 4
          .TextMatrix(.Rows - 1, 0) = mrc2.Fields(1)
          .TextMatrix(.Rows - 1, 1) = mrc2.Fields(0)
          .TextMatrix(.Rows - 1, 2) = mrc2!Date
          .TextMatrix(.Rows - 1, 3) = mrc2!Time
          mrc2.MoveNext
       Loop
       
       End With
       End If
       mrc2.Close
   
   Case 1
       MSHFlexGrid1.Visible = True
       Dim mrc3 As ADODB.Recordset
       txtSQL = "select *from recharge_info where userid='" & comboUserId.Text & "'"
       Set mrc3 = ExecuteSQL(txtSQL, MsgText)
       If mrc3.EOF Then
       MsgBox "没有记录!", vbOKOnly + vbExclamation, "提示"
       Else
       With MSHFlexGrid1
          .Rows = 2
          .CellAlignment = 4
          .TextMatrix(1, 0) = "学号"
          .TextMatrix(1, 1) = "卡号"
          .TextMatrix(1, 2) = "充值金额"
          .TextMatrix(1, 3) = "日期"
          .TextMatrix(1, 4) = "时间"
       Do While Not mrc3.EOF
          .Rows = .Rows + 1
          .CellAlignment = 4
          .TextMatrix(.Rows - 1, 0) = mrc3.Fields(1)
          .TextMatrix(.Rows - 1, 1) = mrc3.Fields(2)
          .TextMatrix(.Rows - 1, 2) = mrc3!addmoney
          .TextMatrix(.Rows - 1, 3) = mrc3!Date
          .TextMatrix(.Rows - 1, 4) = mrc3!Time
          mrc3.MoveNext
       Loop
       
       End With
       End If
       mrc3.Close
       
   Case 2
       MSHFlexGrid3.Visible = True
       Dim mrc4 As ADODB.Recordset
       txtSQL = "select *from cancelcard_info where userid='" & comboUserId.Text & "'"
       Set mrc4 = ExecuteSQL(txtSQL, MsgText)
       If mrc4.EOF Then
       MsgBox "没有记录!", vbOKOnly + vbExclamation, "提示"
       Else
       With MSHFlexGrid3
          .Rows = 2
          .CellAlignment = 4
          .TextMatrix(1, 0) = "学号"
          .TextMatrix(1, 1) = "卡号"
          .TextMatrix(1, 2) = "日期"
          .TextMatrix(1, 3) = "时间"
          .TextMatrix(1, 4) = "退卡金额"
      Do While Not mrc4.EOF
          .Rows = .Rows + 1
          .CellAlignment = 4
          .TextMatrix(.Rows - 1, 0) = mrc4.Fields(0)
          .TextMatrix(.Rows - 1, 1) = mrc4.Fields(1)
          .TextMatrix(.Rows - 1, 2) = mrc4!Date
          .TextMatrix(.Rows - 1, 3) = mrc4!Time
          .TextMatrix(.Rows - 1, 4) = mrc4!cancelcash
          mrc4.MoveNext
       Loop
       
       End With
       End If
       mrc4.Close
       
   Case 3
       MSHFlexGrid4.Visible = True
       Dim mrc5 As ADODB.Recordset
       txtSQL = "select *from student_info where userid='" & comboUserId.Text & "'"
       Set mrc5 = ExecuteSQL(txtSQL, MsgText)
       If mrc5.EOF Then
       MsgBox "没有记录!", vbOKOnly + vbInformation, "提示"
       Else
       With MSHFlexGrid4
          .Rows = 2
          .CellAlignment = 4
          .TextMatrix(1, 0) = "学号"
          .TextMatrix(1, 1) = "卡号"
          .TextMatrix(1, 2) = "日期"
          .TextMatrix(1, 3) = "时间"
      Do While Not mrc5.EOF
          .Rows = .Rows + 1
          .CellAlignment = 4
          .TextMatrix(.Rows - 1, 0) = mrc5.Fields(1)
          .TextMatrix(.Rows - 1, 1) = mrc5.Fields(0)
          .TextMatrix(.Rows - 1, 2) = mrc5!Date
          .TextMatrix(.Rows - 1, 3) = mrc5!Time

          mrc5.MoveNext
       Loop
       
       End With
       End If
       mrc5.Close
       
   Case 4
       Frame1.Visible = True
       Dim mrc6 As ADODB.Recordset

       '售卡张数
       txtSQL = "select * from student_info where userid='" & comboUserId.Text & "'" & " and ischeck='" & "未结账" & "'" & " and status='" & "使用" & "'"
       Set mrc6 = ExecuteSQL(txtSQL, MsgText)
       Text1.Text = mrc6.RecordCount
       mrc6.Close
       
       '退卡张数
       txtSQL = "select * from cancelcard_info where userid='" & comboUserId.Text & "'" & " and status='" & "未结账" & "'"
       Set mrc7 = ExecuteSQL(txtSQL, MsgText)
       Text2.Text = mrc7.RecordCount
       mrc7.Close
       
       '充值金额
       txtSQL = "select sum(addmoney) from recharge_info where userid='" & comboUserId.Text & "'" & " and status='" & "未结账" & "'"
       Set mrc8 = ExecuteSQL(txtSQL, MsgText)
       Do While Not mrc8.Fields(0) = Null
       Text3.Text = mrc8.Fields(0)
       Loop
       
       mrc8.Close
       
       '临时收费金额
       txtSQL = txtSQL & "select sum(cash) from student_info where userid='" & comboUserId & "'" & " and status='" & "未结账" & "'" & " and type='" & "临时用户" & "'"
       Set mrc9 = ExecuteSQL(txtSQL, MsgText)
       Do While Not mrc9.Fields(0) = Null
       Text4.Text = mrc9.Fields(0)
       Loop
       mrc9.Close
       
       
        '退卡金额
        txtSQL = "select sum(cancelcash) from cancelcard_info where userid='" & comboUserId.Text & "'" & " and status='" & "未结账" & "'"
        Set mrc10 = ExecuteSQL(txtSQL, MsgText)
        Do While Not mrc10.Fields(0) = Null
        Text5.Text = mrc10.Fields(0)
        Loop
        mrc10.Close
        
        '总售卡数
       txtSQL = "select * from student_info where userid='" & comboUserId.Text & "'" & " and ischeck='" & "未结账" & "'"
       Set mrc11 = ExecuteSQL(txtSQL, MsgText)
       Text6.Text = mrc11.RecordCount
       mrc11.Close
       
End Select

     '应收金额
     Text7.Text = Val(Text3.Text) - Val(Text5.Text)

End Sub

Private Sub txtUserName_Click()
Dim mrc1 As ADODB.Recordset

If comboUserId <> "" Then
txtSQL = "select * from user_info where userID = '" & comboUserId.Text & "'"
Set mrc1 = ExecuteSQL(txtSQL, MsgText)
txtUserName.Text = mrc1!UserName
mrc1.Close
End If

End Sub

可能完善的不是很好,有问题可以一块探讨!



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值