RTFormwork/项目代码/RTBasicsV1/D02针织坯布检验/U_upPassword.pas

206 lines
4.9 KiB
ObjectPascal
Raw Permalink Normal View History

2024-07-07 09:35:27 +08:00
unit U_upPassword;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, cxLookAndFeelPainters, cxButtons, DB, ADODB,
Buttons, ExtCtrls, cxGraphics, cxLookAndFeels, dxSkinsCore,
dxSkinsDefaultPainters;
type
TfrmupPassword = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
userID: TEdit;
oldPassword: TEdit;
newPassword: TEdit;
DnewPassword: TEdit;
cxOK: TcxButton;
cxClose: TcxButton;
ADO_Cmd: TADOQuery;
Panel3: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton12: TSpeedButton;
procedure cxCloseClick(Sender: TObject);
procedure cxOKClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure userIDKeyPress(Sender: TObject; var Key: Char);
procedure oldPasswordClick(Sender: TObject);
procedure newPasswordClick(Sender: TObject);
procedure DnewPasswordClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton12Click(Sender: TObject);
private
Fint:Integer;
{ Private declarations }
public
fuserID:string;
fuserName:string;
fPassWord:string;
{ Public declarations }
end;
var
frmupPassword: TfrmupPassword;
implementation
uses spmain,ElAES,AES;
{$R *.dfm}
procedure TfrmupPassword.cxCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmupPassword.cxOKClick(Sender: TObject);
begin
if trim(oldPassword.text)<>'' then
fPassWord:=trim(EncryptString(PAnsiChar( trim(oldPassword.text)),keys))
else
fPassWord:='';
WITH ADO_Cmd Do
BEGIN
close;
sql.Clear;
sql.Add(' SELECT * ');
sql.Add(' FROM SY_User A ');
Sql.Add(' where UserID='+quotedstr(trim(fuserID)));
Sql.Add(' and PassWord='+quotedstr(trim(fPassWord)));
Sql.Add(' and Valid=''Y'' ');
open;
END;
IF ADO_Cmd.IsEmpty THEN
BEGIN
Application.MessageBox(<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ', MB_ICONERROR);
oldPassword.Text := '';
exit;
END;
if trim(newPassword.Text)<> trim(dnewPassword.Text) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EBB2BB>£<EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',MB_ICONERROR);
newPassword.Text:='';
dnewPassword.Text:='';
exit;
end;
if trim(newPassword.text)<>'' then
fPassWord:=trim(EncryptString(PAnsiChar( trim(newPassword.text)),keys))
else
fPassWord:='';
try
WITH ADO_Cmd Do
BEGIN
close;
sql.Clear;
sql.Add(' SELECT * ');
sql.Add(' FROM SY_User A ');
Sql.Add(' where UserID='+quotedstr(trim(fuserID)));
Sql.Add(' and Valid=''Y'' ');
open;
END;
ADO_Cmd.Edit;
ADO_Cmd.FieldByName('password').Value:=trim(fPassWord);
ADO_Cmd.Post;
ModalResult:=1;
application.MessageBox('<27>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
except
application.MessageBox('<27>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',MB_ICONERROR);
exit;
end;
end;
procedure TfrmupPassword.FormShow(Sender: TObject);
begin
userID.Text:=trim(fuserID);
oldPassword.SetFocus;
Fint:=1;
end;
procedure TfrmupPassword.userIDKeyPress(Sender: TObject; var Key: Char);
begin
Key:=UpCase(Key);
if key=#13 then
begin
perform(WM_NEXTDLGCTL,0,0);
Key := #0;
end;
end;
procedure TfrmupPassword.oldPasswordClick(Sender: TObject);
begin
Fint:=1;
end;
procedure TfrmupPassword.newPasswordClick(Sender: TObject);
begin
Fint:=2;
end;
procedure TfrmupPassword.DnewPasswordClick(Sender: TObject);
begin
Fint:=3;
end;
procedure TfrmupPassword.SpeedButton1Click(Sender: TObject);
begin
if Fint=1 then
begin
oldPassword.Text:=Trim(oldPassword.Text)+Trim(TSpeedButton(Sender).Caption);
oldPassword.SelectAll;
end else
if Fint=2 then
begin
newPassword.Text:=Trim(newPassword.Text)+Trim(TSpeedButton(Sender).Caption);
newPassword.SelectAll;
end else
if Fint=3 then
begin
DnewPassword.Text:=Trim(DnewPassword.Text)+Trim(TSpeedButton(Sender).Caption);
DnewPassword.SelectAll;
end;
end;
procedure TfrmupPassword.SpeedButton12Click(Sender: TObject);
begin
if Fint=1 then
begin
if Trim(oldPassword.Text)<>'' then
begin
oldPassword.Text:=Copy(Trim(oldPassword.Text),1,Length(Trim(oldPassword.Text))-1);
oldPassword.SelectAll;
end;
end else
if Fint=2 then
begin
if Trim(newPassword.Text)<>'' then
begin
newPassword.Text:=Copy(Trim(newPassword.Text),1,Length(Trim(newPassword.Text))-1);
newPassword.SelectAll;
end;
end else
if Fint=3 then
begin
if Trim(DnewPassword.Text)<>'' then
begin
DnewPassword.Text:=Copy(Trim(DnewPassword.Text),1,Length(Trim(DnewPassword.Text))-1);
DnewPassword.SelectAll;
end;
end;
end;
end.