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

📄 unit_attenstat.pas

📁 主要用于美容院的内部管理.有使用说明.下载后查看其功能!
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{*******************用户过程定义********************}
procedure Tfrm_attendstat.sbtn_attendstatClick(Sender: TObject);
var
   temp_Empno,temp_Empname:string;
   temp_TotalWorkDay,temp_TotalAttendDay,temp_SpecialAttendDay,arow:integer;
   temp_LateTime,temp_EarlyTime:array[1..3] of integer;
begin

  StringGridClear(sg_Statistic);
  
  if (cbb_year.Text ='') or (cbb_month.Text ='') then
  begin
    MessageBox(handle,'请选择统计年月!','提示',mb_ok+mb_iconinformation);
    exit;
  end;

  {if (length(trim(cbb_year.Text)))<>4 then
  begin
    MessageBox(handle,'请输入正确的四位年份!','提示',mb_ok+mb_iconinformation);
    exit;
  end;

  if (not( (StrToInt(edt_month.Text)<10) and (Length(edt_month.Text)=1) )) and (not( (StrToInt(edt_month.Text)>=10) and (Length(edt_month.Text)=2) )) then
  begin
    MessageBox(handle,'请输入正确的一位或两位月份!','提示',mb_ok+mb_iconinformation);
    exit;
  end; }

  if not GetAttendTimeSet then exit;
  
  //得到最大的日期 , 得到最小的日期
  temp_MaxDate:=GetMaxDate(StrToInt(trim(cbb_year.Text)),StrToInt(trim(cbb_month.Text)));
  temp_MinDate:=trim(cbb_year.Text)+'-'+trim(cbb_month.Text)+'-'+'1';
  if length(trim(cbb_month.Text)) <2 then
     temp_yearmonth:= trim(cbb_year.Text)+ '-0'+ trim(cbb_month.Text)
  else
     temp_yearmonth:= trim(cbb_year.Text)+ '-'+ trim(cbb_month.Text);
  
  with dmod.qrydata do
  begin
    Close;
    SQL.Text := 'select emp_no,emp_name from employee';
    Open;
    arow:=1;
    while not eof do
    begin
      temp_Empno:=FieldByName('emp_no').AsString ;
      temp_Empname:=FieldByName('emp_name').asString;

      with dmod.qrydata2 do
      begin
        Close; //得到总的工作天数
        SQL.Text :='select count(*) as count from normalattend where emp_no='+#39+temp_Empno+#39+
                   ' and att_date between '+#39+temp_MinDate+#39+' and '+#39+temp_MaxDate+#39;
        Open;
        temp_TotalWorkDay:=FieldByName('count').AsInteger ;
        //showmessage(inttostr(temp_TotalWorkDay));
        Close; //得到总的考勤天数
        SQL.Text :='select count(*) as count from normalattend where emp_no='+#39+temp_Empno+#39+
                   ' and is_attend="1" and att_date between '+#39+temp_MinDate+#39+' and '+#39+temp_MaxDate+#39;
        Open;
        temp_TotalAttendDay:=FieldByName('count').AsInteger ;
        //showmessage(inttostr(temp_TotalAttendDay));
        Close; //得到上午、下午、晚上迟到次数和上午、下午、晚上早退次数
        SQL.Text :='select * from normalattend where emp_no='+#39+temp_Empno+#39+
                   ' and att_date between '+#39+temp_MinDate+#39+' and '+#39+temp_MaxDate+#39;
        Open;
        
        while not eof do
        begin
          //showmessage(FieldByName('pre_morning').AsString);
          if FieldByName('pre_morning').AsString <> '' then
          begin
          if StrToTime(TimeToStr(FieldByName('pre_morning').AsDateTime)) > StrToTime(time_set[0]) then
             temp_LateTime[1]:=temp_LateTime[1]+1;
          end;
          //showmessage(FieldByName('aft_morning').AsString);
          if FieldByName('aft_morning').AsString <> '' then
          begin
          if StrToTime(TimeToStr(FieldByName('aft_morning').AsDateTime)) < StrToTime(time_set[1]) then
             temp_EarlyTime[1]:=temp_EarlyTime[1]+1;
          end;
          //showmessage(FieldByName('pre_afternoon').AsString);
          if FieldByName('pre_afternoon').AsString <> '' then
          begin
          if StrToTime(TimeToStr(FieldByName('pre_afternoon').AsDateTime)) > StrToTime(time_set[2]) then
             temp_LateTime[2]:=temp_LateTime[2]+1;
          end;
          //showmessage(FieldByName('aft_afternoon').AsString);
          if FieldByName('aft_afternoon').AsString <> '' then
          begin
          if StrToTime(TimeToStr(FieldByName('aft_afternoon').AsDateTime)) < StrToTime(time_set[3]) then
             temp_EarlyTime[2]:=temp_EarlyTime[2]+1;
          end;
          //showmessage(FieldByName('pre_evening').AsString);
          if FieldByName('pre_evening').AsString <> '' then
          begin
          if StrToTime(TimeToStr(FieldByName('pre_evening').AsDateTime)) > StrToTime(time_set[4]) then
             temp_LateTime[3]:=temp_LateTime[3]+1;
          end;
          //showmessage(FieldByName('aft_evening').AsString);
          if FieldByName('aft_evening').AsString <> '' then
          begin
          if StrToTime(TimeToStr(FieldByName('aft_afternoon').AsDateTime)) < StrToTime(time_set[5]) then
             temp_EarlyTime[3]:=temp_EarlyTime[3]+1;
          end;

          next;
        end;

        Close;//得到总的特殊考勤次数
        SQL.Text :='select count(*) as count from SpecialAttend where emp_no='+#39+temp_Empno+#39+
                   ' and att_date between '+#39+temp_MinDate+#39+' and '+#39+temp_MaxDate+#39;
        Open;
        temp_SpecialAttendDay:=FieldByName('count').AsInteger ;
        
      end;

      with sg_Statistic do
      begin
        Cells[0,arow]:=temp_Empno;
        Cells[1,arow]:=temp_Empname;
        Cells[2,arow]:=IntToStr(temp_TotalWorkDay);
        Cells[3,arow]:=IntToStr(temp_TotalAttendDay);
        Cells[4,arow]:=IntToStr(temp_LateTime[1]);
        Cells[5,arow]:=IntToStr(temp_EarlyTime[1]);
        Cells[6,arow]:=IntToStr(temp_LateTime[2]);;
        Cells[7,arow]:=IntToStr(temp_EarlyTime[2]);
        Cells[8,arow]:=IntToStr(temp_LateTime[3]);;
        Cells[9,arow]:=IntToStr(temp_EarlyTime[3]);
        Cells[10,arow]:=IntToStr(temp_LateTime[1]+temp_LateTime[2]+temp_LateTime[3]);
        Cells[11,arow]:=IntToStr(temp_EarlyTime[1]+temp_EarlyTime[2]+temp_EarlyTime[3]);
        cells[12,arow]:=IntToStr(temp_SpecialAttendDay);
      end;
      inc(arow);
      next;
    end;
  end;

  if arow<>1 then
  begin
    sg_Statistic.RowCount := arow+1;
    SaveAttendStatistic;
  end;
end;

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

procedure Tfrm_attendstat.SpeedButton2Click(Sender: TObject);
begin
  close;
end;

procedure Tfrm_attendstat.sg_StatisticSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  if ARow = sg_Statistic.RowCount - 1 then
    CanSelect:= false
  else
  begin
    sbtn_back.Enabled := true;
    sbtn_front.Enabled := true;
    if ARow = sg_Statistic.RowCount - 2 then sbtn_back.Enabled := false;
    if ARow = 1 then sbtn_front.Enabled := false;
    CanSelect := true;
  end;
end;

procedure Tfrm_attendstat.sbtn_ShowClick(Sender: TObject);
begin
  GetDetailNormalAttendInfo(sg_Statistic.Cells[0,sg_statistic.row],sg_Statistic.Cells[1,sg_statistic.row],temp_MinDate,temp_Maxdate);
  GetDetailSpecialAttendInfo(sg_Statistic.Cells[0,sg_statistic.row],sg_Statistic.Cells[1,sg_statistic.row],temp_MinDate,temp_Maxdate);
end;

procedure Tfrm_attendstat.PageControl1Changing(Sender: TObject;
  var AllowChange: Boolean);
begin
  if pagecontrol1.ActivePage = sht_statdetail then exit;
  
  AllowChange := true;
  if sg_Statistic.cells[0,sg_Statistic.Row ]='' then
  begin
    //MessageBox(handle,'请先选择一位员工记录,再查看详细信息!','提示',mb_ok+mb_iconinformation);
    AllowChange:=false;
    exit;
  end;

  sbtn_ShowClick(nil);
end;

procedure Tfrm_attendstat.sbtn_backClick(Sender: TObject);
begin
  if pagecontrol1.ActivePage = sht_statList then
  begin
    if sg_Statistic.Row > sg_Statistic.RowCount-2 then
    begin
       sbtn_back.Enabled := false;
       exit;
    end;
    sbtn_front.Enabled := true;
    sg_Statistic.Row := sg_Statistic.Row+1;
  end else begin
    if sg_Detail.Row > sg_Detail.RowCount-2 then
    begin
       sbtn_back.Enabled := false;
       exit;
    end;
    sbtn_front.Enabled := true;
    sg_Detail.Row := sg_Detail.Row+1
  end;
end;

procedure Tfrm_attendstat.sbtn_frontClick(Sender: TObject);
begin
  if pagecontrol1.ActivePage = sht_statList then
  begin
    if sg_Statistic.Row=1 then
    begin
      sbtn_front.Enabled := false;
      exit;
    end;
    sbtn_back.Enabled := true;
    sg_Statistic.Row := sg_Statistic.Row-1;
  end else begin
    if sg_Detail.Row=1 then
    begin
      sbtn_front.Enabled := false;
      exit;
    end;
    sbtn_back.Enabled := true;
    sg_Detail.Row := sg_Detail.Row-1;
  end;
end;

procedure Tfrm_attendstat.sg_DetailSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  if ARow = sg_Detail.RowCount - 1 then
    CanSelect:= false
  else
  begin
    sbtn_back.Enabled := true;
    sbtn_front.Enabled := true;
    if ARow = sg_Detail.RowCount - 2 then sbtn_back.Enabled := false;
    if ARow = 1 then sbtn_front.Enabled := false;
    CanSelect := true;
  end;
end;

procedure Tfrm_attendstat.sbtn_printClick(Sender: TObject);
begin
  DoReportAttendStatistic;
end;

end.

⌨️ 快捷键说明

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