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

📄 unit4.~pas

📁 机房管理系统源代码2006-7-8制作的非常实用
💻 ~PAS
字号:
unit Unit4;

interface

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

type
  Tfrmlogin = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  //************************************
  //处理错误函数,写入project1.err,全局
  //************************************
   procedure werror(ss:string);

var
  frmlogin: Tfrmlogin;

implementation

uses Unit3, Unit1;

{$R *.dfm}

procedure Tfrmlogin.FormCreate(Sender: TObject);
var sys_path:string;
begin
 sys_path:=ExtractFileName(application.ExeName);
 sys_path:=copy(sys_path,1,pos('.',sys_path));
 sys_path:=ExtractFilePath(application.ExeName)+sys_path;
 if not fileexists(sys_path+'mdb') then
 begin
  application.MessageBox(pchar('找不到数据库:'+sys_path+'mdb'),'',64);
  exit;
 end;
 dm1.ADOCon1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='
     +sys_path+'mdb;Persist Security Info=False;';
 try
  dm1.ADOCon1.Connected:=true;
 except
  application.MessageBox(pchar('找不到数据库:'+sys_path+'.mdb'),'',64);
 end;
 BitBtn1.Enabled:=true;
end;

procedure Tfrmlogin.BitBtn1Click(Sender: TObject);
var pas:string;
begin
 if trim(edit1.Text)='' then
 begin
  application.MessageBox('请输入用户名','',64);
  modalresult:=mrnone;
  exit;
 end;

 if uppercase(edit1.Text)='ADMIN' then //管理员
 begin
 dm1.ADOQuery1.Close;
  dm1.ADOQuery1.SQL.Text:='select passwd from admin';
  dm1.ADOQuery1.Open;
  if dm1.ADOQuery1.eof  then
   application.MessageBox('注意,没有设置管理员口令','',64)
  else
  begin
   pas:=trim(dm1.ADOQuery1.FieldByName('passwd').AsString);
   if pas<>trim(edit2.Text) then
   begin
    application.MessageBox('口令错误','',64);
    modalresult:=mrnone;
    exit;
   end;
   if pas='' then
    application.MessageBox('注意,管理员口令为空白','',64);
  end;
 end
 else
 begin  //普通用户
  dm1.ADOQuery1.SQL.Text:='select passwd from users where name='''
   +trim(edit1.Text)+'''';
  dm1.ADOQuery1.Open;
  if dm1.ADOQuery1.eof  then
  begin
   dm1.ADOQuery1.close;
   application.MessageBox('用户不存在','',64);
   modalresult:=mrnone;
   exit;
  end
  else
  begin
   pas:=trim(dm1.ADOQuery1.FieldByName('passwd').AsString);
   dm1.ADOQuery1.close;
   if pas<>trim(edit2.Text) then
   begin
    application.MessageBox('口令错误','',64);
    modalresult:=mrnone;
    exit;
   end;
  end;
 end;
 users:=trim(edit1.Text);
end;

procedure werror(ss:string);
var  e_file:textfile;
     s:string;
begin
  s:=ExtractFileName(APPLICATION.exeName);
  if pos('.',s)<>-1 then
   s:=copy(s,1,pos('.',s)-1);
  ss:=datetostr(date)+' '+timetostr(time)+' '+ss;
  AssignFile(e_file,ExtractFilePath(Application.ExeName)+s+'.err');
   {$I-}
  append(e_file);
   {$I+}
  if IOResult <> 0 then
    rewrite(e_file);
  writeln(e_file,ss);
  CloseFile(e_file);
end;


end.

⌨️ 快捷键说明

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