KOMPONEN:
1.FORM
2.DUA BUTTON
3.ADOConnection1
4.ADOQuery1
private
PROCEDURE staf;
PROCEDURE admin;
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
uses Unit7, Unit17;
{$R *.dfm}
procedure TForm8.staf ;
begin
form8.Visible:=false;
form7.Button2.Visible:=true;
form7.Button3.Visible:=true;
form7.Button4.Visible:=true;
form7.Button5.Visible:=true;
form7. sButton1.Visible:=true;
end;
procedure TForm8.admin ;
begin
form8.Visible:=false;
form7.Button2.Visible:=true;
form7.Button3.Visible:=true;
form7.Button4.Visible:=true;
form7.Button5.Visible:=true;
form7.Button12.Visible:=true;
form7.sButton1.Visible:=true;
end;
procedure TForm8.Button1Click(Sender: TObject);
begin
//label3.Caption :='login operator';
edit1.Text :='';
edit2.text:='';
close
end;
procedure TForm8.Button2Click(Sender: TObject);
begin
//edit1.text:=form17.edit1.text;
try ADOQuery1.Close; except end;
ADOQuery1.SQL.Text:='select * from login where username='''+(EDIT1.Text)+''' and password='''+(EDIT2.Text)+'''';
ADOQuery1.Open;
if ADOQuery1.RecordCount > 0 then
begin
if ADOQuery1.Fields[3].AsString ='admin'then
admin;
if ADOQuery1.Fields[3].AsString ='staf' then
staf;
end;
// jika tidak ditemukan data yang dicari maka
// tampilkan pesan
if ADOQuery1.RecordCount = 0 then
begin
//Image2.Picture.LoadFromFile('a.jpeg');
Label3.Caption:='ID Belum Terdaftar !';
Label3.Font.Color:=clRed;
Label4.Hide;
end
else if ADOQuery1.FieldByName('password').AsString <> Edit2.Text then
begin
//Image2.Picture.LoadFromFile('a.jpeg');
Label3.Caption:='Login Gagal !';
Label3.Font.Color:=clRed;
Label4.Show;
Label4.Caption:='Periksa username dan password';
Label4.Font.Color:=clRed;
end
else
begin
//form7.show;
form7.Button11.caption:='LOG OFF';
//edit1.Text :='';
edit2.text:='';
end ;
form17.edit1.text:=edit1.text;
end;
procedure TForm8.FormActivate(Sender: TObject);
begin
//sSkinManager1.ReloadSkin;
end;
procedure TForm8.FormClose(Sender: TObject; var Action: TCloseAction);
begin
edit1.Text:='';
edit2.Text:='';
form7.Button11.caption:='LOGIN';
end;
procedure TForm8.FormCreate(Sender: TObject);
var
alamatdb : WideString;
begin
Label4.Hide;
alamatdb := ExtractFilePath(Application.ExeName) + 'db_inventaris';
with ADOConnection1 do begin
Connected := False;
LoginPrompt := False;
Mode := cmShareDenyNone;
ConnectionString := 'Provider=MSDASQL.1;Persist Security Info=False;Data Source=db_inventaris';
end;
ADOConnection1.Connected := True;
end;
0 Comments