Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.87 KB | None | 0 0
  1. unit LoginUnit;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
  8.  
  9. type
  10.   TfrmLogin = class(TForm)
  11.     btnEnter: TButton;
  12.     ledtUsername: TLabeledEdit;
  13.     ledtPassword: TLabeledEdit;
  14.     btnExit: TButton;
  15.     procedure btnEnterClick(Sender: TObject);
  16.     procedure btnExitClick(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23.  
  24. var
  25.   frmLogin: TfrmLogin;
  26.  
  27. implementation
  28.  
  29. {$R *.dfm}
  30.  
  31. Uses
  32.   TeacherMenuUnit , StudentMenuUnit;
  33.  
  34. procedure TfrmLogin.btnEnterClick(Sender: TObject);
  35. begin
  36.  
  37.   //Teacher login entry
  38.   if (ledtUsername.Text = 'BMartin') AND (ledtPassword.Text = 'Glucose') then  //username and password prerequisites
  39.   Begin
  40.     ShowMessage('Login Successful');
  41.     frmTeacherMenu.Show;  //displays teacher menu form
  42.   End
  43.  
  44.   //Student login entry
  45.   Else If (ledtUsername.Text = 'UWaraich') AND (ledtPassword.Text = 'Cellulose') then  //username and password prerequisites
  46.     Begin
  47.     ShowMessage('Login Successful');
  48.     frmStudentMenu.Show; //displays student menu form
  49.     End
  50.  
  51.   //Incorrect username/password
  52.   Else
  53.     Begin
  54.       if Application.Messagebox('Incorrect Login Details, Please Try Again','Incorrect',
  55.                                   MB_RetryCancel or MB_IconError)
  56.         = IDCancel then
  57.         Begin
  58.           Close;   //closes the form when 'Cancel' is clicked in messagebox
  59.         End
  60.       Else
  61.        ledtUsername.Text := ''; //clears username
  62.        ledtPassword.Text := ''; //clears password
  63.     End;
  64. //put the above in 3.7 reviewed section: say you will put in prototype 2
  65. //think of something clever
  66.  
  67. end;
  68.  
  69. procedure TfrmLogin.btnExitClick(Sender: TObject);
  70. begin
  71.   frmLogin.Close; //closes login form
  72. end;
  73.  
  74. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement