⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userchgpwd.pas

📁 有需要的同仁载回去慢慢研究
💻 PAS
字号:
unit UserChgPwd;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  StdCtrls, Buttons, Db, DBTables;

type
  TFrmChgPwd = class(TForm)
    Label1: TLabel;
    edOldPwd: TEdit;
    Label2: TLabel;
    bbOK: TBitBtn;
    edNewPwd: TEdit;
    Label3: TLabel;
    edConfPwd: TEdit;
    bbCancel: TBitBtn;
    procedure bbOKClick(Sender: TObject);
    procedure bbCancelClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    UserName: String;
    OldPassWd: String;
  public
    { Public declarations }
  end;

procedure ChangPasswd(const userName: String);

implementation

uses mycommon, DGSDM;
{$R *.DFM}

procedure ChangPasswd(const userName: String);
var
  frmChgPwd: TfrmChgPwd;
begin
     frmChgPwd:=TfrmChgPwd.Create(Application);
     try
        frmChgPwd.UserName :=userName;
        frmChgPwd.ShowModal;
     finally
        frmChgPwd.Free;
     end;
end;


procedure TFrmChgPwd.bbOKClick(Sender: TObject);
begin
  with DM_GSGL do
  begin
    tbuser.close;
    tbuser.parambyname('pyhgh').asstring:=UserName;
    tbuser.parambyname('pmm').asstring:=Encrypt(edOldPwd.Text);
    tbuser.open;
  end;
  if not DM_GSGL.tbuser.eof then
  begin
    if edNewPwd.Text=edConfPwd.Text then
    begin
      if edNewPwd.Text<>'' then
      begin
        with DM_GSGL do
        begin
          if qrytemp.active=true then
            qrytemp.close;
          qrytemp.sql.clear;
          qrytemp.sql.Add('update 操作用户信息 set 密码=:pmm where 用户工号=:puser');
          qrytemp.parambyname('puser').asstring:=username;
          qrytemp.parambyname('pmm').asstring:=Encrypt(edNewPwd.Text);
          qrytemp.execsql;
          Application.MessageBox('成功地改变密码!','信息',mb_ok or mb_iconInformation);
          Close;
        end;
      end
      else
      begin
        Application.MessageBox('新密码不能是空的!','错误',mb_ok or mb_iconError);
        edNewPwd.SetFocus;
      end
    end
    else
    begin
      Application.MessageBox('新密码不一致,请重新输入!','错误',mb_ok or mb_iconError);
      edNewPwd.SetFocus;
    end
  end
  else
    Application.MessageBox('旧密码错误,请重新输入!','错误',mb_ok or mb_iconError);
end;

procedure TFrmChgPwd.bbCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TFrmChgPwd.FormDestroy(Sender: TObject);
begin
  DM_GSGL.tbUser.Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -