Computer room charge System (iv)

Source: Internet
Author: User
Tags trim

Recently the computer room charge system entered the final sprint period. Computer room charge system is the most important part of the machine button, at first I always feel very dizzy, do not know how to design the code of the two buttons, but in the help of many students, I finally clear the logic, completed the design of the two buttons.


The two buttons are designed to be similar, forming a closed loop that helps me figure out the logic of the two buttons with these two mind maps. Two buttons in front of a few steps very similar, but the lower machine button to determine whether the card number can be used, because the judgment can be used to machine, so there is no need to determine whether the card number can be used. The next step will be a bit more, because to determine the amount of consumption,

Private Sub Cmdoffline_click () Dim TxtSQL As String Dim Msgtext As String Dim mrc as ADODB. The Recordset ' Student_info Dim mrc1 as ADODB. The Recordset ' Bascidata_info Dim mrc2 as ADODB. The Recordset ' Line_info Dim mrc3 as ADODB. Whether the Recordset ' Online_info ' card number is empty if Txtcardno = "Then MsgBox" Enter the card number! ", vbOKOnly," hint "txtcar Dno. SetFocus Txtcardno = "" Exit Sub End if ' card number exists TxtSQL = "SELECT * FROM Student_info wher E cardno= ' "& Trim (Txtcardno.text) &" "Set MRC = ExecuteSQL (TxtSQL, Msgtext) If MRC. EOF then MsgBox "The card number does not exist. ", vbOKOnly," hint "txtcardno.setfocus txtcardno =" Exit Sub End if ' card number is on machine txt SQL = "SELECT * from Online_info where cardno= '" & Trim (Txtcardno.text) & "'" Set mrc3 = ExecuteSQL (TxtSQL, Ms Gtext) If MRC3. EOF then MsgBox "The user is not on the computer.
      ", vbOKOnly," hint "txtcardno.setfocus Txtcardno =" "  Txttype.text = "Txtstudentno.text =" "txtName.Text =" "Txtdepartment.text =" "Combo Sex.text = "Txtonlinedate.text =" "Txtonlinetime.text =" "Txtofflinedate.text =" "txt  Offlinetime.text = "Txttime.text =" "Txtremaincash.text =" "Txtusedcash.text =" "Exit Sub End If ' update interface information txttype.text = Trim (mrc3. Fields (1)) Txtstudentno.text = Trim (mrc3. Fields (2)) txtName.Text = Trim (mrc3. Fields (3)) Txtdepartment.text = Trim (mrc3. Fields (4)) Combosex.text = Trim (mrc3. Fields (5)) Txtonlinedate.text = Trim (mrc3. Fields (6)) Txtonlinetime.text = Trim (mrc3.  Fields (7)) Txtofflinedate.text = Trim (Date) Txtofflinetime.text = Trim (time) Txttime.text = Trim (DateDiff ("N", Trim (Txtonlinetime.text), trim (time))) ' Convert the time difference to minutes ' to get data from the base data table TxtSQL = "SELECT * FROM Basicdata_inf
o "Set mrc1 = ExecuteSQL (TxtSQL, Msgtext) ' calculates consumption amount    Dim mintime As Integer Dim alltime As Single Dim rate As Single Dim money As Integer Mintime = Mr C1. Fields (3) alltime = Txttime.text ' On-machine time is less than prep time, not time, without spending If Trim (txttime.text) < mintime then txt Time.Text = 0 & "Money = 0 Else If alltime > Mintime then does while alltime > M InTime alltime = AllTime-30 If MRC.
                Fields (14) = "Fixed user" then Money = money + 2 Else money = money + 3 End If Loop End If End If Txtusedcash.text = Money ' Calculate balance t
    Xtsql = "SELECT * from Student_info where cardno= '" & Trim (Txtcardno.text) & "' and Status= '" & "Use" & "" Set MRC = ExecuteSQL (TxtSQL, msgtext) Txtremaincash.text = Val (MRC. Fields (7)))-Val (Trim (txtusedcash.text)) TxtSQL = "Update student_info set cash= '" & Trim (txtusedCash. Text) & "' Where Cardno= '" & Trim (Txtcardno.text) & "'" Set MRC = ExecuteSQL (TxtSQL, Msgtext) MSG Box "down machine succeeded."
    
    ", vbOKOnly," Prompt "' update Line table TxtSQL =" SELECT * from Line_info "Set mrc2 = ExecuteSQL (TxtSQL, Msgtext) If not MRC2. EOF then Mrc2. AddNew Mrc2. Fields (1) = Trim (Txtcardno.text) mrc2. Fields (2) = Trim (Txtstudentno.text) mrc2. Fields (3) = Trim (txtName.Text) mrc2. Fields (4) = Trim (Txtdepartment.text) mrc2. Fields (5) = Trim (Combosex.text) mrc2. Fields (6) = Trim (Txtonlinedate.text) mrc2. Fields (7) = Trim (Txtonlinetime.text) mrc2. Fields (8) = Trim (Txtofflinedate.text) mrc2. Fields (9) = Trim (Txtofflinetime.text) mrc2. Fields (Ten) = Trim (Txttime.text) mrc2. Fields (one) = Trim (Txtusedcash.text) mrc2. Fields () = Trim (Txtremaincash.text) mrc2. Fields (13) = "Normal Down" mrc2. Fields = Trim (Environ ("computername")) Mrc2.
    Update    Mrc2. Close End If mrc3.
    Delete ' Update on machine number TxtSQL = ' SELECT count (*) from online_info "Set mrc3 = ExecuteSQL (TxtSQL, Msgtext) Label15.caption = "Current number of machines:" & Trim (MRC3. RecordCount) End Sub Private Sub cmdonline_click () Dim TxtSQL As String Dim Msgtext As String Dim m RC as ADODB. Recordset Dim Mrc1 as ADODB. The Recordset ' Online_info Dim mrc2 as ADODB. The Recordset ' Line_info Dim mrc3 as ADODB. Recordset ' Basicdata_info Dim micount as Integer txttype.text = "Txtstudentno.text =" "txtname. Text = "" Txtdepartment.text = "" Combosex.text = "" Txtonlinedate.text = "" Txtonlinetime.text = "" t Xtofflinedate.text = "Txtofflinetime.text =" "Txttime.text =" "Txtremaincash.text =" "Txtusedcash.tex
        t = "" ' Card number is empty if Txtcardno = "then MsgBox" Please enter card number! ", vbOKOnly," hint "txtcardno.setfocus Txtcardno = "" Exit Sub End If ' card number is registered TxtSQL = "SELECT * from Student_info where cardno= '" & Trim (Txtcardno.text) & ' "Set MRC = ExecuteSQL (TxtSQL, Msgtext) If MRC. EOF then MsgBox "The card number has not been registered, please re-enter." ", vbOKOnly," hint "txtcardno.setfocus txtcardno =" Exit Sub End if ' card number is on machine txts QL = "SELECT * from Online_info where cardno= '" & Trim (Txtcardno.text) & "'" Set Mrc1 = ExecuteSQL (TxtSQL, MSG Text) If Mrc1. EOF = False then MsgBox "The card number is on the machine. ", vbOKOnly," hint "Txtcardno =" "Txtcardno.setfocus txttype.text =" "Txtstudentno.text =
        "txtName.Text =" "Txtdepartment.text =" "Combosex.text =" "Txtonlinedate.text =" "
        Txtonlinetime.text = "Txtofflinedate.text =" "Txtofflinetime.text =" "Txttime.text =" "
    Txtremaincash.text = "" Txtusedcash.text = "" Exit Sub End If "card number is insufficient balance If Mrc. Fields (7) <= 5 Then If MsgBox ("The card number balance is insufficient to recharge. ", vbOKCancel," hint ") = vbOK then Frmrecharge. Show, Me End if Exit Sub End if ' card number uses the status if MRC. Fields (10) = "Not used" then if MsgBox ("The card has not been activated, whether to modify student information.") ", vbOKCancel," hint ") = vbOK then Frmmodifysinfo. Show, Me End if Exit Sub End if ' Set base data TxtSQL = "SELECT * from Basicdata_info" set Mr C3 = ExecuteSQL (TxtSQL, Msgtext) If mrc3. EOF Then If MsgBox ("The card has not set the underlying data, cannot log on, whether set. ", vbOKCancel," hint ") = vbOK then Frmsetbasicdata. Show, Me End if Exit Sub End if ' on machine succeeded, update on machine interface information TxtSQL = "SELECT * FROM Student_info wher  E cardno= ' "& Trim (Txtcardno.text) &" "Set MRC = ExecuteSQL (TxtSQL, Msgtext) ' Show data txtstudentno.text = Trim (MRC. Fields (1)) Txtdepartment.text = Trim (MRC. Fields (4)) Txttype.text = Trim (MRC. Fields) txtName.Text = Trim (MRC. Fields (2)) combosex.text = Trim (MRC. Fields (3)) Txtonlinedate.text = Trim (Date) Txtonlinetime.text = Trim (time) Txtremaincash.text = Val (Trim (mrc.f
    
    Ields (7)) ' Update on machine table information TxtSQL = ' select * from Online_info ' Set mrc1 = ExecuteSQL (TxtSQL, Msgtext) Mrc1. AddNew Mrc1. Fields (0) = Trim (Txtcardno.text) mrc1. Fields (1) = Trim (Txttype.text) mrc1. Fields (2) = Trim (Txtstudentno.text) mrc1. Fields (3) = Trim (txtName.Text) mrc1. Fields (4) = Trim (Txtdepartment.text) mrc1. Fields (5) = Trim (Combosex.text) mrc1. Fields (6) = Trim (Txtonlinedate.text) mrc1. Fields (7) = Trim (Txtonlinetime.text) mrc1. Fields (8) = Trim ("ZOEY") mrc1. Fields (9) = Trim (Date) mrc1. Update lblonlinenum.caption = Mrc1. RecordCount ' shows the current number of MRC1. Close ' Add on machine record TxtSQL = "SELECT * from Line_info" Set mrc2 = ExecuteSQL (TxtSQL, Msgtext) mrc2. AddNew Mrc2. Fields (1) = Trim (Txtcardno.text) mrc2. Fields (2) = Trim (Txtstudentno.text) mrc2. Fields (3) = Trim (txtName.Text) Mrc2. Fields (4) = Trim (Txtdepartment.text) mrc2. Fields (5) = Trim (Combosex.text) mrc2. Fields (6) = Trim (Txtonlinedate.text) mrc2. Fields (7) = Trim (Txtonlinetime.text) mrc2. Fields = Trim ("normal machine") mrc2. Fields = Trim ("ZOEY") mrc2. Update Mrc2.
    
    Close ' Update on machine number TxtSQL = ' SELECT count (*) from online_info "Set mrc1 = ExecuteSQL (TxtSQL, Msgtext) Label15.caption = "Current number of machines:" & Trim (Mrc1. RecordCount + 1) End Sub
The design of the whole code is that I have the help of a lot of classmates to complete, here to those who helped me to express my gratitude, no you have not my today.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.