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

📄 uuserset.~pas

📁 在公司做的一个小的系统源代码
💻 ~PAS
字号:
unit Uuserset;

interface

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

type
  Tfrmuserset = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    edtopass: TEdit;
    Panel2: TPanel;
    Label3: TLabel;
    edtnname: TEdit;
    edtnpass: TEdit;
    edtnpass2: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Panel3: TPanel;
    sbtnsave: TSpeedButton;
    sbtncancel: TSpeedButton;
    sbtnclose: TSpeedButton;
    ADOQuery1: TADOQuery;
    Labname: TLabel;
    ADOQuery2: TADOQuery;
    procedure sbtncloseClick(Sender: TObject);
    procedure edtonameKeyPress(Sender: TObject; var Key: Char);
    procedure edtopassKeyPress(Sender: TObject; var Key: Char);
 
    procedure edtnnameKeyPress(Sender: TObject; var Key: Char);
    procedure edtnpassKeyPress(Sender: TObject; var Key: Char);
    procedure edtnpass2KeyPress(Sender: TObject; var Key: Char);
    procedure sbtnsaveClick(Sender: TObject);
    procedure sbtncancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmuserset: Tfrmuserset;

implementation

{$R *.dfm}
uses udm,ulogin;

procedure Tfrmuserset.sbtncloseClick(Sender: TObject);
begin
   if adoquery1.Active =true then adoquery1.Close;
  close;
end;

procedure Tfrmuserset.edtonameKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
  key:=#0;
  edtnname.Text:=labname.Caption;
  edtopass.SetFocus;
  end;
end;

procedure Tfrmuserset.edtopassKeyPress(Sender: TObject; var Key: Char);
begin
 if key=#13  then
 begin
  key:=#0;
  edtnname.SetFocus;
 end;
end;



procedure Tfrmuserset.edtnnameKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#32 then key:=#0;
  if key=#13 then
  begin
  key:=#0;
  edtnpass.SetFocus;
  end;
end;

procedure Tfrmuserset.edtnpassKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
edtnpass2.SetFocus;
end;
end;

procedure Tfrmuserset.edtnpass2KeyPress(Sender: TObject; var Key: Char);
begin
   if  key=#13 then
   begin
   key:=#0;
   sbtnsave.Click;
   end;
end;

procedure Tfrmuserset.sbtnsaveClick(Sender: TObject);
begin
if adoquery1.Active then adoquery1.Close;
with adoquery1 do
begin
  sql.Clear;
  sql.Add('select * from username where name='+#39+labname.Caption +#39);
end;
 try
 adoquery1.Open;
 except
 begin
    application.MessageBox('网络无法连接,请重试!!!','药品价格库',MB_OK+MB_ICONINFORMATION);
    abort;
 end;
 end;
 with adoquery1 do
 begin
   if (edtopass.Text=fieldbyname('password').AsString) then
    begin
     if edtnname.Text=''then
     begin
     messagebox(GetforegroundWindow,'用户名不能为空!','系统提示',mb_ok+mb_iconexclamation);
     edtnname.SetFocus;
     exit;
     end;
     if edtnpass.Text='' then
     begin
     messagebox(GetforegroundWindow,'密码不能为空!','系统提示',mb_ok+mb_iconexclamation);
     edtnpass.SetFocus;
     exit;
     end;
     if edtnpass.Text <>edtnpass2.Text  then
     begin
       messagebox(GetforegroundWindow,'新密码前后两次输入不正确!请重新输入。','系统提示',mb_ok+mb_iconexclamation);
       edtnpass.SetFocus;
       exit;
     end;
     if edtnname.Text <>labname.caption then
     begin
       if adoquery2.Active then adoquery2.Close;
       with adoquery2 do
       begin
       sql.Clear;
       sql.Add('select * from username where name='+#39+edtnname.Text +#39);
       end;
       try
         adoquery2.Open;
       except
       begin
         application.MessageBox('网络无法连接,请重试!!!','药品价格库',MB_OK+MB_ICONINFORMATION);
         abort;
       end;
       end;
       if adoquery2.IsEmpty then
       begin
       with adoquery1 do
       begin
          edit;
          fieldbyname('name').AsString:=edtnname.Text;
          fieldbyname('password').AsString:=edtnpass.Text;
          post;
          messagebox(GetforegroundWindow,'用户名或密码修改成功!','系统提示',mb_ok+mb_iconexclamation) ;
          abort;
       end;
       end else
       begin
          messagebox(GetforegroundWindow,'用户名已存在!,请重新输入!','系统提示',mb_ok+mb_iconexclamation) ;
          edtnname.SetFocus;
          abort;
       end;
     end else
     begin
       edit;
       fieldbyname('password').AsString:=edtnpass.Text;
       post;
       messagebox(GetforegroundWindow,'用户名或密码修改成功!','系统提示',mb_ok+mb_iconexclamation) ;
       abort;
     end;
    end  else
   begin
    messagebox(GetforegroundWindow,'密码错误!','系统提示',mb_ok+mb_iconexclamation);
    edtopass.SetFocus;
   end;
 end ;


  {
    begin
   if edtnname.Text=''then
   begin
   messagebox(GetforegroundWindow,'用户名不能为空!','系统提示',mb_ok+mb_iconexclamation);
   exit;
   end;
  if edtnpass.Text='' then
  begin
  messagebox(GetforegroundWindow,'密码不能为空!','系统提示',mb_ok+mb_iconexclamation);
  exit;
  end;
  if edtnpass.Text =edtnpass2.Text  then
  begin
   try
  adoquery1.Open;
  except
   begin
    application.MessageBox('网络无法连接,请重试!!!','药品价格库',MB_OK+MB_ICONINFORMATION);
    abort;
   end;
   end;
  if edtnname.Text <>labname.Caption  then
    with adoquery1 do
    begin
      first;
      while not eof do
      begin
         if edtnname.Text =fieldbyname('name').AsString then
         begin
         messagebox(GetforegroundWindow,'用户名已存在!,请重新输入!','系统提示',mb_ok+mb_iconexclamation) ;
         exit;
         end;
         next;
      end;
    end;
  adoquery1.Close;
   with adoquery1 do
   begin
     sql.Add('select * from username where name='+#39+labname.Caption+#39 );
     try
     open;
    except
    begin
      application.MessageBox('网络无法连接,请重试!!!','药品价格库',MB_OK+MB_ICONINFORMATION);
      abort;
     end;
     end;
     if edtnname.Text <>labname.caption then
     begin
       edit;
       fieldbyname('name').AsString:=edtnname.Text;
       fieldbyname('password').AsString:=edtnpass.Text;
       post;
     end else
     begin
       edit;
       fieldbyname('password').AsString:=edtnpass.Text;
       post;
     end;
   end;
   messagebox(GetforegroundWindow,' 密码或用户名修改成功','系统提示',mb_ok+mb_iconexclamation);
   labname.Caption :=edtnname.Text ;
   exit;
   end else
   begin
   messagebox(GetforegroundWindow,'新密码前后两次输入不正确!请重新输入。','系统提示',mb_ok+mb_iconexclamation);
   exit;
   end;
    end;
    next;
    end;
    messagebox(GetforegroundWindow,'密码错误!','系统提示',mb_ok+mb_iconexclamation);
  end;
  adoquery1.Close;}
end;

procedure Tfrmuserset.sbtncancelClick(Sender: TObject);
begin
   edtnname.Text:='';
   edtnpass.Text:='';
   edtnpass2.Text:='';
end;

procedure Tfrmuserset.FormCreate(Sender: TObject);
begin
  labname.caption:=gstrname ;
  edtnname.Text :=gstrname;
end;

end.

⌨️ 快捷键说明

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