Recent Posts

Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi

(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita

Selasa, 17 November 2009

Login

unit login;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Buttons;

type
TfrmLogin = class(TForm)
btnCancel: TButton;
pnLogin: TGroupBox;
edtHost: TEdit;
edtDatabase: TEdit;
edtLogin: TEdit;
edtPassword: TEdit;
lblHost: TLabel;
lblDatabase: TLabel;
lblPassword: TLabel;
lblLogin: TLabel;
edtPort: TEdit;
lblPort: TLabel;
btnOk: TButton;
cbxType: TComboBox;
lblType: TLabel;
cbRemember: TCheckBox;
procedure FormShow(Sender: TObject);
procedure cbxTypeChange(Sender: TObject);
procedure btnOkClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
frmLogin: TfrmLogin;

implementation

uses main, ZSqlScript, ZSqlTypes;

{$R *.DFM}

{ On form show event }
procedure TfrmLogin.FormShow(Sender: TObject);
begin
cbxType.ItemIndex := Ord(frmMain.DatabaseType);
cbxTypeChange(Self);
cbRemember.Checked:=frmMain.RememberPassword;

if edtHost.Text = '' then
ActiveControl := edtHost
else if edtPort.Text = '' then
ActiveControl := edtPort
else if edtDataBase.Text = '' then
ActiveControl := edtDataBase
else if edtLogin.Text = '' then
ActiveControl := edtLogin
else
ActiveControl := edtPassword;
end;

{ When Database Type Change }
procedure TfrmLogin.cbxTypeChange(Sender: TObject);
begin
case cbxType.ItemIndex of
0: begin
edtHost.Text := frmMain.MySqlHost;
edtDatabase.Text := frmMain.MySqlDatabase;
edtPort.Text := IntToStr(frmMain.MySqlPort);
edtLogin.Text := frmMain.MySqlLogin;
if frmMain.RememberPassword then
edtPassword.Text := frmMain.MySQLPassword;
end;
1: begin
edtHost.Text := frmMain.PgSqlHost;
edtDatabase.Text := frmMain.PgSqlDatabase;
edtPort.Text := IntToStr(frmMain.PgSqlPort);
edtLogin.Text := frmMain.PgSqlLogin;
if frmMain.RememberPassword then
edtPassword.Text := frmMain.PgSQLPassword;
end;
2: begin
edtHost.Text := frmMain.IbSqlHost;
edtDatabase.Text := frmMain.IbSqlDatabase;
edtPort.Text := '0';
edtLogin.Text := frmMain.IbSqlLogin;
if frmMain.RememberPassword then
edtPassword.Text := frmMain.IbSqlPassword;
end;
3: begin
edtHost.Text := frmMain.MsSqlHost;
edtDatabase.Text := frmMain.MsSqlDatabase;
edtPort.Text := '0';
edtLogin.Text := frmMain.MsSqlLogin;
if frmMain.RememberPassword then
edtPassword.Text := frmMain.MsSqlPassword;
end;
end;
edtPort.Enabled := (cbxType.ItemIndex <>
end;

{ When apply updates }
procedure TfrmLogin.btnOkClick(Sender: TObject);
begin
case cbxType.ItemIndex of
0: begin
frmMain.MySqlHost := edtHost.Text;
frmMain.MySqlDatabase := edtDatabase.Text;
frmMain.MySqlPort := StrToIntDef(edtPort.Text, 0);
frmMain.MySqlLogin := edtLogin.Text;
frmMain.MySqlPassword := edtPassword.Text;
end;
1: begin
frmMain.PgSqlHost := edtHost.Text;
frmMain.PgSqlDatabase := edtDatabase.Text;
frmMain.PgSqlPort := StrToIntDef(edtPort.Text, 0);
frmMain.PgSqlLogin := edtLogin.Text;
frmMain.PgSqlPassword := edtPassword.Text;
end;
2: begin
frmMain.IbSqlHost := edtHost.Text;
frmMain.IbSqlDatabase := edtDatabase.Text;
frmMain.IbSqlLogin := edtLogin.Text;
frmMain.IbSqlPassword := edtPassword.Text;
end;
3: begin
frmMain.MsSqlHost := edtHost.Text;
frmMain.MsSqlDatabase := edtDatabase.Text;
frmMain.MsSqlLogin := edtLogin.Text;
frmMain.MsSqlPassword := edtPassword.Text;
end;
end;

frmMain.DatabaseType := TDatabaseType(cbxType.ItemIndex);
frmMain.RememberPassword := cbRemember.Checked;
frmMain.SaveOptions;
end;

end.

0 komentar:

Posting Komentar