unit frmChPass;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ADODB, DB, DBClient;

type
  TfrmPass = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    Button1: TButton;
    Button2: TButton;
    ClientDataSet1: TClientDataSet;
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPass: TfrmPass;

implementation

uses service;

{$R *.dfm}

procedure TfrmPass.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
close;
end;

procedure TfrmPass.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  frmService.Visible:=true
end;

procedure TfrmPass.Button1Click(Sender: TObject);
begin
if (edit1.text<>'') and (edit2.text<>'') and (edit2.text=edit3.text) then
  begin
  if strPassword=edit1.Text then
    begin
      with clientdataset1 do
      begin
        close;
        commandtext:='update admins set admins.password='+quotedstr(edit2.Text)+' where name='+quotedstr(strName);
        execute;
        strPassword:=edit2.Text;
        showmessage('密码修改成功');
        frmPass.Close;
      end;
    end
  else
    showmessage('密码错误。');
  end
else
  showmessage('密码不能为空，两次输入的新密码必须相同。');
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end;

end.
