unit1.pas

来自「pasa人力资源考勤管理系统」· PAS 代码 · 共 603 行 · 第 1/2 页

PAS
603
字号
  public
    { Public declarations }
    function printcondition:string;
  end;

var
  Form1: TForm1;

implementation

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

procedure TForm1.FormCreate(Sender: TObject);
begin
   maskedit1.text:=formatdatetime('yyyy/mm/dd',now);
   maskedit2.text:=maskedit1.text;
   maskedit3.text:=formatdatetime('yyyy/mm',now);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  //adocommand1.prepared:=false;
  //adocommand1.commandtext:='delete report_day';
  //adocommand1.execute;
   close;
end;

procedure TForm1.ppReport2BeforePrint(Sender: TObject);
begin
   pplabel14.caption:=maskedit1.text+'…'+maskedit2.text;
end;

procedure TForm1.Button1Click(Sender: TObject);
var s:string;
  fmat1:string;
begin
  if fmat='/' then
    fmat1:='    /  /  ';
  if fmat='-' then
    fmat1:='    -  -  ';
 panel1.visible:=true;
 panel1.update;
 s:=printcondition;
 if radiobutton1.checked then     //每日工时表
 begin
  adodataset1.close;
  if s<>'' then
  begin
    case radiogroup2.ItemIndex of
      0:adodataset1.commandtext:='select distinct workno,name,dept,rq,gotime1,outtime1,gotime2,outtime2,gotime3,outtime3, '+
       ' gotime4, outtime4, gotime5,outtime5,othours,facthours,late,latetimes,early,earlytimes, '+
       ' kuanggong,kuanggongtimes,musthours,leavehave,qianka from report_day where '+s+'  and rq between convert(datetime,'''+maskedit1.text+''') and convert(datetime,'''+maskedit2.text+''') order by dept,workno,rq ';      //按条件显示
      1:adodataset1.commandtext:='select distinct workno,name,dept,rq,gotime1,outtime1,gotime2,outtime2,gotime3,outtime3, '+
       ' gotime4, outtime4, gotime5,outtime5,othours,facthours,late,latetimes,early,earlytimes, '+
       ' kuanggong,kuanggongtimes,musthours,leavehave,qianka from report_day where '+s+'  and rq between convert(datetime,'''+maskedit1.text+''') and convert(datetime,'''+maskedit2.text+''') and  kuanggong=0 and leavehave=0 and late=0 and early=0  order by dept,workno,rq ';
      2:adodataset1.CommandText:='select distinct workno,name,dept,rq,gotime1,outtime1,gotime2,outtime2,gotime3,outtime3, '+
       ' gotime4, outtime4, gotime5,outtime5,othours,facthours,late,latetimes,early,earlytimes, '+
       ' kuanggong,kuanggongtimes,musthours,leavehave,qianka from report_day where '+s+'  and rq between convert(datetime,'''+maskedit1.text+''') and convert(datetime,'''+maskedit2.text+''') and  kuanggong>0 and leavehave>0 and late>0 and early>0  order by dept,workno,rq '
    end;
  end
  else
  begin
    case radiogroup2.ItemIndex of
     0:adodataset1.commandtext:='select distinct workno,name,dept,rq,gotime1,outtime1,gotime2,outtime2,gotime3,outtime3, '+
     ' gotime4, outtime4, gotime5,outtime5,othours,facthours,late,latetimes,early,earlytimes, '+
     ' kuanggong,kuanggongtimes,musthours,leavehave,qianka from report_day where rq between convert(datetime,'''+maskedit1.text+''') and convert(datetime,'''+maskedit2.text+''') order by dept,workno,rq ';      //按条件显示
    1:adodataset1.commandtext:='select distinct workno,name,dept,rq,gotime1,outtime1,gotime2,outtime2,gotime3,outtime3, '+
     ' gotime4, outtime4, gotime5,outtime5,othours,facthours,late,latetimes,early,earlytimes, '+
     ' kuanggong,kuanggongtimes,musthours,leavehave,qianka from report_day where rq between convert(datetime,'''+maskedit1.text+''') and convert(datetime,'''+maskedit2.text+''') and  kuanggong=0 and leavehave=0 and late=0 and early=0  order by dept,workno,rq ';
    2:adodataset1.CommandText:='select distinct workno,name,dept,rq,gotime1,outtime1,gotime2,outtime2,gotime3,outtime3, '+
     ' gotime4, outtime4, gotime5,outtime5,othours,facthours,late,latetimes,early,earlytimes, '+
     ' kuanggong,kuanggongtimes,musthours,leavehave,qianka from report_day where rq between convert(datetime,'''+maskedit1.text+''') and convert(datetime,'''+maskedit2.text+''') and (kuanggong>0 or leavehave>0 or late>0 or early>0) order by dept,workno';
    end;
  end;
  adodataset1.open;
  ppreport2.print;
 end else if radiobutton3.checked then    //
 ///////04/23
    begin
   if (maskedit1.text<>fmat1) and (maskedit2.text<>fmat1) then
    begin
   // DBGrid1.DataSource:=DataSource3;
     adodataset3.Close;
     if s<>'' then
       case radiogroup2.itemindex of
        0:adodataset3.CommandText:='Select * from vatd32010 where '+s+' and rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''') order by dept,workno';
        1:adodataset3.CommandText:='Select * from vatd32010 where '+s+' and rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''') and kuanggong=0 and leavehave=0 and late=0 and early=0 order by dept,workno';
        2:adodataset3.CommandText:='Select * from vatd32010 where '+s+' and rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''') and (kuanggong>0 or leavehave>0 or late>0 or early>0) order by dept,workno';
        end
       else
        case radiogroup2.itemindex of
        0:adodataset3.CommandText:='Select * from Vatd32010 where rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''') order by dept,workno';
        1:adodataset3.CommandText:='Select * from Vatd32010 where rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''')and kuanggong=0 and leavehave=0 and late=0 and early=0 order by dept,workno';
        2:adodataset3.CommandText:='Select * from Vatd32010 where rq between convert(datetime,'''+maskedit1.Text+''') and convert(datetime,'''+maskedit2.Text+''') and (kuanggong>0 or leavehave>0 or late>0 or early>0) order by dept,workno';
        end;
     adodataset3.Open;
     pplabel18.Caption:=maskedit1.text+'~~'+maskedit2.Text;
    end;

    ppreport1.print;
 end else if radiobutton4.checked then
 begin
    adodataset2.close;
    if s<>'' then

     adodataset2.commandtext:='select salok,status,workno,cardno,min(name) name ,dept ,max(latekg) latekg ,max(earlykg) earlykg , '+
                               ' sum(isnull(musthours,0)) musthours,sum(isnull(facthours,0)) facthours,sum(isnull(late,0)) '+
                               ' late,sum(isnull(latetimes,0)) latetimes , '+
                               ' sum(isnull(early,0)) early ,sum(isnull(earlytimes,0)) earlytimes,sum(isnull(kuanggong,0)) '+
                               ' kuanggong,sum(isnull(kuanggongtimes,0)) kuanggongtimes, '+
                               ' sum(isnull(othours,0))+sum(isnull(otjieri,0))+sum(isnull(otjiari,0)) otall, sum(isnull(leavehave,0)) '+
                               ' leavehave from vatd34010  where '+s+' and  monthy='''+maskedit3.text+''' '+
                               ' group by workno,cardno ,salok,status,dept '+
                               ' order by dept,workno '

    else
     adodataset2.commandtext:='select salok,status,workno,cardno,min(name) name ,dept ,max(latekg) latekg ,max(earlykg) earlykg , '+
                               ' sum(isnull(musthours,0)) musthours,sum(isnull(facthours,0)) facthours,sum(isnull(late,0)) '+
                               ' late,sum(isnull(latetimes,0)) latetimes , '+
                               ' sum(isnull(early,0)) early ,sum(isnull(earlytimes,0)) earlytimes,sum(isnull(kuanggong,0)) '+
                               ' kuanggong,sum(isnull(kuanggongtimes,0)) kuanggongtimes, '+
                               ' sum(isnull(othours,0))+sum(isnull(otjieri,0))+sum(isnull(otjiari,0)) otall, sum(isnull(leavehave,0)) '+
                               ' leavehave from vatd34010  where monthy='''+maskedit3.text+''' '+
                               ' group by workno,cardno ,salok,status,dept '+
                               ' order by dept,workno ';


    adodataset2.open;
    ppreport3.print;
 end;
 panel1.visible:=false;
end;

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

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
   if radiobutton1.Checked or radiobutton3.checked then
   begin
      label3.visible:=true;
      label1.visible:=true;
      maskedit1.visible:=true;
      maskedit2.visible:=true;
      maskedit3.visible:=false;
      label1.caption:='请输入开始日期和结束日期';
      label1.update;
      label2.caption:='开始';
   end
   else
   begin
     label3.visible:=false;
     maskedit1.visible:=false;
     maskedit2.visible:=false;
     maskedit3.visible:=true;
     label2.Visible:=false;
     label1.Visible:=false;
     label2.Visible:=true ;
     label2.caption:='月份:';
   end;
end;

procedure TForm1.ppReport1BeforePrint(Sender: TObject);
begin
 pplabel5.Caption:=companyname1;
 pplabel94.Caption:=pubworkname;
end;

procedure TForm1.ppDBCalc9GetText(Sender: TObject; var Text: String);
begin
//   pplabel86.caption:='出勤天数:'+floattostr(strtofloat(text)/8);
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
  edit2.text:=edit1.text;
end;

function TForm1.printcondition:string;
begin
  result:='';
  case RadioGroup1.itemindex of
     0:result:='';
     1:if combobox1.items.indexof(combobox1.text)<>-1 then result:='dept='''+combobox1.text+''' ';
     2:if (trim(edit1.text)<>'') and (trim(edit2.text)<>'') then result:='workno between '''+edit1.text+''' and '''+edit2.text+''' ';
  end;
end;

procedure TForm1.ppDBCalc5GetText(Sender: TObject; var Text: String);
begin
//   pplabel86.caption:='出勤天数:'+floattostr(strtofloat(text)/8);
end;

procedure TForm1.ppReport5PreviewFormCreate(Sender: TObject);
begin
  tppReport(Sender).PreviewForm.WindowState:=wsMaximized;
end;

procedure TForm1.ppReport1AfterPrint(Sender: TObject);
begin
  adodataset1.Close;
end;

procedure TForm1.ComboBox1Enter(Sender: TObject);
begin
  radiogroup1.ItemIndex:=1;
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  radiogroup1.itemindex:=2;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  startrq,endrq,startrq2,endrq2:Tdate;
begin
 panel1.visible:=true;
 panel1.update;
 startrq:=strtodate(maskedit1.text);
 endrq:=strtodate(maskedit2.text);
 startrq2:=strtodate(maskedit3.text+'/01');
 endrq2:=strtodate(maskedit3.text+'/'+inttostr(Getdays(copy(maskedit3.text,6,2),copy(maskedit3.text,1,4))));

 if radiobutton1.checked then     //藩谔驮奀桶
 begin
  adocommand1.prepared:=false;
  Adocommand1.CommandText:='exec rep '''+formatdatetime('yyyy/mm/dd',startrq)+''','''+formatdatetime('yyyy/mm/dd',endrq)+'''';
  adocommand1.Execute;
 end;
 //else if radiobutton2.checked then   //藩堎驮奀桶
{ begin
   adocommand1.prepared:=false;
    Adocommand1.CommandText:='exec rep '''+formatdatetime('yyyy/mm/dd',startrq2)+''','''+formatdatetime('yyyy/mm/dd',endrq2)+'''';
   adocommand1.execute;
 end;}

 panel1.visible:=false;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  action:=cafree;
  form1:=nil;
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  case  radioGroup1.ItemIndex of
  1:
  begin
    with datamod do
    begin
      Query1.close;
      Query1.sql.text:='Select dept from pub05010';
      Query1.Open;
      Combobox1.items.clear;
      while not Query1.eof do
      begin
          combobox1.items.add(Query1.fieldbyname('dept').asstring);
          Query1.next;
      end;
  end;
  end;
  0:
  begin
    combobox1.Text:='';
    Edit1.Text:='';
    Edit2.text:='';
  end;
  2:
   begin
     Combobox1.Text:='';
     Edit1.Text:='';
     Edit2.Text:='';
     Edit1.SetFocus;
  end;
end;
end;
procedure TForm1.ppReport3BeforePrint(Sender: TObject);
begin
  pplabel81.Caption:='月份:'+ maskedit3.text;
  pplabel106.Caption:=pubworkname;

end;

end.







⌨️ 快捷键说明

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