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

📄 1.txt

📁 本系统是用delphi工具制作而成的一个简单的人事管理系统。
💻 TXT
字号:
unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    int_login:integer;     //设置登陆次数
  public
    { Public declarations }
    bool_login:boolean;
  end;

var
  Form4: TForm4;

implementation
uses  Unit1;
{$R *.dfm}

procedure TForm4.Button1Click(Sender: TObject);
var
  ADOQuery1:TADOQuery;              //定义ADOQUERY对象
  str_id :string;      //员工编号
  str_humanid:string;  //权限编号
  str_pwd:string;      //当前用户密码
  bool_select:boolean;
  bool_update:boolean;
  bool_delete:boolean;
  bool_insert:boolean;
begin

  if (edit1.Text='') or (edit2.Text='') then
  begin
    MessageDlg('用户名或密码不能为空!!', mtInformation, [mbYes],0);
    exit;
  end;
  str_pwd:= edit2.Text ;
  ADOQuery1:=TADOQuery.Create(self);
  ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
                              extractfilepath(application.ExeName)+
                              'DATA\db_booksys.mdb;Persist Security Info=False';   //连接字符串
  ADOQuery1.Close;           //关闭QUERY
  ADOQuery1.SQL.Clear;       //清空QUERY中的SQL
  ADOQuery1.SQL.Add('select * from tab_login where user_name=:A and user_password=:B');  //重置SQL语句
  ADOQuery1.Parameters.ParamByName('A').Value:=Edit1.Text;        //赋值
  ADOQuery1.Parameters.ParamByName('B').Value:=edit2.Text;        //赋值
  ADOQuery1.Open;            //打开SQL
  if ADOQuery1.RecordCount > 0 then
  begin
    str_id:=ADOQuery1.FieldValues['employer_id'];
    str_humanid:=ADOQuery1.FieldValues['human_id'];
    form1.Menu_enable;
    ADOQuery1.Close;
    ADOQuery1.SQL.Clear;


    form1.StatusBar1.Panels[0].Text:='操作者:' + str_id ;

    form1.statusbar1.Panels[1].Text:='登陆时间:    '+formatdatetime('yyyy/mm/dd hh:nn:SS',now);//得到登陆时间
    bool_login:=true;
    int_login:=0;
    ADOQuery1.Close;
    ADOQuery1.SQL.Clear;
    ADOQuery1.SQL.Add('select * from tab_human where human_id=:A');
    ADOQuery1.Parameters.ParamByName('A').Value:=str_humanid;
    ADOQuery1.Open;   //得到登陆者的权限
    bool_select:=ADOQuery1.FieldByName('human_select').AsBoolean;
    bool_insert:=ADOQuery1.FieldByName('human_insert').AsBoolean;
    bool_update:=ADOQuery1.FieldByName('human_update').AsBoolean;
    bool_delete:=ADOQuery1.FieldByName('human_delete').AsBoolean;
    form1.int_human:=0;

    if bool_select=true then
    begin
      form1.N8.Enabled:=true;

      form1.N18.Enabled:=true;

      form1.ToolButton11.Visible:=true;
      form1.ToolButton8.Visible:=true;
      form1.int_human:=2;
    end;
    if bool_insert=true then
    begin
      form1.N4.Enabled:=true;
      form1.N15.Enabled:=true;
      form1.ToolButton1.Visible:=true;
      form1.ToolButton11.Visible:=true;
      form1.ToolButton5.Visible:=true;
      form1.int_human:=2;
    end;
    if bool_update= true then
    begin
      form1.N5.Enabled:=true;

      form1.N16.Enabled:=true;
      form1.ToolButton2.Visible:=true;
      form1.ToolButton11.Visible:=true;
      form1.ToolButton6.Visible:=true;
      form1.int_human:=2;
    end;
    if bool_delete=true then
    begin
      form1.N6.Enabled:=true;

      form1.N17.Enabled:=true;
      form1.ToolButton3.Visible:=true;
      form1.ToolButton11.Visible:=true;
      form1.ToolButton7.Visible:=true;
      form1.int_human:=2;
    end;
    if (bool_select) and (bool_insert=true) and (bool_update=true) and (bool_delete=true) then
    begin



      form1.N35.Enabled:=true;

      form1.N37.Enabled:=true;

      form1.int_human:=1;

    end;
    form1.form_panel4Click;
    form1.PageControl1.ActivePageIndex:=1;
    form1.Show;
    form4.hide;


  end
  else
  begin
    MessageDlg('用户名或密码错误'+#13+'请重新输入!',mtWarning,[mbOK],0);
    edit1.Text:='';
    edit2.Text:='';
    int_login:=int_login + 1;
    if int_login=1 then
    begin
      messagedlg('你只有三次机会登录系统'+#13+'现在你还有两次机会!!',mtWarning,[mbOK],0);
    end;
    IF int_login=2 then
    begin
      MessageDlg('您还有最后一次机会'+#13+'如用户名或密码错误'+#13+'本系统将被锁定!!',mtWarning,[mbOK],0);
    end;
    if int_login=3 then   //登陆次数为3次时被锁
    begin
      MessageDlg('由于您登陆次数太多'+#13+'系统己被锁定!!',mtWarning,[mbOK],0);
      application.Terminate;  //超过次数退出程序
    end;
  end;

  ADOQuery1.Free;
end;


procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin

    application.Terminate;

end;

procedure TForm4.Button2Click(Sender: TObject);
begin
if form1.bool_login <> true then
application.Terminate
else
form4.Hide;
end;
end.

⌨️ 快捷键说明

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