第一次机房收费之充值

       充值也很简单,

首先要在student表中查询是否存在该卡号;

若存在,就更新studet表中余额数;

最后还要更新recharge表中的钱数。

如图

Option Explicit
Private Sub cmdOK_Click()
    Dim txtSQL As String
    Dim txtSQL1 As String
    
    Dim msgText1 As String
    Dim msgText As String
    
    Dim mrc As ADODB.Recordset
    Dim mrca As ADODB.Recordset
    
    Dim lastmoney As Single '存储上次余额
    Dim addmoney As Single '存储增加的钱
    Dim sunmoney As Single '存储总和
    
    '检查卡是否为空
    If Not Testtxt(txtcardno.Text) Then
        MsgBox "请重新输入卡号!", 0 + 48, "提示"
        txtcardno.Text = ""
        txtcardno.SetFocus
        Exit Sub
    End If
    If Not Testtxt(txtrecharge.Text) Then
        MsgBox "请重新输入卡号!", 0 + 48, "提示"
        txtrecharge.Text = ""
        txtrecharge.SetFocus
        Exit Sub
    End If
    
   
    '检查student表的卡号是否存在
    txtSQL1 = "select * from student_Info where cardno= '" & txtcardno.Text & "'"
    Set mrca = executeSQL(txtSQL1, msgText1)
   
   lastmoney = Val(mrca.Fields(7))
   addmoney = Val(txtrecharge.Text)
   sunmoney = lastmoney + addmoney
   
   
    If mrca.EOF Then
        MsgBox "此卡不存在或没注册,请重新选择卡号!", 48, "提示"
        txtcardno.Text = ""
        txtcardno.SetFocus
        Exit Sub
    End If

    
    txtInfo.Text = "充值卡号:" & Trim(mrca.Fields(0)) & vbCrLf _
    & "上次卡内余额:" & lastmoney & vbCrLf _
    & "现在卡内余额:" & sunmoney & vbCrLf _
    & "充值时间:" & Time & vbCrLf _
    & "充值老师:" & UserName
    MsgBox "充值成功!", 0 + 48, "提示"
    
    mrca.Fields(7) = sunmoney
    mrca.Update
    
    
    
     '更新ReCharge_Info信息
    txtSQL = "select * from  ReCharge_Info where cardno= '" & txtcardno.Text & "'"
    Set mrc = executeSQL(txtSQL, msgText)
    mrc.AddNew
    mrc.Fields(1) = mrca.Fields(1)
    mrc.Fields(2) = mrca.Fields(0)
    mrc.Fields(3) = Trim(txtrecharge.Text)
    mrc.Fields(4) = Format(Date, "yyyy-mm-dd")
    mrc.Fields(5) = Format(Time, "hh:mm:ss")
    mrc.Fields(6) = mrca.Fields(6)
    mrc.Fields(7) = "未结账"
    mrc.Update
    
    mrca.Close
    mrc.Close
    
End Sub



Private Sub cmdQuit_Click()
Unload Me
End Sub

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 17
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值