📄 login.pas
字号:
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls, DB, ADODB,MD5,inifiles, SkinCtrls,
XPMenu;
type
TForm3 = class(TForm)
Image1: TImage;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
XPMenu1: TXPMenu;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses main,splash,datalink;
{$R *.dfm}
procedure TForm3.FormCreate(Sender: TObject);
var
vinifile:tinifile;
data,inifiles:string;
begin
form2.Hide;
form2.Release ;
self.Width :=image1.Width ;
self.Height :=image1.Height ;
vinifile:=tinifile.Create(extractfilepath(paramstr(0))+'config.ini');
inifiles:=extractfilepath(paramstr(0))+'config.ini';
if not fileExists(inifiles) then
begin
showmessage('对不起,数据库配置文件没有找到,系统将自动创建一个新的配置文件!');
self.Close;
end;
data:='Provider='+vIniFile.Readstring('System','Provider','')+';';
Data:=Data+'Data Source='+vIniFile.Readstring('System','Data Source','')+';';
Data:=Data+'Persist Security Info=False';
ADOConnection1.ConnectionString:=Data;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select * from sup_admin');
Try
ADOQuery1.Active:=True;
Except
self.Hide;
showmessage('对不起,系统数据库源没有找到,请你重新定位系统数据库!');
form30:=tform30.Create(application);
form30.ShowModal;
end;
end;
procedure TForm3.Button2Click(Sender: TObject);
begin
if application.MessageBox('你真的要退出该系统吗?','系统提示框',mb_yesno+mb_defbutton2+mb_iconstop+mb_applmodal)<>idno then
application.Terminate ;
end;
procedure TForm3.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
edit2.SetFocus ;
edit2.Text:='';
end;
end;
procedure TForm3.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
key:=#0;
button1.Click;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
ADOQuery1.SQL.Clear ;
adoquery1.SQL.Add('select * from sup_admin where sup_name="'+edit1.Text+'"');
adoquery1.Open;
if adoquery1.RecordCount <>0 then
Edit1.Text:=ADOQuery1.FieldByName('sup_name').AsString;
if (adoquery1.FieldByName('sup_pass').AsString=edit2.Text) and (adoquery1.RecordCount <>0) then
begin
self.Hide;
form1:=tform1.Create(application);
form1.Show;
form1.StatusBar1.Panels[3].Text:='操作员:'+edit1.Text;
end
else
begin
//application.MessageBox('password was wrong!','worngdd','MR_OK');
showmessage('对不起,你输入的用户名或密码不正确,请你重新输入!');
Edit2.Text:='';
edit2.SetFocus ;
end;
end;
procedure TForm3.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
vinifile:tinifile;
inifiles:string;
begin
inifiles:=extractfilepath(paramstr(0))+'config.ini';
if not fileExists(inifiles) then
begin
vinifile:=tinifile.Create(extractfilepath(paramstr(0))+'config.ini');
vinifile.WriteString('System','Provider','Microsoft.Jet.OLEDB.4.0');
vinifile.WriteString('System','Data Source','.\data\laborage.mdb');
vinifile.WriteString('System','工作室','郑州经济管理干部学院2#301');
vinifile.WriteString('System','主编:','孙守强');
vinifile.WriteString('System','电话:','0371-62508961')
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -