Data room Charging System Series 4: On/Off

Source: Internet
Author: User
In the data room charging system, it took a lot of time to do it on and off the machine. The main reason was that the idea was not clarified, and it was easy to do on the computer. When it got down, after that, I was dumpfounded to find out that it was wrong. To avoid this situation, I should first clarify my thoughts when I was on and off the server, so don't worry about writing code and sharpen the knife without mistake. Next I will talk about the problem of getting on and off the server.

In the data room charging system, it took a lot of time to do it on and off the machine. The main reason was that the idea was not clarified, and it was easy to do on the computer. When it got down, after that, I was dumpfounded to find out that it was wrong. To avoid this situation, I should first clarify my thoughts when I was on and off the server, so don't worry about writing code and sharpen the knife without mistake. Next I will talk about the problem of getting on and off the server.

In the data room charging system, it took a lot of time to do it on and off the machine. The main reason was that the idea was not clarified, and it was easy to do on the computer. When it got down, after that, I was dumpfounded and found that it was not correct ...... In order to avoid this situation, we should first clarify our thinking when we are on and off the machine. Don't worry about writing code and sharpen the knife without mistake. Next we will talk about my understanding of on and off the machine.

Computer

First, the flowchart of the computer

Then it analyzes each process and some code. If the process is clearly analyzed, the code is easy to write.

1. Whether the card number is blank

2. Whether the card number exists (student_Info table)

3. Whether the status of the card number is "use" (student_Info table)

'Check whether the card number can be used normally. txtSQL = "select * from student_Info where cardno = '" & Trim (txtcardno. text) & "'" Set mrc = executesql (txtSQL, msgText) If mrc. EOF Then MsgBox "this card has not been registered! ", VbOKOnly + vbExclamation," warning "txtcardno. text = "" txtcardno. setFocus mrc. close Exit Sub Else status = Trim (mrc. fields (10) If mrc. EOF = False And "not used" = status Then MsgBox "this card is not registered! ", VbOKOnly + vbExclamation," warning! "Txtcardno. Text =" "txtcardno. SetFocus mrc. Close Exit Sub End If

4. Check whether the machine is running

 txtSQL = "select * from OnLine_Info where cardno='" & Trim(txtcardno.Text) & "'"  Set mrcc = executesql(txtSQL, msgText)
5. Check whether the balance in the card is less than the minimum amount on the machine (student_Info table)
'If the card number can be used and is Not available on the computer, check the balance If Not mrc. Fields (7)> frmbasicctsding.txt limitcash then' to determine whether the balance is greater than the minimum amount MsgBox "insufficient balance. Please recharge your account! ", VbOKOnly + vbExclamation," warning "mrc. Close Exit Sub End If
6. If the preceding conditions are met, the host is displayed. The host information and logon count are displayed on the main interface.
'Show logon count onflag = onflag + 1 Label19.Caption = onflag' disconnect database mrc. Close
7. Add the record on the machine to the OnLine_Info table.

8. Add the Host record to the Line_Info table.

Drop-down

Offline Flowchart

1. Check whether the machine is running

2. Update the data in the Line_Info table (update the offline date and the offline time)

'Determine whether the card number is in txtSQL = "select * from OnLine_Info where cardno = '" & Trim (txtcardno. text) & "'" Set mrc = executesql (txtSQL, msgText) If mrc. EOF = True Then Label14.Caption = "this card number is not available yet! "Mrc. Close Exit Sub                                                                 

3. delete data in the OnLine_Info table

4. Calculate the consumption time

'Calculate the time consumed by the computer txtoffdate. text = Format (Date, "yyyy-mm-dd") txtofftime. text = Format (Time, "hh: mm") Usetime = Abs (DateDiff ("n", txtofftime, txtontime) 'check every day. When you check out, force the user to drop txtconsumetime. text = Usetime

5. Calculate the consumption amount

'Calculate the consumption amount' If the consumption time is less than the minimum time, the consumption amount is 1 RMB If txtconsumetime. text <= Leasttime Then txtconsume. text = 1 'txtcash. text = mrc. fields (7)-Trim (txtconsume. text) ElseIf Usetime <= pretime then' In the first case, the consumption time is less than the preparation time, and the consumption amount is 0 Usecash = 0 txtconsume. text = Usecash Else: Money consumed in an incremental period,
'Computing base based on an incremental period (30 minutes)
Unitcash = Format (Halfcash/30) * Unittime, "0.0") 'Second case, the consumption time is shorter than the minimum computer time, and the time is increased by one time period (30 minutes) if Usetime <= Leasttime Then Usecash = Unitcash txtconsume. text = Unitcash Else 'scenario 3 UnitNumber is the number of incremental periods Usetime = Usetime-pretime UnitNumber = Usetime Mod Unittime If UnitNumber = 0 Then UnitNumber = Int (Usetime/Unittime) else UnitNumber = Int (Usetime/Unittime) + 1 End If Usecash = Format (UnitNumber * Unitcash, "0.0") txtconsume. text = Usecash End If
'Calculate the latest balance
TxtSQL = "select * from student_Info where cardno = '" & txtcardno & "'" Set mrc = executesql (txtSQL, msgText) 'get the original balance Totalcash = mrc. fields (7) 'calculate the consumed balance Totalcash = Totalcash-Val (Trim (txtconsume. text) 'update the balance mrc. fields (7 ). value = Totalcash mrc. update mrc. close txtcash. text = Totalcash
6. Update the information to the text box corresponding to the main interface, and the number of people on the computer should also be updated.

7. Update the basic information table (student_Info table)

Going online and downloading is mainly a logical reflection. After clarifying the ideas, you can do a good job. In the data room charging system, not only on/off, checkout, and combined query all reflect the importance of logic, but also have a global grasp of the functions to be implemented, and then break them down, in this way, you can do it well.

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.