ScReportsFrm.pas 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977
  1. {*******************************************************************************
  2. 单元名称: ScReportsFrm.pas
  3. 单元说明: 因报表相关单元使用_ScEncrypt编译变量,为了能直接使用SmartCost中的
  4. 报表相关单元文件,现将本系统中所有编译变量_beEncrypt换成_ScEncrypt
  5. 作 者: 康彤
  6. 修 改 人: Chenshilong, 2011-07-13
  7. *******************************************************************************}
  8. // chenshilong, 2011-07-13
  9. unit ScReportsFrm;
  10. interface
  11. {$IFDEF _beEncrypt}
  12. {$DEFINE _ScCanPrint}
  13. {$ENDIF}
  14. {$IFDEF _ScBidder}
  15. {$DEFINE _ScCanPrint}
  16. {$ENDIF}
  17. {$IFDEF _ScOnline}
  18. {$DEFINE _ScCanPrint}
  19. {$ENDIF}
  20. uses
  21. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  22. Dialogs, dxBar, ImgList, dxBarExtItems, ExtCtrls, DB, Printers,WinSpool,
  23. ExTreeView, PrintCom, PrintComXML, PrintComTypeDefUnit, IniFiles, ScProgressFrm,
  24. ScFileArchiver, Menus, StdCtrls,
  25. {$IFDEF _beEncrypt}
  26. ScEncryptUnit,
  27. {$ENDIF}
  28. // zy
  29. ScUtils, ScConsts, ScReportUtils, ADODB, DirectPrintUnit,
  30. ScWorkListFrm, Grids, DBGrids, ScProjectManager, ScReportDM;
  31. const
  32. crMyIdxNext = -25;
  33. crMyIdxPrevious = -26;
  34. crMyIdxFirst = -27;
  35. crMyIdxLast = -28;
  36. type
  37. // lsm
  38. ScCompareType = (CompareBills, CompareMaterial, CompareRation);
  39. TScReportsForm = class(TForm)
  40. xdcTop: TdxBarDockControl;
  41. xmReports: TdxBarManager;
  42. xlbPrint: TdxBarLargeButton;
  43. ilstLarge: TImageList;
  44. xlbToExcel: TdxBarLargeButton;
  45. xlbOnePage: TdxBarLargeButton;
  46. xlbTwoPage: TdxBarLargeButton;
  47. xlbFourPage: TdxBarLargeButton;
  48. xcbPages: TdxBarCombo;
  49. xlbFirstPage: TdxBarLargeButton;
  50. xlbPrePage: TdxBarLargeButton;
  51. xlbNextPage: TdxBarLargeButton;
  52. xlbLastPage: TdxBarLargeButton;
  53. xlbSetup: TdxBarLargeButton;
  54. xlbClose: TdxBarLargeButton;
  55. xcbBillsItem: TdxBarCombo;
  56. extvReport: TExTreeView;
  57. Splitter1: TSplitter;
  58. ScrollBox1: TScrollBox;
  59. PreviewBox: TImage;
  60. PreviewComXML: TPrintComXML;
  61. xcbStartPage: TdxBarCombo;
  62. xcbEndPage: TdxBarCombo;
  63. xcbRptAfterModified: TdxBarButton;
  64. xlbRealSize: TdxBarLargeButton;
  65. sdOutputExcel: TSaveDialog;
  66. xccRptIsModified: TdxBarControlContainerItem;
  67. pnlRptIsModified: TPanel;
  68. rbRptBeforeModified: TRadioButton;
  69. rbRptAfterModified: TRadioButton;
  70. ilstTree: TImageList;
  71. xlbToPDF: TdxBarLargeButton;
  72. dxBarSubItem1: TdxBarSubItem;
  73. xlbPrintCurPage: TdxBarLargeButton;
  74. dxBarControlContainerItem1: TdxBarControlContainerItem;
  75. dxBarControlContainerItem3: TdxBarControlContainerItem;
  76. PaperSizePanel: TPanel;
  77. rdbtnA3: TRadioButton;
  78. rdbtnA4: TRadioButton;
  79. chkFillZero: TCheckBox;
  80. PopupMenu1: TPopupMenu;
  81. popMnuOutputData: TMenuItem;
  82. cbbPP: TdxBarCombo;
  83. pnlExcelMode: TPanel;
  84. chkExcelMode: TCheckBox;
  85. chkExcel2010: TCheckBox;
  86. procedure FormClose(Sender: TObject; var Action: TCloseAction);
  87. procedure xlbCloseClick(Sender: TObject);
  88. procedure FormResize(Sender: TObject);
  89. procedure FormShow(Sender: TObject);
  90. procedure xlbPrintClick(Sender: TObject);
  91. procedure xlbToExcelClick(Sender: TObject);
  92. procedure xlbOnePageClick(Sender: TObject);
  93. procedure xlbTwoPageClick(Sender: TObject);
  94. procedure xlbFourPageClick(Sender: TObject);
  95. procedure xlbFirstPageClick(Sender: TObject);
  96. procedure xcbPagesChange(Sender: TObject);
  97. procedure xlbPrePageClick(Sender: TObject);
  98. procedure xlbNextPageClick(Sender: TObject);
  99. procedure xlbLastPageClick(Sender: TObject);
  100. procedure xlbSetupClick(Sender: TObject);
  101. procedure PreviewBoxMouseDown(Sender: TObject; Button: TMouseButton;
  102. Shift: TShiftState; X, Y: Integer);
  103. procedure PreviewBoxMouseDownEx(Sender: TObject; Button: TMouseButton;
  104. Shift: TShiftState; X, Y: Integer);
  105. procedure FormCreate(Sender: TObject);
  106. procedure extvReportDblClick(Sender: TObject);
  107. procedure PreviewComXMLGetDataConnection(var ADOCon: TADOConnection);
  108. // 汇总项目要换ADOConnection, chenshilong, 2011-07-13
  109. procedure PreviewComXMLGetGatherProjDataConnection(var ADOCon: TADOConnection);
  110. procedure xcbStartPageCurChange(Sender: TObject);
  111. procedure xcbEndPageCurChange(Sender: TObject);
  112. procedure xcbPagesCurChange(Sender: TObject);
  113. procedure xlbRealSizeClick(Sender: TObject);
  114. procedure Splitter1Moved(Sender: TObject);
  115. procedure PreviewComXMLGetDatasetEvent(DatasetInfo: PDatasetInfoRec;
  116. var ADataset: TDataSet);
  117. procedure xcbRptAfterModifiedClick(Sender: TObject);
  118. procedure FlowDataPrintEvent(var Text: String;
  119. var FontInfo: TFontRec; FieldID: Integer; ARect: TRect; DC: TCanvas);
  120. procedure CrossDataPrintEvent(var Text: String;
  121. var FontInfo: TFontRec; FieldID: Integer; ARect: TRect; DC: TCanvas);
  122. procedure xmReportsClickItem(Sender: TdxBarManager;
  123. ClickedItem: TdxBarItem);
  124. procedure extvReportChanging(Sender: TObject; Node: TExTreeNode;
  125. var AllowChange: Boolean);
  126. procedure extvReportChange(Sender: TObject; Node: TExTreeNode);
  127. procedure PreviewComXMLCrossTabLabelShow(valIDX: Integer; var ExLeft,
  128. ExRight: Double; var isShow: Boolean; CrsTabShowType: Integer);
  129. procedure xlbToPDFClick(Sender: TObject);
  130. procedure xlbPrintCurPageClick(Sender: TObject);
  131. procedure xdcTopDblClick(Sender: TObject);
  132. procedure FormDestroy(Sender: TObject);
  133. procedure ReplaceSpecChar(var ShowText : String);
  134. procedure rdbtnA3Click(Sender: TObject);
  135. procedure rdbtnA4Click(Sender: TObject);
  136. procedure PreviewComXMLContentDisplay(var contentFontRec: TFontRec;
  137. dataType: Integer; isReading : boolean; DrawType : integer; isPrinting : boolean);
  138. procedure popMnuOutputDataClick(Sender: TObject);
  139. procedure chkFillZeroClick(Sender: TObject);
  140. procedure PreviewBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
  141. Y: Integer);
  142. procedure PreviewBoxMouseUp(Sender: TObject; Button: TMouseButton;
  143. Shift: TShiftState; X, Y: Integer);
  144. private
  145. { Private declarations }
  146. intPage : integer;
  147. intGroup : integer;
  148. intCntPerPage : integer;
  149. bShowNormal : boolean; //true是普通方式显示,false是强制1:1显示
  150. ExePath : string;
  151. //intOldX : integer;
  152. //intOldY : integer;
  153. //Tony Kang 2004-09-04----------------------------------------------------
  154. SpIDX : integer;
  155. //特殊指标
  156. //Tony Kang 2004-09-04-end------------------------------------------------
  157. intTimer : integer;
  158. {$IFNDEF _KTDebug}
  159. FProject: TProject;
  160. FGatherProject: TProject;
  161. FCurGatherProjRepName: string;
  162. {$ENDIF}
  163. strModified : string;
  164. //lt
  165. FRefCount: Integer;
  166. strConfigTxt : string;
  167. // zy
  168. FReportManager: TScReportManager;
  169. FWorkListForm: TScWorkListForm;
  170. // for mouse move usage
  171. FCurrentMouseP : TPoint;
  172. StartMoveRpt : boolean;
  173. isNarraw : boolean;
  174. bkContentFontHeight : integer;
  175. intCurStatus : integer;
  176. //0: normal, 1: next page, 2: previous page 3: first page, 4: last page
  177. // Chenshilong
  178. FHaveTempTabDivideCode: Boolean;
  179. FHaveTempTab01: Boolean;
  180. FHaveTempTab08: Boolean;
  181. FProjectPhase: TProjectPhase;
  182. FGatherProjectSL: TStringList;
  183. //lt 2010.3.25
  184. procedure IncRefCount;
  185. function IsNotRefCountAbove: Boolean;
  186. procedure DoWriteReportprogress(APosition: Integer; AMax: Integer = 0);
  187. procedure ReportPreview;
  188. procedure setupReport;
  189. procedure LoadReports;
  190. function IsEstimate1: Boolean;
  191. procedure setupPage(pageSize : String);
  192. procedure setPrinterOrientation();
  193. {$IFNDEF _KTDebug}
  194. procedure SetProject(const Value: TProject);
  195. {$ENDIF}
  196. procedure startMove(X, Y: Integer);
  197. procedure moveRpt(X, Y: integer);
  198. procedure endMove(X, Y: Integer);
  199. //procedure setDefaultExcelBorder(var Border : TColumnLineRec);
  200. // zhangyin
  201. procedure PreviewComXMLProgress(RptName: string; TotalPages: Integer; CurrentPage: Integer);
  202. public
  203. { Public declarations }
  204. ReportName : string;
  205. PreReportName : string;
  206. {$IFNDEF _KTDebug}
  207. property Project: TProject read FProject write SetProject;
  208. {$ENDIF}
  209. function GetProjectPhaseByName(AName: string): TProjectPhase;
  210. property CurGatherProjectReportName: string read FCurGatherProjRepName write FCurGatherProjRepName;
  211. end;
  212. var
  213. ReportsForm: TScReportsForm;
  214. // lsm
  215. CompareType: ScCompareType;
  216. procedure DisplayReports(AProject: TProject);
  217. //{$R PageRolling.res}
  218. implementation
  219. uses ReportAdjusterUnit, CommonMessages, MainForm, ScGatherProjFrm;
  220. const
  221. // 审核比较表DataSet
  222. CompareDataSetID = 1;
  223. // 审核比较表项目名称DataSet
  224. CompareNameDataSetID = 2;
  225. // 总汇总表DataSet
  226. GatherDataSetID = 3;
  227. // 总汇总表名称DataSet
  228. // GatherNameDataSetID = 4;
  229. // 总工料机汇总表DataSet
  230. GLJGatherDataSetID = 5;
  231. // 【03-2】建筑安装工程费审计表(黑龙江)
  232. HLJ_ComareBillsID = 10;
  233. // 【01-3】总预算审计表(黑龙江)01-3
  234. HLJ_ComareRationsID = 11;
  235. // 审核建设项目信息DataSet
  236. CompareBuildProjDataID = 100;
  237. // 汇总建设项目信息DataSet
  238. GatherBuildProjDataID = 101;
  239. // 总工料机汇总建设项目信息DataSet
  240. GLJGatherBuildProjDataID = 102;
  241. // 【03-2】建筑安装工程费审计表(黑龙江)
  242. HLJ_ComareBillsProjID = 110;
  243. // 【01-3】总预算审计表(黑龙江)01-3
  244. HLJ_ComareRationsProjID = 111;
  245. // lsm 新增汇总表
  246. // 汇总建设项目细目直接工程费DWF明细表DataSet
  247. GatheDWFDataSetID = 6;
  248. // 汇总DWF建设项目信息DataSet
  249. GatherDWFBuildProjDataID = 103;
  250. // 主材权重对比表
  251. CompareMaterialDataSetID = 7;
  252. // 主材权重对比项目名称DataSet
  253. CompareMaterialProjNamesID = 8;
  254. // 主材权重对比建设项目信息DataSet
  255. CompareMaterialProjDataID = 104;
  256. // 主材权重对比材料费、建安费信息DataSet
  257. CompareMaterialProjFeeID = 105;
  258. // 工料机权重汇总表DataSet
  259. GatherGLJPropDataSetID = 9;
  260. // 工料机权重汇总建设项目信息DataSet
  261. GatherGLJPropProjDataID = 106;
  262. // 单价偏差汇总表
  263. GatherEcoLineDataSetID = 12;
  264. // 单价偏差汇总项目名称DataSet
  265. GatherEcoLineProjDataID = 107;
  266. // 审核比较定额表(标表4-3格式)
  267. CompareRationDataSetID = 13;
  268. // 审核比较定额表汇总清单名称DataSet
  269. CompareRationBillDataID = 108;
  270. // 指标单价汇总表
  271. GatherUnitPriceDataSetID = 14;
  272. // 指标单价汇总项目名称DataSet
  273. GatherUnitPriceProjDataID = 109;
  274. // 指标单价汇总表(广东)
  275. GatherBillsUnitPriceDataSetID = 15;
  276. // 指标单价汇总(广东)项目名称DataSet
  277. GatherBillsUnitPriceProjDataID = 120;
  278. (*// 审核比较定额表(标表4-3格式) ProjNames
  279. CompareRationProjNamesID = 121;
  280. // 审核比较定额表(标表4-3格式) ProjData
  281. CompareRationBillProjDataID = 122; *)
  282. // 土地项目清单汇总表(广东)
  283. GatherGroundDataSetID = 16;
  284. // 土地项目清单汇总表(广东)项目名称DataSet
  285. GatherGroundProjDataID = 123;
  286. // 标表1汇总表(广东招预总01-2)
  287. GatherStandardOneDataSetID = 17;
  288. // 标表1汇总表(广东招预总01-2)项目名称DataSet
  289. GatherStandardOneProjDataID = 124;
  290. // 合同征拆总01表
  291. GatherGroundChapterDataSetID = 18;
  292. // 合同征拆总01表项目名称DataSet
  293. GatherGroundChapterProjDataID = 125;
  294. // 项目计日工清单汇总表(广东)
  295. GatherDatallerDataSetID = 19;
  296. // 项目计日工清单汇总表(广东)项目名称DataSet
  297. GatherDatallerProjDataID = 126;
  298. var
  299. CompareReportCount: Integer = 0;
  300. GathereReportCount: Integer = 0;
  301. GLJGatherCount: Integer = 0;
  302. HLJCompareBillsCount: Integer = 0;
  303. HLJCompareRationsCount: Integer = 0;
  304. // lsm
  305. GatheDWFReportCount: Integer = 0;
  306. CompareMateCount: Integer = 0;
  307. GatherGLJPropCount: Integer = 0;
  308. GatherEcoLineReportCount: Integer = 0;
  309. CompareRationReportCount: Integer = 0;
  310. GatherUnitPriceCount: Integer = 0;
  311. GatherGroundPriceCount: Integer = 0;
  312. GatherStandardOneCount: Integer = 0;
  313. GatherGroundChapterCount: Integer = 0;
  314. GatherDatallerCount: Integer = 0;
  315. procedure DisplayReports(AProject: TProject);
  316. begin
  317. ReportsForm := TScReportsForm.Create(nil);
  318. ReportsForm.Project := AProject;
  319. ReportsForm.ShowModal;
  320. end;
  321. {$R *.dfm}
  322. (*
  323. procedure TScReportsForm.setDefaultExcelBorder(var Border : TColumnLineRec);
  324. var FileName, ExePath : String;
  325. L_IniFile : TIniFile;
  326. begin
  327. ExePath := ExtractFilePath(Application.ExeName);
  328. FileName := ExePath + STR_CONFIG_TEXT;
  329. L_IniFile := TIniFile.Create(FileName);
  330. Border.LeftThick := 0.5;
  331. Border.TopThick := 0.5;
  332. Border.RightThick := 0.5;
  333. Border.BottomThick := 0.5;
  334. if (L_IniFile.ReadInteger('页面', '报表边框竖线', 0) = 0) then
  335. begin
  336. Border.LeftThick := 0;
  337. Border.RightThick := 0;
  338. end;
  339. L_IniFile.Free;
  340. end;
  341. *)
  342. procedure TScReportsForm.FormClose(Sender: TObject;
  343. var Action: TCloseAction);
  344. begin
  345. Action := caFree;
  346. end;
  347. procedure TScReportsForm.xlbCloseClick(Sender: TObject);
  348. begin
  349. Close;
  350. end;
  351. procedure TScReportsForm.FormResize(Sender: TObject);
  352. var intMaxHeight, intMaxWidth : integer;
  353. begin
  354. if Printer.Printers.Count = 0 then
  355. begin
  356. exit;
  357. end;
  358. if (bShowNormal) then
  359. begin
  360. if PreviewBox.Height <> ScrollBox1.ClientHeight then
  361. begin
  362. PreviewBox.Height := ScrollBox1.ClientHeight;
  363. PreviewBox.Picture.Bitmap.Height := ScrollBox1.ClientHeight;
  364. end;
  365. if PreviewBox.Width <> ScrollBox1.ClientWidth then
  366. begin
  367. PreviewBox.Width := ScrollBox1.ClientWidth;
  368. PreviewBox.Picture.Bitmap.Width := ScrollBox1.ClientWidth;
  369. end;
  370. end else
  371. begin
  372. intMaxHeight := PreviewComXML.PrintHeight + 20;
  373. if intMaxHeight < ScrollBox1.ClientHeight then
  374. intMaxHeight := ScrollBox1.ClientHeight;
  375. intMaxWidth := PreviewComXML.PrintWidth + 20;
  376. if intMaxWidth < ScrollBox1.ClientWidth then
  377. intMaxWidth := ScrollBox1.ClientWidth;
  378. if PreviewBox.Height <> intMaxHeight then
  379. begin
  380. PreviewBox.Height := PreviewComXML.PrintHeight + 20;
  381. PreviewBox.Picture.Bitmap.Height := PreviewBox.Height;
  382. end;
  383. if PreviewBox.Width <> intMaxWidth then
  384. begin
  385. PreviewBox.Width := PreviewComXML.PrintWidth + 20;
  386. PreviewBox.Picture.Bitmap.Width := PreviewBox.Width;
  387. end;
  388. end;
  389. ReportPreview;
  390. end;
  391. procedure TScReportsForm.ReportPreview;
  392. begin
  393. PreviewComXML.FillZero := chkFillZero.Checked;
  394. if bShowNormal then
  395. begin //普通显示
  396. PreviewComXML.PrintPreviewCanvas(-1,intGroup,PreviewBox.Canvas);
  397. end else
  398. begin //强制1:1显示
  399. PreviewComXML.PrintPreviewCanvas(intPage,0,PreviewBox.Canvas);
  400. end;
  401. end;
  402. // zy
  403. procedure TScReportsForm.LoadReports;
  404. var
  405. strVer, sRDir: string;
  406. begin
  407. sRDir := 'BillsEditorReports\*';
  408. FReportManager.LoadFromSRT(ExePath + sRDir + FILEEXT,
  409. '主版本=招投标版');
  410. end;
  411. procedure TScReportsForm.setupReport;
  412. var i,j,k : integer;
  413. douJ : double;
  414. intW : integer;
  415. FIni : TIniFile;
  416. strFileName : string;
  417. ObjList : TList;
  418. TitleRec : PTitleRec;
  419. ColumnRec : PColumnRec;
  420. FlowContentRec : PContentRec;
  421. CrossContentRec : PCrossContentRec;
  422. //CrossContentRec : PContentRec;
  423. SumRec : PSumRec;
  424. HeadTailRec : PHeadRec;
  425. ShapeRec : PPicRec;
  426. PageObj : PPageRec;
  427. AAR : PActiveAreaRec;
  428. SER : PShowElementRec;
  429. procedure setActAreaBorder(intSetType : integer; BorderWidth : double); //0:左右边框; 1: 上下边框; 2:竖线; 3:横线
  430. var i,k : integer;
  431. ActAreaRec : PActiveAreaRec;
  432. PSR : PShowElementRec;
  433. PTR : PTextRec;
  434. PCR : PColumnRec;
  435. begin
  436. ActAreaRec := nil;
  437. PreviewComXML.getAllActAreaObjs(ObjList);
  438. for i := 0 to ObjList.Count - 1 do
  439. begin
  440. ActAreaRec := ObjList[i];
  441. case ActAreaRec.ShowType of
  442. 0..2 :
  443. begin
  444. if ActAreaRec.ElementList <> nil then
  445. begin
  446. for k := 0 to ActAreaRec.ElementList.Count - 1 do
  447. begin
  448. PSR := PShowElementRec(ActAreaRec.ElementList[k]);
  449. case PSR.ElementType of
  450. 0..2 : //文本,参数,字段, 表栏
  451. begin
  452. PTR := PSR.Data;
  453. case intSetType of
  454. 0 : begin //左右边框
  455. //if PTR.ExArea.ExLeft = 0.0 then
  456. (*
  457. if PTR.ExArea.ExLeft = 0.0 then
  458. begin
  459. if BorderWidth <> 1.0 then
  460. PTR.LineInfo.LeftThick := BorderWidth
  461. else
  462. PTR.LineInfo.LeftThick := BorderWidth / 2;
  463. end;
  464. if PTR.ExArea.ExRight = 100.0 then
  465. begin
  466. if BorderWidth <> 1.0 then
  467. PTR.LineInfo.RightThick := BorderWidth
  468. else
  469. PTR.LineInfo.RightThick := BorderWidth / 2;
  470. end;
  471. //*)
  472. if PTR.ExArea.ExLeft = 0.0 then
  473. begin
  474. if BorderWidth = 0.0 then
  475. PTR.LineInfo.LeftThick := BorderWidth
  476. end;
  477. if PTR.ExArea.ExRight = 100.0 then
  478. begin
  479. if BorderWidth = 0.0 then
  480. PTR.LineInfo.RightThick := BorderWidth
  481. end;
  482. end;
  483. 1 : begin //上下边框
  484. //约定中无此项,暂缓
  485. end;
  486. 2 : begin //竖线
  487. (*
  488. if (PTextRec(PSR.Data).LineInfo.LeftThick >= 0.2) and (BorderWidth >= 0.2) then
  489. PTextRec(PSR.Data).LineInfo.LeftThick := BorderWidth;
  490. if (PTextRec(PSR.Data).LineInfo.RightThick >= 0.2) and (BorderWidth >= 0.2) then
  491. PTextRec(PSR.Data).LineInfo.RightThick := BorderWidth;
  492. //
  493. if PTR.ExArea.ExLeft = 0.0 then
  494. PTR.LineInfo.LeftThick := BorderWidth;
  495. if PTR.ExArea.ExRight = 100.0 then
  496. PTR.LineInfo.RightThick := BorderWidth;
  497. //*)
  498. end;
  499. 3 : begin //横线
  500. if (PTR.LineInfo.TopThick >= 0.2) and (BorderWidth <= 0.2) then
  501. PTR.LineInfo.TopThick := BorderWidth;
  502. if (PTR.LineInfo.BottomThick >= 0.2) and (BorderWidth <= 0.2) then
  503. PTR.LineInfo.BottomThick := BorderWidth;
  504. end;
  505. end;
  506. end;
  507. 7 : //Column
  508. begin
  509. PCR := PSR.Data;
  510. case intSetType of
  511. 0 : begin //左右边框
  512. //if PTR.ExArea.ExLeft = 0.0 then
  513. if PCR.ExArea.ExLeft = 0.0 then
  514. begin
  515. if BorderWidth = 0.0 then
  516. PCR.LineInfo.LeftThick := BorderWidth
  517. end;
  518. if PCR.ExArea.ExRight = 100.0 then
  519. begin
  520. if BorderWidth = 0.0 then
  521. PCR.LineInfo.RightThick := BorderWidth
  522. end;
  523. end;
  524. 1 : begin //上下边框
  525. //约定中无此项,暂缓
  526. end;
  527. 2 : begin //竖线
  528. (*
  529. if (PTextRec(PSR.Data).LineInfo.LeftThick >= 0.2) and (BorderWidth >= 0.2) then
  530. PTextRec(PSR.Data).LineInfo.LeftThick := BorderWidth;
  531. if (PTextRec(PSR.Data).LineInfo.RightThick >= 0.2) and (BorderWidth >= 0.2) then
  532. PTextRec(PSR.Data).LineInfo.RightThick := BorderWidth;
  533. //*)
  534. if PCR.ExArea.ExLeft = 0.0 then
  535. PCR.LineInfo.LeftThick := BorderWidth;
  536. if PCR.ExArea.ExRight = 100.0 then
  537. PCR.LineInfo.RightThick := BorderWidth;
  538. end;
  539. 3 : begin //横线
  540. if (PCR.LineInfo.TopThick >= 0.2) and (BorderWidth <= 0.2) then
  541. PCR.LineInfo.TopThick := BorderWidth;
  542. if (PTR.LineInfo.BottomThick >= 0.2) and (BorderWidth <= 0.2) then
  543. PCR.LineInfo.BottomThick := BorderWidth;
  544. end;
  545. end;
  546. end;
  547. end;
  548. PreviewComXML.setActShowElementObj(PSR);
  549. //
  550. end;
  551. end;
  552. end;
  553. end;
  554. end;
  555. //
  556. end;
  557. begin
  558. strFileName := extractFilePath(Application.ExeName) + STR_CONFIG_TEXT;
  559. FIni := TIniFile.Create(strFileName) ;
  560. ObjList := TList.Create;
  561. try
  562. //0. 设置页面大小
  563. PreviewComXML.setPageSize(FIni.ReadString('纸张','幅面','A4'));
  564. //1. 设置边距
  565. PreviewComXML.setEdge(0,'',FIni.ReadInteger('纸张','左边距',0)/10);
  566. PreviewComXML.setEdge(1,'',FIni.ReadInteger('纸张','右边距',0)/10);
  567. PreviewComXML.setEdge(2,'',FIni.ReadInteger('纸张','上边距',0)/10);
  568. PreviewComXML.setEdge(3,'',FIni.ReadInteger('纸张','下边距',0)/10);
  569. //2. 设置表标题
  570. TitleRec := PreviewComXML.getTitleByID(1);
  571. if TitleRec <> nil then
  572. begin
  573. TitleRec.FontRec.FontName := FIni.ReadString('页面','表标题_字体','宋体');
  574. TitleRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表标题_字体大小',18)*4/3) ;
  575. TitleRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表标题_字体粗',0)*200;
  576. TitleRec.FontRec.FontItalic := FIni.ReadInteger('页面','表标题_字体斜',0);
  577. TitleRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','表标题_字体下滑线',0);
  578. PreviewComXML.setTitleObj(TitleRec);
  579. end;
  580. //还有行高
  581. //设置表眉/表脚
  582. if (FIni.ReadFloat('页面','页眉显示',0) = 1) then
  583. begin
  584. //1. 设置页眉显示TITLE
  585. TitleRec := PreviewComXML.getTitleByID(500); //默认ID为500
  586. if TitleRec = nil then
  587. begin
  588. TitleRec := PreviewComXML.newTitleObj;
  589. end;
  590. TitleRec.FontRec.FontName := FIni.ReadString('页面','页眉/页脚_字体','宋体');
  591. TitleRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','页眉/页脚_字体大小',18)*4/3) ;
  592. TitleRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','页眉/页脚_字体粗',0)*200;
  593. TitleRec.FontRec.FontItalic := FIni.ReadInteger('页面','页眉/页脚_字体斜',0);
  594. TitleRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','页眉/页脚_字体下滑线',0);
  595. TitleRec.Content := FIni.ReadString('页面','页眉_显示内容','');
  596. TitleRec.ExArea.ExTop := 1;
  597. TitleRec.ExArea.ExBottom := 1;
  598. TitleRec.Align := getAlignByName(FIni.ReadString('页面','页眉_对齐','中'));
  599. TitleRec.ID := 500;
  600. PreviewComXML.setTitleObj(TitleRec);
  601. //2. 设置表眉横线
  602. if (FIni.ReadFloat('页面','页眉横线',0) = 1) then
  603. begin
  604. ShapeRec := PreviewComXML.getShapeByID(500);
  605. if ShapeRec = nil then
  606. begin
  607. ShapeRec := PreviewComXML.newShapeObj(1);
  608. end;
  609. ShapeRec.AreaName := '表题';
  610. ShapeRec.ID := 500;
  611. ShapeRec.PenWidth := FIni.ReadInteger('页面','页眉/页脚线_线粗',1);
  612. ShapeRec.ExArea.ExTop := 33.33;
  613. ShapeRec.ExArea.ExBottom := 33.33;
  614. PreviewComXML.setShapeObj(ShapeRec);
  615. end else
  616. begin
  617. //删除多余SHAPE对象
  618. PreviewComXML.getAllShapeObjs(1,ObjList);
  619. for i := 0 to ObjList.Count - 1 do
  620. begin
  621. ShapeRec := ObjList[i];
  622. if (ShapeRec.ID = 500) then
  623. begin
  624. PreviewComXML.delShapeObj(ShapeRec);
  625. end;
  626. end;
  627. end;
  628. //3. 整理TITLE区域
  629. TitleRec := PreviewComXML.getTitleByID(1);
  630. if TitleRec <> nil then
  631. begin
  632. TitleRec.ExArea.ExTop := 2;
  633. TitleRec.ExArea.ExBottom := 2;
  634. PreviewComXML.setTitleObj(TitleRec);
  635. end;
  636. PreviewComXML.setNewTitleAreaProperties(1.8,3);
  637. end else
  638. begin
  639. //1. 删除多余TITLE对象
  640. TitleRec := PreviewComXML.getTitleByID(500); //默认ID为500
  641. if TitleRec <> nil then
  642. begin
  643. PreviewComXML.delTitleObj(TitleRec);
  644. end;
  645. //2. 删除多余SHAPE对象
  646. PreviewComXML.getAllShapeObjs(1,ObjList);
  647. for i := 0 to ObjList.Count - 1 do
  648. begin
  649. ShapeRec := ObjList[i];
  650. if (ShapeRec.ID = 500) then
  651. begin
  652. PreviewComXML.delShapeObj(ShapeRec);
  653. end;
  654. end;
  655. //3. 整理TITLE区域
  656. TitleRec := PreviewComXML.getTitleByID(1);
  657. if TitleRec <> nil then
  658. begin
  659. TitleRec.ExArea.ExTop := 1;
  660. TitleRec.ExArea.ExBottom := 1;
  661. PreviewComXML.setTitleObj(TitleRec);
  662. end;
  663. PreviewComXML.setNewTitleAreaProperties(1.2,1);
  664. end;
  665. k := 0;
  666. PreviewComXML.getAllTailObjs(ObjList);
  667. for i := 0 to ObjList.Count - 1 do
  668. begin
  669. if (PHeadRec(ObjList[i]).ExArea.ExTop > k) then
  670. k := Round(PHeadRec(ObjList[i]).ExArea.ExTop);
  671. end;
  672. PreviewComXML.getAllPageObjs(ObjList);
  673. for i := 0 to ObjList.Count - 1 do
  674. begin
  675. if (PPageRec(ObjList[i]).ID <> 500) and (PPageRec(ObjList[i]).ExArea.ExTop > k) then
  676. k := Round(PPageRec(ObjList[i]).ExArea.ExTop);
  677. end;
  678. Inc(k);
  679. if (FIni.ReadFloat('页面','页脚显示',0) = 1) then
  680. begin
  681. //1. 设置页脚显示页码
  682. PageObj := PreviewComXML.getPageByID(500);
  683. if PageObj = nil then
  684. begin
  685. PageObj := PreviewComXML.newPageObj(1);
  686. end;
  687. PageObj.FontRec.FontName := FIni.ReadString('页面','页眉/页脚_字体','宋体');
  688. PageObj.FontRec.FontHeight := Round(FIni.ReadInteger('页面','页眉/页脚_字体大小',18)*4/3) ;
  689. PageObj.FontRec.FontBold := 400 + FIni.ReadInteger('页面','页眉/页脚_字体粗',0)*200;
  690. PageObj.FontRec.FontItalic := FIni.ReadInteger('页面','页眉/页脚_字体斜',0);
  691. PageObj.FontRec.FontUnderLine := FIni.ReadInteger('页面','页眉/页脚_字体下滑线',0);
  692. PageObj.PageDist := FIni.ReadInteger('页面','页脚_起始页码',1) - 1;
  693. PageObj.PrefixContent := '第';
  694. PageObj.SufixContent := '页';
  695. PageObj.AreaName := '表尾';
  696. PageObj.AreaType := false;
  697. PageObj.ExArea.ExTop := k;
  698. PageObj.ExArea.ExBottom := 1;
  699. PageObj.Align := getAlignByName(FIni.ReadString('页面','页脚_对齐','中'));
  700. PageObj.ID := 500;
  701. PreviewComXML.setPageObj(PageObj);
  702. //3. 设置表脚横线
  703. if (FIni.ReadFloat('页面','页脚横线',0) = 1) then
  704. begin
  705. ShapeRec := PreviewComXML.getShapeByID(501);
  706. if ShapeRec = nil then
  707. begin
  708. ShapeRec := PreviewComXML.newShapeObj(1);
  709. end;
  710. ShapeRec.AreaName := '表尾';
  711. ShapeRec.ID := 501;
  712. ShapeRec.PenWidth := FIni.ReadInteger('页面','页眉/页脚线_线粗',1);
  713. PreviewComXML.setNewHeadTailAreaProperties(1,0.6*k,k);
  714. ShapeRec.ExArea.ExTop := (k - 1)/k*100;
  715. ShapeRec.ExArea.ExBottom := ShapeRec.ExArea.ExTop;
  716. PreviewComXML.setShapeObj(ShapeRec);
  717. end else
  718. begin
  719. //删除多余SHAPE对象
  720. PreviewComXML.getAllShapeObjs(1,ObjList);
  721. for i := 0 to ObjList.Count - 1 do
  722. begin
  723. ShapeRec := ObjList[i];
  724. if (ShapeRec.ID = 501) then
  725. begin
  726. PreviewComXML.delShapeObj(ShapeRec);
  727. end;
  728. end;
  729. Dec(k);
  730. PageObj := PreviewComXML.getPageByID(500);
  731. if (k = 0) and (PageObj <> nil) then
  732. Inc(k);
  733. PreviewComXML.setNewHeadTailAreaProperties(1,0.6*k,k);
  734. if k = 0 then
  735. PreviewComXML.setNewHeadTailAreaProperties(1,0,1);
  736. end;
  737. end else
  738. begin
  739. //2. 删除多余SHAPE对象
  740. PreviewComXML.getAllShapeObjs(1,ObjList);
  741. for i := 0 to ObjList.Count - 1 do
  742. begin
  743. ShapeRec := ObjList[i];
  744. if (ShapeRec.ID = 501) then
  745. begin
  746. PreviewComXML.delShapeObj(ShapeRec);
  747. end;
  748. end;
  749. //3. 删除多余的页码对象
  750. PageObj := PreviewComXML.getPageByID(500);
  751. if PageObj <> nil then
  752. begin
  753. PreviewComXML.delPageObj(PageObj);
  754. end;
  755. Dec(k);
  756. PreviewComXML.setNewHeadTailAreaProperties(1,0.6*k,k);
  757. if k = 0 then
  758. PreviewComXML.setNewHeadTailAreaProperties(1,0,1);
  759. end;
  760. //3. 设置列标题(表栏)
  761. douJ := FIni.ReadFloat('页面','表格线粗',0);
  762. PreviewComXML.getAllColumnHeadObjs(ObjList);
  763. for i := 0 to ObjList.Count - 1 do
  764. begin
  765. ColumnRec := ObjList[i];
  766. ColumnRec.FontRec.FontName := FIni.ReadString('页面','列标题_字体','宋体');
  767. ColumnRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','列标题_字体大小',18)*4/3) ;
  768. ColumnRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','列标题_字体粗',0)*200;
  769. ColumnRec.FontRec.FontItalic := FIni.ReadInteger('页面','列标题_字体斜',0);
  770. ColumnRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','列标题_字体下滑线',0);
  771. if (douJ > 0.2) then
  772. begin
  773. if (ColumnRec.LineInfo.LeftThick > 0.2) then
  774. ColumnRec.LineInfo.LeftThick := douJ;
  775. if (ColumnRec.LineInfo.RightThick > 0.2) then
  776. ColumnRec.LineInfo.RightThick := douJ;
  777. if (ColumnRec.LineInfo.TopThick > 0.2) then
  778. ColumnRec.LineInfo.TopThick := douJ;
  779. if (ColumnRec.LineInfo.BottomThick > 0.2) then
  780. ColumnRec.LineInfo.BottomThick := douJ;
  781. end;
  782. PreviewComXML.setColumnHeadTailObj(0,ColumnRec);
  783. end;
  784. PreviewComXML.getAllColumnTailObjs(ObjList);
  785. for i := 0 to ObjList.Count - 1 do
  786. begin
  787. ColumnRec := ObjList[i];
  788. ColumnRec.FontRec.FontName := FIni.ReadString('页面','列标题_字体','宋体');
  789. ColumnRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','列标题_字体大小',18)*4/3) ;
  790. ColumnRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','列标题_字体粗',0)*200;
  791. ColumnRec.FontRec.FontItalic := FIni.ReadInteger('页面','列标题_字体斜',0);
  792. ColumnRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','列标题_字体下滑线',0);
  793. if (douJ > 0.2) then
  794. begin
  795. if (ColumnRec.LineInfo.LeftThick > 0.2) then
  796. ColumnRec.LineInfo.LeftThick := douJ;
  797. if (ColumnRec.LineInfo.RightThick > 0.2) then
  798. ColumnRec.LineInfo.RightThick := douJ;
  799. if (ColumnRec.LineInfo.TopThick > 0.2) then
  800. ColumnRec.LineInfo.TopThick := douJ;
  801. if (ColumnRec.LineInfo.BottomThick > 0.2) then
  802. ColumnRec.LineInfo.BottomThick := douJ;
  803. end;
  804. PreviewComXML.setColumnHeadTailObj(1,ColumnRec);
  805. end;
  806. PreviewComXML.getAllActAreaObjs(ObjList);
  807. for i := 0 to ObjList.Count - 1 do
  808. begin
  809. AAR := ObjList[i];
  810. for j := 0 to AAR.ElementList.Count - 1 do
  811. begin
  812. SER := AAR.ElementList[j];
  813. if (SER.ElementType = 7) then
  814. begin
  815. ColumnRec := SER.Data;
  816. ColumnRec.FontRec.FontName := FIni.ReadString('页面','列标题_字体','宋体');
  817. ColumnRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','列标题_字体大小',18)*4/3) ;
  818. ColumnRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','列标题_字体粗',0)*200;
  819. ColumnRec.FontRec.FontItalic := FIni.ReadInteger('页面','列标题_字体斜',0);
  820. ColumnRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','列标题_字体下滑线',0);
  821. if (douJ > 0.2) then
  822. begin
  823. if (ColumnRec.LineInfo.LeftThick > 0.2) then
  824. ColumnRec.LineInfo.LeftThick := douJ;
  825. if (ColumnRec.LineInfo.RightThick > 0.2) then
  826. ColumnRec.LineInfo.RightThick := douJ;
  827. if (ColumnRec.LineInfo.TopThick > 0.2) then
  828. ColumnRec.LineInfo.TopThick := douJ;
  829. if (ColumnRec.LineInfo.BottomThick > 0.2) then
  830. ColumnRec.LineInfo.BottomThick := douJ;
  831. end;
  832. PreviewComXML.setActShowElementObj(SER);
  833. end;
  834. end;
  835. end;
  836. //4. 设置表正文
  837. //{
  838. PreviewComXML.getAllFlowShowContentObjs(ObjList);
  839. bkContentFontHeight := Round(FIni.ReadInteger('页面','表正文_字体大小',18)*4/3) ;
  840. self.isNarraw := (FIni.ReadInteger('页面','内容窄体输出',0) = 1);
  841. //内容窄体输出
  842. for i := 0 to ObjList.Count - 1 do
  843. begin
  844. FlowContentRec := ObjList[i];
  845. if not(FlowContentRec.Fixed) then
  846. begin
  847. FlowContentRec.FontRec.FontName := FIni.ReadString('页面','表正文_字体','宋体');
  848. FlowContentRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表正文_字体大小',18)*4/3) ;
  849. FlowContentRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表正文_字体粗',0)*200;
  850. FlowContentRec.FontRec.FontItalic := FIni.ReadInteger('页面','表正文_字体斜',0);
  851. FlowContentRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','表正文_字体下滑线',0);
  852. PreviewComXML.setFlowContentObj(FlowContentRec);
  853. end;
  854. end;
  855. PreviewComXML.getAllBillShowContentObjs(ObjList);
  856. for i := 0 to ObjList.Count - 1 do
  857. begin
  858. FlowContentRec := ObjList[i];
  859. if not(FlowContentRec.Fixed) then
  860. begin
  861. FlowContentRec.FontRec.FontName := FIni.ReadString('页面','表正文_字体','宋体');
  862. FlowContentRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表正文_字体大小',18)*4/3) ;
  863. FlowContentRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表正文_字体粗',0)*200;
  864. FlowContentRec.FontRec.FontItalic := FIni.ReadInteger('页面','表正文_字体斜',0);
  865. FlowContentRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','表正文_字体下滑线',0);
  866. PreviewComXML.setBillContentObj(FlowContentRec);
  867. end;
  868. end;
  869. PreviewComXML.getAllCrossContentObjs(ObjList);
  870. for i := 0 to ObjList.Count - 1 do
  871. begin
  872. CrossContentRec := ObjList[i];
  873. if not(CrossContentRec.CrossContent.Fixed) then
  874. begin
  875. CrossContentRec.CrossContent.FontRec.FontName := FIni.ReadString('页面','表正文_字体','宋体');
  876. CrossContentRec.CrossContent.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表正文_字体大小',18)*4/3) ;
  877. CrossContentRec.CrossContent.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表正文_字体粗',0)*200;
  878. CrossContentRec.CrossContent.FontRec.FontItalic := FIni.ReadInteger('页面','表正文_字体斜',0);
  879. CrossContentRec.CrossContent.FontRec.FontUnderLine := FIni.ReadInteger('页面','表正文_字体下滑线',0);
  880. PreviewComXML.setCrossContentObj(CrossContentRec);
  881. end;
  882. end;
  883. //}
  884. //5. 设置表合计
  885. for i := 0 to 2 do
  886. begin
  887. PreviewComXML.getAllSumObjs(i,ObjList);
  888. for j := 0 to ObjList.Count - 1 do
  889. begin
  890. SumRec := ObjList[j];
  891. SumRec.FontRec.FontName := FIni.ReadString('页面','表合计_字体','宋体');
  892. SumRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表合计_字体大小',18)*4/3) ;
  893. SumRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表合计_字体粗',0)*200;
  894. SumRec.FontRec.FontItalic := FIni.ReadInteger('页面','表合计_字体斜',0);
  895. SumRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','表合计_字体下滑线',0);
  896. PreviewComXML.setSumObj(SumRec);
  897. end;
  898. end;
  899. //6. 设置表眉/脚
  900. PreviewComXML.getAllHeadObjs(ObjList);
  901. for i := 0 to ObjList.Count - 1 do
  902. begin
  903. HeadTailRec := ObjList[i];
  904. HeadTailRec.FontRec.FontName := FIni.ReadString('页面','表眉/表脚_字体','宋体');
  905. HeadTailRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表眉/表脚_字体大小',18)*4/3) ;
  906. HeadTailRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表眉/表脚_字体粗',0)*200;
  907. HeadTailRec.FontRec.FontItalic := FIni.ReadInteger('页面','表眉/表脚_字体斜',0);
  908. HeadTailRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','表眉/表脚_字体下滑线',0);
  909. PreviewComXML.setHeadTailObj(0,HeadTailRec);
  910. end;
  911. PreviewComXML.getAllTailObjs(ObjList);
  912. for i := 0 to ObjList.Count - 1 do
  913. begin
  914. HeadTailRec := ObjList[i];
  915. HeadTailRec.FontRec.FontName := FIni.ReadString('页面','表眉/表脚_字体','宋体');
  916. HeadTailRec.FontRec.FontHeight := Round(FIni.ReadInteger('页面','表眉/表脚_字体大小',18)*4/3) ;
  917. HeadTailRec.FontRec.FontBold := 400 + FIni.ReadInteger('页面','表眉/表脚_字体粗',0)*200;
  918. HeadTailRec.FontRec.FontItalic := FIni.ReadInteger('页面','表眉/表脚_字体斜',0);
  919. HeadTailRec.FontRec.FontUnderLine := FIni.ReadInteger('页面','表眉/表脚_字体下滑线',0);
  920. PreviewComXML.setHeadTailObj(1,HeadTailRec);
  921. end;
  922. //7. 设置页眉/脚(无显示必要,暂不实现)
  923. //8. 页眉/页脚线(无显示必要,暂不实现)
  924. //9. 报表边框横线
  925. PreviewComXML.getAllShapeObjs(1,ObjList);
  926. //j := FIni.ReadInteger('页面','报表边框横线',0)*FIni.ReadInteger('页面','边框线粗',0);
  927. douJ := FIni.ReadInteger('页面','报表边框横线',0)*FIni.ReadFloat('页面','边框线粗',0);
  928. for i := 0 to ObjList.Count - 1 do
  929. begin
  930. ShapeRec := ObjList[i];
  931. if (ShapeRec.ExArea.ExLeft <> ShapeRec.ExArea.ExRight) then
  932. begin //这里的判断条件是约定好的
  933. ShapeRec.PenWidth := Round(douJ);
  934. if (douJ = 0.0) then
  935. ShapeRec.PenStyle := integer(psClear)
  936. else
  937. ShapeRec.PenStyle := integer(psSolid)
  938. end;
  939. PreviewComXML.setShapeObj(ShapeRec);
  940. end;
  941. //10. 报表边框竖线
  942. //j := FIni.ReadInteger('页面','报表边框竖线',0)*FIni.ReadInteger('页面','边框线粗',0);
  943. douJ := FIni.ReadInteger('页面','报表边框竖线',0)*FIni.ReadFloat('页面','边框线粗',0);
  944. for i := 0 to ObjList.Count - 1 do
  945. begin
  946. ShapeRec := ObjList[i];
  947. if (ShapeRec.ExArea.ExTop <> ShapeRec.ExArea.ExBottom) and
  948. ((ShapeRec.ExArea.ExLeft = 0) or (ShapeRec.ExArea.ExLeft = 100)) then
  949. begin //这里的判断条件是约定好的
  950. //ShapeRec.PenWidth := j;
  951. ShapeRec.PenWidth := Round(douJ);
  952. //if (j = 0) then
  953. if (douJ = 0.0) then
  954. ShapeRec.PenStyle := integer(psClear)
  955. else
  956. ShapeRec.PenStyle := integer(psSolid)
  957. end;
  958. PreviewComXML.setShapeObj(ShapeRec);
  959. end;
  960. //11. 报表表格横线
  961. //{
  962. PreviewComXML.getAllFlowShowContentObjs(ObjList);
  963. //j := FIni.ReadInteger('页面','报表表格横线',0)*FIni.ReadInteger('页面','表格线粗',0);
  964. douJ := FIni.ReadInteger('页面','报表表格横线',0)*FIni.ReadFloat('页面','表格线粗',0);
  965. for i := 0 to ObjList.Count - 1 do
  966. begin
  967. FlowContentRec := ObjList[i];
  968. //FlowContentRec.LineInfo.TopThick := j;
  969. //FlowContentRec.LineInfo.BottomThick := j;
  970. FlowContentRec.LineInfo.TopThick := douJ;
  971. FlowContentRec.LineInfo.BottomThick := douJ;
  972. PreviewComXML.setFlowContentObj(FlowContentRec);
  973. end;
  974. //}
  975. PreviewComXML.getAllCrossContentObjs(ObjList);
  976. for i := 0 to ObjList.Count - 1 do
  977. begin
  978. CrossContentRec := ObjList[i];
  979. //CrossContentRec.CrossContent.LineInfo.TopThick := j;
  980. //CrossContentRec.CrossContent.LineInfo.BottomThick := j;
  981. CrossContentRec.CrossContent.LineInfo.TopThick := douJ;
  982. CrossContentRec.CrossContent.LineInfo.BottomThick := douJ;
  983. PreviewComXML.setCrossContentObj(CrossContentRec);
  984. end;
  985. //12. 报表表格竖线
  986. //(*
  987. PreviewComXML.getAllFlowShowContentObjs(ObjList);
  988. //j := FIni.ReadInteger('页面','报表表格竖线',0)*FIni.ReadInteger('页面','表格线粗',0);
  989. douJ := FIni.ReadInteger('页面','报表表格竖线',0)*FIni.ReadFloat('页面','表格线粗',0);
  990. intW := FIni.ReadInteger('页面','报表边框竖线',0);
  991. for i := 0 to ObjList.Count - 1 do
  992. begin
  993. FlowContentRec := ObjList[i];
  994. //FlowContentRec.LineInfo.LeftThick := j;
  995. //FlowContentRec.LineInfo.RightThick := j;
  996. FlowContentRec.LineInfo.LeftThick := douJ;
  997. FlowContentRec.LineInfo.RightThick := douJ;
  998. if (i = 0) then
  999. begin
  1000. if (intW = 0) then
  1001. begin
  1002. FlowContentRec.LineInfo.LeftThick := 0;
  1003. end;
  1004. end;
  1005. if (i = ObjList.Count - 1) then
  1006. begin
  1007. if (intW = 0) then
  1008. begin
  1009. FlowContentRec.LineInfo.RightThick := 0;
  1010. end;
  1011. end;
  1012. PreviewComXML.setFlowContentObj(FlowContentRec);
  1013. end;
  1014. //*)
  1015. PreviewComXML.getAllCrossContentObjs(ObjList);
  1016. for i := 0 to ObjList.Count - 1 do
  1017. begin
  1018. CrossContentRec := ObjList[i];
  1019. //CrossContentRec.CrossContent.LineInfo.LeftThick := j;
  1020. //CrossContentRec.CrossContent.LineInfo.RightThick := j;
  1021. CrossContentRec.CrossContent.LineInfo.LeftThick := douJ;
  1022. CrossContentRec.CrossContent.LineInfo.RightThick := douJ;
  1023. ColumnRec := CrossContentRec.CrossContent.Column;
  1024. //这里还要判断如果没有边框竖线的情况下,表格竖线边缘的线粗也为0
  1025. //前提是所属表栏最右位置位于边缘
  1026. if (intW = 0) and (ColumnRec<>nil) and ((ColumnRec.ExArea.ExRight=100.0) or (ColumnRec.ExArea.ExLeft=0.0)) then
  1027. begin
  1028. case CrossContentRec.CrossType of
  1029. 0 : //交叉行
  1030. begin
  1031. if (CrossContentRec.CrossContent.ExArea.ExLeft = ColumnRec.ExArea.ExLeft ) then
  1032. CrossContentRec.CrossContent.LineInfo.LeftThick := 0;
  1033. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1034. CrossContentRec.CrossContent.LineInfo.RightThick := 0;
  1035. end;
  1036. 1 : //交叉列
  1037. begin
  1038. if (CrossContentRec.CrossContent.ExArea.ExLeft = ColumnRec.ExArea.ExLeft ) then
  1039. CrossContentRec.CrossContent.LineInfo.LeftThick := 0;
  1040. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1041. CrossContentRec.CrossContent.LineInfo.RightThick := 0;
  1042. //(*
  1043. if (CrossContentRec.CrossContent.isSpecialBorder) then
  1044. begin
  1045. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1046. CrossContentRec.CrossContent.SpecialLineInfo.RightThick := 0;
  1047. end;
  1048. //*)
  1049. end;
  1050. 2 : //显示数据
  1051. begin
  1052. if (CrossContentRec.CrossContent.ExArea.ExLeft = ColumnRec.ExArea.ExLeft ) then
  1053. CrossContentRec.CrossContent.LineInfo.LeftThick := 0;
  1054. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1055. CrossContentRec.CrossContent.LineInfo.RightThick := 0;
  1056. end;
  1057. 3 : //固定LABEL
  1058. begin
  1059. if (CrossContentRec.CrossContent.ExArea.ExLeft = ColumnRec.ExArea.ExLeft ) then
  1060. CrossContentRec.CrossContent.LineInfo.LeftThick := 0;
  1061. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1062. CrossContentRec.CrossContent.LineInfo.RightThick := 0;
  1063. end;
  1064. 4 : //序号
  1065. begin
  1066. if (CrossContentRec.CrossContent.ExArea.ExLeft = ColumnRec.ExArea.ExLeft ) then
  1067. CrossContentRec.CrossContent.LineInfo.LeftThick := 0;
  1068. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1069. CrossContentRec.CrossContent.LineInfo.RightThick := 0;
  1070. end;
  1071. 5 : //横向统计
  1072. begin
  1073. if (CrossContentRec.CrossContent.ExArea.ExLeft = ColumnRec.ExArea.ExLeft ) then
  1074. CrossContentRec.CrossContent.LineInfo.LeftThick := 0;
  1075. if (CrossContentRec.CrossContent.ExArea.ExRight = ColumnRec.ExArea.ExRight ) then
  1076. CrossContentRec.CrossContent.LineInfo.RightThick := 0;
  1077. end;
  1078. end;
  1079. end;
  1080. PreviewComXML.setCrossContentObj(CrossContentRec);
  1081. end;
  1082. //13. 活动区域
  1083. //j := FIni.ReadInteger('页面','报表表格竖线',0)*FIni.ReadInteger('页面','表格线粗',0);
  1084. douJ := FIni.ReadInteger('页面','报表表格竖线',0)*FIni.ReadFloat('页面','表格线粗',0);
  1085. setActAreaBorder(2,douJ);
  1086. //j := FIni.ReadInteger('页面','报表表格横线',0)*FIni.ReadInteger('页面','表格线粗',0);
  1087. douJ := FIni.ReadInteger('页面','报表表格横线',0)*FIni.ReadFloat('页面','表格线粗',0);
  1088. setActAreaBorder(3,douJ);
  1089. //j := FIni.ReadInteger('页面','报表边框竖线',0)*FIni.ReadInteger('页面','边框线粗',0);
  1090. douJ := FIni.ReadInteger('页面','报表边框竖线',0)*FIni.ReadFloat('页面','边框线粗',0);
  1091. setActAreaBorder(0,douJ);
  1092. finally
  1093. FIni.Free;
  1094. ObjList.Free;
  1095. end;
  1096. end;
  1097. procedure TScReportsForm.FormShow(Sender: TObject);
  1098. var wd : integer;
  1099. begin
  1100. LoadReports;
  1101. PreviewComXML.OnReplaceString := ReplaceSpecChar;
  1102. xcbRptAfterModifiedClick(xcbRptAfterModified);
  1103. extvReport.Selected := extvReport.Items.GetFirstNode;
  1104. rdbtnA4Click(rdbtnA4);
  1105. // 取得汇总项目 chenshilong, 2011-07-12
  1106. MainFrm.GetGatherProjects(FGatherProjectSL);
  1107. end;
  1108. procedure TScReportsForm.xlbPrintClick(Sender: TObject);
  1109. var
  1110. i : integer;
  1111. intStartPage , intEndPage : integer;
  1112. Node: TExTreeNode;
  1113. strFile: string;
  1114. begin
  1115. try
  1116. Screen.Cursor := crHourGlass;
  1117. PreviewComXML.OnProgress := PreviewComXMLProgress;
  1118. if extvReport.LeafCheckedCount > 0 then
  1119. begin
  1120. for I := 0 to extvReport.Items.Count - 1 do
  1121. begin
  1122. Node := extvReport.Items[I];
  1123. if (not Node.HasChildren) and (Node.Checked = csChecked) then
  1124. begin
  1125. bIsEstimate1 := IsEstimate1;
  1126. evCrossDataPrintEvent := CrossDataPrintEvent;
  1127. evFlowDataPrintEvent := FlowDataPrintEvent;
  1128. FReportManager.RecordNo := Integer(Node.Data);
  1129. strFile := FReportManager.FieldValue['FileName'];
  1130. //if FileExists(strFile) then
  1131. // directPrintReport(PreviewBox.Canvas, strFile, PreviewComXML, False);
  1132. if FileExists(strFile) then
  1133. begin
  1134. directPrintReport(PreviewBox.Canvas, strFile, PreviewComXML, False, False, oemNormal,'','', chkExcel2010.Checked);
  1135. end;
  1136. end;
  1137. end;
  1138. extvReport.ClearChecked;
  1139. end
  1140. else
  1141. //打印
  1142. if (TestInt(xcbStartPage.Text)) and (TestInt(xcbEndPage.Text)) then
  1143. begin
  1144. intStartPage := StrToInt(xcbStartPage.Text);
  1145. intEndPage := StrToInt(xcbEndPage.Text);
  1146. if (intStartPage>0) and (intEndPage <= PreviewComXML.TotalPages) then
  1147. begin
  1148. PreviewComXML.PrintMultiPages(intStartPage,intEndPage);
  1149. end;
  1150. end;
  1151. finally
  1152. Screen.Cursor := crDefault;
  1153. PreviewComXML.OnProgress := nil;
  1154. CloseFloatProgress;
  1155. end;
  1156. end;
  1157. procedure TScReportsForm.setPrinterOrientation();
  1158. begin
  1159. if (rdbtnA4.Checked) then
  1160. begin
  1161. PreviewComXML.PrintPageSizeIdx := DMPAPER_A4;
  1162. end else if (rdbtnA3.Checked) then
  1163. begin
  1164. PreviewComXML.PrintPageSizeIdx := DMPAPER_A3;
  1165. end;
  1166. //
  1167. end;
  1168. procedure TScReportsForm.xlbToExcelClick(Sender: TObject);
  1169. var
  1170. i, idx, iCount: integer;
  1171. intStartPage, intEndPage, iStart, iEnd: integer;
  1172. strOutput, strTemplate: string;
  1173. Border : TColumnLineRec;
  1174. excelMode : TOutputExcelMode;
  1175. Node: TExTreeNode;
  1176. strFile : string;
  1177. strPath : string;
  1178. strTemp : string;
  1179. isFirst : boolean;
  1180. begin
  1181. //导出到EXCEL
  1182. SetMessageInfoFile(ExtractFilePath(Application.ExeName) + 'Data\' + 'DlgInfo.dat');
  1183. {$IFDEF _ScCanPrint}
  1184. { CommonMessage(pmtHint, [pmbOK],
  1185. '不必再导出到EXCEL中修改了,针对各地业主的不同单价分析表要求,海德纵横smartcost提供报表定制服务,只需以下三步:'#13#10 +
  1186. '传真报表格式到海德→海德服务人员制作报表→客户接收报表模板邮件'#13#10 +
  1187. '只需几分钟,即可完成以往几小时,几天才能完成的报表编辑工作,在激烈的投标竞争中占尽先机!'#13#10 +
  1188. '客服热线:' + LoadServicePhone, True, 'OutToXL');}
  1189. strTemplate := ExtractFilePath(Application.ExeName) + 'Data\basic.xls';
  1190. { strOutput := extvReport.Selected.Text;
  1191. sdOutputExcel.FileName := strOutput;}
  1192. if (chkExcelMode.Checked) then
  1193. begin
  1194. excelMode := oemOneSheet;
  1195. end else
  1196. begin
  1197. excelMode := oemNormal;
  1198. end;
  1199. //set printer direction
  1200. setPrinterOrientation;
  1201. if extvReport.LeafCheckedCount > 0 then
  1202. begin
  1203. isFirst := true;
  1204. for I := 0 to extvReport.Items.Count - 1 do
  1205. begin
  1206. Node := extvReport.Items[I];
  1207. if (not Node.HasChildren) and (Node.Checked = csChecked) then
  1208. begin
  1209. bIsEstimate1 := IsEstimate1;
  1210. evCrossDataPrintEvent := CrossDataPrintEvent;
  1211. evFlowDataPrintEvent := FlowDataPrintEvent;
  1212. FReportManager.RecordNo := Integer(Node.Data);
  1213. strFile := FReportManager.FieldValue['FileName'];
  1214. try
  1215. Update;
  1216. Screen.Cursor := crHourGlass;
  1217. PreviewComXML.OnProgress := PreviewComXMLProgress;
  1218. if (FileExists(strFile)) then
  1219. begin
  1220. // CheckTempTabs(Node.Text);
  1221. //ShowFloatProgress(Format('正在导出 %s ,请稍候……', [FReportManager.FieldValue['名称']]),
  1222. // ((I + 1) * 100) div (extvReport.Items.Count) );
  1223. strTemp := ExtractFileName(Node.Text);
  1224. idx := Pos('.', strTemp);
  1225. if (idx > 0) then
  1226. begin
  1227. strTemp := Copy(strTemp, 1, idx - 1);
  1228. end;
  1229. //sdOutputExcel.FileName := strTemp + '.xls';
  1230. sdOutputExcel.FileName := strTemp ;
  1231. if (isFirst) then
  1232. begin
  1233. if (sdOutputExcel.Execute) then
  1234. begin
  1235. isFirst := false;
  1236. strPath := ExtractFilePath(sdOutputExcel.FileName);
  1237. directPrintReport(PreviewBox.Canvas, strFile, PreviewComXML, False, True, excelMode,sdOutputExcel.FileName, strTemplate, chkExcel2010.Checked);
  1238. end;
  1239. end else
  1240. begin
  1241. directPrintReport(PreviewBox.Canvas, strFile, PreviewComXML, False, True, excelMode, strPath + strTemp + '.xls', strTemplate, chkExcel2010.Checked);
  1242. end;
  1243. end;
  1244. finally
  1245. Screen.Cursor := crDefault;
  1246. PreviewComXML.OnProgress := nil;
  1247. CloseFloatProgress;
  1248. end;
  1249. end;
  1250. end;
  1251. extvReport.ClearChecked;
  1252. end else
  1253. begin
  1254. strOutput := extvReport.Selected.Text;
  1255. sdOutputExcel.FileName := strOutput;
  1256. if (TestInt(xcbStartPage.Text)) and (TestInt(xcbEndPage.Text)) then
  1257. begin
  1258. intStartPage := StrToInt(xcbStartPage.Text);
  1259. intEndPage := StrToInt(xcbEndPage.Text);
  1260. if (intStartPage>0) and (intEndPage <= PreviewComXML.TotalPages) then
  1261. begin
  1262. if not sdOutputExcel.Execute then
  1263. Exit;
  1264. if (intEndPage - intStartPage > 30) and (excelMode <> oemOneSheet) then
  1265. begin
  1266. Update;
  1267. Screen.Cursor := crHourGlass;
  1268. try
  1269. PreviewComXML.OnProgress := PreviewComXMLProgress;
  1270. iStart := intStartPage;
  1271. iEnd := 20;
  1272. I := 1;
  1273. iCount := (intEndPage - intStartPage + 1) div 20;
  1274. if (intEndPage - intStartPage + 1) mod 20 > 0 then
  1275. Inc(iCount);
  1276. repeat
  1277. begin
  1278. //ShowFloatProgress(Format('分 %d 个文件导出,正在导出第 %d 个文件,请稍候……', [iCount, I]),
  1279. // (I * 100) div iCount);
  1280. strOutput := sdOutputExcel.FileName + Format('(%d)', [I]);
  1281. FixFileExt(strOutput, '.xls');
  1282. (*
  1283. Border.LeftThick := 0.5;
  1284. Border.TopThick := 0.5;
  1285. Border.RightThick := 0.5;
  1286. Border.BottomThick := 0.5;
  1287. *)
  1288. //OutputExcelMode
  1289. setDefaultExcelBorder(Border);
  1290. if (chkExcel2010.Checked) then
  1291. begin
  1292. PreViewComXML.OutputToExcelRangeXMLEx(PreviewBox.Canvas,iStart,iEnd, strTemplate, strOutput, Border, excelMode);
  1293. end else
  1294. begin
  1295. PreViewComXML.OutputToExcelFile(PreviewBox.Canvas,iStart,iEnd, strTemplate, strOutput, excelMode, Border);
  1296. end;
  1297. //PreViewComXML.OutputToExcelRangeXMLEx(PreviewBox.Canvas,iStart,iEnd, strTemplate, strOutput, Border, excelMode);
  1298. iStart := iStart + 20;
  1299. iEnd := iEnd + 20;
  1300. if iEnd > intEndPage then
  1301. iEnd := intEndPage;
  1302. Inc(I);
  1303. end
  1304. //until iStart >= intEndPage;
  1305. until iStart > intEndPage;
  1306. // PreViewComXML.OutputToExcelRange(PreviewBox.Canvas,intStartPage,intEndPage);
  1307. finally
  1308. Screen.Cursor := crDefault;
  1309. PreviewComXML.OnProgress := nil;
  1310. CloseFloatProgress;
  1311. end;
  1312. end
  1313. else
  1314. begin
  1315. Update;
  1316. Screen.Cursor := crHourGlass;
  1317. try
  1318. PreviewComXML.OnProgress := PreviewComXMLProgress;
  1319. strOutput := sdOutputExcel.FileName;
  1320. FixFileExt(strOutput, '.xls');
  1321. (*
  1322. Border.LeftThick := 0.5;
  1323. Border.TopThick := 0.5;
  1324. Border.RightThick := 0.5;
  1325. Border.BottomThick := 0.5;
  1326. *)
  1327. setDefaultExcelBorder(Border);
  1328. if (chkExcel2010.Checked) then
  1329. begin
  1330. PreViewComXML.OutputToExcelRangeXMLEx(PreviewBox.Canvas,intStartPage,intEndPage, strTemplate, strOutput, Border, excelMode);
  1331. end else
  1332. begin
  1333. PreViewComXML.OutputToExcelFile(PreviewBox.Canvas,intStartPage,intEndPage, strTemplate, strOutput, excelMode, Border);
  1334. end;
  1335. finally
  1336. Screen.Cursor := crDefault;
  1337. PreviewComXML.OnProgress := nil;
  1338. CloseFloatProgress;
  1339. end;
  1340. end;
  1341. end;
  1342. end;
  1343. end;
  1344. {$ELSE}
  1345. {$IFDEF _KTDebug}
  1346. //My implementation
  1347. //Standard message show dialog.
  1348. //No need to implement this for debug purpose
  1349. {$ELSE}
  1350. CommonMessage(pmtHint, [pmbOK],
  1351. {'不必再导出到EXCEL中修改了,针对各地业主的不同单价分析表要求,纵横smartcost提供报表定制服务,只需以下三步:'#13#10 +
  1352. '传真报表格式到客服中心→服务人员制作报表→客户接收报表模板邮件'#13#10 +
  1353. '只需几分钟,即可完成以往几小时,几天才能完成的报表编辑工作,在激烈的投标竞争中占尽先机!'#13#10 +}
  1354. '对不起,学习版不提供导出功能。'#13#10#13#10 +
  1355. '以下为收费服务项目,请在必要时联系纵横:'#13#10 +
  1356. '针对各地业主的不同单价分析表要求,纵横SmartCost提供报表模板定制服务,只需几分钟,即可完成以往几小时,几天才能完成的报表编辑工作,在激烈的投标竞争中占尽先机!'#13#10#13#10+
  1357. '客服热线:' + LoadServicePhone);
  1358. {$ENDIF}
  1359. {$ENDIF}
  1360. end;
  1361. procedure TScReportsForm.xlbToPDFClick(Sender: TObject);
  1362. var
  1363. i : integer;
  1364. intStartPage , intEndPage : integer;
  1365. Node: TExTreeNode;
  1366. strFile: string;
  1367. begin
  1368. if extvReport.LeafCheckedCount > 0 then
  1369. begin
  1370. try
  1371. Screen.Cursor := crHourGlass;
  1372. PreviewComXML.OnProgress := PreviewComXMLProgress;
  1373. for I := 0 to extvReport.Items.Count - 1 do
  1374. begin
  1375. Node := extvReport.Items[I];
  1376. if (not Node.HasChildren) and (Node.Checked = csChecked) then
  1377. begin
  1378. bIsEstimate1 := IsEstimate1;
  1379. evCrossDataPrintEvent := CrossDataPrintEvent;
  1380. evFlowDataPrintEvent := FlowDataPrintEvent;
  1381. FReportManager.RecordNo := Integer(Node.Data);
  1382. strFile := FReportManager.FieldValue['FileName'];
  1383. if FileExists(strFile) then
  1384. begin
  1385. //ShowFloatProgress(Format('正在导出 %s ,请稍候……', [FReportManager.FieldValue['名称']]),
  1386. // ((I + 1) * 100) div (extvReport.Items.Count) );
  1387. //directPrintReport(PreviewBox.Canvas, strFile, PreviewComXML, True);
  1388. directPrintReport(PreviewBox.Canvas, strFile, PreviewComXML, True, False, oemNormal,'','', chkExcel2010.Checked);
  1389. end;
  1390. end;
  1391. end;
  1392. //extvReport.ClearChecked;
  1393. finally
  1394. Screen.Cursor := crDefault;
  1395. PreviewComXML.OnProgress := nil;
  1396. CloseFloatProgress;
  1397. end;
  1398. end
  1399. else
  1400. //打印
  1401. if (TestInt(xcbStartPage.Text)) and (TestInt(xcbEndPage.Text)) then
  1402. begin
  1403. try
  1404. PreviewComXML.OnProgress := PreviewComXMLProgress;
  1405. Screen.Cursor := crHourGlass;
  1406. intStartPage := StrToInt(xcbStartPage.Text);
  1407. intEndPage := StrToInt(xcbEndPage.Text);
  1408. if (intStartPage>0) and (intEndPage <= PreviewComXML.TotalPages) then
  1409. PreviewComXML.PrintPDF(intStartPage, intEndPage);
  1410. finally
  1411. Screen.Cursor := crDefault;
  1412. PreviewComXML.OnProgress := nil;
  1413. CloseFloatProgress;
  1414. end;
  1415. end;
  1416. end;
  1417. procedure TScReportsForm.xlbOnePageClick(Sender: TObject);
  1418. begin
  1419. PreviewComXML.PreviewRows := 1;
  1420. PreviewComXML.PreviewCols := 1;
  1421. intCntPerPage := 1;
  1422. intGroup := intPage;
  1423. bShowNormal := true; //强制为普通输出模式
  1424. //ReportPreview;
  1425. FormResize(Self);
  1426. end;
  1427. procedure TScReportsForm.xlbTwoPageClick(Sender: TObject);
  1428. begin
  1429. if PreviewComXML.ReportSize.X > PreviewComXML.ReportSize.Y then
  1430. begin
  1431. PreviewComXML.PreviewRows := 2;
  1432. PreviewComXML.PreviewCols := 1;
  1433. end else
  1434. begin
  1435. PreviewComXML.PreviewRows := 1;
  1436. PreviewComXML.PreviewCols := 2;
  1437. end;
  1438. intCntPerPage := 2;
  1439. intGroup := intPage div 2;
  1440. if (intPage mod 2) > 0 then Inc(intGroup);
  1441. bShowNormal := true; //强制为普通输出模式
  1442. //ReportPreview;
  1443. FormResize(Self);
  1444. end;
  1445. procedure TScReportsForm.xlbFourPageClick(Sender: TObject);
  1446. begin
  1447. PreviewComXML.PreviewRows := 2;
  1448. PreviewComXML.PreviewCols := 2;
  1449. intCntPerPage := 4;
  1450. intGroup := intPage div 4;
  1451. if (intPage mod 4) > 0 then Inc(intGroup);
  1452. bShowNormal := true; //强制为普通输出模式
  1453. //ReportPreview;
  1454. FormResize(Self);
  1455. end;
  1456. procedure TScReportsForm.xlbFirstPageClick(Sender: TObject);
  1457. begin
  1458. intPage := 1;
  1459. xcbPages.Text := IntToStr(intPage);
  1460. xcbPagesChange(nil);
  1461. end;
  1462. procedure TScReportsForm.xcbPagesChange(Sender: TObject);
  1463. var intValue : integer;
  1464. begin
  1465. if TestInt(xcbPages.Text) then
  1466. begin
  1467. intValue := StrToInt(xcbPages.Text);
  1468. if (intValue <= PreviewComXML.TotalPages) and (intValue > 0) then
  1469. begin
  1470. intPage := intValue;
  1471. intGroup := intValue div intCntPerPage;
  1472. if (intValue mod intCntPerPage) > 0 then
  1473. Inc(intGroup);
  1474. ReportPreview;
  1475. end;
  1476. end;
  1477. end;
  1478. procedure TScReportsForm.xlbPrePageClick(Sender: TObject);
  1479. begin
  1480. if intPage > 1 then
  1481. begin
  1482. Dec(intPage);
  1483. xcbPages.Text := IntToStr(intPage);
  1484. xcbPagesChange(nil);
  1485. end;
  1486. end;
  1487. procedure TScReportsForm.xlbNextPageClick(Sender: TObject);
  1488. begin
  1489. if intPage < PreviewComXML.TotalPages then
  1490. begin
  1491. Inc(intPage);
  1492. xcbPages.Text := IntToStr(intPage);
  1493. xcbPagesChange(nil);
  1494. end;
  1495. end;
  1496. procedure TScReportsForm.xlbLastPageClick(Sender: TObject);
  1497. begin
  1498. intPage := PreviewComXML.TotalPages;
  1499. xcbPages.Text := IntToStr(intPage);
  1500. xcbPagesChange(nil);
  1501. end;
  1502. procedure TScReportsForm.xlbSetupClick(Sender: TObject);
  1503. var intIdx : integer;
  1504. begin
  1505. //打印机设置
  1506. //{
  1507. if extvReport.Selected = nil then
  1508. begin
  1509. MessageBox(Handle, '请选择报表。', '提示', MB_OK or MB_ICONINFORMATION);
  1510. Exit;
  1511. end;
  1512. try
  1513. Application.CreateForm(TReportAdjuster, ReportAdjuster);
  1514. ReportAdjuster.SetupReportName := ExtractFileName(ReportName);
  1515. ReportAdjuster.Project := Project;
  1516. intIdx := Pos(FILEEXT,ReportAdjuster.SetupReportName);
  1517. if intIdx > 0 then
  1518. begin
  1519. //ReportAdjuster.SetupReportName := Copy(ReportAdjuster.SetupReportName, 1 , intIdx - 1 );
  1520. FReportManager.RecordNo := Integer(extvReport.Selected.Data);
  1521. ReportName := FReportManager.FieldValue['FileName'];
  1522. ReportAdjuster.IsTender := rbRptAfterModified.Checked;
  1523. ReportAdjuster.SetupReportName := ReportName;
  1524. ReportAdjuster.SetupReportNo := FReportManager.RecordNo;
  1525. end;
  1526. ReportAdjuster.ShowModal;
  1527. if ReportAdjuster.ReportChanged then
  1528. begin
  1529. //FormShow(nil);
  1530. extvReportDblClick(nil);
  1531. end else
  1532. if ReportAdjuster.SetupChanged then
  1533. begin
  1534. setupReport;
  1535. ReportPreview;
  1536. end;
  1537. finally
  1538. ReportAdjuster.free;
  1539. end;
  1540. //}
  1541. end;
  1542. procedure TScReportsForm.PreviewBoxMouseDownEx(Sender: TObject;
  1543. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1544. begin
  1545. //0: normal, 1: next page, 2: previous page 3: first page, 4: last page
  1546. case intCurStatus of
  1547. 0 : begin
  1548. //
  1549. end;
  1550. 1 : begin
  1551. xlbNextPageClick(nil);
  1552. end;
  1553. 2 : begin
  1554. xlbPrePageClick(nil);
  1555. end;
  1556. 3 : begin
  1557. xlbFirstPageClick(nil);
  1558. end;
  1559. 4 : begin
  1560. xlbLastPageClick(nil);
  1561. end;
  1562. end;
  1563. end;
  1564. procedure TScReportsForm.PreviewBoxMouseMove(Sender: TObject;
  1565. Shift: TShiftState; X, Y: Integer);
  1566. var offset, offsetex : integer;
  1567. semiW : integer;
  1568. begin
  1569. offset := 150;
  1570. offsetex := 50;
  1571. semiW := PreviewBox.Width div 2;
  1572. //0: normal, 1: next page, 2: previous page 3: first page, 4: last page
  1573. if (X > (semiW + offset)) then
  1574. begin
  1575. if (X >= PreviewBox.Width - offsetex) then
  1576. begin
  1577. PreviewBox.Cursor := crMyIdxLast;
  1578. intCurStatus := 4;
  1579. end else
  1580. begin
  1581. PreviewBox.Cursor := crMyIdxNext;
  1582. intCurStatus := 1;
  1583. end;
  1584. end else if (X < (semiW - offset)) then
  1585. begin
  1586. if (X <= offsetex) then
  1587. begin
  1588. PreviewBox.Cursor := crMyIdxFirst;
  1589. intCurStatus := 3;
  1590. end else
  1591. begin
  1592. PreviewBox.Cursor := crMyIdxPrevious;
  1593. intCurStatus := 2;
  1594. end;
  1595. end else
  1596. begin
  1597. PreviewBox.Cursor := crDefault;
  1598. intCurStatus := 0;
  1599. //ScReportsForm.Caption := 'X: ' + IntToStr(PreviewBox.Left) + ' Y: ' + IntToStr(PreviewBox.Top);
  1600. end;
  1601. end;
  1602. procedure TScReportsForm.PreviewBoxMouseDown(Sender: TObject;
  1603. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1604. var intVertical, intHorizontal : integer;
  1605. i,j : integer;
  1606. begin
  1607. //intOldX := X;
  1608. //intOldY := Y;
  1609. //if ScaleBtn.Down then
  1610. if (Button = mbLeft) then
  1611. begin
  1612. //根据放大缩小情况来显示
  1613. intVertical := Self.ClientWidth div 2;
  1614. intHorizontal := Self.ClientHeight div 2;
  1615. if (bShowNormal) then
  1616. begin
  1617. bShowNormal := not(bShowNormal);
  1618. xlbRealSize.Down := True;
  1619. case intCntPerPage of
  1620. 2 :
  1621. begin
  1622. if (PreviewComXML.PreviewRows > PreviewComXML.PreviewCols) then
  1623. begin
  1624. if (Y < intHorizontal) then
  1625. intPage := intGroup * 2 - 1
  1626. else
  1627. intPage := intGroup * 2 ;
  1628. end else
  1629. begin
  1630. if (X < intVertical) then
  1631. intPage := intGroup * 2 - 1
  1632. else
  1633. intPage := intGroup * 2 ;
  1634. end;
  1635. end;
  1636. 4 :
  1637. begin
  1638. if (Y < intHorizontal) then
  1639. begin
  1640. if (X < intVertical) then
  1641. intPage := intGroup * 4 - 3
  1642. else
  1643. intPage := intGroup * 4 - 2;
  1644. end else
  1645. begin
  1646. if (X < intVertical) then
  1647. intPage := intGroup * 4 - 1
  1648. else
  1649. intPage := intGroup * 4;
  1650. end;
  1651. end;
  1652. end;
  1653. //FormResize(Self);
  1654. end else
  1655. begin
  1656. case intCntPerPage of
  1657. 1:
  1658. xlbOnePage.Down := True;
  1659. 2:
  1660. xlbTwoPage.Down := True;
  1661. 4:
  1662. xlbFourPage.Down := True;
  1663. end;
  1664. bShowNormal := not(bShowNormal);
  1665. //ReportPreview;
  1666. end;
  1667. FormResize(Self);
  1668. //ReportPreview;
  1669. end else
  1670. begin
  1671. startMove(X, Y);
  1672. end;
  1673. end;
  1674. procedure TScReportsForm.FormCreate(Sender: TObject);
  1675. var
  1676. rst1, rst2 : integer;
  1677. //fp : PChar;
  1678. pn : PAnsiChar;
  1679. begin
  1680. pn := PChar(extractFilePath(Application.ExeName) + 'NextPage.cur');
  1681. rst1 := LoadcursorFromFile(pn);
  1682. if rst1 <> 0 then
  1683. begin
  1684. Screen.Cursors[crMyIdxNext] := rst1;
  1685. end;
  1686. pn := PChar(extractFilePath(Application.ExeName) + 'PreviousPage.cur');
  1687. rst2 := LoadcursorFromFile(pn);
  1688. if rst2 <> 0 then
  1689. begin
  1690. Screen.Cursors[crMyIdxPrevious] := rst2;
  1691. end;
  1692. pn := PChar(extractFilePath(Application.ExeName) + 'LastPage.cur');
  1693. rst1 := LoadcursorFromFile(pn);
  1694. if rst1 <> 0 then
  1695. begin
  1696. Screen.Cursors[crMyIdxLast] := rst1;
  1697. end;
  1698. pn := PChar(extractFilePath(Application.ExeName) + 'FirstPage.cur');
  1699. rst2 := LoadcursorFromFile(pn);
  1700. if rst2 <> 0 then
  1701. begin
  1702. Screen.Cursors[crMyIdxFirst] := rst2;
  1703. end;
  1704. intCurStatus := 0;
  1705. //0: normal, 1: next page, 2: previous page 3: first page, 4: last page
  1706. // zy 2005-05-18 加速读取报表列表速度
  1707. FReportManager := ReportManager;//TScReportManager.Create;
  1708. FWorkListForm := TScWorkListForm.Create(nil);
  1709. bShowNormal := true;
  1710. ExePath := ExtractFilePath(Application.ExeName);
  1711. strModified := '(调价后)';
  1712. //strConfigTxt := '报表打印机设置.INI';
  1713. rbRptBeforeModified.Checked := True;
  1714. isNarraw := false;
  1715. xccRptIsModified.Visible := ivNever;
  1716. pnlRptIsModified.Visible := False;
  1717. {$IFNDEF _ScCanPrint}
  1718. xlbPrint.Enabled := False;
  1719. xlbToPDF.Enabled := False;
  1720. {$ENDIF}
  1721. // xlbToExcel.Enabled := False;
  1722. {$IFDEF _beEncrypt}
  1723. ClearReportFuncList;
  1724. ClearReportOprList;
  1725. {$ENDIF}
  1726. {$IFDEF _ScInternal}
  1727. xlbPrint.Enabled := True;
  1728. xlbToExcel.Enabled := True;
  1729. {$ENDIF}
  1730. extvReport.IsRecurCheck := False;
  1731. FGatherProjectSL := TStringList.Create;
  1732. end;
  1733. function FindEmptyReport(AReportName: string; var AEmptyReportName: string): Boolean;
  1734. var
  1735. strPath, strEmptyReport: string;
  1736. iPos: Integer;
  1737. begin
  1738. strPath := ExtractFilePath(Application.ExeName) + 'BillsEditorReports\EmptyReports\';
  1739. strEmptyReport := ExtractFileNameWithoutExt(AReportName);
  1740. // 如果表名是“xxxx(预算)”,需要先将“(预算)”去掉
  1741. iPos := Pos('(', strEmptyReport);
  1742. if iPos > 0 then
  1743. strEmptyReport := Copy(strEmptyReport, 1, iPos - 1);
  1744. strEmptyReport := strPath + strEmptyReport + '(空表).srt';
  1745. Result := FileExists(strEmptyReport);
  1746. if Result then
  1747. AEmptyReportName := strEmptyReport;
  1748. end;
  1749. procedure TScReportsForm.extvReportDblClick(Sender: TObject);
  1750. var
  1751. CurPoint : TPoint;
  1752. GatherProjFrm: TGatherProjForm;
  1753. P: TPoint;
  1754. function IsGatherProjectReport(AReportName: string): Boolean;
  1755. begin
  1756. Result := False;
  1757. if (Pos('【表2-1】', AReportName) > 0) or (Pos('【表2-2】', AReportName) > 0) then
  1758. Result := True;
  1759. end;
  1760. procedure ExecReport(AIsGthPrjRep: Boolean);
  1761. var i : integer;
  1762. strRptName: string;
  1763. strM : string;
  1764. RptArchiverObj : TReportArchiver;
  1765. MemFile : TMemoryStream;
  1766. OldBrushColor, OldPenColor: TColor;
  1767. isBillingGrp : boolean;
  1768. function NeedReBuild(AIsGthPrjRep: Boolean): Boolean;
  1769. begin
  1770. Result := False;
  1771. if AIsGthPrjRep then
  1772. begin
  1773. Result := True;
  1774. end
  1775. else
  1776. begin
  1777. if (Sender = nil) or (PreReportName <> ReportName) and (FileExists(ReportName)) then
  1778. Result := True;
  1779. end;
  1780. end;
  1781. begin
  1782. if extvReport.Selected = nil then Exit;
  1783. if Integer(extvReport.Selected.Data) = 10000 then Exit;
  1784. FReportManager.RecordNo := Integer(extvReport.Selected.Data);
  1785. ReportName := FReportManager.FieldValue['FileName'];
  1786. isBillingGrp := FReportManager.FieldValue['清单分类'] = '是';
  1787. MemFile := nil;
  1788. if not NeedReBuild(AIsGthPrjRep) then Exit;
  1789. Screen.Cursor := crHourGlass;
  1790. {$IFNDEF _KTDebug}
  1791. RptArchiverObj := TReportArchiver.Create;
  1792. RptArchiverObj.FileName := ReportName;
  1793. MemFile := RptArchiverObj.Extract;
  1794. {$ENDIF}
  1795. try
  1796. if MemFile = nil then
  1797. begin
  1798. MemFile := TMemoryStream.Create;
  1799. MemFile.LoadFromFile(ReportName);
  1800. end;
  1801. if PreviewComXML.ReadReportStream(MemFile) then
  1802. begin
  1803. try
  1804. if (FReportManager.FieldValue['格式固化'] <> '是') then
  1805. begin
  1806. setupReport;
  1807. //存盘
  1808. PreviewComXML.SaveToStream(MemFile);
  1809. end;
  1810. PreviewComXML.ReadReportStream(MemFile);
  1811. PreviewComXML.ReadDBData;
  1812. PreviewComXML.AnalyseData;
  1813. PreReportName := ReportName;
  1814. if PreviewComXML.TotalPages > 0 then
  1815. begin
  1816. // zy 暂时以此方法屏蔽所有异常
  1817. try
  1818. intPage := 1;
  1819. intGroup := 1;
  1820. intCntPerPage := 1;
  1821. bShowNormal := false;
  1822. xlbRealSize.Down := True;
  1823. xcbPages.Items.Clear;
  1824. xcbStartPage.Items.Clear;
  1825. xcbEndPage.Items.Clear;
  1826. for i := 1 to PreviewComXML.TotalPages do
  1827. begin
  1828. xcbPages.Items.Add(IntToStr(i));
  1829. end;
  1830. xcbStartPage.Items.Assign(xcbPages.Items);
  1831. xcbEndPage.Items.Assign(xcbPages.Items);
  1832. xcbPages.ItemIndex := 0;
  1833. xcbStartPage.ItemIndex := 0;
  1834. xcbEndPage.ItemIndex := xcbEndPage.Items.Count - 1;
  1835. FormResize(nil); //有刷新
  1836. if isBillingGrp then
  1837. begin
  1838. FWorkListForm.initialize(PreviewComXML);
  1839. FWorkListForm.FormStyle := fsStayOnTop;
  1840. GetCursorPos(CurPoint);
  1841. FWorkListForm.Left := CurPoint.X + 5;
  1842. FWorkListForm.Top := CurPoint.Y + 5;
  1843. FWorkListForm.Show;
  1844. end else
  1845. begin
  1846. FWorkListForm.Hide;
  1847. end;
  1848. except
  1849. Application.MessageBox(PChar('当前报表显示可能存在问题,请与纵横客服中心联系:' + LoadServicePhone + '。'), '注意', MB_OK or MB_ICONINFORMATION);
  1850. OldBrushColor := PreviewBox.Canvas.Brush.Color;
  1851. OldPenColor := PreviewBox.Canvas.Pen.Color;
  1852. try
  1853. PreviewBox.Canvas.Brush.Color := clBtnFace;
  1854. PreviewBox.Canvas.Pen.Color := clBlack;
  1855. PreviewBox.Canvas.Rectangle(PreviewBox.BoundsRect);
  1856. finally
  1857. PreviewBox.Canvas.Brush.Color := OldBrushColor;
  1858. PreviewBox.Canvas.Pen.Color := OldPenColor;
  1859. end;
  1860. end;
  1861. end else
  1862. begin
  1863. // 显示空表
  1864. if FindEmptyReport(ReportName, strRptName) then
  1865. begin
  1866. if MemFile <> nil then
  1867. MemFile.Free;
  1868. RptArchiverObj.Free;
  1869. RptArchiverObj := TReportArchiver.Create;
  1870. RptArchiverObj.FileName := strRptName;
  1871. MemFile := RptArchiverObj.Extract;
  1872. if PreviewComXML.ReadReportStream(MemFile) then
  1873. begin
  1874. setupReport;
  1875. //存盘
  1876. PreviewComXML.SaveToStream(MemFile);
  1877. PreviewComXML.ReadReportStream(MemFile);
  1878. PreviewComXML.ReadDBData;
  1879. PreviewComXML.AnalyseData;
  1880. try
  1881. intPage := 1;
  1882. intGroup := 1;
  1883. intCntPerPage := 1;
  1884. bShowNormal := false;
  1885. xlbRealSize.Down := True;
  1886. xcbPages.Items.Clear;
  1887. xcbStartPage.Items.Clear;
  1888. xcbEndPage.Items.Clear;
  1889. for i := 1 to PreviewComXML.TotalPages do
  1890. begin
  1891. xcbPages.Items.Add(IntToStr(i));
  1892. end;
  1893. xcbStartPage.Items.Assign(xcbPages.Items);
  1894. xcbEndPage.Items.Assign(xcbPages.Items);
  1895. xcbPages.ItemIndex := 0;
  1896. xcbStartPage.ItemIndex := 0;
  1897. xcbEndPage.ItemIndex := xcbEndPage.Items.Count - 1;
  1898. FormResize(nil); //有刷新
  1899. except
  1900. Application.MessageBox(PChar('当前报表显示可能存在问题,请与纵横客服中心联系:' + LoadServicePhone + '。'), '注意', MB_OK or MB_ICONINFORMATION);
  1901. OldBrushColor := PreviewBox.Canvas.Brush.Color;
  1902. OldPenColor := PreviewBox.Canvas.Pen.Color;
  1903. try
  1904. PreviewBox.Canvas.Brush.Color := clBtnFace;
  1905. PreviewBox.Canvas.Pen.Color := clBlack;
  1906. PreviewBox.Canvas.Rectangle(PreviewBox.BoundsRect);
  1907. finally
  1908. PreviewBox.Canvas.Brush.Color := OldBrushColor;
  1909. PreviewBox.Canvas.Pen.Color := OldPenColor;
  1910. end;
  1911. end;
  1912. end;
  1913. end
  1914. else
  1915. begin
  1916. Application.MessageBox('报表无数据,请选择其他报表。','注意',MB_OK or MB_ICONINFORMATION);
  1917. OldBrushColor := PreviewBox.Canvas.Brush.Color;
  1918. OldPenColor := PreviewBox.Canvas.Pen.Color;
  1919. try
  1920. PreviewBox.Canvas.Brush.Color := clBtnFace;
  1921. PreviewBox.Canvas.Pen.Color := clBlack;
  1922. PreviewBox.Canvas.Rectangle(PreviewBox.BoundsRect);
  1923. finally
  1924. PreviewBox.Canvas.Brush.Color := OldBrushColor;
  1925. PreviewBox.Canvas.Pen.Color := OldPenColor;
  1926. end;
  1927. end;
  1928. end;
  1929. finally
  1930. //FIni.Free;
  1931. //ObjList.Free;
  1932. end;
  1933. end;
  1934. finally
  1935. Screen.Cursor := crDefault;
  1936. if MemFile <> nil then
  1937. MemFile.Free;
  1938. {$IFNDEF _KTDebug}
  1939. RptArchiverObj.free;
  1940. {$ENDIF}
  1941. end;
  1942. end;
  1943. begin
  1944. {$IFDEF _beEncrypt}
  1945. ClearReportOprList;
  1946. ClearReportFuncList;
  1947. {$ENDIF}
  1948. // 汇总报表先打开一个小窗口供项目选择 chenshilong, 2011-07-12
  1949. if IsGatherProjectReport(extvReport.Selected.Text) then
  1950. begin
  1951. CurGatherProjectReportName := '';
  1952. GatherProjFrm := TGatherProjForm.Create(nil);
  1953. try
  1954. GetCursorPos(P);
  1955. GatherProjFrm.init(FGatherProjectSL, Self);
  1956. GatherProjFrm.Left := P.X;
  1957. GatherProjFrm.Top := P.Y;
  1958. GatherProjFrm.ShowModal;
  1959. if GatherProjFrm.ModalResult <> mrOK then Exit;
  1960. if CurGatherProjectReportName = '' then Exit;
  1961. FGatherProject := MainFrm.ProjectManager.OpenProjectForReport(CurGatherProjectReportName);
  1962. if not Assigned(FGatherProject) then Exit;
  1963. PreviewComXML.OnGetDataConnection := PreviewComXMLGetGatherProjDataConnection;
  1964. ExecReport(True);
  1965. finally
  1966. PreviewComXML.OnGetDataConnection := PreviewComXMLGetDataConnection;
  1967. GatherProjFrm.Free;
  1968. end;
  1969. end
  1970. else
  1971. begin
  1972. ExecReport(False);
  1973. end;
  1974. end;
  1975. {$IFNDEF _KTDebug}
  1976. procedure TScReportsForm.SetProject(const Value: TProject);
  1977. begin
  1978. FProject := Value;
  1979. FProject.Report.RefreshData;
  1980. end;
  1981. {$ENDIF}
  1982. procedure TScReportsForm.PreviewComXMLGetDataConnection(
  1983. var ADOCon: TADOConnection);
  1984. begin
  1985. ADOCon := FProject.Report.Connection;
  1986. end;
  1987. procedure TScReportsForm.xcbStartPageCurChange(Sender: TObject);
  1988. begin
  1989. xcbStartPage.Text := xcbStartPage.CurText;
  1990. end;
  1991. procedure TScReportsForm.xcbEndPageCurChange(Sender: TObject);
  1992. begin
  1993. xcbEndPage.Text := xcbEndPage.CurText;
  1994. end;
  1995. procedure TScReportsForm.xcbPagesCurChange(Sender: TObject);
  1996. begin
  1997. xcbPages.Text := xcbPages.CurText;
  1998. end;
  1999. // zy
  2000. procedure TScReportsForm.xlbRealSizeClick(Sender: TObject);
  2001. begin
  2002. bShowNormal := False;
  2003. FormResize(Self);
  2004. end;
  2005. function TScReportsForm.GetProjectPhaseByName(AName: string): TProjectPhase;
  2006. var i, iFrom, iTo: Integer;
  2007. begin
  2008. iFrom := Ord(Low(TProjectPhase));
  2009. iTo := Ord(High(TProjectPhase));
  2010. for i := iFrom to iTo do
  2011. begin
  2012. if aryPPStr[TProjectPhase(i)] = AName then
  2013. begin
  2014. Result := TProjectPhase(i);
  2015. Break;
  2016. end
  2017. else Result := ppNull;
  2018. end;
  2019. end;
  2020. procedure TScReportsForm.Splitter1Moved(Sender: TObject);
  2021. begin
  2022. // FormResize(Self);
  2023. end;
  2024. procedure TScReportsForm.PreviewComXMLGetDatasetEvent(
  2025. DatasetInfo: PDatasetInfoRec; var ADataset: TDataSet);
  2026. //var
  2027. // CompareForm: TScReportCompareHLJForm;
  2028. begin
  2029. // {$IFNDEF _KTDebug}
  2030. // {$IFNDEF _ScPersonal}
  2031. // case DataSetInfo.ID of
  2032. // CompareDataSetID, CompareNameDataSetID, CompareBuildProjDataID:
  2033. // begin
  2034. // // lsm
  2035. // CompareType := CompareBills;
  2036. // if FCompareReport = nil then
  2037. // FCompareReport := TScReportCompareForm.Create(Self);
  2038. // if CompareReportCount = 0 then
  2039. // begin
  2040. // // litao
  2041. // FCompareReport.CompositeCompareName(FProjData.BuildProjectName, FProjData.Alias);
  2042. // FCompareReport.CompareAlias := Format('%s\%s', [FProjData.BuildProjectName, FProjData.Alias]);
  2043. // if (FCompareReport.ShowModal <> mrOK) then
  2044. // begin
  2045. //// Exit;
  2046. // end;
  2047. // end;
  2048. // Inc(CompareReportCount);
  2049. // if CompareReportCount >= 3 then
  2050. // CompareReportCount := 0;
  2051. // case DataSetInfo.ID of
  2052. // CompareDataSetID:
  2053. // ADataSet := FCompareReport.DM.cdsCompare;
  2054. // CompareNameDataSetID:
  2055. // ADataSet := FCompareReport.DM.cdsProjNames;
  2056. // CompareBuildProjDataID:
  2057. // ADataSet := FCompareReport.DM.cdsProjData;
  2058. // end;
  2059. // end;
  2060. // GatherDataSetID, GatherBuildProjDataID:
  2061. // begin
  2062. // if FGatherReport = nil then
  2063. // FGatherReport := TScProjGatherDM.Create(nil);
  2064. // if GathereReportCount = 0 then
  2065. // // lsm
  2066. // FGatherReport.GatherProjsForReport(FProjData.BuildProjectName, gtBuildProject);
  2067. // Inc(GathereReportCount);
  2068. // if GathereReportCount >= 2 then
  2069. // GathereReportCount := 0;
  2070. // case DataSetInfo.ID of
  2071. // GatherDataSetID:
  2072. // ADataSet := FGatherReport.cdsProjGatherForReport;
  2073. // GatherBuildProjDataID:
  2074. // ADataSet := FGatherReport.cdsProjData;
  2075. // end;
  2076. // end;
  2077. // GLJGatherDataSetID, GLJGatherBuildProjDataID:
  2078. // begin
  2079. // if FGLJGatherReport = nil then
  2080. // FGLJGatherReport := TScProjGLJGather.Create(Self);
  2081. // {Litao 2010.4.29 02—1表不需要砼}
  2082. // if DatasetInfo.ID = GLJGatherBuildProjDataID then
  2083. // FGLJGatherReport.ReportType := rtTable_02_1;
  2084. //
  2085. // if GLJGatherCount = 0 then
  2086. // FGLJGatherReport.GatherProjs(FProjData.BuildProjectName);
  2087. // Inc(GLJGatherCount);
  2088. // if GLJGatherCount >= 2 then
  2089. // GLJGatherCount := 0;
  2090. // case DatasetInfo.ID of
  2091. // GLJGatherDataSetID:
  2092. // ADataSet := FGLJGatherReport.cdsGLJGather;
  2093. // GLJGatherBuildProjDataID:
  2094. // ADataSet := FGLJGatherReport.cdsProjData;
  2095. // end;
  2096. //
  2097. // {Litao 2010.4.29 还原设置}
  2098. // FGLJGatherReport.ReportType := rtNone;
  2099. // end;
  2100. // HLJ_ComareBillsID, HLJ_ComareBillsProjID:
  2101. // begin
  2102. // if FCompareHLJ = nil then
  2103. // FCompareHLJ := TScProjectCompareHLJDM.Create(Self);
  2104. // CompareForm := TScReportCompareHLJForm.Create(Self);
  2105. // try
  2106. // if HLJCompareBillsCount = 0 then
  2107. // begin
  2108. // CompareForm.Compare := FProjData.FileName;
  2109. // if CompareForm.ShowModal = mrOK then
  2110. // begin
  2111. // FCompareHLJ.CompareBills(CompareForm.Compare, CompareForm.Source);
  2112. // end;
  2113. // end;
  2114. // Inc(HLJCompareBillsCount);
  2115. // if HLJCompareBillsCount >= 2 then
  2116. // HLJCompareBillsCount := 0;
  2117. // case DataSetInfo.ID of
  2118. // HLJ_ComareBillsID:
  2119. // ADataSet := FCompareHLJ.cdsCompareBills;
  2120. // HLJ_ComareBillsProjID:
  2121. // ADataSet := FCompareHLJ.cdsProjData;
  2122. // end;
  2123. // finally
  2124. // FreeAndNil(CompareForm);
  2125. // end;
  2126. // end;
  2127. // HLJ_ComareRationsID, HLJ_ComareRationsProjID:
  2128. // begin
  2129. // if FCompareHLJ = nil then
  2130. // FCompareHLJ := TScProjectCompareHLJDM.Create(Self);
  2131. // CompareForm := TScReportCompareHLJForm.Create(Self);
  2132. // try
  2133. // if HLJCompareBillsCount = 0 then
  2134. // begin
  2135. // CompareForm.Compare := FProjData.FileName;
  2136. // if CompareForm.ShowModal = mrOK then
  2137. // begin
  2138. // FCompareHLJ.CompareRations(CompareForm.Compare, CompareForm.Source);
  2139. // end;
  2140. // end;
  2141. // Inc(HLJCompareBillsCount);
  2142. // if HLJCompareBillsCount >= 2 then
  2143. // HLJCompareBillsCount := 0;
  2144. // case DataSetInfo.ID of
  2145. // HLJ_ComareRationsID:
  2146. // ADataSet := FCompareHLJ.cdsCompareRations;
  2147. // HLJ_ComareRationsProjID:
  2148. // ADataSet := FCompareHLJ.cdsProjData;
  2149. // end;
  2150. // finally
  2151. // FreeAndNil(CompareForm);
  2152. // end;
  2153. // end;
  2154. // // lsm 新增汇总表
  2155. // GatheDWFDataSetID, GatherDWFBuildProjDataID:
  2156. // begin
  2157. // if FGatherDWFReport = nil then
  2158. // FGatherDWFReport := TScProjGatherDM.Create(nil);
  2159. // if GatheDWFReportCount = 0 then
  2160. // FGatherDWFReport.GatherProjsDWFForReport(FProjData.BuildProjectName);
  2161. // Inc(GatheDWFReportCount);
  2162. // if GatheDWFReportCount >= 2 then
  2163. // GatheDWFReportCount := 0;
  2164. // case DataSetInfo.ID of
  2165. // GatheDWFDataSetID:
  2166. // ADataSet := FGatherDWFReport.cdsDWFForReport;
  2167. // GatherDWFBuildProjDataID:
  2168. // ADataSet := FGatherDWFReport.cdsProjDataDWF;
  2169. // end;
  2170. // end;
  2171. // // 主材权重对比表
  2172. // CompareMaterialDataSetID, CompareMaterialProjNamesID, CompareMaterialProjDataID, CompareMaterialProjFeeID:
  2173. // begin
  2174. // CompareType := CompareMaterial;
  2175. // if FCompareMateReport = nil then
  2176. // begin
  2177. // FCompareMateReport := TScReportCompareForm.Create(nil);
  2178. // end;
  2179. // if CompareMateCount = 0 then
  2180. // begin
  2181. // FCompareMateReport.CompositeCompareName(FProjData.BuildProjectName, FProjData.Alias);
  2182. // FCompareMateReport.CompareAlias := Format('%s\%s', [FProjData.BuildProjectName, FProjData.Alias]);
  2183. // if (FCompareMateReport.ShowModal <> mrOK) then
  2184. // begin
  2185. //// Exit;
  2186. // end;
  2187. // end;
  2188. // Inc(CompareMateCount);
  2189. // if CompareMateCount >= 4 then
  2190. // CompareMateCount := 0;
  2191. // case DataSetInfo.ID of
  2192. // CompareMaterialDataSetID:
  2193. // ADataSet := FCompareMateReport.DM.cdsMaterial;
  2194. // CompareMaterialProjNamesID:
  2195. // ADataSet := FCompareMateReport.DM.cdsProjNames;
  2196. // CompareMaterialProjDataID:
  2197. // ADataSet := FCompareMateReport.DM.cdsProjData;
  2198. // CompareMaterialProjFeeID:
  2199. // ADataSet := FCompareMateReport.DM.cdsProjFees;
  2200. // end;
  2201. // end;
  2202. // // 工料机权重汇总表
  2203. // GatherGLJPropDataSetID, GatherGLJPropProjDataID:
  2204. // begin
  2205. // if FGatherGLJPropReport = nil then
  2206. // FGatherGLJPropReport := TScProjGLJGather.Create(Self);
  2207. // if GatherGLJPropCount = 0 then
  2208. // FGatherGLJPropReport.GatherGLJForReport(FProjData.BuildProjectName);
  2209. // Inc(GatherGLJPropCount);
  2210. // if GatherGLJPropCount >= 2 then
  2211. // GatherGLJPropCount := 0;
  2212. // case DatasetInfo.ID of
  2213. // GatherGLJPropDataSetID:
  2214. // ADataSet := FGatherGLJPropReport.cdsGLJForReport;
  2215. // GatherGLJPropProjDataID:
  2216. // ADataSet := FGatherGLJPropReport.cdsProjData;
  2217. // end;
  2218. // end;
  2219. // // 汇总单价偏差
  2220. // GatherEcoLineDataSetID, GatherEcoLineProjDataID:
  2221. // begin
  2222. // if FGatherReport = nil then
  2223. // FGatherReport := TScProjGatherDM.Create(nil);
  2224. // if GatherEcoLineReportCount = 0 then
  2225. // FGatherReport.GatherProjsForReport(FProjData.BuildProjectName, gtWeightPrice);
  2226. // Inc(GatherEcoLineReportCount);
  2227. // if GatherEcoLineReportCount >= 2 then
  2228. // GatherEcoLineReportCount := 0;
  2229. // case DataSetInfo.ID of
  2230. // GatherEcoLineDataSetID:
  2231. // ADataSet := FGatherReport.cdsProjGatherForReport;
  2232. // GatherEcoLineProjDataID:
  2233. // ADataSet := FGatherReport.cdsProjData;
  2234. // end;
  2235. // end;
  2236. // // 汇总指标单价
  2237. // GatherUnitPriceDataSetID, GatherUnitPriceProjDataID:
  2238. // begin
  2239. // if FGatherUnitPriceReport = nil then
  2240. // FGatherUnitPriceReport := TScProjGatherDM.Create(nil);
  2241. // if GatherUnitPriceCount = 0 then
  2242. // FGatherUnitPriceReport.GatherProjsForReport(FProjData.BuildProjectName, gtUnitPrice);
  2243. // Inc(GatherUnitPriceCount);
  2244. // if GatherUnitPriceCount >= 2 then
  2245. // GatherUnitPriceCount := 0;
  2246. // case DataSetInfo.ID of
  2247. // GatherUnitPriceDataSetID:
  2248. // ADataSet := FGatherUnitPriceReport.cdsProjGatherForReport;
  2249. // GatherUnitPriceProjDataID:
  2250. // ADataSet := FGatherUnitPriceReport.cdsProjData;
  2251. // end;
  2252. // end;
  2253. // // 汇总指标单价(广东)
  2254. // GatherBillsUnitPriceDataSetID, GatherBillsUnitPriceProjDataID:
  2255. // begin
  2256. // if FGatherUnitPriceReport = nil then
  2257. // FGatherUnitPriceReport := TScProjGatherDM.Create(nil);
  2258. // if GatherUnitPriceCount = 0 then
  2259. // FGatherUnitPriceReport.GatherProjsForReport(FProjData.BuildProjectName, gtBillsUnitPrice);
  2260. // Inc(GatherUnitPriceCount);
  2261. // if GatherUnitPriceCount >= 2 then
  2262. // GatherUnitPriceCount := 0;
  2263. // case DataSetInfo.ID of
  2264. // GatherBillsUnitPriceDataSetID:
  2265. // ADataSet := FGatherUnitPriceReport.cdsProjGatherForReport;
  2266. // GatherBillsUnitPriceProjDataID:
  2267. // ADataSet := FGatherUnitPriceReport.cdsProjData;
  2268. // end;
  2269. // end;
  2270. // // 审核比较定额表(标表4-3格式)
  2271. // CompareRationDataSetID, CompareRationBillDataID{, CompareRationProjNamesID, CompareRationBillProjDataID}:
  2272. // begin
  2273. // CompareType := CompareRation;
  2274. // if FCompareRationReport = nil then
  2275. // begin
  2276. // FCompareRationReport := TScReportCompareForm.Create(nil);
  2277. // end;
  2278. // if CompareRationReportCount = 0 then
  2279. // begin
  2280. // FCompareRationReport.CompositeCompareName(FProjData.BuildProjectName, FProjData.Alias);
  2281. // FCompareRationReport.CompareAlias := Format('%s\%s', [FProjData.BuildProjectName, FProjData.Alias]);
  2282. // if (FCompareRationReport.ShowModal <> mrOK) then
  2283. // begin
  2284. //// Exit;
  2285. // end;
  2286. // end;
  2287. // Inc(CompareRationReportCount);
  2288. // if CompareRationReportCount >= 2 then
  2289. // CompareRationReportCount := 0;
  2290. // case DataSetInfo.ID of
  2291. // CompareRationDataSetID:
  2292. // ADataSet := FCompareRationReport.DM.cdsRationsData;
  2293. // CompareRationBillDataID:
  2294. // ADataSet := FCompareRationReport.DM.cdsBillsData;
  2295. // end;
  2296. // end;
  2297. //
  2298. // // 汇总土地项目清单(广东)
  2299. // GatherGroundDataSetID, GatherGroundProjDataID:
  2300. // begin
  2301. // if FGatherGroundPriceReport = nil then
  2302. // FGatherGroundPriceReport := TScProjGatherDM.Create(nil);
  2303. // if GatherGroundPriceCount = 0 then
  2304. // FGatherGroundPriceReport.GatherProjsForReport(FProjData.BuildProjectName, gtGroundBills);
  2305. // Inc(GatherGroundPriceCount);
  2306. // if GatherGroundPriceCount >= 2 then
  2307. // GatherGroundPriceCount := 0;
  2308. // case DataSetInfo.ID of
  2309. // GatherGroundDataSetID:
  2310. // ADataSet := FGatherGroundPriceReport.cdsProjGatherForReport;
  2311. // GatherGroundProjDataID:
  2312. // ADataSet := FGatherGroundPriceReport.cdsProjData;
  2313. // end;
  2314. // end;
  2315. //
  2316. // // 汇总标表1(广东)(招预总01-2)
  2317. // GatherStandardOneDataSetID, GatherStandardOneProjDataID:
  2318. // begin
  2319. // if FGatherStandardOneReport = nil then
  2320. // FGatherStandardOneReport := TScProjGatherDM.Create(nil);
  2321. // if GatherStandardOneCount = 0 then
  2322. // FGatherStandardOneReport.GatherProjsStandardOneForReport(FProjData.BuildProjectName);
  2323. // Inc(GatherStandardOneCount);
  2324. // if GatherStandardOneCount >= 2 then
  2325. // GatherStandardOneCount := 0;
  2326. // case DataSetInfo.ID of
  2327. // GatherStandardOneDataSetID:
  2328. // ADataSet := FGatherStandardOneReport.cdsStandardOneForReport;
  2329. // GatherStandardOneProjDataID:
  2330. // ADataSet := FGatherStandardOneReport.cdsProjData;
  2331. // end;
  2332. // end;
  2333. //
  2334. // // 合同征拆总01表
  2335. // GatherGroundChapterDataSetID, GatherGroundChapterProjDataID:
  2336. // begin
  2337. // if FGatherGroundChapterReport = nil then
  2338. // FGatherGroundChapterReport := TScProjGatherDM.Create(nil);
  2339. // if GatherGroundChapterCount = 0 then
  2340. // FGatherGroundChapterReport.GatherProjsForReport(FProjData.BuildProjectName, gtGroundChapter);
  2341. // Inc(GatherGroundChapterCount);
  2342. // if GatherGroundChapterCount >= 2 then
  2343. // GatherGroundChapterCount := 0;
  2344. // case DataSetInfo.ID of
  2345. // GatherGroundChapterDataSetID:
  2346. // ADataSet := FGatherGroundChapterReport.cdsProjGatherForReport;
  2347. // //FGatherGroundChapterReport.cdsProjGatherForReport.savetofile('E:\TEMP\cdsProjGatherForReport.cds');
  2348. // GatherGroundChapterProjDataID:
  2349. // ADataSet := FGatherGroundChapterReport.cdsProjData;
  2350. // end;
  2351. // end;
  2352. //
  2353. // // 计日工汇总 合同总01-2表
  2354. // GatherDatallerDataSetID, GatherDatallerProjDataID:
  2355. // begin
  2356. // if FGatherDatallerReport = nil then
  2357. // FGatherDatallerReport := TScProjGatherDM.Create(nil);
  2358. // if GatherDatallerCount = 0 then
  2359. // FGatherDatallerReport.GatherProjsForReport(FProjData.BuildProjectName, gtDataller);
  2360. // Inc(GatherDatallerCount);
  2361. // if GatherDatallerCount >= 2 then
  2362. // GatherDatallerCount := 0;
  2363. // case DataSetInfo.ID of
  2364. // GatherDatallerDataSetID:
  2365. // ADataSet := FGatherDatallerReport.cdsProjGatherForReport;
  2366. // //FGatherGroundChapterReport.cdsProjGatherForReport.savetofile('E:\TEMP\cdsProjGatherForReport.cds');
  2367. // GatherDatallerProjDataID:
  2368. // ADataSet := FGatherDatallerReport.cdsProjData;
  2369. // end;
  2370. // end;
  2371. //
  2372. // end;
  2373. // {$ENDIF}
  2374. // {$ENDIF}
  2375. end;
  2376. procedure TScReportsForm.DoWriteReportprogress(APosition, AMax: Integer);
  2377. begin
  2378. if AMax > 0 then
  2379. begin
  2380. CreateProgressForm(AMax);
  2381. end
  2382. else if APosition = 0 then
  2383. CloseProgressForm
  2384. else
  2385. RefreshProgressForm(APosition, '正在生成报表,请稍候……');
  2386. end;
  2387. procedure TScReportsForm.IncRefCount;
  2388. begin
  2389. Inc(FRefCount);
  2390. end;
  2391. function TScReportsForm.IsNotRefCountAbove: Boolean;
  2392. begin
  2393. if FRefCount <= 0 then Result := True
  2394. else Result := False;
  2395. end;
  2396. procedure TScReportsForm.xcbRptAfterModifiedClick(Sender: TObject);
  2397. var
  2398. ParentNode, Node: TExTreeNode;
  2399. SubParentNode, tempNode : TExTreeNode;
  2400. strType, strTypeName, strRptName: string;
  2401. strSubType, strSubTypeName : String;
  2402. i : integer;
  2403. ParentList : TList;
  2404. SubParentList : TList;
  2405. function addParent() : TExTreeNode;
  2406. var compNode : TExTreeNode;
  2407. loop : integer;
  2408. begin
  2409. Result := nil;
  2410. ParentNode := nil;
  2411. for loop := 0 to ParentList.Count - 1 do
  2412. begin
  2413. compNode := TExTreeNode(ParentList[loop]);
  2414. if SameText(compNode.Text, strTypeName) then
  2415. begin
  2416. ParentNode := compNode;
  2417. end;
  2418. end;
  2419. if (ParentNode = nil) then
  2420. begin
  2421. if (strType <> '') then
  2422. begin
  2423. ParentNode := extvReport.Items.AddChildObject(nil, strTypeName, Pointer(10000));
  2424. ParentNode.ImageIndex := 0;
  2425. ParentNode.SelectedIndex := 1;
  2426. ParentList.Add(ParentNode);
  2427. end;
  2428. (*
  2429. end else if (strType <> '') and (not SameText(ParentNode.Text, strTypeName)) then
  2430. begin
  2431. ParentNode := extvReport.Items.AddChildObject(nil, strTypeName, Pointer(10000));
  2432. ParentNode.ImageIndex := 0;
  2433. ParentNode.SelectedIndex := 1;
  2434. //*)
  2435. end;
  2436. Result := ParentNode;
  2437. end;
  2438. function addSubParent() : TExTreeNode;
  2439. var compNode : TExTreeNode;
  2440. loop : integer;
  2441. begin
  2442. Result := nil;
  2443. if (ParentNode <> nil) then
  2444. begin
  2445. SubParentNode := nil;
  2446. if (strSubType <> '') then
  2447. begin
  2448. for loop := 0 to SubParentList.Count - 1 do
  2449. begin
  2450. compNode := TExTreeNode(SubParentList[loop]);
  2451. if SameText(compNode.Text, strSubTypeName) then
  2452. begin
  2453. SubParentNode := compNode;
  2454. end;
  2455. end;
  2456. if (SubParentNode = nil) then
  2457. begin
  2458. SubParentNode := extvReport.Items.AddChildObject(ParentNode, strSubTypeName, Pointer(10000));
  2459. SubParentNode.ImageIndex := 0;
  2460. SubParentNode.SelectedIndex := 1;
  2461. end;
  2462. end;
  2463. end else
  2464. begin
  2465. SubParentNode := nil;
  2466. end;
  2467. Result := SubParentNode;
  2468. if (Result <> nil) then
  2469. begin
  2470. SubParentList.Add(Result);
  2471. end;
  2472. end;
  2473. begin
  2474. if (extvReport.Selected <> nil) then
  2475. begin
  2476. strRptName := extvReport.Selected.Text;
  2477. extvReport.Selected := nil;
  2478. end;
  2479. LockWindowUpdate(extvReport.Handle);
  2480. try
  2481. ParentNode := nil;
  2482. SubParentNode := nil;
  2483. ParentList := TList.Create;
  2484. SubParentList := TList.Create;
  2485. extvReport.Items.Clear;
  2486. FReportManager.First;
  2487. while not FReportManager.Eof do
  2488. begin
  2489. strType := FReportManager.FieldValue['分类'];
  2490. strTypeName := FReportManager.FieldValue['分类'] + '.' +FReportManager.FieldValue['分类名称'];
  2491. strSubType := FReportManager.FieldValue['子分类'];
  2492. strSubTypeName := FReportManager.FieldValue['子分类'] + '.' +FReportManager.FieldValue['子分类名称'];
  2493. //(*
  2494. ParentNode := addParent();
  2495. SubParentNode := addSubParent();
  2496. //*)
  2497. (*
  2498. if ParentNode = nil then
  2499. begin
  2500. if strType <> '' then
  2501. begin
  2502. ParentNode := extvReport.Items.AddChildObject(nil, strTypeName, Pointer(10000));
  2503. ParentNode.ImageIndex := 0;
  2504. ParentNode.SelectedIndex := 1;
  2505. if (strSubType <> '') then
  2506. begin
  2507. SubParentNode := extvReport.Items.AddChildObject(ParentNode, strSubTypeName, Pointer(10000));
  2508. SubParentNode.ImageIndex := 0;
  2509. SubParentNode.SelectedIndex := 1;
  2510. end;
  2511. end;
  2512. end
  2513. else if strType = '' then
  2514. begin
  2515. ParentNode := nil;
  2516. SubParentNode := nil;
  2517. end
  2518. else if not SameText(ParentNode.Text, strTypeName) then
  2519. begin
  2520. if strType <> '' then
  2521. begin
  2522. ParentNode := extvReport.Items.AddChildObject(nil, strTypeName, Pointer(10000));
  2523. ParentNode.ImageIndex := 0;
  2524. ParentNode.SelectedIndex := 1;
  2525. if (strSubType <> '') then
  2526. begin
  2527. SubParentNode := extvReport.Items.AddChildObject(ParentNode, strSubTypeName, Pointer(10000));
  2528. SubParentNode.ImageIndex := 0;
  2529. SubParentNode.SelectedIndex := 1;
  2530. end else
  2531. begin
  2532. SubParentNode := nil;
  2533. end;
  2534. end;
  2535. end;
  2536. //*)
  2537. tempNode := ParentNode;
  2538. if (ParentNode <> nil) and (SubParentNode <> nil) then
  2539. begin
  2540. tempNode := SubParentNode;
  2541. end;
  2542. Node := extvReport.Items.AddChildObject(tempNode, FReportManager.FieldValue['名称'], Pointer(FReportManager.RecordNo));
  2543. //Node := extvReport.Items.AddChildObject(ParentNode, FReportManager.FieldValue['名称'], Pointer(FReportManager.RecordNo));
  2544. Node.ImageIndex := 2;
  2545. Node.SelectedIndex := 3;
  2546. Node.Checked := csUnchecked;
  2547. if ParentNode <> nil then
  2548. ParentNode.Expanded := True;
  2549. FReportManager.Next;
  2550. end;
  2551. extvReport.AlphaSort;
  2552. finally
  2553. LockWindowUpdate(0);
  2554. ParentList.Free;
  2555. SubParentList.Free;
  2556. end;
  2557. //----------------------------------------------------------------------------
  2558. for i := 0 to extvReport.Items.Count - 1 do
  2559. begin
  2560. if strRptName = extvReport.Items[i].Text then
  2561. begin
  2562. extvReport.Selected := extvReport.Items[i];
  2563. extvReportDblClick(extvReport);
  2564. break;
  2565. end;
  2566. end;
  2567. //备注: 这里前提是调价前与调价后报表的显示名称要一致,否则不会去自动刷新
  2568. //----------------------------------------------------------------------------
  2569. end;
  2570. //Tony Kang 2004-09-04----------------------------------------------------
  2571. procedure TScReportsForm.FlowDataPrintEvent(var Text: String;
  2572. var FontInfo: TFontRec; FieldID: Integer; ARect: TRect; DC: TCanvas);
  2573. begin
  2574. if IsEstimate1 then
  2575. begin
  2576. if ((FieldID = 2) and (Text = '元')) then
  2577. begin
  2578. Inc(SpIDX);
  2579. end else
  2580. if ((FieldID = 4) and (SpIDX > 0) ) then
  2581. begin
  2582. Text := '1.00';
  2583. SpIDX := 0;
  2584. end;
  2585. //备注: 以上代码是一个比较特殊的判断,目的是为了在单位为元条件下(在此报表模板中字段ID为2),
  2586. // 单价(字段ID为4)确定在1.00
  2587. end;
  2588. end;
  2589. procedure TScReportsForm.CrossDataPrintEvent(var Text: String;
  2590. var FontInfo: TFontRec; FieldID: Integer; ARect: TRect; DC: TCanvas);
  2591. begin
  2592. if IsEstimate1 then
  2593. begin
  2594. if ((FieldID = 3) and (Text = '元')) then
  2595. begin
  2596. Inc(SpIDX);
  2597. end else
  2598. if ((FieldID = 5) and (SpIDX > 0) ) then
  2599. begin
  2600. Text := '1.00';
  2601. SpIDX := 0;
  2602. end;
  2603. //备注: 以上代码是一个比较特殊的判断,目的是为了在单位为元条件下(在此报表模板中字段ID为2),
  2604. // 单价(字段ID为4)确定在1.00
  2605. end;
  2606. end;
  2607. //Tony Kang 2004-09-04-end------------------------------------------------
  2608. // begin [ZhangYin] 2004-09-04-----------------------------------------------------
  2609. function TScReportsForm.IsEstimate1: Boolean;
  2610. begin
  2611. Result := false;
  2612. end;
  2613. // end [ZhangYin] 2004-09-04-----------------------------------------------------
  2614. procedure TScReportsForm.xmReportsClickItem(Sender: TdxBarManager;
  2615. ClickedItem: TdxBarItem);
  2616. begin
  2617. {$IFDEF _beEncrypt}
  2618. DelayCheckDog;
  2619. {$ENDIF}
  2620. end;
  2621. procedure TScReportsForm.extvReportChanging(Sender: TObject;
  2622. Node: TExTreeNode; var AllowChange: Boolean);
  2623. begin
  2624. { AllowChange := True;
  2625. if (Node = extvReport.Selected) or (Integer(Node.Data) = 10000) then
  2626. AllowChange := False;}
  2627. end;
  2628. procedure TScReportsForm.extvReportChange(Sender: TObject;
  2629. Node: TExTreeNode);
  2630. begin
  2631. // extvReportDblClick(Sender);
  2632. end;
  2633. procedure TScReportsForm.PreviewComXMLCrossTabLabelShow(valIDX: Integer;
  2634. var ExLeft, ExRight: Double; var isShow: Boolean;
  2635. CrsTabShowType: Integer);
  2636. var field : PFieldRec;
  2637. begin
  2638. if (CrsTabShowType = -1) then exit;
  2639. field := PreviewComXML.getFieldByID(6);
  2640. if (field <> nil) then
  2641. begin
  2642. if (field.DataLen > valIDX) and (valIDX >= 0) then
  2643. begin
  2644. if (field.Value[valIDX] = 1.5) then
  2645. begin
  2646. case CrsTabShowType of
  2647. 1 : begin
  2648. isShow := false;
  2649. end;
  2650. 2 : begin
  2651. ExLeft := 0;
  2652. ExRight := 100;
  2653. end;
  2654. 3 : begin
  2655. //
  2656. end
  2657. else
  2658. begin
  2659. //
  2660. end;
  2661. end;
  2662. end;
  2663. end;
  2664. end;
  2665. end;
  2666. procedure TScReportsForm.xlbPrintCurPageClick(Sender: TObject);
  2667. begin
  2668. //Print current page
  2669. if (TestInt(xcbPages.Text)) then
  2670. begin
  2671. PreviewComXML.Print(StrToInt(xcbPages.Text),1);
  2672. end else
  2673. begin
  2674. Application.MessageBox('请选择正确的报表或页码.','注意');
  2675. end;
  2676. end;
  2677. procedure TScReportsForm.xdcTopDblClick(Sender: TObject);
  2678. begin
  2679. //chkSafePrintMode.Visible := not chkSafePrintMode.Visible;
  2680. end;
  2681. procedure TScReportsForm.FormDestroy(Sender: TObject);
  2682. begin
  2683. FWorkListForm.Free;
  2684. // chenshilong, 2011-07-12
  2685. // 清除为预览报表创建打开的汇总项目
  2686. MainFrm.ProjectManager.CloseProjectsForReport;
  2687. // 这个属性能够保证每次点“报表”按钮时,重新读取最新数据
  2688. // MainFrm.ProjectManager.SetReportsFirstGetData;
  2689. FGatherProjectSL.Free;
  2690. end;
  2691. procedure TScReportsForm.ReplaceSpecChar(var ShowText : String);
  2692. begin
  2693. replaceSubString(ShowText, 'à','m3');
  2694. replaceSubString(ShowText, '㎡','m2');
  2695. end;
  2696. procedure TScReportsForm.rdbtnA3Click(Sender: TObject);
  2697. var FIni : TIniFile;
  2698. strFileName : String;
  2699. begin
  2700. strFileName := extractFilePath(Application.ExeName) + STR_CONFIG_TEXT;
  2701. FIni := TIniFile.Create(strFileName) ;
  2702. FIni.WriteString('纸张','幅面','A3');
  2703. FIni.Free;
  2704. PreReportName := '';
  2705. setupPage('A3');
  2706. extvReportDblClick(extvReport);
  2707. end;
  2708. procedure TScReportsForm.rdbtnA4Click(Sender: TObject);
  2709. var FIni : TIniFile;
  2710. strFileName : String;
  2711. begin
  2712. strFileName := extractFilePath(Application.ExeName) + STR_CONFIG_TEXT;
  2713. FIni := TIniFile.Create(strFileName) ;
  2714. FIni.WriteString('纸张','幅面','A4');
  2715. FIni.Free;
  2716. PreReportName := '';
  2717. setupPage('A4');
  2718. extvReportDblClick(extvReport);
  2719. end;
  2720. procedure TScReportsForm.setupPage(pageSize : String);
  2721. var pDevModeInput : PDeviceMode;
  2722. DevHandle : THandle;
  2723. DevSetHandle : THandle;
  2724. StubDevMode: TDeviceMode;
  2725. arr_szDeviceName: array[0..64] of char;
  2726. arr_szDriver : array[0..64] of char;
  2727. arr_szPort : array[0..64] of char;
  2728. begin
  2729. Printer.GetPrinter(arr_szDeviceName,arr_szDriver,arr_szPort,DevHandle);
  2730. try
  2731. //L_IniFile.WriteString('纸张','幅面',PageNameCBox.Text);
  2732. pDevModeInput := PDeviceMode(GlobalLock(DevHandle));
  2733. StrCopy(pDevModeInput.dmFormName,PChar(pageSize));
  2734. //pDevModeInput.dmPaperLength := arr_PaperSize[PageNameCBox.ItemIndex].Y;
  2735. //pDevModeInput.dmPaperWidth := arr_PaperSize[PageNameCBox.ItemIndex].X;
  2736. if (pageSize = 'A4') then
  2737. begin
  2738. pDevModeInput.dmPaperSize := DMPAPER_A4;
  2739. end else if (pageSize = 'A3') then
  2740. begin
  2741. pDevModeInput.dmPaperSize := DMPAPER_A3;
  2742. end;
  2743. //要改变项
  2744. pDevModeInput.dmFields := pDevModeInput.dmFields or DM_FORMNAME;
  2745. //pDevModeInput.dmFields := pDevModeInput.dmFields or DM_PAPERLENGTH;
  2746. //pDevModeInput.dmFields := pDevModeInput.dmFields or DM_PAPERWIDTH;
  2747. pDevModeInput.dmFields := pDevModeInput.dmFields or DM_PAPERSIZE;
  2748. DocumentProperties(0, Printer.Handle, arr_szDeviceName, pDevModeInput^,
  2749. pDevModeInput^, DM_OUT_BUFFER);
  2750. finally
  2751. GlobalUnLock(DevHandle);
  2752. //GlobalFree(DevHandle);
  2753. end;
  2754. end;
  2755. procedure TScReportsForm.PreviewComXMLContentDisplay(
  2756. var contentFontRec: TFontRec; dataType: Integer; isReading : boolean; DrawType : integer; isPrinting : boolean);
  2757. begin
  2758. if (isNarraw) then
  2759. begin
  2760. //(*
  2761. if (isReading) then
  2762. begin
  2763. //bkContentFontHeight := contentFontRec.FontHeight;
  2764. //if (dataType = 5) or (dataType = 4) then
  2765. begin
  2766. contentFontRec.FontName := 'Arial Narrow';
  2767. contentFontRec.FontHeight := bkContentFontHeight * 4 div 3;
  2768. end;
  2769. end else
  2770. begin
  2771. //if ((dataType = 5) or (dataType = 4)) and (contentFontRec.FontName = 'Arial Narrow')
  2772. // and (contentFontRec.FontHeight >= 16) then
  2773. if (DrawType = 3) or (DrawType = 5) then
  2774. begin
  2775. //contentFontRec.FontName := 'Arial Narrow';
  2776. contentFontRec.FontHeight := bkContentFontHeight;
  2777. end else if (isPrinting) then
  2778. begin
  2779. contentFontRec.FontName := 'Arial Narrow';
  2780. //contentFontRec.FontHeight := bkContentFontHeight;
  2781. contentFontRec.FontHeight := bkContentFontHeight * 7 div 6;
  2782. end else
  2783. begin
  2784. contentFontRec.FontHeight := bkContentFontHeight * 4 div 3;
  2785. //contentFontRec.FontHeight := bkContentFontHeight;
  2786. end;
  2787. end;
  2788. //*)
  2789. end;
  2790. end;
  2791. procedure TScReportsForm.popMnuOutputDataClick(Sender: TObject);
  2792. var strFileName : String;
  2793. begin
  2794. //显示报表数据,调试用
  2795. strFileName := extractFilePath(Application.ExeName) + 'data.log';
  2796. end;
  2797. procedure TScReportsForm.startMove(X, Y: Integer);
  2798. begin
  2799. FCurrentMouseP.X := X;
  2800. FCurrentMouseP.Y := Y;
  2801. //FCurrentMouseP.
  2802. StartMoveRpt := true;
  2803. end;
  2804. procedure TScReportsForm.endMove(X, Y: Integer);
  2805. begin
  2806. StartMoveRpt := false;
  2807. end;
  2808. procedure TScReportsForm.moveRpt(X, Y: integer);
  2809. begin
  2810. //
  2811. end;
  2812. procedure TScReportsForm.chkFillZeroClick(Sender: TObject);
  2813. begin
  2814. //PreviewComXML.FillZero := chkFillZero.Checked;
  2815. ReportPreview();
  2816. end;
  2817. procedure TScReportsForm.PreviewComXMLProgress(RptName: string; TotalPages,
  2818. CurrentPage: Integer);
  2819. begin
  2820. //ShowFloatProgress
  2821. ShowFloatProgress(Format('正在处理 %s 第 %d 页,共 %d 页,请稍候…', [RptName, CurrentPage, TotalPages]),
  2822. (CurrentPage * 100) div TotalPages);
  2823. end;
  2824. procedure TScReportsForm.PreviewBoxMouseUp(Sender: TObject;
  2825. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  2826. begin
  2827. //
  2828. end;
  2829. procedure TScReportsForm.PreviewComXMLGetGatherProjDataConnection(
  2830. var ADOCon: TADOConnection);
  2831. begin
  2832. ADOCon := FGatherProject.Report.Connection;
  2833. end;
  2834. end.