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

📄 unit3.pas

📁 工资管理源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:

procedure Tmain.ADOQuery1AfterOpen(DataSet: TDataSet);
var
i:integer;
begin
  with DBGrid1 do
   for I := 0 to Columns.Count - 1 do
    begin
       if (Columns[I].Title.Caption='科室') or (Columns[I].Title.Caption ='姓名') then Columns[I].Width := 50 else Columns[I].Width := 50;
     // if adoquery1.Fields[I].datatype<>ftstring then (adoquery1.Fields[I] as TNumericField).DisplayFormat:='#.00';
    end;
end;

procedure Tmain.BitBtn5Click(Sender: TObject);
var
 i:integer;
begin
title_rep:=edit1.Text+'年'+combobox1.Text+'月份'+'工资发放花名册'+'('+combobox3.text+')';
hmc_tmp:='';
 for i := 0 to adoquery1.FieldCount - 1 do
  begin
   if (adoquery1.Fields[i].FieldName<>'ID') and (adoquery1.Fields[i].FieldName<>'排序') and (adoquery1.Fields[i].FieldName<>'编制') then
     if hmc_tmp='' then hmc_tmp:=adoquery1.Fields[i].FieldName else hmc_tmp:=hmc_tmp+','+adoquery1.Fields[i].FieldName;
   end;
  with gz do
   begin
     close;
     sql.Clear;
     sql.Add('select '+hmc_tmp+' from '+edit1.Text+combobox1.Text);
     if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
     sql.add('order by 排序');
     open;
   end;

     rmReport1.Pages.Clear;
     rmReport1.Pages.Add;
     rmReport1.pages.Pages[0].ChangePaper(256,3800,2800, 0,poPortrait);
     Page := rmReport1.Pages[0];

     gz_x:=40;

     b := TrmBandView(rmCreateObject(gtBand, ''));
     b.SetBounds(20, 20, 0, 112);
	   b.BandType := btpageheader;
     Page.Objects.Add(b);

    v := rmCreateObject(gtMemo, '');
	  v.SetBounds(20,60, 600, 32);
	  v.Memo.Add(title_rep);
    TrmMemoView(v).Font.Name:='黑体';
    TrmMemoView(v).Font.Size:=14;
    TrmMemoView(v).BandAlign:=rmbacenter;
    Page.Objects.Add(v);
    b := TrmBandView(rmCreateObject(gtBand, ''));
	  b.SetBounds(20, 160, 0, 24);
	  b.BandType := btMasterData;
	  b.Dataset := 'rmDBDataSet1';
	  Page.Objects.Add(b);

    b := TrmBandView(rmCreateObject(gtBand, ''));
	  b.SetBounds(20, 220, 0, 24);
	  b.BandType := btMasterfooter;
    Page.Objects.Add(b);


  for I:=0 to gz.FieldCount-1 do
      begin
       gz_xm:=gz.Fields[i].FieldName;
       gzjg.locate('项目',gz_xm,[loCaseInsensitive]);
      if gzjg.FieldByName('是否打印').asstring='Y' then
       begin

       if (gz_xm='科室') or (gz_xm='姓名') then fie_len:=40 else
        begin
         with chd do
          begin
           close;
           sql.Clear;
           sql.add('select sum('+gz_xm+') from '+table_name);
           if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
           open;
          end;
          fie_len:=length(formatfloat('0.00',chd.Fields[0].asfloat))*6+5;
          if fie_len<40 then fie_len:=40;

        end;



       begin
          v := rmCreateObject(gtMemo, '');
	        v.SetBounds(gz_x,100, fie_len, 32);
	        v.Memo.Add(gz_xm);
          v.Prop['WordWrap']:=true;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          TrmMemoView(v).Alignment:=rmtamiddle+rmtacenter;
	        Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	        v.SetBounds(gz_x,160, fie_len, 24);
	        v.Memo.Add('[gz."'+gz_xm+'"]');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          TrmMemoView(v).FormatStr:='@@######';
         if gz.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
          begin
           TrmMemoView(v).Format:=1 * $01000000 + 4 * $00010000+2*$00000100;
           TrmMemoView(v).Format := TrmMemoView(v).Format + Ord('.');
           TrmMemoView(v).FormatStr:='0.00';
          end;

         if (gz_xm='科室') or (gz_xm='姓名') then TrmMemoView(v).Alignment:=rmtamiddle
           else TrmMemoView(v).Alignment:=rmtamiddle+rmtaright;
	  Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	  v.SetBounds(gz_x,220, fie_len, 24);
	  if gz_xm='科室'
            then v.Memo.Add('合计')
            else if gz_xm='姓名'
              then v.Memo.Add(inttostr(gz.recordcount)+'人')
            else  
          v.Memo.Add('[sum('+gz_xm+')]');

          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
        v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          if gz.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
           begin
           TrmMemoView(v).Format:=1 * $01000000 + 4 * $00010000+2*$00000100;
           TrmMemoView(v).Format := TrmMemoView(v).Format + Ord('.');
           TrmMemoView(v).FormatStr:='0.00';
            end;
            if (gz_xm='科室') or (gz_xm='姓名') then TrmMemoView(v).Alignment:=rmtamiddle+rmtacenter
            else TrmMemoView(v).Alignment:=rmtamiddle+rmtaright;
	      Page.Objects.Add(v);

          gz_x:=gz_x+fie_len;
       end;
      end;
      end;

          v := rmCreateObject(gtMemo, '');
	  v.SetBounds(gz_x,100, 70, 32);
	  v.Memo.Add('签名');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
           TrmMemoView(v).Alignment:=rmtamiddle+rmtacenter;
	  Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	  v.SetBounds(gz_x,160, 70, 24);
	  v.Memo.Add('');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
        v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	  v.SetBounds(gz_x,220, 70, 24);
          v.Memo.Add('');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
           v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          Page.Objects.Add(v);


          rmReport1.ShowReport;
      // rmReport1.DesignReport;

end;

procedure Tmain.BitBtn3Click(Sender: TObject);
var
 i:integer;
begin
table_name:=edit1.Text+combobox1.Text;
title_rep:=edit1.Text+'年'+combobox1.Text+'月份'+'工资发放汇总表'+'('+combobox3.text+')';
hz_tmp:='';
 for i := 0 to adoquery1.FieldCount - 1 do
  begin
   if (adoquery1.Fields[i].FieldName<>'ID') and (adoquery1.Fields[i].FieldName<>'排序') and (adoquery1.Fields[i].FieldName<>'编制') and (adoquery1.Fields[i].FieldName<>'姓名') then
     if (adoquery1.Fields[i].FieldName='科室') then if hz_tmp='' then hz_tmp:='科室,count(科室) as 人数' else hz_tmp:=hz_tmp+','+'科室,count(科室) as 人数' else if hz_tmp='' then hz_tmp:='sum('+adoquery1.Fields[i].FieldName+') as '+adoquery1.Fields[i].FieldName else hz_tmp:=hz_tmp+','+'sum('+adoquery1.Fields[i].FieldName+') as '+adoquery1.Fields[i].FieldName;
   end;

 with gz do
   begin
     close;
     sql.Clear;
     sql.Add('select '+hz_tmp+' from '+edit1.Text+combobox1.Text);
     if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
     sql.add('group by 科室');
     open;
   end;


   rmReport1.Pages.Clear;
     	  rmReport1.Pages.Add;
         rmReport1.pages.Pages[0].ChangePaper(256,3800,2800, 0,poPortrait);
          Page := rmReport1.Pages[0];


          gz_x:=40;

           b := TrmBandView(rmCreateObject(gtBand, ''));
	         b.SetBounds(20, 20, 0, 60);
	         b.BandType := btpageheader;
           Page.Objects.Add(b);

           v := rmCreateObject(gtMemo, '');
	         v.SetBounds(20,40, 700, 32);
	         v.Memo.Add(title_rep);
           TrmMemoView(v).Font.Name:='黑体';
           TrmMemoView(v).Font.Size:=14;
           TrmMemoView(v).BandAlign:=rmbacenter;
           Page.Objects.Add(v);

	         b := TrmBandView(rmCreateObject(gtBand, ''));
	         b.SetBounds(20, 100, 0, 40);
	         b.BandType := btMasterheader;
           Page.Objects.Add(b);


          b := TrmBandView(rmCreateObject(gtBand, ''));
	        b.SetBounds(20, 160, 0, 16);
	        b.BandType := btMasterData;
          b.Dataset := 'rmDBDataSet1';
	        Page.Objects.Add(b);

          b := TrmBandView(rmCreateObject(gtBand, ''));
	        b.SetBounds(20, 220, 0, 16);
	        b.BandType := btMasterfooter;
          Page.Objects.Add(b);


   for I:=0 to gz.FieldCount-1 do
      begin
       gz_xm:=gz.Fields[i].FieldName;
       gzjg.locate('项目',gz_xm,[loCaseInsensitive]);
      if gzjg.FieldByName('是否打印').asstring='Y' then
      begin
       if gz_xm='科室' then fie_len:=40 else
        if gz_xm='人数' then fie_len:=30 else
        begin
         with chd do
          begin
           close;
           sql.Clear;
           sql.add('select sum('+gz_xm+') from '+table_name);
           if combobox3.text<>'全部人员' then sql.Add('where 编制='+''''+combobox3.text+'''');
           open;

          end;
         fie_len:=length(formatfloat('0.00',chd.Fields[0].asfloat))*6+5;
          if fie_len<40 then fie_len:=40;
            if odd(fie_len)=false then fie_len:=fie_len+1;

        end;


          v := rmCreateObject(gtMemo, '');
	        v.SetBounds(gz_x,100, fie_len, 40);
	        v.Memo.Add(gz_xm);
          v.Prop['WordWrap']:=true;
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
           v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          TrmMemoView(v).Alignment:=rmtamiddle+rmtacenter;
	        Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	        v.SetBounds(gz_x,160, fie_len, 16);
	        v.Memo.Add('[gz."'+gz_xm+'"]');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          if gz.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
           begin
            TrmMemoView(v).Format:=1 * $01000000 + 4 * $00010000+2*$00000100;
            TrmMemoView(v).Format := TrmMemoView(v).Format + Ord('.');
            TrmMemoView(v).FormatStr:='0.00';
           end;
          if gz_xm='科室' then TrmMemoView(v).Alignment:=rmtamiddle
           else TrmMemoView(v).Alignment:=rmtamiddle+rmtaright;
	        Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	        v.SetBounds(gz_x,220, fie_len, 16);
          if gz.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
           begin
            TrmMemoView(v).Format:=1 * $01000000 + 4 * $00010000+2*$00000100;
            TrmMemoView(v).Format := TrmMemoView(v).Format + Ord('.');
            TrmMemoView(v).FormatStr:='0.00';
           end;
	      if gz_xm='科室' then v.Memo.Add('合计') else v.Memo.Add('[sum('+gz_xm+')]');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          if gz_xm='科室' then TrmMemoView(v).Alignment:=rmtamiddle+rmtacenter
           else TrmMemoView(v).Alignment:=rmtamiddle+rmtaright;
	  Page.Objects.Add(v);

          gz_x:=gz_x+fie_len;
      end;
      end;

	  rmReport1.ShowReport;


end;

procedure Tmain.BitBtn6Click(Sender: TObject);
var
 i:integer;
begin
title_rep:=edit1.Text+'年'+combobox1.Text+'月份'+'工资发放个人表';
hmc_tmp:='';
 for i := 0 to adoquery1.FieldCount - 1 do
  begin
   if (adoquery1.Fields[i].FieldName<>'ID') and (adoquery1.Fields[i].FieldName<>'排序') and (adoquery1.Fields[i].FieldName<>'编制') then
     if hmc_tmp='' then hmc_tmp:=adoquery1.Fields[i].FieldName else hmc_tmp:=hmc_tmp+','+adoquery1.Fields[i].FieldName;
   end;
  with gz do
   begin
     close;
     sql.Clear;
     sql.Add('select '+hmc_tmp+' from '+edit1.Text+combobox1.Text);
     sql.add('order by 排序');
     open;
   end;


    rmReport1.Pages.Clear;
    rmReport1.Pages.Add;
    rmReport1.pages.Pages[0].ChangePaper(256,3800,2800, 0,poPortrait);
    Page := rmReport1.Pages[0];

   
    b := TrmBandView(rmCreateObject(gtBand, ''));
	  b.SetBounds(20, 20, 0, 60);
	  b.BandType := btpageheader;
    Page.Objects.Add(b);


    v := rmCreateObject(gtMemo, '');
	  v.SetBounds(20,40, 600, 32);
	  v.Memo.Add(title_rep);
    TrmMemoView(v).Font.Name:='黑体';
    TrmMemoView(v).Font.Size:=14;
    TrmMemoView(v).BandAlign:=rmbacenter;
    Page.Objects.Add(v);

    b := TrmBandView(rmCreateObject(gtBand, ''));
	  b.SetBounds(20, 140, 20, 68);
	  b.BandType := btMasterData;
	  b.Dataset := 'rmDBDataSet1';
	  Page.Objects.Add(b);

    gz_x:=40;

   for I:=0 to gz.FieldCount-1 do
      begin
       gz_xm:=gz.Fields[i].FieldName;
       gzjg.locate('项目',gz_xm,[loCaseInsensitive]);
      if gzjg.FieldByName('是否打印').asstring='Y' then
       begin

        if (gz_xm='科室') or (gz_xm='姓名') then fie_len:=40 else
        begin
         with chd do
          begin
           close;
           sql.Clear;
           sql.add('select sum('+gz_xm+') from '+table_name);
           open;
          end;
         fie_len:=length(formatfloat('0.00',chd.Fields[0].asfloat))*6;
          if fie_len<40 then fie_len:=40;
            if odd(fie_len)=false then fie_len:=fie_len+1;

        end;


          v := rmCreateObject(gtMemo, '');
      	  v.SetBounds(gz_x,140,fie_len, 32);
	        v.Memo.Add(gz_xm);
          v.Prop['WordWrap']:=true;
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          TrmMemoView(v).Alignment:=rmtamiddle+rmtacenter;
      	  Page.Objects.Add(v);


          v := rmCreateObject(gtMemo, '');
	        v.SetBounds(gz_x,172, fie_len, 16);
	        v.Memo.Add('[gz."'+gz_xm+'"]');
          TrmMemoView(v).Font.Name:='宋体';
          TrmMemoView(v).Font.Size:=9;
          v.TopFrame.Visible:=true;v.BottomFrame.Visible:=true;v.rightFrame.Visible:=true;v.LeftFrame.Visible:=true;
          if gz.Fields[i].DataType in [ftFloat,ftCurrency,ftBCD] then
           begin
            TrmMemoView(v).Format:=1 * $01000000 + 4 * $00010000+2*$00000100;
            TrmMemoView(v).Format := TrmMemoView(v).Format + Ord('.');
            TrmMemoView(v).FormatStr:='0.00';
           end;
          if (gz_xm='科室') or (gz_xm='姓名') then TrmMemoView(v).Alignment:=rmtamiddle
            else TrmMemoView(v).Alignment:=rmtamiddle+rmtaright;
      	  Page.Objects.Add(v);

         gz_x:=gz_x+fie_len;
        end;
      end;


	  rmReport1.ShowReport;


end;

procedure Tmain.ADOTable1AfterPost(DataSet: TDataSet);
begin
combobox3.items.clear;
combobox3.items.add('全部人员');
adotable1.First;
while adotable1.eof=false do
begin
combobox3.items.add(adotable1.Fields[1].asstring);
adotable1.Next;
end;
combobox3.ItemIndex:=0;
end;

end.

⌨️ 快捷键说明

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