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

📄 salcal.pas

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

unit salcal;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, StdCtrls, ExtCtrls, RxLookup, ADODB, Db, DBTables, PicClip,
  Mask, Buttons;

type
  TFormsalcal = class(TForm)
    Animate1: TAnimate;
    PBar1: TProgressBar;
    Qry: TADOQuery;
    ADOCommand1: TADOCommand;
    SpeedButton1: TSpeedButton;
    Label5: TLabel;
    Label6: TLabel;
    radiobutton2: TRadioButton;
    radiobutton1: TRadioButton;
    Label2: TLabel;
    Label7: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    cbrq: TComboBox;
    cbday1: TComboBox;
    cbrq2: TComboBox;
    cbday2: TComboBox;
    OK: TButton;
    Cancel: TButton;
    Label1: TLabel;
    Edit2: TMaskEdit;
    Label4: TLabel;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure CancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure OKClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure formkeyup(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure cbrqExit(Sender: TObject);
    procedure cbrq2Exit(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure radiobutton1Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Formsalcal: TFormsalcal;
  condi:string;
  saltry:boolean;
  f100,f50,f20,f10,f5,f2,f1:integer;
  allman:string;

implementation

uses datamol,main,publicfunction, saldata, multi;
{$R *.DFM}

procedure TFormsalcal.FormShow(Sender: TObject);
var
    month,year,item:string;
    day,i:integer;
    s,s1,s2:string;
begin
    month:=formatdatetime('mm',now);
    year:=formatdatetime('yyyy',now);
    if (Cbrq.Items.Count < 1) then
    begin
      cbrq.Items.clear;
      cbrq2.Items.Clear;
      S := Formatdatetime('yyyy/mm', Date);
      Cbrq.Text := S;
      cbrq2.text := s;
      S1 := Copy(S, 1, 5);
      S2 := Copy(S, 6, 2);
      if StrtoINT(S2) > 1 then
      begin
        for i := 0 to Strtoint(S2) - 1 do
        begin
          if Length(S2) < 2 then
            S2 := '0' + S2;
          S := S1 + S2;
          Cbrq.Items.Add(S);
          cbrq2.items.add(s);
          S2 := inttoStr(Strtoint(S2) - 1);
        end;
      end else
      begin
        Cbrq.Items.Add(S);
        Cbrq2.Items.Add(s);
      end;
    end;
    day:=getdays(month,year);
    cbday1.items.clear;
    cbday2.items.clear;
    for i:=1 to day do
    begin
        item:=inttostr(i);
        if length(item)=1 then
          item:='0'+item;
        cbday1.items.add(item);
        cbday2.items.add(item);
    end;
    cbday1.text:='01';
    cbday2.text:=inttostr(day);
end;

procedure TFormsalcal.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     formsalcal:=nil;
     action:=cafree;
end;

procedure TFormsalcal.CancelClick(Sender: TObject);
begin
    close;
end;

procedure TFormsalcal.FormCreate(Sender: TObject);
begin
   saltry:=false;;
end;

procedure TFormsalcal.OKClick(Sender: TObject);
var
    beginrq,endrq:string;
    monthy,p:string;
    f:textfile;
    dyh,taxstr:string;
begin
 with datamod do
 begin
    if trim(edit2.text)=fmat then
    begin
       application.messagebox('必须输入一个月份.','月份不能为空',mb_ok+mb_iconerror);
       edit2.setfocus;
       exit;
    end;
    adoquery1.close;
    adoquery1.sql.text:='Select * from atd34010 where substring(monthy,1,4)+'''+fmat+'''+substring(monthy,6,2)='''+edit2.text+''' ';  //月出勤汇总表
   // adoquery1.sql.savetofile('e:\sal.sql');
    adoquery1.open; //薪资参数设定
    if adoquery1.eof then
    begin
       application.messagebox(pchar('对不起,尚无 '+edit2.text+' 月的考勤资料,所以不允许计算工资'),'无考勤资料',mb_ok+mb_iconinformation);
       exit;
    end;
    adoquery1.close;
    if radiobutton1.Checked then allman:='1'
    else if radiobutton2.checked then allman:='0';
    animate1.Active:=true;
    try
      adosalset.open;
      beginrq:=cbrq.text+fmat+cbday1.text;
      endrq:=cbrq.text+fmat+cbday2.text;
      monthy:=edit2.text;
      p:=extractfilepath(application.exename)+'log\salcal.log';
      assignfile(f,p);
      append(f);
      PBar1.Max:=2;
      PBar1.Step:=1;
      PBar1.Position:=0;
      writeln(f,'-------------------------------------------------------');
      writeln(f,'开始算薪资:'+formatdatetime('yyyy/mm/dd hh:mm:ss',now));
    //为防止用户忘记汇总就餐记录、就诊记录、保险金,系统再重算一遍
      label4.caption:='正在计算'+monthy+'月份的保险金,就诊费,就餐费';
      label4.update;
      inscal;
      medcal;
      //mealcal(monthy);
      Label4.caption:='正在计算'+monthy+'月份的薪资';
      label4.update;
      //query1.close;
      //query1.sql.text:='exec Upper24010sal '''+monthy+''','+allman+' ';
      //query1.execsql;
      taxstr:=tax;
      try
      if (sal_cal=0)or(sal_cal=5)  then
      begin
          adocommand1.prepared:=false;
          adocommand1.commandtext:='Exec sal_yj_cal '''+monthy+''','''+pubworkname+''','''+allman+'''';
          adocommand1.Execute;
          // adocommand1.prepared:=false;
         // adocommand1.commandtext:='Exec sal_notbrushcard '''+monthy+''','''+pubworkname+''',''ALL'','''+tax+'''';
         // adocommand1.Execute;
      end;
      if (sal_cal=4)  then
      begin
         // adocommand1.prepared:=false;
         // adocommand1.commandtext:='Exec sal_notbrushcard '''+monthy+''','''+pubworkname+''',''ALL'','''+taxstr+'''';
        //  adocommand1.Execute;
      end;
      except
      end;
      PBar1.StepIt;
    except
      application.messagebox('计算薪资出错,请检查薪资参数设定是否正确'+#13#10+'(c:\xx.sql,c:\salcal.sql,c:\hesuan.sql).','计算出错',mb_ok+mb_iconerror);
    end;
    adosalset.close;
 end; //datamod
 writeln(f,'结束算薪资:'+formatdatetime('yyyy/mm/dd hh:mm:ss',now));
 writeln(f,'-------------------------------------------------------');
 closefile(f);
 Close;
 if not assigned(formsaldata) then
    formsaldata:=TFormsaldata.create(application);
    formsaldata.show;
end;


procedure TFormsalcal.FormActivate(Sender: TObject);
begin
     Edit2.text:=Formatdatetime('yyyy/mm',date);
     left:=5;
     top:=2;
end;

procedure TFormsalcal.formkeyup(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=vk_f1 then
  begin
   Application.helpfile :=extractfilepath(application.exename) +'help\pasahelp.hlp';
   application.HelpJump('shm_contents0031');
  end;
end;

procedure TFormsalcal.cbrqExit(Sender: TObject);
var
    day,i:integer;
    item:string;
begin
    day:=getdays(copy(cbrq.text,6,2),copy(cbrq.text,1,4));
    cbday1.items.Clear;
    for i:=1 to day do
    begin
        item:=inttostr(i);
        if length(item)=1 then
          item:='0'+item;
        cbday1.items.add(item);
    end;
    cbday1.text:='01';
    edit2.text:=cbrq.text;
end;

procedure TFormsalcal.cbrq2Exit(Sender: TObject);
var
    day,i:integer;
    item:string;
begin
    day:=getdays(copy(cbrq2.text,6,2),copy(cbrq2.text,1,4));
    cbday2.items.Clear;
    for i:=1 to day do
    begin
        item:=inttostr(i);
        if length(item)=1 then
          item:='0'+item;
        cbday2.items.add(item);
    end;
    cbday2.text:=inttostr(day);
end;

procedure TFormsalcal.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if key=#13 then
   begin
      selectnext(activecontrol,true,true);
      key:=#0;
   end;
end;

procedure TFormsalcal.radiobutton1Click(Sender: TObject);
begin
   if radiobutton1.Checked then
   begin
      speedbutton1.enabled:=false;
      ok.enabled:=true;
      label6.Visible:=false;
      label5.visible:=false;
   end else if radiobutton2.checked then
   begin
      datamod.adoquery1.close;
      datamod.adoquery1.sql.text:='select * from workno';
      datamod.adoquery1.open;
      if not datamod.adoquery1.eof then
      begin
         label6.caption:=inttostr(datamod.adoquery1.recordcount);
         ok.enabled:=true;
      end else
      begin
         label6.caption:='0';
         ok.enabled:=false;
      end;
      speedbutton1.enabled:=true;
      label6.Visible:=true;
      label5.visible:=true;
   end;
end;

procedure TFormsalcal.SpeedButton1Click(Sender: TObject);
begin
   datamod.adoquery1.close;
   datamod.adoquery1.sql.text:='delete workno';
   datamod.adoquery1.execsql;
   if not assigned(formmulti) then
     formmulti:=Tformmulti.create(self);
     formmulti.showmodal;
   radiobutton2.onclick(radiobutton2);
end;

end.

⌨️ 快捷键说明

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