frmpassword.pas
来自「pasa人力资源考勤管理系统」· PAS 代码 · 共 303 行
PAS
303 行
unit frmpassword;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, Db, ADODB, DBTables,inifiles, jpeg, ComCtrls,
Gauges, Animate, GIFCtrl;
type
Tformpassword = class(TForm)
Edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
combobox1: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
ADOConnection1: TADOConnection;
Button1: TButton;
ADOQuery1: TADOQuery;
ADOConnection2: TADOConnection;
Panel1: TPanel;
ADODataSet1: TADODataSet;
Gauge1: TGauge;
RxGIFAnimator1: TRxGIFAnimator;
qryUser: TADOQuery;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure combobox1KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
Function readother:string ;
private
{ Private declarations }
mpb_cn:boolean;
public
{ Public declarations }
end;
var
formpassword: Tformpassword;
init:boolean;
implementation
uses main, datamol, publicfunction;
{$R *.DFM}
Function Tformpassword.readother:string ;
var login:textfile;
myfile1,fline1:string ;
begin
myfile1:=extractfilepath(application.ExeName)+'data\loginother.ini';
if fileexists(myfile1) then
begin
assignfile(login,myfile1);
reset(login);
readln(login,fline1);
closefile(login) ;
readother:=fline1 ;
end
else
showmessage('指示的数据库连接文件不存在') ;
end ;
procedure Tformpassword.BitBtn1Click(Sender: TObject);
var ary:Tadoquery;
p:string;
f:textfile;
begin
///超级用户
if (combobox1.text='pasa') and (edit1.text='pasa') then
begin
pubworkname:='pasa';
pubworkno:='pasa';
close;
exit;
end else
begin
ary:=tadoquery.Create(application);
ary.Connection :=adoconnection1;
ary.SQL.text:='select * from sys03011 where no='''+combobox1.text+''' and isnull(password,'''')='''+addpassword(edit1.text)+''' ';
ary.Open;
if ary.Eof then
begin
Application.Messagebox('密码错误,请重新输入','Error',mb_ok+mb_iconerror);
combobox1.SetFocus;
end
else begin
pubworkname:=ary.fieldbyname('name').AsString;
pubworkno:=ary.fieldbyname('no').AsString;
p:=extractfilepath(application.exename)+'\Log\login.log';
assignfile(f,p);
append(f);
writeln(f,'登入系统时间:'+formatdatetime('yyyy/mm/dd hh:mm:ss',now)+',使用者:'+pubworkname);
closefile(f);
close;
end;
ary.Close;
ary.SQL.Clear;
ary.SQL.Text:='exec Upper24010sp '''+pubworkname+'''';
ary.ExecSQL;
ary.free;
end;
end;
procedure Tformpassword.BitBtn2Click(Sender: TObject);
begin
application.Terminate;
close;
end;
procedure Tformpassword.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
perform(cm_dialogkey,vk_tab,0);
key:=#0;
end;
end;
procedure Tformpassword.FormCreate(Sender: TObject);
var f:textfile;
myfile,fline:string ;
AdoConnect:string ;
Adoquery1 :Tadoquery ;
begin
try
adoconnection1.Connected :=false;
adoconnection1.LoginPrompt :=false;
Adoconnect :='' ;
myfile:=extractfilepath(application.ExeName)+'data\login.ini';
if fileexists(myfile) then
begin
assignfile(f,myfile);
reset(f);
readln(f,fline);
AdoConnect:=AdoConnect+'User ID='+copy(fline,pos('=',fline)+1,20)+';' ; // database user
readln(f,fline);
AdoConnect:=AdoConnect+'Initial Catalog='+copy(fline,pos('=',fline)+1,20)+';' ; // database name
database :=copy(fline,pos('=',fline)+1,20) ;
readln(f,fline);
AdoConnect:=AdoConnect+'Data Source='+copy(fline,pos('=',fline)+1,20)+';' ; // sql server name
server :=copy(fline,pos('=',fline)+1,20) ;
readln(f,fline);
if pos('word',fline)>0 then
if length(trim(copy(fline,pos('=',fline)+1,20)))>0 then
AdoConnect:=AdoConnect+'password='+copy(fline,pos('=',fline)+1,20)+';Persist Security Info=True;' //蚚討躇钨 password of database user
else
AdoConnect:=AdoConnect+'Persist Security Info=false;';
readln(f,fline) ;//查看数据库连接方式2.其它,1.ODBC,0.ADO
if pos('type',fline)>0 then
begin
if copy(fline,pos('=',fline)+1,20)='3' then //OTHER
adoconnection1.ConnectionString:= readother //读取其它数据连接文件
else if copy(fline,pos('=',fline)+1,20)='2' then //ODBC
ADoconnection1.ConnectionString := 'Provider=MSDASQL;Persist Security Info=False;'+Adoconnect +'Auto Translate=True'
else if copy(fline,pos('=',fline)+1,20)='1' then //SQL
begin
readln(f,fline) ;
if copy(fline,pos('=',fline)+1,20)='false' then
Adoconnect:='Provider=SQLOLEDB.1;'+Adoconnect
else
AdoConnect:='Provider=SQLOLEDB.1;Integrated Security=SSPI;'+Adoconnect;
adoconnection1.ConnectionString:=AdoConnect+'Auto Translate=True';
end
else if copy(fline,pos('=',fline)+1,20)='0' then //WINDOWS
ADoconnection1.ConnectionString :='Integrated Security=SSPI;Provider=SQLOLEDB.1;'+Adoconnect+'Auto Translate=True' ;
end;
closefile(f);
datamod.Database1.Connected :=false;
datamod.Database1.ConnectionString := Adoconnection1.ConnectionString ;
datamod.Database1.Connected :=true;
adoconnection1.Connected :=true;
adoquery1 :=Tadoquery.Create(self) ;
adoquery1.Connection :=adoconnection1 ;
adoquery1.sql.text:='Select * from sys04010';
adoquery1.open;
if adoquery1.eof then
begin
button1.visible:=true;
init:=true;
end else init:=false;
adoquery1.Close ;
adoquery1.Free ;
end
else
begin
Application.Messagebox('无法连接数据库,指示数据库的文件不存在','Warning',mb_ok+mb_iconwarning);
BitBtn2.onclick(sender);
end;
except
Application.Messagebox('连接数据库时出现错误,请检查网络和设定','Error',mb_ok+mb_iconerror);
BitBtn2.OnClick(sender);
end;
//--- 往用户框中添加用户
combobox1.clear;
with qryUser do
begin
close;
open;
while not eof do
begin
combobox1.Items.Add(fieldbyname('no').asstring) ;
next;
end;
first;
end;
end;
procedure Tformpassword.combobox1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#27 then
application.Terminate;
end;
procedure Tformpassword.Button1Click(Sender: TObject);
Var Adodataset1 :Tadodataset ;
Adoquery1 :Tadoquery ;
Adoconnection2 :Tadoconnection ;
begin
Adoconnection2 :=Tadoconnection.Create (self) ;
Adodataset1 :=Tadodataset.Create (self) ;
Adoquery1 :=TAdoquery.Create (self) ;
Adodataset1.Connection :=Adoconnection1 ;
Adoquery1.Connection :=Adoconnection1 ;
panel1.visible:=true;
panel1.update;
Gauge1.visible:=true;
try
adoconnection2.connected:=false;
adoconnection2.connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+extractfilepath(Application.exename)+'\Data\Initialize.mdb'+';Persist Security Info=False';
adoconnection2.loginprompt:=false;
adoconnection2.connected:=true;
adodataset1.close;
adodataset1.Connection :=adoconnection2 ;
adodataset1.CommandText:='Select * from sys04010gb';
adodataset1.open;
Gauge1.Progress:=1;
Gauge1.MaxValue:=adodataset1.RecordCount;
while not adodataset1.eof do
begin
adoquery1.close;
adoquery1.sql.text:='Insert into sys04010 select '''+adodataset1.fieldbyname('tablename').asstring+''','''+adodataset1.fieldbyname('tablechinese').asstring+''','+
''''+adodataset1.fieldbyname('adoname').asstring+''' ';
adoquery1.execsql;
adodataset1.next;
Gauge1.AddProgress(1);
end;
adodataset1.close;
adodataset1.CommandText:='Select * from salfieldgb';
adodataset1.open;
Gauge1.Progress:=1;
Gauge1.MaxValue:=adodataset1.RecordCount;
while not adodataset1.eof do
begin
adoquery1.close;
adoquery1.sql.text:='Insert into syssalfields(name,chinename,sys,flat) values( '''+adodataset1.fieldbyname('name').asstring+''','''+adodataset1.fieldbyname('chinename').asstring+''','''+adodataset1.fieldbyname('sysback').asstring+''','''+adodataset1.fieldbyname('flatback').asstring+''' )';
adoquery1.execsql;
adodataset1.next;
Gauge1.AddProgress(1);
end;
adodataset1.close;
adodataset1.CommandText:='Select * from per03010gb';
adodataset1.open;
Gauge1.Progress:=1;
Gauge1.MaxValue:=adodataset1.RecordCount;
while not adodataset1.eof do
begin
adoquery1.close;
adoquery1.sql.text:='Insert into per03010 values( '''+adodataset1.fieldbyname('provno').asstring+''','''+adodataset1.fieldbyname('parent').asstring+''','''+adodataset1.fieldbyname('provname').asstring+''' )';
adoquery1.execsql;
adodataset1.next;
Gauge1.AddProgress(1);
end;
adoquery1.close;
adoquery1.SQL.text:='Insert into atdauto values(0,'''','''','''',0,'''','''','''')';
adoquery1.execsql ;
adodataset1.close ;
adodataset1.Free ;
adoquery1.close ;
Adoquery1.Free ;
Application.messagebox('初始化系统资料成功。','开帐成功',mb_ok+mb_iconinformation);
except
Application.messagebox('初始化系统资料出错。','开帐失败',mb_ok+mb_iconerror);
init:=false;
end;
Adoconnection2.Free ;
panel1.visible:=false;
Gauge1.visible:=false;
if init then button1.visible:=false;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?