User Management for an Internet Access Control Application
In this part of the Internet access control application, we are going to discuss the last section of the server application that deals with user management. The term "user management" is somewhat misleading in the context of our application because it is not actually users of the Internet café that we are referring to, but rather the staff members. This section will deal with how staff members allocate Internet sessions to users and also how staff members with administration level access can add, remove and change new staff member details.
User Management for an Internet Access Control Application (Page 1 of 4 )
The first section deals with adding an Internet session for a user.
Adding an Internet session
This part of the server application is where most of the money making is taking place. Below is a screen shot of what the session allocating application looks like:
The above image shows the allocating screen detailing the following: the name of the workstation to which the session is being allocated; in this case the workstation is called “janedoe.” It also shows the length of time that is allocated; in this case it is sixty minutes. Finally, it shows the charge, which is twenty dollars.
The session time, charge and the name of the workstation will then be sent to the client application, which will use that information to start up an Internet session. The allocation form is activated when a staff member double clicks on the workstation name in the list view control. When a staff member double clicks on it, the name of the workstation is transferred to the allocation screen.
Below is a listing of the code that makes all of the above happen:
The first procedure in the code deals with what happens when a staff member clicks on the “OK” button that is on the form. It is essentially responsible for updating the mula table and then sending the session information over to the workstation. The first part of the code initializes a couple of variables:
procedure TForm2.BitBtn1Click(Sender: TObject);
The name of the workstation is added to the label control and other information, such as the time and charge, is added to the just-initialized variables from appropriate edit and combo box controls:
Then the mula table is updated. Essentially, two pieces of information are sent to the database. The first piece is the user id of the currently logged-in staff member, which is captured at login, and the second piece is the total charge of the session that the staff member is allocating:
Finally, the information is sent to the workstation for processing. This is done by calling the timing() function which we discussed in the previous article. This function takes three arguments, which in this case are answered by adding the name of the workstation, the charge, and the time that is allocated for the Internet session:
The remaining procedure in this form deals with the allocation of the time and charge. As I’ve stated previously, the time and charge for a session is hard coded (which is not good practice, as it will be difficult to change the values at a later stage), but you might be well advised to make the setting of these values more flexible: