📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMenu, DB, ADODB, StdCtrls, Buttons,implemntation;
type
TForm2 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
XPMenu1: TXPMenu;
Label3: TLabel;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormActivate(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit5,unit6, Unit4;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
u,p:string;
begin
u:=edit1.Text ;
p:=edit2.Text ;
Adoquery1.Close ;
ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select user,pass,Allow from users where user='+''''+u+''''+'and pass='+''''+p+''''+'and Allow=true');
ADOQuery1.Open ;
if ADOQuery1.RecordCount=0 then
begin
Application.MessageBox('密码错误,请重新输入','提示',mb_ok);
edit1.SetFocus;
end else
begin
login_user:='LoginOk';
login_user_name:=u;
self.close;
//Application.MessageBox('登录成功,欢迎使用本系统!','登录提示',mb_ok);
form5.Update;
// form4:=tform4.Create(application); //登录成功后显示数据查看编辑子窗口
//以下为记录当前登录用户的权限
Adoquery1.Close; ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select user,power from users where user='+''''+u+''''+'and power='+''''+'admin'+'''');
ADOQuery1.Open ; if ADOQuery1.RecordCount=1 then login_user:='admin';
Adoquery1.Close; ADOQuery1.SQL.Clear ;
ADOQuery1.SQL.Add('select user,power from users where user='+''''+u+''''+'and power='+''''+'read'+'''');
ADOQuery1.Open ; if ADOQuery1.RecordCount=1 then login_user:='read';
end;
edit1.Text:='';
edit2.Text:='';
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
self.Close;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
Product_Dir+data_path+';Persist Security Info=False';
try
ADOConnection1.Open;
except
application.MessageBox('找不到数据库,引起该问题的原因是数据库可能被删除或改名.','无法打开数据库',0);
application.Terminate;
end;
end;
procedure TForm2.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_ESCAPE then application.Terminate;
end;
procedure TForm2.FormActivate(Sender: TObject);
begin
edit1.SetFocus;
end;
procedure TForm2.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
state:='管理登录';
end;
procedure TForm2.FormPaint(Sender: TObject);
begin
try
if FileExists(Bakup_Dir+'data.000') then
//检查设置是否每天自动备份和当前日期和备份日期是否相同
begin if (start_bakup and (DateToStr(FileDateToDateTime(FileAge(Product_Dir+Bakup_Dir+'data.000')))<>DateToStr(Date))) then
begin
deletefile(Product_Dir+Bakup_Dir+'data.000');
if not (copyfile(pchar(Product_Dir+data_path),pchar(Product_Dir+Bakup_Dir+'data.000'),true)) then showmessage('数据库备份出错!请检查数据文件或磁盘。');
end;
end
else if not (copyfile(pchar(Product_Dir+data_path),pchar(Product_Dir+Bakup_Dir+'data.000'),true)) then showmessage('数据库备份出错!请检查数据文件或磁盘。');
except;
end;
if login_user='do_not_login' then begin close; end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -