unit PasswordFrm;
//Download by http://www.okbase.net
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, RzLabel, RzBckgnd, StdCtrls, Mask, RzEdit, RzButton;

type
  TCpassFrm = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    RzSeparator1: TRzSeparator;
    RzLabel1: TRzLabel;
    RzLabel2: TRzLabel;
    RzLabel3: TRzLabel;
    RzEdit1: TRzEdit;
    RzEdit2: TRzEdit;
    RzEdit3: TRzEdit;
    Bevel1: TBevel;
    rzbtbtn_OK: TRzBitBtn;
    rzbtbtn_Cancel: TRzBitBtn;
    Image1: TImage;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyPress(Sender: TObject; var Key: char);
    procedure rzbtbtn_CancelClick(Sender: TObject);
    procedure rzbtbtn_OKClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CpassFrm: TCpassFrm;

implementation

uses FunctionPas, DataModuleU;

{$R *.dfm}

procedure TCpassFrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  CpassFrm := nil;
  Action := Cafree;
end;

procedure TCpassFrm.FormKeyPress(Sender: TObject; var Key: char);
begin
  if Key = #13 then
  begin
    Key := #0;
    perform(WM_NEXTDLGCTL, 0, 0);
  end;
end;

procedure TCpassFrm.rzbtbtn_CancelClick(Sender: TObject);
begin
  Close;
end;

procedure TCpassFrm.rzbtbtn_OKClick(Sender: TObject);
var
  m_Sql :string;
begin
  if RzEdit1.Text <> DmFrm.LogPass then
  begin
    ShowMessage('旧密码不正确!');
    RzEdit1.SetFocus;
    Exit;
  end
  else begin
    if RzEdit3.Text <> RzEdit2.Text then
    begin
      ShowMessage('确认密码不正确!');
      RzEdit3.SetFocus;
      Exit;
    end
    else begin
      m_Sql := 'Update User_Table Set Yhmm = '
        + QuotedStr(EncrypKey(RzEdit2.Text))
        + ' Where id = ' + IntToStr(DmFrm.LogUserID);
      if DmFrm.ExecAdoquery(m_Sql) then
      begin
        ShowMessage('恭喜您,修改成功!');
        Close;
      end else
      begin
        ShowMessage('修改失败,请重试!');
        Exit;
      end;
    end;
  end;
end;

end.