机房收费系统之上下机

来源:互联网 发布:如何设置监控网络连接 编辑:程序博客网 时间:2024/05/20 23:05

   背景:经过第一次的机房验收,发现自己的问题,现在整理一下自己的思路,就上下机而言理理思路!

 

上机:用到表student_Info,Basic_info,line,Online表

      

下机:重点是时间和花费的钱的计算,区分是临时用户还是固定用户,如果是临时用户下机就等于是退卡!下机的时候当钱不够一个小时的花费时提醒,钱<=0时强制下机!

  一般用户下有一个学生上机状态查看这个窗体就涉及到下机:


说明:选中学生下线:selectssoffMenu

      所有学生下线:allssoffMenu

    一开始我是把写下机的代码差不多都写到这个窗体下,但是发现代码好多,感觉好麻烦,尤其写所有学生下线后来受到一个人的启发就把代码给改了:

1.选中学生下线

<<span style="font-size:24px;">span style="font-size:24px;"><pre name="code" class="html">Private Sub selectssoffMenu_Click()  Dim mrc As Recordset  Dim MsgText As String  Dim txtSQL As String  Dim i As Integer   If Val(MSFlexGrid.RowSel) = 0 Then    MsgBox "请选择学生下线!", vbOKOnly + vbExclamation, "警告"    Exit Sub End If If MSFlexGrid.RowSel = MSFlexGrid.Row = 0 Then    MsgBox "首行不能删除!", vbOKOnly + vbExclamation, "警告"    Exit Sub End If txtSQL = "select * from student_Info where cardno='" & Trim(MSFlexGrid.TextMatrix(MSFlexGrid.RowSel, 0)) & "'" Set mrc = ExecuteSQL(txtSQL, MsgText) i = mrc.Fields(0)    '卡号 frmMain.Show frmMain.txtcardno = i    '将卡号赋给frmMain窗体中的卡号文本框 frmMain.cmdoff = True    ’执行下机操作 MSFlexGrid.RemoveItem MSFlexGrid.RowSel  '删除Msflexgrid表中选中的一行</span>End Sub</span>

2.所有学生下线

<span style="font-size:24px;"><span style="font-size:24px;">Private Sub allssoffMenu_Click() Dim mrc As ADODB.Recordset Dim MsgText As String Dim txtSQL As String Dim i As Integer Dim m As Integer  txtSQL = "select * from OnLine_Info " Set mrc = ExecuteSQL(txtSQL, MsgText)  If mrc.EOF = True Then    MsgBox "没有学生上机!", vbOKOnly + vbExclamation, "警告" Else   Do While Not mrc.EOF      i = mrc.Fields(0)      frmMain.Show      frmMain.txtcardno = i     '<span style="font-family: KaiTi_GB2312;">将卡号赋给frmMain窗体中的卡号文本框</span>      frmMain.cmdoff = True     <span style="font-family: KaiTi_GB2312;">’执行下机操作</span>      mrc.MoveNext   Loop    MSFlexGrid.Rows = 1     '删除MSFlexGrid中的数据 MsgBox "所有学生成功下机!", vbOKOnly + vbExclamation, "提示"End IfEnd Sub</span></span>
   但是如果下机时执行frmMain中的下机操作MsgBox会提示下机成功,如果是全部下机的话每个都要点一次,这样好麻烦,所以就在frmMain窗体添加一段代码:当提示下机成功时让它在几秒钟自动消失!

<span style="font-size:24px;"><span style="font-size:24px;">Option Explicit</span></span>
<span style="font-size:24px;"><span style="font-size:24px;">Private Declare Function MessageBoxTimeout Lib "user32" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long        '声明一个过程</span></span>
<span style="font-size:24px;"><span style="font-size:24px;">部分代码:</span></span>
<span style="font-size:24px;"><span style="font-size:24px;">txtSQL1 = "delete from OnLine_Info where cardno= '" & Trim(txtcardno.Text) & "'" '更新Online表Set mrc1 = ExecuteSQL(txtSQL1, MsgText1)MessageBoxTimeout Me.hwnd, "成功下机", "提示", vbInformation, 0, 600</span></span>
总结:一个人的力量总是有限,像执行frmMain中的下机操作就是我们讨论的结果,代码是她摸索出来的(名字不就不说了她比较低调微笑)上下机过程理清逻辑关系,实践下来也不是很难!


0 0
原创粉丝点击