Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. ULogin unit;
  2. interface
  3. uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, dialogs, StdCtrls, DB, ADODB;
  4. type
  5. TFrmLogin = class (TForm)
  6. Label1: TLabel;
  7. edusername: TEdit;
  8. Label2: TLabel;
  9. edpassword: TEdit;
  10. Button1: TButton;
  11. ADOQuery1: TADOQuery;
  12. ADOConnection1: TADOConnection;
  13. Button1Click procedure (Sender: TObject);
  14. FormCreate procedure (Sender: TObject);
  15. private
  16. {Private Declarations}
  17. public
  18. {Public Declarations} end;
  19. var FrmLogin: TFrmLogin;
  20. implementation uses
  21. / / XPMan for display form such as the button following the theme on windows
  22. / / Add to ULogin UHasilLogin unit by pressing Alt + F11, or with
  23. / / typed it
  24.  
  25. XPMan, UHasilLogin;
  26.  
  27. {$ R *. DFM}
  28.  
  29. TFrmLogin.FormCreate procedure (Sender: TObject);
  30. var
  31. s: Char;
  32. alamatdb: WideString;
  33. begin
  34.  
  35. / / Manipulation cursors crSQLWait order not to appear
  36. Screen.Cursors [crSQLWait]: = Screen.Cursors [crDefault];
  37.  
  38. / / set the display form
  39. s: = '*';
  40. edusername.Text: ='';
  41. edpassword.PasswordChar: = s;
  42. edpassword.Text: ='';
  43.  
  44. / / set the connection on ADOConnection
  45. / / This script allows you to manage database connections in applications
  46. / / in order to application can process database that has been selected in a computer
  47. / / anywhere without the need to have a path / address the same database.
  48.  
  49. alamatdb: = ExtractFilePath (Application.ExeName) + 'data.mdb';
  50. with ADOConnection1 do begin
  51. Connected: = False;
  52. LoginPrompt: = False;
  53. Mode: = cmShareDenyNone;
  54. ConnectionString: = 'Provider = Microsoft.Jet.OLEDB.4.0; Data Source =' +
  55. alamatdb + '; persist Security Info = False';
  56. end;
  57. ADOConnection1.Connected: = True;
  58. end;
  59.  
  60. TFrmLogin.Button1Click procedure (Sender: TObject);
  61. begin
  62. with ADOQuery1 do begin
  63. Close;
  64. SQL.Clear; / / clear command sql if there is.
  65. SQL.Add ('SELECT * FROM login WHERE username =' +
  66. QuotedStr (edusername.Text));
  67. Open;
  68. end; / / end with
  69.  
  70. / / if not found then the data sought
  71. / / display message
  72. if ADOQuery1.RecordCount = 0 then
  73. Application.MessageBox ('Sorry, your username does not exist', 'Information',
  74. MB_OK or MB_ICONINFORMATION)
  75. else begin
  76. if ADOQuery1.FieldByName ('password'). AsString <> edpassword.Text then
  77. Application.MessageBox ('Make sure the correct username or password',
  78. 'Error', MB_OK or MB_ICONERROR)
  79. else begin
  80. Hide;
  81. Form1.Show;
  82. end
  83. end;
  84. end;
  85.  
  86. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement