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 - User Management Module Explained (Page 3 of 4 )
This module does three things. First, it prepares the form for user input, and then it checks that all the fields in the form is updated. The newly inputted data is then posted to the database and a confirmation message is displayed, stating that a new user has been created. Let’s look at the code that makes each of these three steps happen.
The first procedure checks that the administrator entered all the required information:
procedure TForm6.BitBtn1Click(Sender: TObject);
The first part of the code checks that the administrator entered all the required information. This information comprises the user's name, password, etc.:
if (edname.Text = '') OR (eduname.Text = '') OR (edupass.Text = '') OR (edupass2.Text = '') OR (edupass.Text <> edupass2.Text) then begin
If the administrator leaves out any of the information, an error message is displayed informing her of it:
messagedlg('Please ensure that you fill in all the fields and that the password fields are the same.',mtInformation,[mbOK],0);
If the administrator has entered all the information correctly, it is posted to the database using the insert property of the ado component:
messagedlg(edname.Text + ' has now been created.',mtinformation,[mbOK],0);
The next option in the user management module covers changing a staff member's password in the database. The code should be familiar to you by now. The following takes place in this module: first, all the names of the users in the database are retrieved and stored in a combo box. You have to select the name of the user whose details you want to change, and then add the new fields to the form. The changes are posted to the database and a confirmation message is displayed. Below is the code for the module: