Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitAddStudent;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls,
- Data.Win.ADODB, MmSystem;
- type
- TfrmAddStudent = class(TForm)
- lblAddStudent: TLabel;
- ledtStudentNumber: TLabeledEdit;
- ledtFirstName: TLabeledEdit;
- ledtLastName: TLabeledEdit;
- ledtCandidateNumber: TLabeledEdit;
- rgStudentDetails: TRadioGroup;
- rgAcademicYear: TRadioGroup;
- ledtTeacherName: TLabeledEdit;
- ledtStudentEmail: TLabeledEdit;
- ledtParentGuardianEmail: TLabeledEdit;
- btnBackToGroupProfiles: TButton;
- btnCreateStudent: TButton;
- rbNoASQaulfication: TRadioButton;
- rgAcademicInformation: TRadioGroup;
- cboTargetGradeInput: TComboBox;
- cboPastASQualification: TComboBox;
- lblPastASQualification: TLabel;
- lblTargetGrade: TLabel;
- cboASSelectGroup: TComboBox;
- btnGCSESubjects: TButton;
- cboGCSEGrade1: TComboBox;
- cboGCSEGrade2: TComboBox;
- lblGCSESubject1: TLabel;
- lblGCSESubject2: TLabel;
- lblGPGroupName: TLabel;
- procedure btnBackToGroupProfilesClick(Sender: TObject);
- procedure btnCreateStudentClick(Sender: TObject);
- procedure ledtStudentNumberKeyPress(Sender: TObject; var Key: Char);
- procedure ledtCandidateNumberKeyPress(Sender: TObject; var Key: Char);
- procedure ledtFirstNameKeyPress(Sender: TObject; var Key: Char);
- procedure ledtLastNameKeyPress(Sender: TObject; var Key: Char);
- procedure ledtTeacherNameKeyPress(Sender: TObject; var Key: Char);
- procedure rgAcademicYearClick(Sender: TObject);
- procedure ledtGroupNameKeyPress(Sender: TObject; var Key: Char);
- procedure FormShow(Sender: TObject);
- procedure btnGCSESubjectsClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmAddStudent: TfrmAddStudent;
- implementation
- uses UnitGroupProfiles, UnitdmDatabaseComponents, UnitGCSESubjects;
- {$R *.dfm}
- procedure ExistanceCheck(SQLText, FieldName, Fine: string; Ledt : TLabeledEdit; DataExists : boolean);
- begin
- with dmDatabaseComponents.adoExistanceCheck do
- begin
- Close;
- SQL.Clear;
- SQL.Text := SQLText;
- ExecSQL;
- Open;
- { ---------- Traverse through the table ---------- }
- First; // Start at the first record
- while not EoF do
- begin
- if Ledt.Text = FieldByName(FieldName).AsString then
- begin
- DataExists := True;
- Break; // Once item stop the loop
- Fine := 'Fine'
- end
- else
- begin
- Next; // If the student number does not match move to the next record
- end;
- end;
- end;
- end;
- procedure ErrorOutputComboBox(ErrorMessage : string; Cbo : TComboBox);
- begin
- { ---------- Highlight the input with an error ---------- }
- Cbo.Color := clRed; // Turn the input into a red color
- Cbo.Font.Color := clWhite; // Turn the text into the input to white
- PlaySound('SYSTEMEXCLAMATION', 0, SND_ASYNC); // Play error sound
- Showmessage(ErrorMessage); // Output an error message
- { ---------- Remove the highlight ----------}
- Cbo.Color := clWhite; // Make the input white again
- Cbo.Font.Color := clBlack; // Make the font black again
- end;
- procedure ErrorOutputLabeledEdit(ErrorMessage : string; Ledt : TLabeledEdit);
- begin
- { ---------- Highlight the input with an error ---------- }
- Ledt.Color := clRed; // Turn the input into a red color
- ledt.Font.Color := clWhite; // Turn the text into the input to white
- PlaySound('SYSTEMEXCLAMATION', 0, SND_ASYNC); // Play error sound
- Showmessage(ErrorMessage); // Output an error message
- { ---------- Remove the highlight ----------}
- Ledt.Color := clWhite; // Make the input white again
- ledt.Font.Color := clBlack; // Make the font black again
- end;
- procedure CorrectKeyPressedName(KeyIn : Char; Field : string);
- begin
- if (not (KeyIn in ['A'..'Z','a'..'z', #8])) then // If a letter key is not pressed
- begin
- PlaySound('SYSTEMEXCLAMATION', 0, SND_ASYNC); // Play error sound
- Showmessage('ERROR: '+Field+' must be a letters only'); // Produce an error message
- KeyIn := #0; // Remove the last character
- end; // end if
- end;
- procedure CorrectKeyPressedNumerical(KeyIn : Char; Field : string);
- begin
- if not (KeyIn in ['0'..'9', #8]) then // If a letter pressed is pressed
- begin
- PlaySound('SYSTEMEXCLAMATION', 0, SND_ASYNC); // Play error sound
- Showmessage('ERROR: '+Field+' must only be numerical'); // Produce an error message
- KeyIn := #0; // Remove the last character
- end; // end if
- end;
- procedure TfrmAddStudent.btnBackToGroupProfilesClick(Sender: TObject);
- begin
- frmAddStudent.Hide;
- frmGroupProfile.Show;
- end;
- function IsEmailValid(Email : string): Boolean;
- function CheckAllowed(EmailAdress : string): Boolean;
- var
- i : integer;
- begin
- Result := False;
- // Loop through the entire string
- for i := 1 to Length(EmailAdress) do
- // If the string does not contain these charaters
- if not (EmailAdress[i] in ['A'..'Z','a'..'z','0'..'9','_','-','.']) then
- begin
- // Make the email address invalid
- Result := False
- end // End of if statement
- else
- begin
- // Make the email address invalid
- Result := True;
- end; // End of the else statement
- end; // End of checked allowed
- var
- i : integer;
- // Email variables
- NamePart, ServerPart : string;
- begin
- Result := False;
- // Find the intial position of the at value
- i := Pos('@', Email);
- // If it has not been included...
- if i = 0 then
- begin
- // Returen that the email is not valid
- Result := False;
- end // End of the if statement
- // Otherwise...
- else
- begin
- // ...Find the name part of the email
- NamePart:= Copy(Email, 1, i-1);
- // ...Find the server part
- ServerPart:= Copy(Email, i+1, Length(Email));
- // If the name was not included or server is less than 5 characters
- if (Length(NamePart)=0) or (Length(ServerPart)<5) then
- begin
- // Returen that the email is not valid
- Result := False;
- end // end of the if statement statement
- // Otherwise...
- else
- begin
- // Find the position of the . in the server
- i := Pos('.', ServerPart);
- // If the . was not included
- if (i = 0) or (i > (Length(ServerPart)-2)) then
- begin
- // Returen that the email is not valid
- Result := False
- end // End of the if statement
- // Otherwise
- else
- begin
- {
- Check to see if the name part and the server part
- contain valid characters
- }
- //
- Result := CheckAllowed(NamePart) and CheckAllowed(ServerPart);
- end; // End of the else statement
- end; // End of the else statement
- end; // End of the else statement
- end;
- procedure TfrmAddStudent.btnCreateStudentClick(Sender: TObject);
- var
- // Existance Check variables
- StudentNumberExists, StudentEmailExists, ParentGuardianEmailExists : Boolean;
- ExistanceCheckSQL, ExistanceCheckFieldName : string;
- // Email format check variables
- x : integer;
- ValidEmailFormat : Boolean;
- ErrorMessagePram, Fine : string;
- begin
- { ---------- Carry out the format check for... ---------- }
- // ...For the student email
- IsEmailValid(ledtStudentEmail.Text);
- // ...For the parent guardian email
- IsEmailValid(ledtParentGuardianEmail.Text);
- { ---------- Carry out any existance checks ---------- }
- with dmDatabaseComponents.adoExistanceCheck do
- begin
- Close;
- SQL.Text; // Initialise the SQL
- // Set the SQL
- SQL.Text :='SELECT * FROM [StudentDetails]';
- ExecSQL; // Execute the SQL
- Open;
- First; // Start at the first record
- // Traverse through the table
- while not Eof do
- begin
- // if the student number matchs the student number at a particular record
- if ledtStudentNumber.Text = FieldByName('StudentNumber').AsString then
- begin
- // The student exists
- StudentNumberExists := True;
- Break;
- end // End of if statement
- else
- Next; // Move on to the next record
- end; // End of while loop
- end; // End of with
- //
- { ---------- Carry out any existance checks ---------- }
- with dmDatabaseComponents.adoExistanceCheck do
- begin
- Close;
- SQL.Text :='SELECT * FROM [StudentDetails]';
- ExecSQL;
- Open;
- First;
- while not Eof do
- begin
- if ledtStudentEmail.Text = FieldByName('StudentEmail').AsString then
- begin
- StudentEmailExists := True;
- Break;
- end
- else
- Next;
- end;
- end;
- //
- { ---------- Carry out any existance checks ---------- }
- with dmDatabaseComponents.adoExistanceCheck do
- begin
- Close;
- SQL.Text :='SELECT * FROM [StudentDetails]';
- ExecSQL;
- Open;
- First;
- while not Eof do
- begin
- if ledtParentGuardianEmail.Text = FieldByName('ParentGuardianEmail').AsString then
- begin
- ParentGuardianEmailExists := True;
- Break;
- end
- else
- Next;
- end;
- end;
- { ---------- Create A Student Profile ---------- }
- if (lblGCSESubject1.Caption = '') OR (lblGCSESubject2.Caption = '') then
- begin
- Showmessage('Please add a GCSE Subjects');
- end
- { ---------- Student Number Validation ---------- }
- { ---------- Presence Check ----------- }
- else if ledtStudentNumber.Text = '' then // Checks if entry is empty
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Student Number is of an invalid type';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentNumber);
- end // end if
- { ---------- Range Check ---------- }
- else if (StrToInt(ledtStudentNumber.Text) < 150000) OR (StrToInt(ledtStudentNumber.Text) > 169999) then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Student Number is of an invalid type';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentNumber);
- end
- { ---------- Existance Check ---------- }
- else if StudentNumberExists = True then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Student Number already exists';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentNumber);
- end
- { ---------- First Name Validation ---------- }
- { ---------- Length Check ---------- }
- else if Length(ledtFirstName.Text) > 15 then // Checks if first name is greater than 15 characters
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: First name must be under 15 characters';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtFirstName);
- end // end if
- { ---------- Presence Check ---------- }
- else if ledtFirstName.Text = '' then // Check to see if the input is empty
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter first name';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtFirstName);
- end // end if
- { ---------- Last Name Validation ---------- }
- { ---------- Length Check ---------- }
- else if Length(ledtLastName.Text) > 15 then // Checks if last name is greater than 15 characters
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Last name must be 15 charaters or less';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtLastName);
- end
- { ---------- Presence Check ---------- }
- else if ledtLastName.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter last name';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtLastName);
- end
- { ---------- Candidate Number Validation ---------- }
- { ---------- Presence Check ---------- }
- else if ledtCandidateNumber.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter candidate number';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtCandidateNumber);
- end
- { ---------- Length Check ---------- }
- else if (StrToInt(ledtCandidateNumber.Text) < 1000) AND (StrToInt(ledtCandidateNumber.Text) > 9999) then // Checks if Candidae Number is in required range
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Candidate number is of an invalid type';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtCandidateNumber);
- end // end if
- { ---------- Teacher Name Validation ---------- }
- { ---------- Length Check ---------- }
- else if Length(ledtTeacherName.Text) > 25 then // Check if Teacher name is greater than 25
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Teacher name must be 25 characters or less';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtCandidateNumber);
- end // end if
- { ---------- Presence Check ---------- }
- else if ledtTeacherName.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter a teacher name';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtTeacherName);
- end
- { ---------- Group Name Validation ---------- }
- { ---------- Length Check ---------- }
- { ---------- Presence Check ---------- }
- else if cboASSelectGroup.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter a group name';
- ErrorOutputComboBox(ErrorMessagePram, cboASSelectGroup);
- end
- { ---------- Student Email Validation ---------- }
- { ---------- Format Check ---------- }
- else if IsEmailValid(ledtStudentEmail.Text) = False then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Student email is in the wrong format';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentEmail);
- end
- { ---------- Lentgh Check ---------- }
- else if Length(ledtStudentEmail.Text) > 30 then // Check if Student Email is greater than 30
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Student Email must be 30 characters or less';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentEmail);
- end // end if
- { ---------- Presence Check ----------}
- else if ledtStudentEmail.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter a student email';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentEmail);
- end
- { ---------- Existance Check ---------- }
- else if StudentEmailExists = True then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Student email already exists';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtStudentEmail);
- end
- { ---------- Parent/Guardian Email Validation ---------- }
- { ---------- Presence Check ---------- }
- else if ledtParentGuardianEmail.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter an email for Parent/Guardian';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtParentGuardianEmail);
- end
- { ---------- Length Check ---------- }
- else if Length(ledtParentGuardianEmail.Text) > 30 then // Check if Parent/Guardian Email is greater than 30
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Parent/Guardian email must be 30 characters or less';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtParentGuardianEmail);
- end // end if
- { ---------- Existance Check ---------- }
- else if ParentGuardianEmailExists = True then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Parent/guardian email already exists';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtParentGuardianEmail);
- end
- { ---------- Format Check ---------- }
- else if IsEmailValid(ledtParentGuardianEmail.Text) = False then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Parent/Guardian email is in the wrong format';
- ErrorOutputLabeledEdit(ErrorMessagePram, ledtParentGuardianEmail);
- end
- { ---------- GCSE Subject 1 Presence Check ---------- }
- else if cboGCSEGrade1.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter a GCSE grade';
- ErrorOutputComboBox(ErrorMessagePram, cboGCSEGrade1);
- end
- { ---------- GCSE Subject 2 Presence Check ---------- }
- else if cboGCSEGrade2.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter a GCSE grade';
- ErrorOutputComboBox(ErrorMessagePram, cboGCSEGrade1);
- end
- { ---------- Target Grade Presence Check ---------- }
- else if cboTargetGradeInput.Text = '' then
- begin
- ErrorMessagePram := '';
- ErrorMessagePram := 'ERROR: Please enter a target grade';
- ErrorOutputComboBox(ErrorMessagePram, cboTargetGradeInput);
- end
- else
- { ---------- Begin process of a dding a new student ---------- }
- begin
- { ---------- Add Student To StudentDetails Table ---------- }
- with dmDatabaseComponents.adoUnitAddStudent do
- begin
- SQL.Clear; // Initialize the SQL
- // The query to INSERT
- SQL.Text:='INSERT INTO StudentDetails (StudentNumber, FirstName, LastName, CandidateNumber, TeacherName, GroupName, StudentEmail, ParentGuardianEmail) values (:SNo,:FN,:LN,:CN,:TN,:GN,:SE,:PGE)';
- // Set parameters to their inputs
- Parameters.ParamByName('SNo').Value:=StrToInt(ledtStudentNumber.Text);
- Parameters.ParamByName('FN').Value:=ledtFirstName.Text;
- Parameters.ParamByName('LN').Value:=ledtLastName.Text;
- Parameters.ParamByName('CN').Value:=StrToInt(ledtCandidateNumber.Text);
- Parameters.ParamByName('TN').Value:=ledtTeacherName.Text;
- Parameters.ParamByName('GN').Value:=cboASSelectGroup.Items[cboASSelectGroup.ItemIndex];
- Parameters.ParamByName('SE').Value:=ledtStudentEmail.Text;
- Parameters.ParamByName('PGE').Value:=ledtParentGuardianEmail.Text;
- ExecSQL; // Execute the SQL
- SQL.Clear; // Initialize the SQL
- // The query to INSERT
- SQL.Text:='UPDATE [StudentDetails] SET TargetGrade = :TG, PastASQualification = :PASQ, GCSESubject1 = :GCSE1, GCSESubject2 = :GCSE2, AcademicYear = :AY WHERE StudentNumber = '+ledtStudentNumber.Text;
- // Set parameters to their inputs
- Parameters.ParamByName('TG').Value:=cboTargetGradeInput.Items[cboTargetGradeInput.ItemIndex];
- // If the user selected No past AS Qualification
- if rbNoASQaulfication.Checked = True then
- begin
- // Make the parameter 'None'
- Parameters.ParamByName('PASQ').Value:='None'
- end
- else
- begin
- // Make the parameter the qaulification selected
- Parameters.ParamByName('PASQ').Value:=cboPastASQualification.Items[cboPastASQualification.ItemIndex];
- end;
- Parameters.ParamByName('GCSE1').Value:=cboGCSEGrade1.Items[cboGCSEGrade1.ItemIndex];
- Parameters.ParamByName('GCSE2').Value:=cboGCSEGrade2.Items[cboGCSEGrade2.ItemIndex];
- Parameters.ParamByName('AY').Value:=rgAcademicYear.Items[rgAcademicYear.ItemIndex];
- ExecSQL; // Execute the SQL
- end;
- { ---------- Add Student Into Correct Homework Table ---------- }
- with dmDatabaseComponents.adoUnitAddStudent do
- begin
- Close;
- SQL.Clear; // Initialize the SQL
- SQL.Text:='INSERT INTO [HOMEWORK'+cboASSelectGroup.Items[cboASSelectGroup.ItemIndex]+'] (StudentID, StudentName) values (:SNo,:SN)'; // Set SQL Query
- // Set parameters to correct inputs
- Parameters.ParamByName('SNo').Value:=StrToInt(ledtStudentNumber.Text);
- Parameters.ParamByName('SN').Value:=ledtFirstName.Text+' '+ledtLastName.Text;
- ExecSQL; // Execute the SQL
- end; // End with
- { ---------- Add Student Into Correct Assessment Table ---------- }
- with dmDatabaseComponents.adoUnitAddStudent do
- begin
- Close;
- SQL.Clear; // Initialize the SQL
- SQL.Text:='INSERT INTO [ASSESSMENT'+cboASSelectGroup.Items[cboASSelectGroup.ItemIndex]+'] (StudentID, StudentName) values (:SNo,:SN)'; // Set SQL Query
- // Set parameter values
- Parameters.ParamByName('SNo').Value:=StrToInt(ledtStudentNumber.Text);
- Parameters.ParamByName('SN').Value:=ledtFirstName.Text+' '+ledtLastName.Text;
- ExecSQL; // Execute the SQL
- end; // End with
- Showmessage('Student has successfully been added'); // Confirmation Message
- { ---------- Reset the inputs ---------- }
- // Once the student is saved clear inputs
- ledtStudentNumber.Text := ''; // Clear the student number field
- ledtFirstName.Text := ''; // Clear the first name field
- ledtLastName.Text := ''; // Clear the last field
- ledtCandidateNumber.Text := ''; // Clear the candidate number field
- ledtTeacherName.Text := ''; // Clear the teacher name field
- cboASSelectGroup.Text := ''; // Clear the group name field
- ledtStudentEmail.Text := ''; // Clear the student email field
- ledtParentGuardianEmail.Text := ''; // Clear the parent/guardian email field
- cboGCSEGrade1.Text := ''; // Clear the GCSE grade 1 field
- cboGCSEGrade2.Text := ''; // Clear the GCSE grade 2 field
- rbNoASQaulfication.Checked := False; // Uncheck the no past AS qualificatioin
- cboTargetGradeInput.Text := ''; // Clear the target grade field
- cboPastASQualification.Text := ''; // Clear the past AS qualification field
- end; // End of else
- end;
- procedure TfrmAddStudent.btnGCSESubjectsClick(Sender: TObject);
- begin
- frmGCSESubjects.Show;
- end;
- procedure TfrmAddStudent.FormShow(Sender: TObject);
- begin
- cboASSelectGroup.Clear;
- with dmDatabaseComponents.adoASDisplayGroup do
- begin
- First; // Start from the fist record
- while not Eof do
- begin
- // Add the group
- cboASSelectGroup.Items.Add(FieldByName('GroupName').AsString); // Read the GroupNames record only
- Next; // Next Record
- end;
- end;
- GCSESubjectsFileRead := '';
- AssignFile(GCSESubjectsFile, 'GCSESubjects.txt');
- // Open the file for reading access
- Reset(GCSESubjectsFile);
- // Read the first line
- Readln(GCSESubjectsFile, GCSESubjectsFileRead);
- lblGCSESubject1.Caption := GCSESubjectsFileRead;
- // Read the second line
- Readln(GCSESubjectsFile, GCSESubjectsFileRead);
- lblGCSESubject2.Caption := GCSESubjectsFileRead;
- // Close the file
- CloseFile(GCSESubjectsFile);
- end;
- procedure TfrmAddStudent.ledtCandidateNumberKeyPress(Sender: TObject;
- var Key: Char);
- begin
- CorrectKeyPressedNumerical(Key, 'Candidate Number');
- end;
- procedure TfrmAddStudent.ledtFirstNameKeyPress(Sender: TObject; var Key: Char);
- begin
- CorrectKeyPressedName(Key, 'First Name')
- end;
- procedure TfrmAddStudent.ledtGroupNameKeyPress(Sender: TObject; var Key: Char);
- begin
- if (not (Key in ['A'..'Z','a'..'z','-','/','0'..'9'])) then // If a letter key is not pressed
- begin
- PlaySound('SYSTEMEXCLAMATION', 0, SND_ASYNC); // Play error sound
- Showmessage('ERROR: Invalid key entered for group name'); // Produce an error message
- Key := #0; // Remove the last character
- end; // end if
- end;
- procedure TfrmAddStudent.ledtLastNameKeyPress(Sender: TObject; var Key: Char);
- begin
- CorrectKeyPressedName(Key, 'Last Name');
- end;
- procedure TfrmAddStudent.ledtStudentNumberKeyPress(Sender: TObject;
- var Key: Char);
- begin
- CorrectKeyPressedNumerical(Key, 'Student Number');
- end;
- procedure TfrmAddStudent.ledtTeacherNameKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if (not (Key in ['A'..'Z','a'..'z', #32])) then // If a letter key is not pressed
- begin
- PlaySound('SYSTEMEXCLAMATION', 0, SND_ASYNC); // Play error sound
- Showmessage('ERROR: Teacher name must be a letters only'); // Produce an error message
- Key := #0; // Remove the last character
- end; // end if
- end;
- procedure TfrmAddStudent.rgAcademicYearClick(Sender: TObject);
- begin
- { ---------- Disable Past AS Qaulification if AS student ----------- }
- if rgAcademicYear.Items[rgAcademicYear.ItemIndex] = 'AS' then // If the user is creating an AS student profile
- begin
- cboPastASQualification.Enabled:=False; // Allow input for Past AS qualification
- end // end if
- else if rgAcademicYear.Items[rgAcademicYear.ItemIndex] = 'A2' then // If the user is creating an A2 student profile
- begin
- cboPastASQualification.Enabled:=True; // Allow input for an A2 qualification
- end; // end else
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement