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

📄 pub_rep.pas

📁 工程预算系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
unit pub_rep;

interface

uses
    Windows, Messages, Variants, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    Db, ADODB, ImgList, StdCtrls, Buttons, ComCtrls, dbctrls, menus,
    Math,ComObj,Gauges,grids,DBGrids,pubunit,Contnrs,printers, FR_Class,DBGridEh,
    hu_pub,Types,OleCtrls,ExtCtrls,FR_View;
type
  TDocMode = (dmDesigning, dmTable , dmprintcoutin);  //打印,预览报表时是什么模式,设计、从表读数据
  TdmAllrcj = (dmAllrcj,dmJc);  //创建报表是 是人材机还是价差
  TRepMode = (dmcoutin,dmsingl);  //报表方法(连打、单独打)
  TModifyMode = (dmUpdate,dmAdd);
 
 //从表中取得报表的基本信息
  procedure getxx(strid:string);
 //给stringgrid赋值
  procedure setxx(strid:string;mygrid:TStringGrid);
 {取得万用表的数据}
  procedure getwyb(strid:string);
 {取得自由表的数据}
  procedure getzyb(strid:string);
{以下开始是对报表信息的处理,包括表头,表头字体,页眉、页脚}
  {取得对齐方式}
  function getalignment(mygrid:TStringGrid;nr:integer):integer;
  {取得报表的表头标题列的名称}
  function gettitle(str:string):string;
  {取得报表标题向上的高度系数}
  function getheightup(str:string):integer;
  {取得报表标题向下的高度系数}
  function getheightdown(str:string):integer;
  {取得报表标题向左的宽度系数}
  function getwidthl(str:string):integer;
  {取得报表标题向右的宽度系数 }
  function getwidthr(str:string):integer;
  {取得报表行的左边距}
  function getdisl(mygrid:TStringGrid;nc,nr:integer;nleft:integer;b_xh:boolean):integer;
  {取得报表的标题行的高度                              行高                   }
  function getheight(mygrid:TStringGrid;nc,nr:integer;ntmp:integer):integer;
  {取得报表向上离纸的高度}
  function gettopdis(mygrid:TStringGrid;nc,nr:integer;ntmp:integer;ntop:integer):integer;
  {取得表头行的宽度}
  function getwidth(mygrid:TStringGrid;nc,nr:integer;b_xh:boolean):integer;
  {计算报表总长度}
  function getl(mygrid:TStringGrid;nc:integer;nw:integer):integer;
  {计算表注部分的高度}
  function getup(str11,str12,str13,str21,str22,str23,str31,str32,str33:string):integer;
  {表头总高度}
  function gethead(mygrid:TStringGrid;ntmp:integer):integer;
  {纸的宽度}
  function getpagew(nw:integer;b_xh:boolean):integer;
  {报表的高度}
  function getpageh(nh:integer;b_xh:boolean):integer;
  {取得报表标题的frametyp}
  function getframetyp(str:string):integer;
  {取的表注部分字符串}
  function getstr(str:string):string;
  {创建报表标题表注部分}
  procedure creatbt(frrep:TfrReport;npage:integer;mygrid:TStringGrid);
  {创建表注下}
  procedure createbzx(frrep:TfrReport;npage:integer;nup:integer);
  {创建报表表头标题部分}
  procedure createbt(frrep:TfrReport;npage:integer;mygrid:TStringGrid);
  {取得计算表的数据}
  procedure getjsb;
  {取得计算表中竖排表的数据}
  procedure gethjsb;
  {取得人材机数据}
  procedure getrcj;
  {取得动态费率数据}
  procedure getdtfl(b_falg:boolean);
  {取得字体名称}
  function getzt(ntmp:integer):string;
  {字号}
  function getzh(ntmp:integer):integer;
  {对齐方式}
  function getdj(ntmp:integer):integer;
  {左边距}
  function getlbj(ntmp:integer):integer;
  {上边距}
  function getsbj(ntmp:integer):integer;
  {取得字符串}
  function getfmstr(ntmp:integer):string;
  {取得颜色}
  function getys(ntmp:integer):integer;
  {是否有下划线}
  function getxhx(ntmp:integer):string;
  {替换字符串}
  function resetstr(str:string):string;
  {报表换行的依据}
  function getlinecount(str:string;ntmp:integer):integer;
  {计算人材机报表表达的值}
  function calrcj(i:integer;mygrid:TStringGrid;ncol:integer):string;
  {创建人材机报表}
  procedure creatercjbb(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;IsAllrcj:TdmAllrcj;dmrepmode:TRepMode;npage:integer;strselectid,strselectbh:string);  //创建报表
  {创建自由表}
  procedure createzybbb(frrep:TfrReport;dmrepmode:TRepMode;npage:integer);                           //创建报表
  {计算万用表表达式}
  function calwyb(i:integer;mygrid:TStringGrid;ncol:integer):string;
  {创建万用表}
  procedure createwybbb(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;dmrepmode:TRepMode;npage:integer;strselectid:string); //创建报表
  {计算取费报表表达的值}
  function calqf(i:integer;mygrid:TStringGrid;ncol:integer):string;
  {取得取费表的数据}
  procedure getqf(strtemp:string);
  {创建取费报表}
  procedure createqfbb(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;dmrepmode:TRepMode;npage:integer;strselectid,strselectbh:string); //创建报表
  {}
  function gettotalhj(str:string;i:integer):real;
  {}
  function exchangezu(A,B:Tjc_rcj;j:integer):Tjc_rcj;
  {}
  procedure rcjhj(i:integer;templist:Tobjectlist);
    {取得价差数据}
  procedure getjc(strtemp:string);
  {计算费率报表表达的值}
  function calfl(i:integer;mygrid:TStringGrid;ncol:integer):string;
  function comparestr(str:string;ntemp,nitem:integer;b_falg:boolean):string;
  procedure setdtfl;
  {创建动态费率报表}
  procedure createdtflbb(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;dmrepmode:TRepMode;npage:integer;strselectid:string); //创建报表
  {取得计算表数据格式}
  procedure exchangejsb(A:Tjc_rcj;i,j:integer);
  {}
  procedure setjsb;
  {计算}
  function caljsb(i:integer;mygrid:TStringGrid;ncol:integer):string;
  {排序}
  procedure Quicksort_rcj(var A:Tobjectlist;iLo,iHi:integer);
  {取得每条定额的人材机}
  procedure geteachrcj(str:string);
  {计算每条定额的人材机}
  function caleachrcj(i:integer;mygrid:TStringGrid;ncol:integer):string;
  {取得最大数}
  function getmaxstr(nmax,ntemp:integer;str:string):integer;
  {创建单价分析表格}
  procedure createdjfxbb(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;dmrepmode:TRepMode;npage:integer;strselectid:string);  //创建报表
  {开始创建计算表}
  procedure createjsbbb(frrep:TfrReport;mygrid:TStringGrid;dmDocMode:TDocMode;dmrepmode:TRepMode;npage:integer;strselectid:string);   //创建报表
  {创建计算表报表表头标题部分}
  procedure createjsbbt(frrep:TfrReport;npage:integer;ntmp:integer;mygrid:TStringGrid);
  {创建计算表竖排合计}
  procedure createhhj(frrep:TfrReport;npage,ntop,nheight:integer;str:string);
  {取得定额人材机数据}
  procedure getdercj;
  {计算高度}
  function calhgd(ntmp:integer):integer;
  {报表过程}
  procedure buildhbt(frrep:TfrReport;npage,nleft,ntop,nwidth,nheight:integer;str:string);
  {排序}
  procedure tmp_sort(var A:Tobjectlist;iLo,iHi:integer);
  {取得固定量的人材机}
  procedure getgdrcj(i:integer);
  {创建竖排表}
  procedure createhjsbbb(frrep:TfrReport;mygrid:Tstringgrid;dmrepmode:TRepMode;npage:integer);     //创建报表
  {字符转换为浮点}
  function exchangestr(str:string):real;
  {保存版本信息}
  function savepbxx(datarecord:Trcjdatarecord):Trcjdatarecord;
  {保存报表基本信息}
  function savebbjbxx(datarecord:Trcjdatarecord;nfalg:integer):Trcjdatarecord;
  {保存报表打印信息}
  function savebbdyxx(datarecord:Trcjdatarecord;nfalg:integer):Trcjdatarecord;
  {取得行号}
  function getgridrow(str:string):integer;
  {取得行宽}
  function getgridcolwidth(str:string):integer;
  {取得标题}
  function getgridstr(str:string):string;
  {将文件结构的内容按指定的格式读入到stringgrid中}
  procedure readfiles(mygrid:Tstringgrid;datarecord:Trcjdatarecord;nr:integer);
  {所有表格另存为}
  procedure saveallbg;
  {打开报表模板}
  procedure operallbg;
  {将stringgrid的内容按指定的格式存入文件结构中}
  function savetomyfilebb(mystring:Tstringgrid;datarecord:Trcjdatarecord;r:integer;flag:integer):Trcjdatarecord;
  {在一个字符串中用|替代回车键}
  function replacehome(str:string):string;
  procedure dygcxx(frrep:TfrReport);
  {给工程信息,工程数据值}
  procedure setvalues(mygrid:TStringgrid);
  {提取所有人才机数据}
  procedure getallrcj(mygrid:Tstringgrid);  //在万用表中用到
  //True为打印,False为预览
  procedure Report_Print(vType:integer;vfrReport:TfrReport;Print_PrVw:Boolean);
  //
  procedure Report_P(vfrReport:TfrReport;frPre: TfrPreview);       //True为打印,False为预览

  type
    Trcj=class(Tobject)
      xh:string;
      r_ID:integer;   //序号 主键 与随机生成的ID对应
   // list_ID:integer; //内部编号  每条定额的人材机都有自已的内部编号
      r_bh:string;    //编号 与定额库的ID对应
      r_mc:string;    //名称
      r_unit:string;  //单位
      r_dj:currency;     //单价
      r_market:currency;  //市场单价
      r_hl:real;      //含量
      r_sl:real;       //数量
      r_calu:string;  //计算公式
      r_order:integer;  //用于显示是否此条记录是否被替换
      r_type:byte;   //所属分类
      R_fj:integer;  //是否分解  1为分解,0为末分解
      R_isjj:integer;  // 是否是基价 1为基价的前7行固定数据
    end;
type
  Trcjj=class(Tobject)    //create by hyde at 2004-04-08
    xh:string;
    r_ID:integer;   //序号 主键 与随机生成的ID对应
   // list_ID:integer; //内部编号  每条定额的人材机都有自已的内部编号
    r_bh:string;    //编号 与定额库的ID对应
    r_mc:string;    //名称
    r_unit:string;  //单位
    r_dj:currency;     //单价
    r_market:currency;  //市场单价
    r_hl:real;      //含量
    r_sl:real;       //数量
    r_calu:string;  //计算公式
    r_order:integer;  //用于显示是否此条记录是否被替换
    r_type:byte;   //所属分类
    R_fj:integer;  //是否分解  1为分解,0为末分解
    R_isjj:integer;  // 是否是基价 1为基价的前7行固定数据
  end;

type
  PDataqf= ^TDataqf; //指针,用于给TreeView.TreeNode.Data赋值
  TDataqf = record
  pname:string;
  dh:string;
  end;

type
  PDatajc= ^TDatajc; //指针,用于给TreeView.TreeNode.Data赋值
  TDatajc = record
  pname:string;
  dh:string;
  end;
var
  array_jbxx:array[1..50] of string;   //用于保存报表的基本信息(即报表中的公共属性)
  array_dyxx:array[1..40] of string;   //用于保存报表的其他打印信息(不同报表类型所有的)
  r:array[1..50] of real;              //用于统计数组
  array_rcjbl:array[1..50] of string;
  wyblist:Tobjectlist;
  zyblist:Tobjectlist;
  jsblist:Tobjectlist;
  rcjlist:Tobjectlist;
  dtfllist:TObjectList;
  qflist:TobjectList;
  djfxlist:TObjectlist;
  rclist:Tobjectlist;
  dercj:TobjectList;
  tmprcjlist:TObjectList;
  b_frist:boolean;
  array_gcxx:array[1..100] of string;
  array_gcsj:array[1..100] of string;
  npagecount:integer;     //计算总页数
  npagetmp:integer;   //当前页
  rep_type:integer;          //报表类型
  str_bbdw:TStrings;         //报表单位

implementation
  uses ys,MAIN,Hu_jsfy,MyPreView,F_qdfm;

{从表中取得报表的基本信息}
procedure getxx(strid:string);
var
  strSQL:string;
  i:integer;
begin
  for i:=1 to 50 do
    array_jbxx[i]:='';
  for i:=1 to 40 do
    array_dyxx[i]:='';
  strSQL:='select * from repinfo where id='+strid;
  RunSQL((getactiveform as TFrm_ys).ADOQry_rep,strSQL,0);
  array_jbxx[1]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Titelvisible').AsInteger);
  array_jbxx[2]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('PaperHeight').AsInteger);
  array_jbxx[3]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('PHUnderLine').AsInteger);
  array_jbxx[4]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('LeftMargin').AsInteger);
  array_jbxx[5]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('TopMargin').AsInteger);
  array_jbxx[6]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('RightMargin').AsInteger);
  array_jbxx[7]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('BottomMargin').AsInteger);
  array_jbxx[8]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Pagedirect').AsInteger);
  array_jbxx[9]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('LTitle1').AsString;
  array_jbxx[10]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Ltitle2').AsString;
  array_jbxx[11]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Ltitle3').AsString;
  array_jbxx[12]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('mtitle').AsString;
  array_jbxx[13]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('stitle').AsString;
  array_jbxx[14]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('mtitlename').AsString;
  array_jbxx[15]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('mtitlesize').AsInteger);
  array_jbxx[16]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('mtitlecolor').AsInteger);
  array_jbxx[17]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Rtitle1').AsString;
  array_jbxx[18]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Rtitle2').AsString;
  array_jbxx[19]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Rtitle3').AsString;
  array_jbxx[20]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Head1').AsString;
  array_jbxx[21]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Head2').AsString;
  array_jbxx[22]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Head3').AsString;
  array_jbxx[23]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Foot1').AsString;
  array_jbxx[24]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Foot2').AsString;
  array_jbxx[25]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Foot3').AsString;
  array_jbxx[26]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up11').AsString;
  array_jbxx[27]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up12').AsString;
  array_jbxx[28]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up13').AsString;
  array_jbxx[29]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up21').AsString;
  array_jbxx[30]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up22').AsString;
  array_jbxx[31]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up23').AsString;
  array_jbxx[32]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up31').AsString;
  array_jbxx[33]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up32').AsString;
  array_jbxx[34]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Up33').AsString;
  array_jbxx[35]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down11').AsString;
  array_jbxx[36]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down12').AsString;
  array_jbxx[37]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down13').AsString;
  array_jbxx[38]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down21').AsString;
  array_jbxx[39]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down22').AsString;
  array_jbxx[40]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down23').AsString;
  array_jbxx[41]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down31').AsString;
  array_jbxx[42]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down32').AsString;
  array_jbxx[43]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Down33').AsString;
  array_jbxx[44]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Rowcount').AsInteger);
  array_jbxx[45]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('Colcount').AsInteger);
  array_jbxx[46]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('bwhj').AsInteger);
  array_jbxx[47]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('zdsx').AsInteger);
  array_jbxx[48]:=inttostr((getactiveform as TFrm_ys).ADOQry_rep.FieldByName('gridh').AsInteger);

  strSQL:='select * from repotherinfo where id='+strid;
  RunSQL((getactiveform as TFrm_ys).ADOQry_rep,strSQL,0);
  array_dyxx[1]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep1').AsString;
  array_dyxx[2]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep2').AsString;
  array_dyxx[3]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep3').AsString;
  array_dyxx[4]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep4').AsString;
  array_dyxx[5]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep5').AsString;
  array_dyxx[6]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep6').AsString;
  array_dyxx[7]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep7').AsString;
  array_dyxx[8]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep8').AsString;
  array_dyxx[9]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep9').AsString;
  array_dyxx[10]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep10').AsString;
  array_dyxx[11]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep11').AsString;
  array_dyxx[12]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep12').AsString;
  array_dyxx[13]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep13').AsString;
  array_dyxx[14]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep14').AsString;
  array_dyxx[15]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep15').AsString;
  array_dyxx[16]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep16').AsString;
  array_dyxx[17]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep17').AsString;
  array_dyxx[18]:=(getactiveform as TFrm_ys).ADOQry_rep.FieldByName('rep18').AsString;

⌨️ 快捷键说明

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