unit frmChPass;

interface

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

type
  TfrmPass = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    Button1: TButton;
    Button2: TButton;
    ADOCommand1: TADOCommand;
    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 login, admin;

{$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
  frmAdmin.Enabled:=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 ADOCommand1 do
      begin
        close;
        commandtext:='update admins set admins.password="'+edit2.Text+'" where name="'+strName+'"';
        execute;
        strPassword:=edit2.Text;
      end;
    end
  else
    showmessage('密码错误。');
  end
else
  showmessage('密码不能为空，两次输入的新密码必须相同。');
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end;

end.
