About
Contact
Disclaimer
Sitemap
coretanhans
Artikel dan Tips & Trick ada di website ini, selamat datang di coretanhans.com
Blogger
Food
Insurance
Lifestyle
Healthy
Technology
Error
More
Disclaimer
Sitemap
Theme
Tutorial
Home
Delphi 7
Perpustakaan
Aplikasi Perpustakaan - Edisi 8 (Form Login)
Aplikasi Perpustakaan - Edisi 8 (Form Login)
Hans
Agustus 19, 2019
Program Perpustakaan.
Tampilan Menu Utama
1. Membuat Form Login.
Selanjutnya kita membuat Form Login untuk memberikan akses atau membedakan akses admin dan user, untuk source kode kalian bisa lihat di bawah sini:
source code:
1: unit Unit3;
2:
3: interface
4:
5: uses
6: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7: Dialogs, Mask, StdCtrls, XPMan, DB, ADODB, acPNG, ExtCtrls;
8:
9: type
10: TForm_Login = class(TForm)
11: GroupBox1: TGroupBox;
12: Label1: TLabel;
13: Label2: TLabel;
14: eUID: TEdit;
15: Button1: TButton;
16: Button2: TButton;
17: ePassword: TEdit;
18: XPManifest1: TXPManifest;
19: Query: TADOQuery;
20: Image1: TImage;
21: procedure Button2Click(Sender: TObject);
22: procedure Button1Click(Sender: TObject);
23: procedure ePasswordEnter(Sender: TObject);
24: procedure ePasswordExit(Sender: TObject);
25: procedure FormClose(Sender: TObject; var Action: TCloseAction);
26: procedure FormActivate(Sender: TObject);
27: private
28: { Private declarations }
29: public
30: { Public declarations }
31: end;
32:
33: var
34: Form_Login: TForm_Login;
35:
36: implementation
37:
38: uses unit1,unit2;
39:
40: {$R *.dfm}
41:
42: procedure TForm_Login.Button2Click(Sender: TObject);
43: begin
44: Close;
45: end;
46:
47: procedure TForm_Login.Button1Click(Sender: TObject);
48: begin
49: Query.Connection := Form_Utama.Koneksi;
50: Query.SQL.Add('select * from tabel_user where id_user="' + eUID.Text + '";');
51: Query.Active := true;
52: if Query.RecordCount = 0 then
53: begin
54: MessageDlg('User tidak ditemukan!',mtError,[mbOk],0);
55: Query.Active := false;
56: Query.SQL.Clear;
57: eUID.Clear;
58: ePassword.Clear;
59: eUID.SetFocus;
60: end
61: else
62: begin
63: if Query['password'] = ePassword.Text then
64: begin
65: Form_Utama.StatusBar1.Panels[2].Text := Query['nm_user'];
66: if Query['akses_level'] = 1 then
67: Form_Utama.StatusBar1.Panels[3].Text := 'Admin'
68: else
69: Form_Utama.StatusBar1.Panels[3].Text := 'User';
70: Form_Utama.Panel1.Show;
71: eUID.Clear;
72: ePassword.Clear;
73: Query.Active := false;
74: Query.SQL.Clear;
75: self.close;
76: end
77: else
78: begin
79: MessageDlg('Password salah!',mtError,[mbOk],0);
80: ePassword.Clear;
81: ePassword.SetFocus;
82: Query.Active := false;
83: Query.SQL.Clear;
84: end;
85: end;
86: end;
87:
88: procedure TForm_Login.ePasswordEnter(Sender: TObject);
89: begin
90: Button1.Default := true;
91: end;
92:
93: procedure TForm_Login.ePasswordExit(Sender: TObject);
94: begin
95: Button1.Default := false;
96: end;
97:
98: procedure TForm_Login.FormClose(Sender: TObject; var Action: TCloseAction);
99: begin
100: if Form_Utama.StatusBar1.Panels[3].Text = '' then
101: begin
102: if MessageDlg('Yakin ingin keluar?',mtConfirmation,[mbCancel,mbOk],0) = mrCancel then
103: Action := caNone
104: else
105: Form_Startup.Close;
106: end;
107: end;
108:
109: procedure TForm_Login.FormActivate(Sender: TObject);
110: begin
111: eUID.Clear;
112: ePassword.Clear;
113: eUID.SetFocus;
114: end;
115:
116: end.
Posting Lebih Baru
Posting Lama
Related Posts
Comments
Langganan:
Posting Komentar ( Atom )
Info Arlina
Comments