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

📄 uuserlogin.pas

📁 说明: 比较简单的人事档案管理程序,包含了人事档案的大部分功能,做人事档案的兄弟可以看看. 本程序类型:delphi7 + Access2000 桌面数据库 初始用户名/密码:admin
💻 PAS
字号:
unit UUserLogin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg;

type
  TForm_UserLogin = class(TForm)
    Image1:TImage;
    Edit1:TEdit;
    ComboBox1:TComboBox;
    btOK:TButton;
    btCancel:TButton;
    procedure FormShow(Sender:TObject);
    procedure btCancelClick(Sender:TObject);
    procedure btOKClick(Sender:TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
    i:integer; //输入错误次数
  public
    { Public declarations }
    loginflag:integer;
    username:string;
  end;

var
  Form_UserLogin:TForm_UserLogin;

implementation
uses Umain;
{$R *.dfm}

procedure TForm_UserLogin.FormShow(Sender:TObject);
begin
  ComboBox1.Clear;
  edit1.Clear;
  i := 0;
  //EDIT2是用来判断输入的密码是否正确
  loginflag:=0;
  //载入用户名称到下拉列表
  try
    with FORM_main.TabUser  do
    begin
      close;
      open;
      first;
      while not eof do
      begin
        ComboBox1.Items.Add(FieldByName('User_Name').AsString);
        ComboBox1.Text := FieldByName('User_Name').AsString;
        next;
      end;
      close;
    end;
  except
    beep;
    showmessage('打开用户表失败!');
  end;
end;

procedure TForm_UserLogin.btCancelClick(Sender:TObject);
begin
  application.Terminate;
end;

//=====================================
//按确定进行用户/密码判断
//=====================================
procedure TForm_UserLogin.btOKClick(Sender:TObject);
begin
  i := i + 1;
  try
    with form_main.TabUser do
    begin
      close;
      open;
      first;
      while not eof do
      begin
        if fieldByName('User_Name').AsString = trim(ComboBox1.Text) then
        begin
          if edit1.Text = fieldByName('User_PassWord').AsString then
           begin
            username:=fieldByName('User_Name').AsString;
            loginflag:=1;
            end
          else
            loginflag:=0;
          last;
        end;
        next;
      end;
      close;
    end;
  except
    beep;
    showmessage('打开用户表错误!');
    loginflag:=0;
    exit;
  end;
  if loginflag=1 then
  begin
    close;
    end
  else
  begin
    if i = 3 then
    begin
      beep;
      showmessage('密码错误次数太多,程序即将中止');
      loginflag:=0;
      application.Terminate;
    end
    else
    begin
      beep;
      showmessage('你输入的密码不正确,请重新输入');
      edit1.SetFocus;
    end;
  end;
end;
procedure TForm_UserLogin.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
 btOKClick(Sender);
end;

end.

⌨️ 快捷键说明

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