⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treadprocess.pas

📁 pasa人力资源考勤管理系统
💻 PAS
字号:
unit Treadprocess;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,ADODB,DB, ComCtrls;

type
  Tprocess = class(TThread)
  private
    { Private declarations }
    Animate1: TAnimate;
    PBar1: TProgressBar;
    Label1: TLabel;
    Label2: TLabel;
  protected
    procedure Execute; override;
    procedure Buttonclick; virtual; abstract;
  public
    constructor Create(Ani1:Tanimate;Lab,Labe:Tlabel;pb:TprogressBar);
  end;

  TKaoqing = class(Tprocess)
  protected
    procedure buttonclick; override;
  end;

implementation

uses datamol,publicfunction;
{ Important: Methods and properties of objects in VCL can only be used in a
  method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure Tprocess.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ Tprocess }

Constructor Tprocess.Create(Ani1:Tanimate;Lab,Labe:Tlabel;pb:TprogressBar);
begin
  Animate1:=Ani1;
  Label1:=lab;
  Label2:=labe;
  pbar1:=pb;
  FreeOnTerminate := True;
  inherited Create(False);
end;

procedure Tprocess.Execute;
begin
  { Place thread code here }
  Synchronize(Buttonclick);
end;

procedure TKaoqing.buttonclick;
var
   Qry:TADOQuery;
   p:string;
   f:Textfile;
begin
   p:=extractfilepath(application.exename)+'\log\Atdprocess.log';
   assignfile(f,p);
   append(f);
   with datamod do
   begin  //datamod
     try
        Animate1.active:=TRUE;
        pbar1.max:=11;
        pbar1.position:=0;
        pbar1.step:=1;
        Qry:=TADOQuery.create(application);
        Qry.Connection:=Query1.Connection;
        label1.caption:='开始初始化考勤处理,读打卡资料和考勤分析';
        label1.update;
        writeln(f,'-------------------------------------------------------');
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'开始初始化考勤处理'));
        Qry.close;
        Qry.sql.text:='Exec kaoqinall';
        Qry.execsql;
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'结束初始化考勤处理'));
        pbar1.stepit;
        label1.caption:='开始读打卡资料';
        label1.update;
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'开始读打卡资料'));
        Qry.close;
        Qry.sql.text:='Exec kaoqinfact';
        Qry.execsql;
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'结束读打卡资料'));
        pbar1.stepit;
        label1.caption:='开始分考勤资料';
        label1.update;
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'开始分考勤资料'));
        Qry.close;
        Qry.sql.text:='exec kaoqin_divide';
        Qry.execsql;
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'结束分考勤资料'));
        pbar1.stepit;
        Qry.close;
//处理考勤
        adoatdset.open;
        adosalset.open;
        writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'开始考勤处理'));
        try
          label1.caption:='考勤处理开始--1';
          label1.update;
          normal('atd25010','atd25011');  //正常班考勤处理
          pbar1.stepit;
          label1.caption:='考勤处理开始--2';
          label1.update;
          normal('atd28010','atd28011');  //轮班考勤处理
          pbar1.stepit;
          label1.caption:='考勤处理开始--3';
          label1.update;
          normal('atd29010','atd29011');  //换班考勤处理
          pbar1.stepit;
          label1.caption:='考勤处理开始--4';
          label1.update;
          temp('atd27010','atd27011');    //计时工考勤处理
          pbar1.stepit;
          label1.caption:='考勤处理开始--5';
          label1.update;
          temp('atd30010','atd30011');    //工读生考勤处理
          pbar1.stepit;
          label1.caption:='考勤处理开始--6';
          label1.update;
          temp('atd31010','atd31011');    //临时班考勤处理
          pbar1.stepit;
          label1.caption:='汇总考勤资料';
          label1.update;
          dayormontotal;          //月考勤汇总及日结薪资和月结薪资
          writeln(f,pchar(formatdatetime('yyyy/mm/dd hh:mm:ss',now)+'结束考勤处理'));
          writeln(f,'-------------------------------------------------------');
          pbar1.stepit;
        except
          Application.messagebox('考勤处理和薪资计算时出错.','Error',mb_ok+mb_iconerror);
          exit;
        end;
        adoclock.close;
        adosalset.close;
        adoatdset.close;
     finally
        Qry.free;
     end;
   end;   //datamod
   Animate1.active:=false;
   label1.caption:='考勤处理完毕';
   label1.update;
   closefile(f);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -