You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
5.9 KiB
Plaintext

unit lcxQxsz;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinData, BusinessSkinForm, bsSkinCtrls, DB, ADODB,inifiles;
type
TfrmLcxQxsz = class(TForm)
db_load: TADOConnection;
btnqxrestore: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
btnqxBack: TbsSkinButton;
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsStoredSkin1: TbsStoredSkin;
bsSkinData1: TbsSkinData;
bsSkinGroupBox1: TbsSkinGroupBox;
chkseae: TbsSkinCheckRadioBox;
chkseaei: TbsSkinCheckRadioBox;
chkair: TbsSkinCheckRadioBox;
chkairi: TbsSkinCheckRadioBox;
qrytmp: TADOQuery;
qryUpdate: TADOQuery;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
procedure FormShow(Sender: TObject);
procedure db_loadBeforeConnect(Sender: TObject);
procedure bsSkinButton4Click(Sender: TObject);
procedure btnqxBackClick(Sender: TObject);
procedure btnqxrestoreClick(Sender: TObject);
private
function connect_string(file_name:string):string;
{ Private declarations }
public
{ Public declarations }
end;
var
frmLcxQxsz: TfrmLcxQxsz;
implementation
uses u_sys_login;
{$R *.dfm}
procedure TfrmLcxQxsz.FormShow(Sender: TObject);
begin
db_load.Connected:=true ;
frm_sys_login:=Tfrm_sys_login.create(self);
if frm_sys_login.showmodal=mrok then
begin
with qrytmp,sql do //¼ì²éÉϴλ¹Ô­Çé¿ö
begin
close ;clear ;
add('select count(*)as cnt from t_sys_code_emp_back ');
open ;
btnqxrestore.Enabled:= fieldbyname('cnt').AsInteger>0 ;
btnqxBack.Enabled:= not btnqxrestore.Enabled ;
end;
end ;
frm_sys_login.free ;
end;
procedure TfrmLcxQxsz.db_loadBeforeConnect(Sender: TObject);
begin
db_load.ConnectionString:=connect_string('main.ini');
end;
function TfrmLcxQxsz.connect_string(file_name:string):string;
var
str:string;
inifile1:Tinifile;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+file_name);
str:='';
str:='Provider='+inifile1.ReadString('database','Provider','');
str:=str+'Password='+inifile1.ReadString('database','Password','');
str:=str+'Persist Security Info='+inifile1.ReadString('database','Persist Security Info','');
str:=str+'User ID='+inifile1.ReadString('database','User ID','');
str:=str+'Initial Catalog='+inifile1.ReadString('database','Initial Catalog','');
str:=str+'Data Source='+inifile1.ReadString('database','Data Source','');
result:=str;
inifile1.Free;
end;
procedure TfrmLcxQxsz.bsSkinButton4Click(Sender: TObject);
begin
close ;
end;
procedure TfrmLcxQxsz.btnqxBackClick(Sender: TObject);
var str :string ;
begin
with qrytmp,sql do //¼ì²éÉϴλ¹Ô­Çé¿ö
begin
close ;clear ;
add('select count(*)as cnt from t_sys_code_emp_back ');
open ;
if fieldbyname('cnt').AsInteger>0 then
begin
if Application.MessageBox('ÉÏ´ÎÈ¡ÏûȨÏÞδ»¹Ô­£¬ÊÇ·ñ¸²¸Ç£¿', 'Ìáʾ',
MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON2) <> IDYES then
Abort;
end ;
end ;
with qrytmp,sql do // ɾ³ý±¸·ÝȨÏÞ
begin
close ;clear ;
add('delete from t_sys_code_emp_back ');
execsql ;
end ;
with qrytmp,sql do ///±¸·ÝȨÏÞ
begin
close ; clear ;
add('insert into t_sys_code_emp_back(ȨÏÞ´úÂë, Ò»¼¶Ä£¿é, ¶þ¼¶Ä£¿é,ȨÏÞÃû³Æ,ÈËÔ±,ÊÇ·ñ¿É²Ù×÷,ÊÚȨÈË, ÊÚȨÈÕÆÚ,È¡ÏûÈÕÆÚ) ');
add('select ȨÏÞ´úÂë, Ò»¼¶Ä£¿é, ¶þ¼¶Ä£¿é,ȨÏÞÃû³Æ,ÈËÔ±,ÊÇ·ñ¿É²Ù×÷,ÊÚȨÈË, ÊÚȨÈÕÆÚ,'''+datetostr(date)+'''');
add('from t_sys_code_emp where (1=1)');
if chkseae.Checked then str:='(ȨÏÞ´úÂë='''+'023'''+')or(ȨÏÞ´úÂë='''+'022'''+')' ;
if chkseaei.Checked then
begin
if str<>'' then str:=str+ 'or (ȨÏÞ´úÂë='''+'055'''+')'+'or(ȨÏÞ´úÂë='''+'056'''+')'
else str:='(ȨÏÞ´úÂë='''+'022'''+')'+'or(ȨÏÞ´úÂë='''+'056'''+')' ;
end ;
if chkair.Checked then
begin
if str<>'' then str:=str+ 'or (ȨÏÞ´úÂë='''+'073'''+')'+'or(ȨÏÞ´úÂë='''+'074'''+')'
else str:='(ȨÏÞ´úÂë='''+'073'''+')'+'or(ȨÏÞ´úÂë='''+'074'''+')' ;
end ;
if chkairi.Checked then
begin
if str<>'' then str:=str+ 'or (ȨÏÞ´úÂë='''+'081'''+')'+'or(ȨÏÞ´úÂë='''+'082'''+')'
else str:='(ȨÏÞ´úÂë='''+'081'''+')'+'or(ȨÏÞ´úÂë='''+'082'''+')' ;
end ;
if str='' then exit else add('and ('+str+')');
execsql ;
end ;
with qrytmp,sql do // ȨÏÞ¿âÇåÁã
begin
close ;clear ;
add('update t_sys_code_emp set ÊÇ·ñ¿É²Ù×÷=0 where (1=1) ');
if str='' then exit else add('and ('+str+')');
execsql ;
end ;
with qrytmp,sql do
begin
close ; clear ;
add('update t_sys_parameters_value set ²ÎÊýÖµ='+''''+'TRUE'+'''');
add(' where VL_ID=109 ');
execsql ;
end ;
showmessage('³É¹¦È¡ÏûȨÏÞ£¡');
btnqxrestore.Enabled:= true ;
btnqxBack.Enabled:= not btnqxrestore.Enabled ;
end;
procedure TfrmLcxQxsz.btnqxrestoreClick(Sender: TObject);
begin
with qrytmp,sql do //¼ì²é»¹Ô­±¸·Ý
begin
close ;clear ;
add('select count(*)as cnt from t_sys_code_emp_back ');
open ;
if fieldbyname('cnt').AsInteger<=0 then
begin
showmessage('ûÓÐÕÒµ½±¸·ÝȨÏÞ£¬²»ÄÜ»¹Ô­£¡');
exit;
end ;
end ;
with qrytmp,sql do //ÐÞ¸ÄȨÏÞ±í
begin
close ;clear ;
add('select * from t_sys_code_emp_back');
open ; first ;
while not eof do
begin
qryUpdate.Close ;
qryUpdate.Parameters.ParamByName('mypermiss').Value:=fieldbyname('ÊÇ·ñ¿É²Ù×÷').Value ;
qryUpdate.Parameters.ParamByName('myqxdm').Value:=fieldbyname('ȨÏÞ´úÂë').Value ;
qryUpdate.Parameters.ParamByName('myuser').Value:=fieldbyname('ÈËÔ±').Value ;
qryUpdate.ExecSQL ;
next ;
end ;
end ;
// ɾ³ý±¸·ÝȨÏÞ¿â
with qrytmp,sql do // ɾ³ý±¸·ÝȨÏÞ
begin
close ;clear ;
add('delete from t_sys_code_emp_back ');
execsql ;
end ;
with qrytmp,sql do
begin
close ; clear ;
add('update t_sys_parameters_value set ²ÎÊýÖµ='+''''+'FALSE'+'''');
add(' where VL_ID=109 ');
execsql ;
end ;
showmessage('»¹Ô­³É¹¦£¡');
btnqxBack.Enabled:= true ;
btnqxrestore.Enabled:= not btnqxrestore.Enabled ;
end;
end.