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

📄 qd_rep.pas

📁 工程预算系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  if Trim(array_jbxx[43])<>'' then
  begin
    v:=TfrMemoView.Create;
    nw:=getqdw(getqdzt(array_dyxx[8]),getstr(array_jbxx[43]),getqdzh(array_dyxx[9]));
    nh:=getqdh(getqdzt(array_dyxx[8]),getstr(array_jbxx[43]),getqdzh(array_dyxx[9]));
    v.SetBounds(nwidth-nmax+nleftdis,nup+71,nw,nh);
    v.Font.Name:=getqdzt(array_dyxx[8]);
    v.Font.Size:=getqdzh(array_dyxx[9]);
    v.Font.Color:=getqdys(array_dyxx[10]);
    v.Memo.Add(getstr(array_jbxx[43]));
    page.Objects.Add(v);
  end;
end;

{创建报表表头标题部分}
procedure createqdbtbb(frrep:TfrReport;npage:integer;mygrid:TStringGrid);
var
  v:TfrMemoView;
  page:TfrPage;
  i,j:integer;
  strl,strt,strw,strh:integer;
  nleftdis,ntopdis,ntop,nhheight:integer;
  nh:integer;
  nrowcount:integer;
  ntemp:integer;
  nw:integer;
  strname:string;
  nzh,ncolor:integer;
begin
  strname:=getqdzt(array_dyxx[11]);
  nzh:=getqdzh(array_dyxx[12]);
  ncolor:=getqdys(array_dyxx[13]);

  ntemp:=0;
  for i:=0 to mygrid.ColCount-1 do
    ntemp:=ntemp+mygrid.ColWidths[i];

  if Trim(array_jbxx[1])='1' then               //表头框架的宽度
    nw:=ntemp
  else
    nw:=ntemp-mygrid.ColWidths[0];

  page:=frrep.Pages.Pages[npage];
  nleftdis:=strtoint(array_jbxx[4])*3;
  ntopdis:=strtoint(array_jbxx[5])*3;
  nh:=getup(array_jbxx[26],array_jbxx[27],array_jbxx[28],array_jbxx[29],array_jbxx[30],array_jbxx[31],array_jbxx[32],array_jbxx[33],array_jbxx[34]);
  ntop:=ntopdis+60+nh;
  nhheight:=gethead(mygrid,strtoint(array_jbxx[48]));
  nrowcount:=mygrid.RowCount;

  v:=TfrMemoView.Create;
  v.SetBounds(nleftdis,ntop,nw,nhheight);
  v.FrameTyp:=15;
  page.Objects.Add(v);
//创建序号
  if Trim(array_jbxx[1])='1' then
  begin
    if nrowcount=6 then
    begin
      v:=TfrMemoView.Create;
      v.SetBounds(nleftdis,ntop,mygrid.ColWidths[0],nhheight);
      v.Alignment:=10;
      v.FrameTyp:=15;
      v.Font.Name:=strname;
      v.Font.Size:=nzh;
      v.Font.Color:=ncolor;
      v.Memo.Add('序号');
      page.Objects.Add(v);
    end
    else if nrowcount>6 then
    begin
      v:=TfrMemoView.Create;
      v.SetBounds(nleftdis,ntop,mygrid.ColWidths[0],nhheight);
      v.Alignment:=10;
      v.FrameTyp:=15;
      v.Font.Name:=strname;
      v.Font.Size:=nzh;
      v.Font.Color:=ncolor;
      v.Memo.Add('序'#13'号');
      page.Objects.Add(v);
    end;
  end;
////  创建完序号
  for i:=5 to strtoint(array_jbxx[44])+4 do
  begin
    for j:=1 to strtoint(array_jbxx[45])-1 do
    begin
      if mygrid.Cells[j,i]<>'' then
      begin
        v:=TfrMemoView.Create;
        if Trim(array_jbxx[1])='1' then
        begin
          strl:=getdisl(mygrid,j,i,nleftdis,True);
          strt:=gettopdis(mygrid,j,i,strtoint(array_jbxx[48]),ntop);
          strw:=getwidth(mygrid,j,i,True);
          strh:=getheight(mygrid,j,i,strtoint(array_jbxx[48]));
        end
        else
        begin
          strl:=getdisl(mygrid,j,i,nleftdis,False);
          strt:=gettopdis(mygrid,j,i,strtoint(array_jbxx[48]),ntop);
          strw:=getwidth(mygrid,j,i,False);
          strh:=getheight(mygrid,j,i,strtoint(array_jbxx[48]));
        end;
        v.SetBounds(strl,strt,strw,strh);
        v.Alignment:=10;
        v.FrameTyp:=getframetyp(mygrid.Cells[j,i]);
        v.Font.Name:=strname;
        v.Font.Size:=nzh;
        v.Font.Color:=ncolor;
        v.Memo.Add(gettitle(mygrid.Cells[j,i]));
        page.Objects.Add(v);
      end;
    end;
  end;
//创建完表头
end;


{创建自由表}
procedure rep_qdfm(frrep:TfrReport;dmrepmode:TRepMode;npage:integer);
var
  v:TfrMemoView;              //文本框
  page:TfrPage;               //纸
  i:integer;
  lzyb:Tjc_rcj;
  nw,nh:integer;
begin
  if dmrepmode = dmsingl then
  begin
    frrep.Clear;
    frrep.Pages.Clear;
    npagecount:=1;
    npagetmp:=0;
  end;

  frrep.Pages.Add;
  page:=frrep.Pages.Pages[npage];
  inc(npagetmp);
  if Trim(array_jbxx[8])='0' then      //判断是否是纵向打印
    page.ChangePaper(9,1069,756,65535,poLandscape);

  for i:=0 to zyblist.Count-1 do
  begin
    lzyb:=Tjc_rcj(zyblist.Items[i]);
    if (Trim(lzyb.column7)<>'') or (Trim(lzyb.column9)<>'') then
    begin
      mainform.l_label.Canvas.Font.Name:=getzt(i);
      mainform.l_label.Canvas.Font.Size:=getzh(i);
      nw:=mainform.l_label.Canvas.TextWidth(getstr(getfmstr(i)))+10;
      nh:=mainform.l_label.Canvas.TextHeight(getstr(getfmstr(i)))+7;

      v:=TfrMemoView.Create;
      v.SetBounds(getlbj(i),getsbj(i),nw,nh);
      v.Font.Name:=getzt(i);
      v.Font.Size:=getzh(i);
      v.Font.Color:=getys(i);
      v.Alignment:=getdj(i);
      if getxhx(i)='√' then
        v.FrameTyp:=2
      else
        v.FrameTyp:=0;
      v.Memo.Add(getstr(getfmstr(i)));
      page.Objects.Add(v);
    end;
  end;
end;

{取得工程清单数据}
procedure getgcqdlist(mygrid:TStringGrid);
var
  lgcqd:Trcjdatarecord;
  lrcj:Tjc_rcj;
  nr,nc,k,ncol:integer;
  str,strbh:string;
  ncount:integer;  //取得清单*号的个数
  ntmp:integer;   //清单的序号
begin
{说明如果是有*号,类型是清单的才是清单,falgd标志0清单1项目2是合计
  column[1]是清单的序号}
  gcqdlist:=TObjectList.Create(True);
  gcqdlist.Clear;
  ntmp:=1;
  for nr:=2 to mygrid.RowCount-2 do
  begin
    str:=Trim(mygrid.Cells[4,nr]);
    if Trim(str)<>'' then
    begin
      if str[1]='*' then
      begin
        if Trim(mygrid.Cells[5,nr])='清单' then
        begin
          ncount:=0;
          for k:=1 to length(str) do
          begin
            if str[k]='*' then
              ncount:=ncount+1
            else
              break;
          end;//end for
          strbh:=copy(str,ncount+1,Length(str)-ncount);
          lrcj:=Tjc_rcj.Create;
          lgcqd.flag:=0;
          lgcqd.column[1]:=inttostr(ntmp);    //序号
          lgcqd.column[2]:=Trim(mygrid.Cells[1,nr]);  //随机ID
          lgcqd.column[3]:=Trim(mygrid.Cells[2,nr]); // 关联ID
          lgcqd.column[4]:=Trim(mygrid.Cells[3,nr]); // 系数说明
          lgcqd.column[5]:=strbh; //  编号
         // lgcqd.column[3]:=strbh;
          for ncol:=5 to mygrid.ColCount-1 do
            lgcqd.column[ncol+1]:=Trim(mygrid.Cells[ncol,nr]);
          readfromfile(lrcj,lgcqd);
          gcqdlist.Add(lrcj);
          inc(ntmp);
        end
        else
        begin
          lrcj:=Tjc_rcj.Create;
          lgcqd.flag:=1;
          lgcqd.column[1]:='';
          for ncol:=1 to mygrid.ColCount-1 do
            lgcqd.column[ncol+1]:=Trim(mygrid.Cells[ncol,nr]);
          readfromfile(lrcj,lgcqd);
          gcqdlist.Add(lrcj);
        end;
      end; //end if pos
    end;    //end <>''
  end;    //end for
  if Trim(array_jbxx[46])='1' then  //合计
  begin
    lrcj:=Tjc_rcj.Create;
    lgcqd.flag:=2;
    lgcqd.column[1]:='';
    for nc:=1 to mygrid.ColCount-1 do
      lgcqd.column[nc+1]:=Trim(mygrid.Cells[1,nc]);
    readfromfile(lrcj,lgcqd);
    lrcj.column5:='';
    lrcj.column10:='合计';
    gcqdlist.Add(lrcj);
  end;
end;

{创建分部分项工程量清单}
procedure creatgcqd(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;dmrepmode:TRepMode;npage:integer;strselectid:string);
var
  v:TfrMemoView;
  page:TfrPage;
  i,j,k:integer;
  ntopdis,nleftdis,nbottomdis:integer;//报表上,下,左,右边距的值
  dy:integer;                                //报表纸张的宽度和高度
  nh,nb:integer;                                   //标题离纸的高度
  ntop:integer;                                //表头离纸的高度
  nbottomtop:integer;                          //纸张表注部分所占的高度
  nhheight:integer;                           //表头边框的高度
  rcj:Tjc_rcj;
  ntup:integer;
  ntempcount:integer;
  nmin,nmax:integer;
  nht:integer;
  ncol:integer;        //用于本页小计用
  b_frist:boolean;
  ntmppage:integer;
begin
  if dmDocMode = dmTable then
  begin
    getxx(strselectid);  //取得报表基本信息
    setxx(strselectid,mygrid);   //给临时的grid赋值
  end
  else if dmDocMode = dmDesigning then
    frm_qdfm.getfmxx;

  case rep_type of
    11: getqd_xmlist((getactiveform as Tfrm_ys).StringGrid1); //清单编辑
    12: getqd_xmlist((getactiveform as Tfrm_ys).StringGrid1);  //措施项目
  end;

  if array_dyxx[17]='1' then
  begin
    creatgcqdjsb1(frrep,mygrid,dmrepmode,npage);
  end
  else
  begin
    nht:=strtoint(array_jbxx[48]);
    ntopdis:=strtoint(array_jbxx[5])*3;
    nbottomdis:=strtoint(array_jbxx[7])*3;
    nleftdis:=strtoint(array_jbxx[4])*3;

    nhheight:=gethead(mygrid,strtoint(array_jbxx[48]));

    if Trim(array_jbxx[8])='1' then
      dy:=getpageh(0,True)
    else
      dy:=getpageh(0,False);

    nh:=getup(array_jbxx[26],array_jbxx[27],array_jbxx[28],array_jbxx[29],array_jbxx[30],array_jbxx[31],array_jbxx[32],array_jbxx[33],array_jbxx[34]);
    nb:=getup(array_jbxx[35],array_jbxx[38],array_jbxx[41],array_jbxx[36],array_jbxx[39],array_jbxx[41],array_jbxx[37],array_jbxx[40],array_jbxx[43]);

    ntop:=ntopdis+60+nh;                    //表头开始离纸的高度
    nbottomtop:=dy-nbottomdis-nb;           //作为换页的依据;
    ntmppage:=0;   ntempcount:=0;
    while ntempcount<=gcqdlist.Count do
    begin
      ntup:=ntop+nhheight;
      for i:=ntempcount to gcqdlist.Count-1 do
      begin
        nmax:=1;
        for j:=1 to mygrid.ColCount-1 do
        begin
          nmin:=getlinecount(calgclqd(i,mygrid,j),mygrid.ColWidths[j]);
          if nmin>nmax then
            nmax:=nmin;
        end;
        if array_jbxx[46]='1' then
        begin
          if i+1=gcqdlist.Count-1 then    //创建本页小计  因为记录不够,那就在合计前
          begin
            if array_dyxx[1]='1' then
            begin
              ntup:=ntup+nht*nmax;
              nmax:=1;
            end;
          end;
        end;
        ntup:=ntup+nht*nmax;
        if ntup+50>nbottomtop then
          break;
      end;
      ntempcount:=i+1;
      inc(ntmppage);
    end;

    if dmrepmode = dmsingl then
    begin
      frrep.Clear;
      frrep.Pages.Clear;
      npagecount:=ntmppage;
      npagetmp:=0;
    end;
    
    b_frist:=False;
    ntempcount:=0;
    while ntempcount<=gcqdlist.Count do
    begin
      for k:=1 to 40 do
        array_hj[k]:=0;
      frrep.Pages.Add;
      page:=frrep.Pages.Pages[npage];
      if Trim(array_jbxx[8])='0' then      //判断是否是纵向打印
        page.ChangePaper(9,1069,756,65535,poLandscape);
      //创建表头
      npagetmp:=npagetmp+1;

⌨️ 快捷键说明

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