重置用户密码制作

效果:

 源码:

unit UUpdateSign;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,Data.Win.ADODB;

type
  TFUpdateSign = class(TForm)
    lbl1: TLabel;
    lbl2: TLabel;
    lbl3: TLabel;
    edtadmid3: TEdit;
    edtadmps3: TEdit;
    edtadmps4: TEdit;
    btn1: TButton;
    procedure btn1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FUpdateSign: TFUpdateSign;

implementation

{$R *.dfm}

uses FDataPool, 日常管理助手;

procedure TFUpdateSign.btn1Click(Sender: TObject);
var
MyAdoq: TADOQuery;
begin
try
 MyAdoq:=TADOQuery.create(nil);
 MyAdoq.connection:= frmDataPool.ADOConnection1;
 with MyAdoq do
 begin
   Close;
   SQL.Text:='select * from 用户账号表 where admid = :admid' ;
   Parameters.ParamByName('admid').Value:=edtadmid3.Text;
   Open;
 end;
 if MyAdoq['admps']=null then
 begin
   ShowMessage('您输入的账号不存在,请重新输入');
   Exit;
 end  else if MyAdoq['admps']<>edtadmps3.Text then
 begin
   ShowMessage('原密码不对,请重新输入');
   Exit;
 end;

 if edtadmps4.Text <> edtadmps3.text then
  begin
  with MyAdoq do
   begin
     Close;
     SQL.Clear;
     SQL.Text:='update 用户账号表 set admps = '''+edtadmps4.text+''' where admid ='''+edtadmid3.text+''' and admps = '''+edtadmps3.text+'''';
     ExecSQL;
     if MessageDlg('重置成功,是否关闭窗口',mtConfirmation,[mbYes,mbno],0)=mryes then
     Self.Close;
   end;
  end else if edtadmps4.Text = edtadmps3.text then
  begin
    ShowMessage('新密码不可以跟原密码设置一样');
    Exit;
  end;

finally
 MyAdoq.Free;
end;
end;

procedure TFUpdateSign.FormShow(Sender: TObject);
begin
edtadmid3.Clear;
edtadmps3.Clear;
edtadmps4.Clear;
end;

end.

  

posted @ 2017-05-23 17:53  delphi学习交流吧  阅读(352)  评论(0编辑  收藏  举报