KOMPONEN:
1.FORM
2.DUA BUTTON
3.ADOConnection1
4.ADOQuery1private
{ Private declarations }
procedure EditData;
function CheckData: boolean;
public
{ Public declarations }
end;
var
Form17: TForm17;
implementation
uses Unit8;
{$R *.dfm}
procedure TForm17.EditData;
begin
ADOQuery1.edit;
ADOQuery1['password']:=EDIT3.Text;
ADOQuery1.post;
end;
procedure TForm17.FormActivate(Sender: TObject);
begin
edit2.SetFocus;
end;
procedure TForm17.FormClose(Sender: TObject; var Action: TCloseAction);
begin
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
end;
function TForm17.CheckData: boolean;
var
pesan: string;
begin
try
adoquery1.Close; except end;
adoquery1.SQL.Text:='select * from login where nama='''+(EDIT1.text)+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
pesan := '';
if Trim(edIT2.text) <>adoquery1 .Fields[2].AsString then pesan := 'Password Lama Tidak Sama.';
if Trim(edIT3.Text) = '' then pesan := 'Password Baru belum dimasukan.';
if Trim(edIT3.Text) <> Trim(edIT4.Text) then pesan := 'Password user berbeda dengan validasi password.';
if pesan = '' then
Result := True
else
begin
MessageBox(Handle,PChar(pesan),'Users',MB_OK + MB_ICONERROR);
Result := False;
end;
end;
end;
procedure TForm17.Button1Click(Sender: TObject);
begin
if CheckData then
begin
editdata;
// bUTTON2.Enabled:=true;
//BUTTON1.Enabled:=false;
//EDIT2.Enabled:=false;
// EDIT3.Enabled:=False;
//EDIT4.Enabled:=false;
application.MessageBox('Password anda telah berubah','Ganti Password',mb_OK + mb_iconExclamation);
end;
close;
end;
procedure TForm17.Button2Click(Sender: TObject);
begin
//button2.Enabled:=false;
//button1.Enabled:=True;
//edit3.SetFocus;
//edit3.Enabled:=true;
//edit4.Enabled:=true;
end;
procedure TForm17.Button3Click(Sender: TObject);
begin
close;
end;
end.
0 Comments