ผมกำลังหา componant - DCPCrypt ใน delphixe อยู่ครับ คงตอบโจทย์ข้อนี้ได้ครับ
http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=459.0
ตอนนี้ผมเขียนแบบนี้ครับ
if RzEdit2.Text = 'xxxxx' then
begin
Formlogin.Hide;
if formmain = nil then
Application.CreateForm(Tformmain,formmain);
MessageDlg('Programmer Mode', mtInformation, [mbOK], 0);
with FormMain do
begin
RzEdit1.Text:=Self.RzEdit1.Text;
RzEdit2.Text:=Self.RzEdit2.Text;
RzEdit3.Text:='0';
dxRibbonStatusBar1.Panels[0].Text:='ProgrammerMode';
Show;
end;
//Close;
//Abort;
end;
if (RzEdit1.Text<> '' ) and (RzEdit2.Text <> '' ) then
begin
with MyQuery1 do
begin
Close;
sql.Text := 'select * from hospital_member where loginname =:vlogin and password =:vpassword ';
Params.ParamValues['vlogin'] := trim(RzEdit1.Text);
Params.ParamValues['vpassword'] :=trim(RzEdit2.Text);
Open;
end;
if not MyQuery1.eof then
begin
Formlogin.Hide;
if formmain = nil then
Application.CreateForm(Tformmain,formmain);
with FormMain do
begin
RzEdit1.Text:=Self.MyQuery1['personcode'];
RzEdit2.Text:=Self.MyQuery1['name'];
RzEdit3.Text:='0';
dxRibbonStatusBar1.Panels[0].Text:=Self.myQuery1['loginname'];
show;
end;
//Close; }
end
else
begin
ShowMessage('ลองใหม่อีกทีจิ');
RzEdit2.Clear;
RzEdit2.SetFocus;
Abort;
end;
ขอบคุณครับ สำหรับตัวอย่าง code
ทำได้แล้วครับ
procedure TFrlogin4.RzButton1Click(Sender: TObject);
var
Md5:TIdHashMessageDigest5;
Str:string;
Sai:string;
begin
Md5:=TIdHashMessageDigest5.Create;
Str := md5.HashStringAsHex(RzEdit2.Text);
// Str := RzEdit2.Text;
DataModule1.Qmember2.Close;
DataModule1.Qmember2.SQL.Clear;
DataModule1.Qmember2.SQL.Add('Select username,password From member_info where username ="'+RzEdit1.Text+'" and password = "'+Str+'"');
DataModule1.Qmember2.Open;
// while not DataModule1.Qmember2.Eof do
// if(RzEdit1.Text = DataModule1.Qmember2['username']) and (RzEdit2.Text = DataModule1.Qmember2['password'])
if((RzEdit1.Text = DataModule1.Qmember2['username']) and (Str = DataModule1.Qmember2['password'])) then
// if((RzEdit1.Text = DataModule1.Qmember2['username']) and (Str = DataModule1.Qmember2['password']) ) then
begin
if Fmenu=nil then
Application.CreateForm(TFmenu, Fmenu);
Fmenu.Show;
//Frlogin4.Hide;
Frlogin4.Close;
exit;
end
else
begin
if((RzEdit1.Text <> DataModule1.Qmember2['username'])or (RzEdit1.Text = DataModule1.Qmember2['username']) and (Str <> DataModule1.Qmember2['password'])) then
begin
ShowMessage('กรุณาล็อกอินใหม: Invalid Username/Password ');
RzEdit1.Text:='';
RzEdit2.Text:='';
RzEdit1.SetFocus;
Exit;
Exit;
end
end;
end;