本文主要是介绍充值窗体 机房收费系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
声明:这个文章上个星期写已发表结果误删了,从回收站没法还原,只能从新发表了,见谅。
首先我们先对这个窗体进行下分析。
(1)检测卡号和金钱的输入
1.1 首先输入卡号(检查输入卡号是否存在。若不存在,提示没有该卡号请重新输入,从student表中调去信息判断卡号是否存在,若该卡号存在,下一步)
1.2 输入充值金额,
从basicdata表中调去数据 充值金额不能小于最小充值金额,
(2)单机确定按钮 充值成功 文本框(下图)显示本次充值的信息,根据信息我们可以得知
2.1 在recharge表中显示本次的充值记录,
2.2 在student表中更新金额总数
(3)文本框显示充值信息
代码如下:
- Private Sub CmdOK_Click()
- Dim txtsql As String
- Dim msgtext As String
- Dim mrc As adodb.Recordset
- Dim mrcc As adodb.Recordset
- Dim mrcc1 As adodb.Recordset
- Dim Number As String '获取学号
- Dim lastcash As Integer '上次余额
- Dim leastcash As Integer '最小金额
- Dim nowcash As Integer ' 最新余额
- '检查输入
- If Not Testtxt(CardIdtxt.Text) Then
- MsgBox "请输入卡号!", vbOKOnly + vbExclamation, "警告!"
- CardIdtxt.SetFocus
- Exit Sub
- End If
- If Not Testtxt(Rechargetxt.Text) Then
- MsgBox "请输入金额!", vbOKOnly + vbExclamation, "警告!"
- Rechargetxt.SetFocus
- Exit Sub
- End If
- If Not IsNumeric(Rechargetxt.Text) Then
- MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告!"
- Rechargetxt.SetFocus
- Exit Sub
- End If
- '判断卡号是否注册
- txtsql = "select * from student_info where cardno= '" & Trim(CardIdtxt.Text) & "' "
- Set mrcc = ExecuteSQL(txtsql, msgtext)
- If mrcc.EOF Then
- MsgBox "该卡号没有注册,请重新输入!", vbOKOnly + vbExclamation, "警告!"
- CardIdtxt.Text = ""
- CardIdtxt.SetFocus
- Exit Sub
- Else
- Number = Trim(mrcc.Fields(1))
- lastcash = Val(Trim(CStr(mrcc.Fields(7))))
- mrcc.Close
- End If
- '获取最新金额,与输入的金额做比较
- txtsql = "select * from BasicData_Info "
- Set mrcc1 = ExecuteSQL(txtsql, msgtext)
- mrcc1.MoveLast
- leastcash = Val(Trim(CStr(mrcc1.Fields(5))))
- mrcc1.Close
- If Val(Trim(Rechargetxt.Text)) < leastcash Then
- MsgBox "输入金额不得小于" & leastcash & "元!", vbOKOnly + vbExclamation, "警告!"
- Rechargetxt.Text = ""
- Rechargetxt.SetFocus
- Exit Sub
- End If
- '更新recharge表中的数据
- txtsql = "select * from ReCharge_info "
- Set mrc = ExecuteSQL(txtsql, msgtext)
- mrc.AddNew
- mrc.Fields(1) = Number
- mrc.Fields(2) = Trim(CardIdtxt.Text)
- mrc.Fields(3) = Trim(Rechargetxt.Text)
- mrc.Fields(4) = Format(Date, "yyyy-mm-dd")
- mrc.Fields(5) = Time
- mrc.Fields(6) = "Username"
- mrc.Fields(7) = "未结账"
- mrc.Update
- mrc.Close
- '更新student表中的最新余额
- txtsql = "select * from student_info where cardno= '" & Trim(CardIdtxt.Text) & "' "
- Set mrcc = ExecuteSQL(txtsql, msgtext)
- mrcc.Fields(7).Value = lastcash + Val(Rechargetxt.Text)
- a = mrcc.Fields(7)
- mrcc.Update
- mrcc.Close
- bsp;
- '显示充值信息
- Showtxt.Text = "充值卡号:" & Trim(CardIdtxt.Text) & vbCrLf _
- & "上次余额 " & lastcash & vbCrLf _
- & "最新余额 " & a & vbCrLf _
- & "冲卡日期" & Date & vbCrLf _
- & "冲卡时间" & Time & vbCrLf _
- & "充值教师" & Username &
- MsgBox "充值成功!", vbOKOnly + vbExclamation, "警告!"
- CardIdtxt.Text = ""
- Rechargetxt.Text = ""
- Showtxt.Text = ""
- d Sub
这篇关于充值窗体 机房收费系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!