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

📄 access.~pas

📁 该源码采用DELPHI语言,主要实现了对员工信息管理的功能.
💻 ~PAS
字号:
unit Access;

interface

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

type
  TForm2 = class(TForm)
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  flag1:boolean;  //定义全局变量
  flag2:boolean;
  count:integer;
  name : string;
  user : string;

implementation

uses Welcome, Main;

{$R *.dfm}

procedure TForm2.BitBtn2Click(Sender: TObject);
begin
   if messagedlg('真的要退出系统吗?',mtconfirmation,[mbYes,mbNo],0)=mryes then
   form1.close;
end;

procedure TForm2.BitBtn1Click(Sender: TObject);
begin
    with ADOquery1 do
    begin
    if flag1 = true then     //以管理员的身份登陆
    begin
         SQL.Clear;
         SQL.Add('select 姓名 from 管理员 where 管理员帐号 = '''+Edit1.Text+''' and 密码 = '''+Edit2.Text+'''');       //根据管理员的员工号和密码在数据库中进行选择
         Open;
         if not ADOquery1.IsEmpty then    //该管理员在数据库中存在
         begin
           user := ADOquery1.fieldByname('姓名').AsString;   //将管理员名字赋值给user变量
           form3.show;
         end
         else
           begin
              count := count + 1;
              showmessage('用户名或密码错误!');
              if (count = 3) then       //输入密码错误三次,系统自动关闭
              form1.Close;
           end;
     end
     else
     if flag2 = true then     //以员工的身份登陆
     begin
         SQL.Clear;
         SQL.Add('select 姓名 from 员工 where 员工号 = '''+Edit1.Text+''' and 密码 = '''+Edit2.Text+'''');
         Open;
         if not ADOquery1.IsEmpty then
         begin
             user := ADOquery1.fieldByName('姓名').AsString;
             form3.show;
         end
         else
         begin
             count := count + 1;
             showmessage('用户名或密码错误!');
             if (count = 3) then
             form1.Close;
         end;
     end;
     end;
end;

procedure TForm2.RadioButton1Click(Sender: TObject);
begin
flag1:=true;
flag2:=false;
end;

procedure TForm2.RadioButton2Click(Sender: TObject);
begin
flag1:=false;
flag2:=true;
end;

end.

⌨️ 快捷键说明

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