www.pudn.com > dianlijiankong.rar > ULOGIN.pas, change:2005-12-22,size:5168b


unit ULOGIN; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, Buttons, StdCtrls, ExtCtrls, jpeg; 
 
type 
  TFRM_LOGIN = class(TForm) 
    Panel1: TPanel; 
    Image1: TImage; 
    SpeedButton1: TSpeedButton; 
    SpeedButton2: TSpeedButton; 
    Edit1: TEdit; 
    ComboBox1: TComboBox; 
    procedure SpeedButton1Click(Sender: TObject); 
    procedure SpeedButton2Click(Sender: TObject); 
    procedure ComboBox1Change(Sender: TObject); 
    procedure ComboBox1DropDown(Sender: TObject); 
    procedure Edit1KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit1Change(Sender: TObject); 
    procedure FormClose(Sender: TObject; var Action: TCloseAction); 
    procedure FormCreate(Sender: TObject); 
  private 
    iTimes: Integer; 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  FRM_LOGIN: TFRM_LOGIN; 
  m: Boolean = False;//防止用户关闭登录窗口进入系统 
implementation 
 
uses UMAIN, UDM; 
 
{$R *.dfm} 
procedure TFRM_LOGIN.ComboBox1Change(Sender: TObject); 
begin 
  DM.QUSER.Locate('用户名称', ComboBox1.text,[]); 
  Edit1.SetFocus; 
end; 
 
procedure TFRM_LOGIN.SpeedButton1Click(Sender: TObject); 
begin 
  Inc(iTimes); 
  FRM_MAIN.Auser.UserID:=DM.QUSER.FieldByName('用户编号').AsString; 
  FRM_MAIN.Auser.UserName:=DM.QUSER.FieldByName('用户名称').AsString; 
  if FRM_MAIN.Auser.UserName='' then 
    Application.MessageBox('没有用户存在,请预先设定好用户!','提示',4); 
  if (ComboBox1.Text<>'') and (Trim(Edit1.Text)=DM.QUSER.FieldByName('密码').AsString) then 
   begin 
   Close; 
    FRM_MAIN.Caption:='物流管理系统V2.0版'; 
    m:=True; 
    DM.QUSER.Open; 
    FRM_MAIN.SpeedButton1.Enabled:=True; 
    FRM_MAIN.SpeedButton2.Enabled:=True; 
    FRM_MAIN.SpeedButton3.Enabled:=True; 
    FRM_MAIN.SpeedButton4.Enabled:=True; 
    FRM_MAIN.SpeedButton5.Enabled:=True; 
    FRM_MAIN.SpeedButton6.Enabled:=True; 
    FRM_MAIN.SpeedButton7.Enabled:=True; 
    FRM_MAIN.SpeedButton8.Enabled:=True; 
    FRM_MAIN.SpeedButton9.Enabled:=True; 
    FRM_MAIN.SpeedButton10.Enabled:=True; 
    FRM_MAIN.SpeedButton11.Enabled:=True; 
    FRM_MAIN.SpeedButton12.Enabled:=True; 
    FRM_MAIN.SpeedButton13.Enabled:=True; 
    FRM_MAIN.SpeedButton14.Enabled:=True; 
    FRM_MAIN.SpeedButton15.Enabled:=True; 
    FRM_MAIN.SpeedButton16.Enabled:=True; 
    FRM_MAIN.SpeedButton17.Enabled:=True; 
    with FRM_MAIN do 
    begin  //主菜单是否可用,取决于数据库中预设的值 
      FRM_MAIN.SpeedButton1.Enabled:=DM.QUSER.FieldByName('B1').AsBoolean; 
      FRM_MAIN.SpeedButton2.Enabled:=DM.QUSER.FieldByName('B2').AsBoolean; 
      FRM_MAIN.SpeedButton3.Enabled:=DM.QUSER.FieldByName('B3').AsBoolean; 
      FRM_MAIN.SpeedButton4.Enabled:=DM.QUSER.FieldByName('B4').AsBoolean; 
      FRM_MAIN.SpeedButton5.Enabled:=DM.QUSER.FieldByName('B5').AsBoolean; 
      FRM_MAIN.SpeedButton6.Enabled:=DM.QUSER.FieldByName('B6').AsBoolean; 
      FRM_MAIN.SpeedButton7.Enabled:=DM.QUSER.FieldByName('B7').AsBoolean; 
      FRM_MAIN.SpeedButton8.Enabled:=DM.QUSER.FieldByName('B8').AsBoolean; 
      FRM_MAIN.SpeedButton9.Enabled:=DM.QUSER.FieldByName('B9').AsBoolean; 
      FRM_MAIN.SpeedButton16.Enabled:=DM.QUSER.FieldByName('B10').AsBoolean; 
      FRM_MAIN.SpeedButton11.Enabled:=DM.QUSER.FieldByName('B11').AsBoolean; 
      FRM_MAIN.SpeedButton12.Enabled:=DM.QUSER.FieldByName('B12').AsBoolean; 
      FRM_MAIN.SpeedButton13.Enabled:=DM.QUSER.FieldByName('B13').AsBoolean; 
      FRM_MAIN.SpeedButton14.Enabled:=DM.QUSER.FieldByName('B14').AsBoolean; 
      FRM_MAIN.SpeedButton15.Enabled:=DM.QUSER.FieldByName('B15').AsBoolean; 
      FRM_MAIN.SpeedButton17.Enabled:=DM.QUSER.FieldByName('B16').AsBoolean; 
    end; 
    end 
    else 
    begin 
      Messagebox(0,'用户名或密码错误,请重新输入!'+#13#10+'并请确定您有进入的权限。','',MB_OK+MB_ICONSTOP); 
      Edit1.Text:=''; 
    end; 
    IF iTimes=4 then 
    begin 
      Application.MessageBox('您进行系统身份确认程序错误已经超过3次,本系统将停止执行!','提示!',0); 
      Application.Terminate; 
    end; 
end; 
 
procedure TFRM_LOGIN.SpeedButton2Click(Sender: TObject); 
begin 
  Application.Terminate; 
end; 
 
 
procedure TFRM_LOGIN.ComboBox1DropDown(Sender: TObject); 
var 
  i:integer; 
begin 
  ComboBox1.Clear; 
  DM.QUSER.Open; 
  if (DM.QUSER.RecordCount>0) then 
    DM.QUSER.First; 
  for i:=0 to DM.QUSER.RecordCount-1 do 
  begin   //得到所有用户名称 
    ComboBox1.Items.Add(DM.QUSER.FieldByName('用户名称').AsString); 
    DM.QUSER.Next; 
  end; 
end; 
procedure TFRM_LOGIN.Edit1KeyPress(Sender: TObject; var Key: Char); 
begin 
   if (key = #13) then //当输入完密码,敲入回车键,Button1执行单击操作 
    SpeedButton1Click(Sender); 
end; 
 
procedure TFRM_LOGIN.Edit1Change(Sender: TObject); 
begin 
  Edit1.Text:=Trim(Edit1.Text); 
end; 
 
procedure TFRM_LOGIN.FormClose(Sender: TObject; var Action: TCloseAction); 
begin 
  DM.QUSER.Close; 
  if m = False then 
    Application.Terminate ; 
end; 
 
procedure TFRM_LOGIN.FormCreate(Sender: TObject); 
begin 
  with DM.QUSER do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('Select * from 用户表'); 
    Open; 
  end; 
end; 
 
end.