atdprocess.pas
来自「pasa人力资源考勤管理系统」· PAS 代码 · 共 1,026 行 · 第 1/5 页
PAS
1,026 行
unit atdprocess;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, Db, ADODB;
type
TFormatdprocess = class(TForm)
Label1: TLabel;
Animate1: TAnimate;
PBar1: TProgressBar;
Timer1: TTimer;
Qry1: TADOQuery;
Qry1workno: TStringField;
Qry1cardno: TStringField;
Qry1rq: TStringField;
Qry1scheno: TStringField;
Qry1dothing: TStringField;
Qry1itemtime: TIntegerField;
Qry1mustgo: TStringField;
Qry1factgo: TStringField;
Qry1mustout: TStringField;
Qry1factout: TStringField;
Qry1musthours: TBCDField;
Qry1tempvalue: TBCDField;
Qry1addtime: TBooleanField;
Qry1continuetime: TBooleanField;
Qry1decrease: TBCDField;
Qry1ot: TBooleanField;
Qry1users: TStringField;
Qry1process: TBooleanField;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure readcard(tablename,users:string); //读卡
procedure daytotal(source,dest,ottable,sourcechange,destchange,otchange:string);//日汇表
end;
var
Formatdprocess: TFormatdprocess;
da:string;
days:real;
implementation
uses publicfunction,datamol,main, atddata;
{$R *.DFM}
procedure TFormatdprocess.FormCreate(Sender: TObject);
begin
datamod.adoatdset.open;
end;
procedure TFormatdprocess.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
formatdprocess:=nil;
action:=cafree;
end;
procedure TFormatdprocess.Button1Click(Sender: TObject);
begin
if Application.messagebox('你确定要进行读卡和考勤计算吗?这可能会需要很久的时间!','请问',mb_okcancel+mb_iconquestion)=idok then
timer1.enabled:=true;
end;
procedure TFormatdprocess.Timer1Timer(Sender: TObject);
begin
timer1.Enabled:=false;
button1.Visible:=false;
animate1.active:=true;
Label1.Caption:='正在准备数据...';
Label1.Update;
//正常班
readcard('atd25010','正常');
daytotal('atd25010','atd25012','atd25013','atd25011','atd250121','atd250131');
//计时
readcard('atd27010','计时');
daytotal('atd27010','atd27012','atd27013','atd27011','atd270121','atd270131');
//轮班
readcard('atd28010','轮班');
daytotal('atd28010','atd28012','atd28013','atd28011','atd280121','atd280131');
if not assigned(formatddata) then
formatddata:=TFormatddata.create(application);
formatddata.show;
Close;
end;
procedure TFormatdprocess.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
datamod.adoatdset.Close;
end;
//读卡
procedure TFormatdprocess.readcard(tablename,users:string);
var
rq,lastrq,cardno:string;
i,item:integer;
logfile:TextFile;
log,state:string;
go1,out1,recdatetime:string;
g,o,readok:Boolean;
sql:String;
error:boolean;
begin
lastrq:='';
with datamod do
begin //with
adoclock.close;
adoclock.CommandText:='Select * from atd09010 where atd=1 and yndefault=1 ';
adoclock.open;
//读刷卡档
adooriginal.Close;
adooriginal.commandText:='Select * from atd15010 where readok=0 order by recdate,cardno';
adooriginal.Open;
adooriginal.First;
Adomanchange.Open;
While not adooriginal.eof do
begin //while
rq:=adooriginalrecdate.asstring;
cardno:=adooriginalcardno.asstring;
state:=adooriginalstate.asstring;
readok:=false;
recdatetime:=adooriginalrecdatetime.value;
g:=false;
o:=false;
sql:='';
Query1.Close; //查找人事异动档中有无异动资料
Query1.SQL.Text:='Select * from per24013 where cardno='''+cardno+''' and '''+rq+''' between usefuldate and unusedate ';
Query1.Open;
//初始化应出勤时段
for i:=1 to 5 do
begin
Query2.Close;
Query2.SQL.Clear;
Query2.Sql.add('Select * from '+tablename+' where cardno='''+cardno+''' and rq='''+rq+''' and itemtime='''+inttostr(i)+''' ');
Query2.Open;
if query2.eof then
begin //if
Adoquery1.close;
adoquery1.sql.clear;
if Query1.eof then //若没有异动抓取主档中的资料
Adoquery1.sql.add('Insert into '+tablename+' (workno,cardno,rq,scheno,dothing,itemtime,mustgo,mustout,musthours,addtime,continuetime,decrease,ot,users,process) '+
' select distinct c.workno,c.cardno,'''+rq+''',c.scheno,c.dothing,'+inttostr(i)+',d.gotime'+inttostr(i)+',d.outtime'+inttostr(i)+',d.daytime'+inttostr(i)+','+
' d.add'+inttostr(i)+',d.continue'+inttostr(i)+',d.decrease'+inttostr(i)+',d.ot'+inttostr(i)+',d.users,0 from per24010 as c,atd01010 as d,pub06010 as e '+
' where c.cardno='''+cardno+''' and c.scheno=d.scheno and ((d.gotime'+inttostr(i)+' is not null) or (d.outtime'+inttostr(i)+' is not null)) and '+
' e.comdate<>'''+rq+''' and c.dothing=e.comcode and d.users='''+users+''' ')
else
Adoquery1.sql.add('Insert into '+tablename+' (workno,cardno,rq,scheno,dothing,itemtime,mustgo,mustout,musthours,addtime,continuetime,decrease,ot,users,process) '+
' Select distinct c.workno,c.cardno,'''+rq+''',c.shceno,c.dothing,'+inttostr(i)+',d.gotime'+inttostr(i)+',d.outtime'+inttostr(i)+',d.daytime'+inttostr(i)+','+
' d.add'+inttostr(i)+',d.continue'+inttostr(i)+',d.decrease'+inttostr(i)+',d.ot'+inttostr(i)+',d.users,0 from per24013 c,atd01010 d,pub06010 e '+
' where c.cardno='''+cardno+''' and c.scheno=d.scheno and ((d.gotime'+inttostr(i)+' is not null) or (d.outtime'+inttostr(i)+' is not null)) and '+
' e.comdate<>'''+rq+''' and c.dothing=e.comcode and d.users='''+users+''' ');
Adoquery1.execsql;
end; //if
end; //for
Label1.Caption:='正在抓取班别异动档和换班中的资料.....';
Label1.Update;
//抓取班别异动档中的资料
try
Query2.Close;
Query2.SQL.Clear;
query2.SQL.Add('Update '+tablename+' set mustgo=b.gotime,mustout=b.outtime,musthours=b.daytime,addtime=b.ot,'+
' continuetime=b.continuetime,decrease=b.decrease,ot=b.otherot,users=b.users'+
' from '+tablename+' as a, atd01011 as b where b.scheno=a.scheno and (a.rq between b.startrq and b.endrq)'+
' and a.rq='''+rq+''' and a.itemtime=b.times');
for i:=1 to 5 do
begin //for
//抓取换班资料档中的资料
query2.SQL.Add('Update '+tablename+' set scheno=b.nowsche from '+tablename+' as a, atd08010 as b where a.scheno=b.latesche and '+
' a.workno=b.workno and a.workno='+cardno+' and (a.rq between b.startrq and b.endrq) and a.rq='''+rq+''' and a.itemtime='+inttostr(i)+' ');
query2.SQL.Add('Update '+tablename+' set mustgo=b.gotime'+inttostr(i)+',mustout=b.outtime'+inttostr(i)+',musthours=b.daytime'+inttostr(i)+',addtime=b.add'+inttostr(i)+','+
' continuetime=b.continue'+inttostr(i)+',decrease=b.decrease'+inttostr(i)+',ot=b.ot'+inttostr(i)+',users=''换班'' from '+tablename+' as a,atd01010 as b'+
' where a.scheno=b.scheno and a.workno='''+cardno+''' and a.rq='''+rq+''' and a.itemtime='+inttostr(i)+' ');
end; //for
query2.ExecSQL;
except
end;
label1.Caption:='从加班单中抓取资料......';
label1.update;
try
query2.Close;
query2.SQL.Clear;
query2.SQL.Add('Update '+tablename+' set mustgo=b.gotime,mustout=b.outtime,addtime=1,decrease=0,musthours=b.hours,otkind=b.otkind '+
' from '+tablename+' as a,atd11010 as b where (a.rq between b.startrq and b.endrq) and a.rq='''+rq+''' and '+
' a.itemtime=b.items and a.workno=b.workno and a.cardno='''+cardno+''' ');
query2.ExecSQL;
except
end;
label1.Caption:='从连班单中抓取资料......';
label1.update;
Query2.Close;
Query2.sql.clear;
Query2.SQL.Add('Update '+tablename+' set factout=left(b.endrq,4)+'''+dateseparator+'''+substring(b.endrq,5,2)+'''+dateseparator+'''+right(b.endrq,2)+'' ''+'+
' left(b.outtime,2)+'''+timeseparator+'''+right(b.outtime,2),continuetime=1 from '+tablename+' as a,atd11010 as b '+
' where b.items=a.itemtime and b.workno=a.workno and (a.rq between b.startrq and b.endrq) and a.rq='''+rq+''' ');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?