rmHaBaiCustomizedDm.pas 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  1. unit rmHaBaiCustomizedDm;
  2. // 内蒙古 哈白项目/国道306定制汇总表 严禁任何其他项目或标表调用该单元
  3. // 包括支表2/3/14/3-1/4-1
  4. interface
  5. uses
  6. SysUtils, Classes, DB, rmSelectProjectFrm, ProjectData, mDataRecord,
  7. BillsTree, DBClient;
  8. type
  9. TDoubleArray = array of Double;
  10. TStringArray = array of string;
  11. TGclNode = class
  12. private
  13. FProjectCount: Integer;
  14. FB_Code: string;
  15. FIndexCode: string;
  16. FName: string;
  17. FUnits: string;
  18. FPrice: Double;
  19. FCalcType: Integer;
  20. FQuantity: Double;
  21. FTotalPrice: Double;
  22. FCurGatherQuantity: Double;
  23. FCurGatherTotalPrice: Double;
  24. FEndGatherQuantity: Double;
  25. FEndGatherTotalPrice: Double;
  26. FPreGatherQuantity: Double;
  27. FPreGatherTotalPrice: Double;
  28. FP_Quantity: TDoubleArray;
  29. FP_TotalPrice: TDoubleArray;
  30. FP_CurGatherQuantity: TDoubleArray;
  31. FP_CurGatherTotalPrice: TDoubleArray;
  32. FP_EndGatherQuantity: TDoubleArray;
  33. FP_EndGatherTotalPrice: TDoubleArray;
  34. procedure SetB_Code(const Value: string);
  35. function GetCurPercent: Double;
  36. function GetEndPercent: Double;
  37. public
  38. constructor Create(AProjectCount: Integer);
  39. procedure Calculate;
  40. property B_Code: string read FB_Code write SetB_Code;
  41. property IndexCode: string read FIndexCode;
  42. property Name: string read FName write FName;
  43. property Units: string read FUnits write FUnits;
  44. property Price: Double read FPrice write FPrice;
  45. property CalcType: Integer read FCalcType write FCalcType;
  46. property Quantity: Double read FQuantity write FQuantity;
  47. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  48. property CurGatherQuantity: Double read FCurGatherQuantity write FCurGatherQuantity;
  49. property CurGatherTotalPrice: Double read FCurGatherTotalPrice write FCurGatherTotalPrice;
  50. property EndGatherQuantity: Double read FEndGatherQuantity write FEndGatherQuantity;
  51. property EndGatherTotalPrice: Double read FEndGatherTotalPrice write FEndGatherTotalPrice;
  52. property PreGatherQuantity: Double read FPreGatherQuantity write FPreGatherQuantity;
  53. property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
  54. property P_Quantity: TDoubleArray read FP_Quantity write FP_Quantity;
  55. property P_TotalPrice: TDoubleArray read FP_TotalPrice write FP_TotalPrice;
  56. property P_CurGatherQuantity: TDoubleArray read FP_CurGatherQuantity write FP_CurGatherQuantity;
  57. property P_CurGatherTotalPrice: TDoubleArray read FP_CurGatherTotalPrice write FP_CurGatherTotalPrice;
  58. property P_EndGatherQuantity: TDoubleArray read FP_EndGatherQuantity write FP_EndGatherQuantity;
  59. property P_EndGatherTotalPrice: TDoubleArray read FP_EndGatherTotalPrice write FP_EndGatherTotalPrice;
  60. property CurPercent: Double read GetCurPercent;
  61. property EndPercent: Double read GetEndPercent;
  62. end;
  63. TGclChapter = class
  64. private
  65. FProjectCount: Integer;
  66. FGclNodes: TList;
  67. FChapterID: Integer;
  68. FChapterBegin: Integer;
  69. FChapterEnd: Integer;
  70. FChapterName: string;
  71. FName: string;
  72. FTotalPrice: Double;
  73. FCurGatherTotalPrice: Double;
  74. FEndGatherTotalPrice: Double;
  75. FPreGatherTotalPrice: Double;
  76. FP_TotalPrice: TDoubleArray;
  77. FP_CurGatherTotalPrice: TDoubleArray;
  78. FP_EndGatherTotalPrice: TDoubleArray;
  79. function GetGclNode(AIndex: Integer): TGclNode;
  80. function GetGclNodeCount: Integer;
  81. function GetCurPercent: Double;
  82. function GetEndPercent: Double;
  83. public
  84. constructor Create(AChapterID: Integer; const AName: string; AProjectCount: Integer);
  85. destructor Destroy; override;
  86. procedure AddGclNode(AGclNode: TGclNode);
  87. procedure CalculateChapter;
  88. property ChapterID: Integer read FChapterID;
  89. property ChapterBegin: Integer read FChapterBegin;
  90. property ChapterEnd: Integer read FChapterEnd;
  91. property ChapterName: string read FChapterName;
  92. property Name: string read FName;
  93. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  94. property CurGatherTotalPrice: Double read FCurGatherTotalPrice write FCurGatherTotalPrice;
  95. property EndGatherTotalPrice: Double read FEndGatherTotalPrice write FEndGatherTotalPrice;
  96. property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
  97. property P_TotalPrice: TDoubleArray read FP_TotalPrice write FP_TotalPrice;
  98. property P_CurGatherTotalPrice: TDoubleArray read FP_CurGatherTotalPrice write FP_CurGatherTotalPrice;
  99. property P_EndGatherTotalPrice: TDoubleArray read FP_EndGatherTotalPrice write FP_EndGatherTotalPrice;
  100. property CurPercent: Double read GetCurPercent;
  101. property EndPercent: Double read GetEndPercent;
  102. property GclNodeCount: Integer read GetGclNodeCount;
  103. property GclNode[AIndex: Integer]: TGclNode read GetGclNode;
  104. end;
  105. TGclControl = class
  106. private
  107. FProjectCount: Integer;
  108. FProjectName: TStringArray;
  109. FGclNodes: TList;
  110. FGclChapters: TList;
  111. FGclChapterGather: TGclChapter;
  112. FOtherGcl: TGclChapter;
  113. function FindGclNode(ARec: TBillsRecord): TGclNode;
  114. function NewGclNode(ARec: TBillsRecord): TGclNode;
  115. function B_CodeToChapter(const AB_Code: string): Integer;
  116. procedure LinkGclChapter(AGclNode: TGclNode);
  117. function FindGclChapter(AChapterID: Integer): TGclChapter;
  118. procedure CalculateChapterGather;
  119. function GetGclChapterCount: Integer;
  120. function GetGclChapter(AIndex: Integer): TGclChapter;
  121. public
  122. constructor Create(AProjectCount: Integer; AIsHaBai: Boolean);
  123. destructor Destroy;
  124. function AddGclNode(ANode: TMeasureBillsIDTreeNode; AProjectIndex: Integer): TGclNode; overload;
  125. function AddGclNode(ARec: TBillsRecord; AStageRec: TStageRecord; AProjectIndex: Integer): TGclNode; overload;
  126. procedure ReCalculateTotalPrice;
  127. procedure Calculate;
  128. property GclChapterCount: Integer read GetGclChapterCount;
  129. property GclChapter[AIndex: Integer]: TGclChapter read GetGclChapter;
  130. property GclChapterGather: TGclChapter read FGclChapterGather;
  131. property ProjectName: TStringArray read FProjectName write FProjectName;
  132. property ProjectCount: Integer read FProjectCount;
  133. end;
  134. TPayNode = class
  135. private
  136. FName: string;
  137. FIsMinus: Boolean;
  138. FCurTotalPrice: Double;
  139. FEndTotalPrice: Double;
  140. FPreTotalPrice: Double;
  141. public
  142. property Name: string read FName write FName;
  143. property IsMinus: Boolean read FIsMinus write FisMinus;
  144. property CurTotalPrice: Double read FCurTotalPrice write FCurTotalPrice;
  145. property EndTotalPrice: Double read FEndTotalPrice write FEndTotalPrice;
  146. property PreTotalPrice: Double read FPreTotalPrice write FPreTotalPrice;
  147. end;
  148. TDealPayControl = class
  149. private
  150. FPlusPayNodes: TList;
  151. FMinusPayNodes: TList;
  152. FPlusGather: TPayNode;
  153. FMinusGather: TPayNode;
  154. FGatherPayNode: TPayNode;
  155. FCompletePayNode: TPayNode;
  156. function FindPlusPayNode(const AName: string): TPayNode;
  157. function NewPlusPayNode(const AName: string): TPayNode;
  158. function AddPlusPayNode(const AName: string): TPayNode;
  159. function FindMinusPayNode(const AName: string): TPayNode;
  160. function NewMinusPayNode(const AName: string): TPayNode;
  161. function AddMinusPayNode(const AName: string): TPayNode;
  162. procedure CalculateGather(AGather: TPayNode; ANodes: TList);
  163. function GetMinusPayCount: Integer;
  164. function GetMinusPayNode(AIndex: Integer): TPayNode;
  165. function GetPlusPayCount: Integer;
  166. function GetPlusPayNode(AIndex: Integer): TPayNode;
  167. public
  168. constructor Create;
  169. destructor Destroy; override;
  170. function AddPayNode(const AName: string; AIsMinus: Boolean): TPayNode;
  171. procedure CalculateAll;
  172. property PlusPayCount: Integer read GetPlusPayCount;
  173. property PlusPayNode[AIndex: Integer]: TPayNode read GetPlusPayNode;
  174. property PlusGather: TPayNode read FPlusGather;
  175. property MinusPayCount: Integer read GetMinusPayCount;
  176. property MinusPayNode[AIndex: Integer]:TPayNode read GetMinusPayNode;
  177. property MinusGather: TPayNode read FMinusGather;
  178. property GatherPayNode: TPayNode read FGatherPayNode;
  179. property CompletePayNode: TPayNode read FCompletePayNode;
  180. end;
  181. // 分别对应5张定制汇总表的编号,详见文档
  182. THaBaiGatherType = (hbgt2, hbgt3, hbgt14, hbgt3_1, hbgt4_1, hbgt_CS);
  183. // CS: Counter Sign 会签
  184. TrmHaBaiCustomizedData = class(TDataModule)
  185. cdsCustom2: TClientDataSet;
  186. cdsCustom2Chapter: TIntegerField;
  187. cdsCustom2Name: TWideStringField;
  188. cdsCustom2TotalPrice: TFloatField;
  189. cdsCustom2CTotalPrice: TFloatField;
  190. cdsCustom2GTotalPrice: TFloatField;
  191. cdsCustom2EndGatherTotalPrice: TFloatField;
  192. cdsCustom2PreGatherTotalPrice: TFloatField;
  193. cdsCustom2CurGatherTotalPrice: TFloatField;
  194. cdsCustom2Percent: TFloatField;
  195. cdsCustom3: TClientDataSet;
  196. cdsCustom3ChapterID: TIntegerField;
  197. cdsCustom3InnerPartID: TIntegerField;
  198. cdsCustom3IndexCode: TStringField;
  199. cdsCustom3B_Code: TWideStringField;
  200. cdsCustom3Name: TWideStringField;
  201. cdsCustom3Units: TWideStringField;
  202. cdsCustom3Price: TFloatField;
  203. cdsCustom3Quantity: TFloatField;
  204. cdsCustom3TotalPrice: TFloatField;
  205. cdsCustom3PreGatherQuantity: TFloatField;
  206. cdsCustom3PreGatherTotalPrice: TFloatField;
  207. cdsCustom3EndGatherQuantity: TFloatField;
  208. cdsCustom3EndGatherTotalPrice: TFloatField;
  209. cdsCustom3CurGatherQuantity: TFloatField;
  210. cdsCustom3CurGatherTotalPrice: TFloatField;
  211. cdsCustom3Percent: TFloatField;
  212. cdsCustom14: TClientDataSet;
  213. cdsCustom14IndexCode: TWideStringField;
  214. cdsCustom14B_Code: TWideStringField;
  215. cdsCustom14Name: TWideStringField;
  216. cdsCustom14Units: TWideStringField;
  217. cdsCustom14Price: TFloatField;
  218. cdsCustom14Quantity: TFloatField;
  219. cdsCustom14TotalPrice: TFloatField;
  220. cdsCustom14CertificateCode: TWideStringField;
  221. cdsCustomProj: TClientDataSet;
  222. cdsCustomProjProjectID: TIntegerField;
  223. cdsCustomProjProjectName: TWideStringField;
  224. cdsCustomProjChapterID: TIntegerField;
  225. cdsCustomProjInnerPartID: TIntegerField;
  226. cdsCustomProjIndexCode: TWideStringField;
  227. cdsCustomProjB_Code: TWideStringField;
  228. cdsCustomProjName: TWideStringField;
  229. cdsCustomProjUnits: TWideStringField;
  230. cdsCustomProjPrice: TFloatField;
  231. cdsCustomProjQuantity: TFloatField;
  232. cdsCustomProjTotalPrice: TFloatField;
  233. cdsCustomProjCurGatherQuantity: TFloatField;
  234. cdsCustomProjCurGatherTotalPrice: TFloatField;
  235. cdsCustomProjEndGatherQuantity: TFloatField;
  236. cdsCustomProjEndGatherTotalPrice: TFloatField;
  237. cdsCustomProjP_CurGatherQuantity: TFloatField;
  238. cdsCustomProjP_CurGatherTotalPrice: TFloatField;
  239. cdsCustomProjP_EndGatherQuantity: TFloatField;
  240. cdsCustomProjP_EndGatherTotalPrice: TFloatField;
  241. cdsCustomProjCurPercent: TFloatField;
  242. cdsCustomProjEndPercent: TFloatField;
  243. cdsCustomProjSerialNo: TIntegerField;
  244. // 会签表
  245. // 流水
  246. cdsCustomCS_1: TClientDataSet;
  247. cdsCustomCS_1PulsPayName: TWideStringField;
  248. cdsCustomCS_1PulsPayTotalPrice: TFloatField;
  249. cdsCustomCS_1MinusPayName: TWideStringField;
  250. cdsCustomCS_1MinusPayTotalPrice: TFloatField;
  251. // 账单
  252. cdsCustomCS_2: TClientDataSet;
  253. cdsCustomCS_2DealTotalPrice: TFloatField;
  254. cdsCustomCS_2EndCompleteTotalPrice: TFloatField;
  255. cdsCustomCS_2PreCompleteTotalPrice: TFloatField;
  256. cdsCustomCS_2CurPayTotalPrice: TFloatField;
  257. private
  258. FhbGatherType: THaBaiGatherType;
  259. FProjectData: TProjectData;
  260. FProjectName: string;
  261. FGclControl: TGclControl;
  262. FDealPayControl: TDealPayControl;
  263. FDealTotalPrice: Double;
  264. FIsNewOpen: Boolean;
  265. procedure BeforeGather(AProjectCount: Integer; AIsHaBai: Boolean);
  266. procedure AfterGather;
  267. procedure OpenProjectData(AProject: TSelectProject);
  268. procedure FreeProjectData;
  269. procedure GatherProject(AProject: TSelectProject; AProjectIndex: Integer);
  270. procedure FilterGcl(AProjectIndex: Integer);
  271. procedure FilterDealPay;
  272. procedure WriteFlowData;
  273. procedure WriteReport2;
  274. procedure WriteReport3;
  275. procedure WriteReport3_1;
  276. procedure WriteReport4_1;
  277. procedure WriteReportCounterSign;
  278. procedure WriteData;
  279. public
  280. function AssignData(AProjects: TList; AhbGatherType: THaBaiGatherType; AReCalc: Boolean): TDataSet;
  281. function AssignAssistantData(AhbGatherType: THaBaiGatherType): TDataSet;
  282. property hbGatherType: THaBaiGatherType read FhbGatherType;
  283. end;
  284. implementation
  285. uses
  286. UtilMethods, ZhAPI, BillsCompileDm, sdDB, Globals, Math, BillsMeasureDm,
  287. ZJJLDm, BillsDm, ScUtils, Windows, PhaseData, sdIDTree, StageDm;
  288. {$R *.dfm}
  289. { TrmHaBaiCustomizedData }
  290. function TrmHaBaiCustomizedData.AssignData(AProjects: TList;
  291. AhbGatherType: THaBaiGatherType; AReCalc: Boolean): TDataSet;
  292. var
  293. iProject: Integer;
  294. begin
  295. FhbGatherType := AhbGatherType;
  296. BeforeGather(AProjects.Count, AReCalc);
  297. try
  298. for iProject := 0 to AProjects.Count - 1 do
  299. GatherProject(TSelectProject(AProjects.Items[iProject]), iProject);
  300. if AReCalc then
  301. FGclControl.ReCalculateTotalPrice;
  302. FGclControl.Calculate;
  303. WriteData;
  304. finally
  305. AfterGather;
  306. case FhbGatherType of
  307. hbgt2: Result := cdsCustom2;
  308. hbgt3: Result := cdsCustom3;
  309. hbgt14: Result := cdsCustom14;
  310. hbgt3_1, hbgt4_1: Result := cdsCustomProj;
  311. hbgt_CS: Result := cdsCustomCS_1;
  312. end;
  313. end;
  314. end;
  315. procedure TrmHaBaiCustomizedData.BeforeGather(AProjectCount: Integer; AIsHaBai: Boolean);
  316. begin
  317. cdsCustom2.DisableControls;
  318. cdsCustom2.Active := True;
  319. cdsCustom2.EmptyDataSet;
  320. cdsCustom3.DisableControls;
  321. cdsCustom3.Active := True;
  322. cdsCustom3.EmptyDataSet;
  323. cdsCustom14.DisableControls;
  324. cdsCustom14.Active := True;
  325. cdsCustom14.EmptyDataSet;
  326. cdsCustomProj.DisableControls;
  327. cdsCustomProj.Active := True;
  328. cdsCustomProj.EmptyDataSet;
  329. cdsCustomCS_1.DisableControls;
  330. cdsCustomCS_1.Active := True;
  331. cdsCustomCS_1.EmptyDataSet;
  332. cdsCustomCS_2.DisableControls;
  333. cdsCustomCS_2.Active := True;
  334. cdsCustomCS_2.EmptyDataSet;
  335. FGclControl := TGclControl.Create(AProjectCount, AIsHaBai);
  336. FDealPayControl := TDealPayControl.Create;
  337. FDealTotalPrice := 0;
  338. end;
  339. procedure TrmHaBaiCustomizedData.AfterGather;
  340. begin
  341. FDealPayControl.Free;
  342. FGclControl.Free;
  343. cdsCustomCS_2.EnableControls;
  344. cdsCustomCS_1.EnableControls;
  345. cdsCustomProj.EnableControls;
  346. cdsCustom14.EnableControls;
  347. cdsCustom3.EnableControls;
  348. cdsCustom2.EnableControls;
  349. end;
  350. procedure TrmHaBaiCustomizedData.FreeProjectData;
  351. begin
  352. if not Assigned(OpenProjectManager.FindProjectData(FProjectData.ProjectID)) then
  353. FProjectData.Free;
  354. end;
  355. procedure TrmHaBaiCustomizedData.OpenProjectData(AProject: TSelectProject);
  356. var
  357. Rec: TsdDataRecord;
  358. begin
  359. FIsNewOpen := False;
  360. FProjectData := OpenProjectManager.FindProjectData(AProject.ProjectID);
  361. Rec := ProjectManager.sddProjectsInfo.FindKey('idxID', AProject.ProjectID);
  362. if not Assigned(FProjectData) then
  363. begin
  364. FProjectData := TProjectData.Create;
  365. FProjectData.OpenForReport4(GetMyProjectsFilePath + Rec.ValueByName('FileName').AsString);
  366. FIsNewOpen := True;
  367. end;
  368. FProjectName := Rec.ValueByName('Name').AsString;
  369. end;
  370. procedure TrmHaBaiCustomizedData.GatherProject(AProject: TSelectProject;
  371. AProjectIndex: Integer);
  372. begin
  373. OpenProjectData(AProject);
  374. try
  375. FGclControl.ProjectName[AProjectIndex] := FProjectName;
  376. if FhbGatherType in [hbgt2, hbgt3, hbgt3_1, hbgt4_1] then
  377. FilterGcl(AProjectIndex);
  378. if FhbGatherType in [hbgt2, hbgt_CS] then
  379. FilterDealPay;
  380. if FhbGatherType = hbgt14 then
  381. WriteFlowData;
  382. if FhbGatherType = hbgt_CS then
  383. FDealTotalPrice := FDealTotalPrice + FProjectData.BillsData.Settlement[0];
  384. finally
  385. FreeProjectData;
  386. end;
  387. end;
  388. procedure TrmHaBaiCustomizedData.FilterGcl(AProjectIndex: Integer);
  389. function FindStage(AID: Integer; AList: TList): TStageRecord;
  390. var
  391. i: Integer;
  392. Rec: TStageRecord;
  393. begin
  394. Result := nil;
  395. for i := 0 to AList.Count - 1 do
  396. begin
  397. Rec := TStageRecord(AList.Items[i]);
  398. if Rec.BillsID.AsInteger = AID then
  399. begin
  400. Result := Rec;
  401. Break;
  402. end;
  403. end;
  404. end;
  405. procedure FilterNewOpened;
  406. var
  407. vList: TList;
  408. i: Integer;
  409. GclNode: TGclNode;
  410. Rec: TBillsRecord;
  411. StageRec: TStageRecord;
  412. begin
  413. vList := TList.Create;
  414. try
  415. with FProjectData.PhaseData.StageData do
  416. begin
  417. for i := 0 to sddStage.RecordCount - 1 do
  418. vList.Add(sddStage.Records[i]);
  419. end;
  420. FProjectData.BillsData.sddBills.DisableControls;
  421. FProjectData.PhaseData.StageData.sddStage.DisableControls;
  422. with FProjectData.BillsData do
  423. begin
  424. for i := 0 to sddBills.RecordCount - 1 do
  425. begin
  426. Rec := TBillsRecord(sddBills.Records[i]);
  427. if Rec.IsLeaf.AsBoolean and (Rec.B_Code.AsString <> '') then
  428. begin
  429. StageRec := FindStage(Rec.ID.AsInteger, vList);
  430. GclNode := FGclControl.AddGclNode(Rec, StageRec, AProjectIndex);
  431. vList.Remove(StageRec);
  432. end;
  433. end;
  434. end;
  435. finally
  436. vList.Free;
  437. end;
  438. end;
  439. procedure FilterOrg;
  440. var
  441. i: Integer;
  442. vNode: TMeasureBillsIDTreeNode;
  443. GclNode: TGclNode;
  444. StageRec: TStageRecord;
  445. begin
  446. with FProjectData.BillsMeasureData do
  447. begin
  448. for i := 0 to BillsMeasureTree.Count - 1 do
  449. begin
  450. vNode := TMeasureBillsIDTreeNode(BillsMeasureTree.Items[i]);
  451. if not vNode.HasChildren and (vNode.Rec.B_Code.AsString <> '') then
  452. GclNode := FGclControl.AddGclNode(vNode, AProjectIndex);
  453. end;
  454. end;
  455. end;
  456. begin
  457. if FIsNewOpen then
  458. FilterNewOpened
  459. else
  460. FilterOrg;
  461. end;
  462. procedure TrmHaBaiCustomizedData.FilterDealPay;
  463. var
  464. sCurField, sPreField, sEndField: string;
  465. procedure GatherCommonDealPayData;
  466. var
  467. iRec: Integer;
  468. Rec, StageRec: TsdDataRecord;
  469. DealPay: TPayNode;
  470. begin
  471. with FProjectData.DealPaymentData do
  472. begin
  473. for iRec := 0 to sddDealPayment.RecordCount - 1 do
  474. begin
  475. Rec := sddDealPayment.Records[iRec];
  476. if SameText(Rec.ValueByName('Name').AsString, '本期完成计量') or
  477. SameText(Rec.ValueByName('Name').AsString, '本期应付') or
  478. SameText(Rec.ValueByName('Name').AsString, '本期实付') then
  479. Continue;
  480. if FProjectData.PhaseData.Active then
  481. StageRec := FProjectData.PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger)
  482. else
  483. StageRec := nil;
  484. DealPay := FDealPayControl.AddPayNode(Rec.ValueByName('Name').AsString, Rec.ValueByName('IsMinus').AsBoolean);
  485. if Assigned(StageRec) then
  486. begin
  487. DealPay.CurTotalPrice := DealPay.CurTotalPrice + StageRec.ValueByName(sCurField).AsFloat;
  488. DealPay.PreTotalPrice := DealPay.PreTotalPrice + StageRec.ValueByName(sPreField).AsFloat;
  489. DealPay.EndTotalPrice := DealPay.EndTotalPrice + StageRec.ValueByName(sEndField).AsFloat;
  490. end;
  491. end;
  492. end;
  493. end;
  494. procedure GatherCompletePayData;
  495. var
  496. Rec, StageRec: TsdDataRecord;
  497. begin
  498. Rec := FProjectData.DealPaymentData.DealPayRecord('本期完成计量');
  499. if FProjectData.PhaseData.Active then
  500. StageRec := FProjectData.PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger)
  501. else
  502. StageRec := nil;
  503. if not Assigned(StageRec) then Exit;
  504. with FDealPayControl.CompletePayNode do
  505. begin
  506. CurTotalPrice := CurTotalPrice + StageRec.ValueByName(sCurField).AsFloat;
  507. PreTotalPrice := PreTotalPrice + StageRec.ValueByName(sPreField).AsFloat;
  508. EndTotalPrice := EndTotalPrice + StageRec.ValueByName(sEndField).AsFloat;
  509. end;
  510. end;
  511. procedure GatherPayData;
  512. var
  513. Rec, StageRec: TsdDataRecord;
  514. begin
  515. Rec := FProjectData.DealPaymentData.DealPayRecord('本期应付');
  516. if FProjectData.PhaseData.Active then
  517. StageRec := FProjectData.PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger)
  518. else
  519. StageRec := nil;
  520. if not Assigned(StageRec) then Exit;
  521. with FDealPayControl.GatherPayNode do
  522. begin
  523. CurTotalPrice := CurTotalPrice + StageRec.ValueByName(sCurField).AsFloat;
  524. PreTotalPrice := PreTotalPrice + StageRec.ValueByName(sPreField).AsFloat;
  525. EndTotalPrice := EndTotalPrice + StageRec.ValueByName(sEndField).AsFloat;
  526. end;
  527. end;
  528. begin
  529. sCurField := 'TotalPrice' + IntToStr(FProjectData.PhaseData.AuditCount);
  530. sPreField := 'PreTotalPrice' + IntToStr(FProjectData.PhaseData.AuditCount);
  531. sEndField := 'EndTotalPrice' + IntToStr(FProjectData.PhaseData.AuditCount);
  532. GatherCommonDealPayData;
  533. GatherCompletePayData;
  534. GatherPayData;
  535. FDealPayControl.CalculateAll;
  536. end;
  537. procedure TrmHaBaiCustomizedData.WriteData;
  538. begin
  539. case FhbGatherType of
  540. hbgt2: WriteReport2;
  541. hbgt3: WriteReport3;
  542. hbgt3_1: WriteReport3_1;
  543. hbgt4_1: WriteReport4_1;
  544. hbgt_CS: WriteReportCounterSign;
  545. end;
  546. end;
  547. procedure TrmHaBaiCustomizedData.WriteReport2;
  548. procedure WriteGclChapter(AGclChapter: TGclChapter; const AName: string = '');
  549. begin
  550. cdsCustom2.Append;
  551. if AGclChapter.ChapterBegin > 0 then
  552. cdsCustom2Chapter.AsInteger := AGclChapter.ChapterBegin;
  553. if AName = '' then
  554. cdsCustom2Name.AsString := AGclChapter.Name
  555. else
  556. cdsCustom2Name.AsString := AName;
  557. cdsCustom2TotalPrice.AsFloat := AGclChapter.TotalPrice;
  558. cdsCustom2GTotalPrice.AsFloat := AGclChapter.TotalPrice;
  559. cdsCustom2EndGatherTotalPrice.AsFloat := AGclChapter.EndGatherTotalPrice;
  560. cdsCustom2PreGatherTotalPrice.AsFloat := AGclChapter.PreGatherTotalPrice;
  561. cdsCustom2CurGatherTotalPrice.AsFloat := AGclChapter.CurGatherTotalPrice;
  562. cdsCustom2Percent.AsFloat := AGclChapter.EndPercent;
  563. cdsCustom2.Post;
  564. end;
  565. procedure WriteBlankRecord(const AName: string);
  566. begin
  567. cdsCustom2.Append;
  568. cdsCustom2Name.AsString := AName;
  569. cdsCustom2.Post;
  570. end;
  571. procedure WritePayNode(APayNode: TPayNode; const AName: string = '');
  572. begin
  573. cdsCustom2.Append;
  574. if AName = '' then
  575. cdsCustom2Name.AsString := APayNode.Name
  576. else
  577. cdsCustom2Name.AsString := AName;
  578. cdsCustom2EndGatherTotalPrice.AsFloat := APayNode.EndTotalPrice;
  579. cdsCustom2PreGatherTotalPrice.AsFloat := APayNode.PreTotalPrice;
  580. cdsCustom2CurGatherTotalPrice.AsFloat := APayNode.CurTotalPrice;
  581. cdsCustom2.Post;
  582. end;
  583. procedure WriteSpecialRecord;
  584. begin
  585. cdsCustom2.Append;
  586. cdsCustom2Name.AsString := '合 计';
  587. cdsCustom2EndGatherTotalPrice.AsFloat := FGclControl.GclChapterGather.EndGatherTotalPrice + FDealPayControl.PlusGather.EndTotalPrice;
  588. cdsCustom2PreGatherTotalPrice.AsFloat := FGclControl.GclChapterGather.PreGatherTotalPrice + FDealPayControl.PlusGather.PreTotalPrice;
  589. cdsCustom2CurGatherTotalPrice.AsFloat := FGclControl.GclChapterGather.CurGatherTotalPrice + FDealPayControl.PlusGather.CurTotalPrice;
  590. cdsCustom2.Post;
  591. end;
  592. procedure WriteMentalNode;
  593. begin
  594. cdsCustom2.Append;
  595. cdsCustom2Name.AsString := '支 付';
  596. cdsCustom2EndGatherTotalPrice.AsFloat := FGclControl.GclChapterGather.EndGatherTotalPrice + FDealPayControl.PlusGather.EndTotalPrice
  597. - FDealPayControl.MinusGather.EndTotalPrice;
  598. cdsCustom2PreGatherTotalPrice.AsFloat := FGclControl.GclChapterGather.PreGatherTotalPrice + FDealPayControl.PlusGather.PreTotalPrice
  599. - FDealPayControl.MinusGather.PreTotalPrice;
  600. cdsCustom2CurGatherTotalPrice.AsFloat := FGclControl.GclChapterGather.CurGatherTotalPrice + FDealPayControl.PlusGather.CurTotalPrice
  601. - FDealPayControl.MinusGather.CurTotalPrice;
  602. cdsCustom2.Post;
  603. end;
  604. var
  605. iIndex: Integer;
  606. begin
  607. for iIndex := 0 to FGclControl.GclChapterCount - 1 do
  608. WriteGclChapter(FGclControl.GclChapter[iIndex]);
  609. WriteGclChapter(FGclControl.GclChapterGather);
  610. WriteGclChapter(FGclControl.GclChapterGather, '小 计');
  611. WriteBlankRecord('价格调整');
  612. WriteBlankRecord('违约罚金');
  613. WriteBlankRecord('迟付款利息');
  614. for iIndex := 0 to FDealPayControl.PlusPayCount - 1 do
  615. WritePayNode(FDealPayControl.PlusPayNode[iIndex]);
  616. WriteSpecialRecord;
  617. for iIndex := 0 to FDealPayControl.MinusPayCount - 1 do
  618. WritePayNode(FDealPayControl.MinusPayNode[iIndex]);
  619. //WritePayNode(FDealPayControl.GatherPayNode, '支 付');
  620. // 神经病有毛病
  621. WriteMentalNode;
  622. end;
  623. procedure TrmHaBaiCustomizedData.WriteReport3;
  624. procedure WriteChapterName(AGclChapter: TGclChapter);
  625. begin
  626. cdsCustom3.Append;
  627. cdsCustom3ChapterID.AsInteger := AGclChapter.ChapterID;
  628. cdsCustom3InnerPartID.AsInteger := 1;
  629. cdsCustom3B_Code.AsString := AGclChapter.ChapterName;
  630. cdsCustom3Name.AsString := AGclChapter.Name;
  631. cdsCustom3.Post;
  632. end;
  633. procedure WriteGclNodeData(AGclNode: TGclNode; AChapterID: Integer);
  634. begin
  635. cdsCustom3.Append;
  636. cdsCustom3ChapterID.AsInteger := AChapterID;
  637. cdsCustom3InnerPartID.AsInteger := 2;
  638. cdsCustom3IndexCode.AsString := AGclNode.IndexCode;
  639. cdsCustom3B_Code.AsString := AGclNode.B_Code;
  640. cdsCustom3Name.AsString := AGclNode.Name;
  641. cdsCustom3Units.AsString := AGclNode.Units;
  642. cdsCustom3Price.AsFloat := AGclNode.Price;
  643. cdsCustom3Quantity.AsFloat := AGclNode.Quantity;
  644. cdsCustom3TotalPrice.AsFloat := AGclNode.TotalPrice;
  645. cdsCustom3CurGatherQuantity.AsFloat := AGclNode.CurGatherQuantity;
  646. cdsCustom3CurGatherTotalPrice.AsFloat := AGclNode.CurGatherTotalPrice;
  647. cdsCustom3EndGatherQuantity.AsFloat := AGclNode.EndGatherQuantity;
  648. cdsCustom3EndGatherTotalPrice.AsFloat := AGclNode.EndGatherTotalPrice;
  649. cdsCustom3PreGatherQuantity.AsFloat := AGclNode.PreGatherQuantity;
  650. cdsCustom3PreGatherTotalPrice.AsFloat := AGclNode.PreGatherTotalPrice;
  651. cdsCustom3Percent.AsFloat := AGclNode.EndPercent;
  652. cdsCustom3.Post;
  653. end;
  654. procedure WriteChapterGather(AGclChapter: TGclChapter; const AName: string = '');
  655. begin
  656. cdsCustom3.Append;
  657. cdsCustom3ChapterID.AsInteger := AGclChapter.ChapterID;
  658. cdsCustom3InnerPartID.AsInteger := 3;
  659. if AName = '' then
  660. cdsCustom3Name.AsString := AGclChapter.Name
  661. else
  662. cdsCustom3Name.AsString := AName;
  663. cdsCustom3TotalPrice.AsFloat := AGclChapter.TotalPrice;
  664. cdsCustom3CurGatherTotalPrice.AsFloat := AGclChapter.CurGatherTotalPrice;
  665. cdsCustom3EndGatherTotalPrice.AsFloat := AGclChapter.EndGatherTotalPrice;
  666. cdsCustom3PreGatherTotalPrice.AsFloat := AGclChapter.PreGatherTotalPrice;
  667. cdsCustom3Percent.AsFloat := AGclChapter.EndPercent;
  668. cdsCustom3.Post;
  669. end;
  670. procedure WriteGclChapterData(AGclChapter: TGclChapter);
  671. var
  672. iGcl: Integer;
  673. begin
  674. if AGclChapter.GclNodeCount = 0 then Exit;
  675. WriteChapterName(AGclChapter);
  676. for iGcl := 0 to AGclChapter.GclNodeCount - 1 do
  677. WriteGclNodeData(AGclChapter.GclNode[iGcl], AGclChapter.ChapterID);
  678. WriteChapterGather(AGclChapter, Format('%s 小计', [AGclChapter.ChapterName]));
  679. end;
  680. var
  681. iIndex: Integer;
  682. begin
  683. for iIndex := 0 to FGclControl.GclChapterCount - 1 do
  684. WriteGclChapterData(FGclControl.GclChapter[iIndex]);
  685. WriteChapterGather(FGclControl.GclChapterGather, '第100章~第900章 合计');
  686. end;
  687. procedure TrmHaBaiCustomizedData.WriteReport3_1;
  688. var
  689. iProject, iChapter: Integer;
  690. sProjectName: string;
  691. procedure WriteChapterName(AGclChapter: TGclChapter);
  692. begin
  693. cdsCustomProj.Append;
  694. cdsCustomProjProjectID.AsInteger := iProject;
  695. cdsCustomProjProjectName.AsString := sProjectName;
  696. cdsCustomProjChapterID.AsInteger := AGclChapter.ChapterID;
  697. cdsCustomProjInnerPartID.AsInteger := 1;
  698. cdsCustomProjB_Code.AsString := AGclChapter.ChapterName;
  699. cdsCustomProjName.AsString := AGclChapter.Name;
  700. cdsCustomProj.Post;
  701. end;
  702. procedure WriteGclNodeData(AGclNode: TGclNode; AChapterID: Integer);
  703. begin
  704. cdsCustomProj.Append;
  705. cdsCustomProjProjectID.AsInteger := iProject;
  706. cdsCustomProjProjectName.AsString := sProjectName;
  707. cdsCustomProjChapterID.AsInteger := AChapterID;
  708. cdsCustomProjInnerPartID.AsInteger := 2;
  709. cdsCustomProjIndexCode.AsString := AGclNode.IndexCode;
  710. cdsCustomProjB_Code.AsString := AGclNode.B_Code;
  711. cdsCustomProjName.AsString := AGclNode.Name;
  712. cdsCustomProjUnits.AsString := AGclNode.Units;
  713. cdsCustomProjPrice.AsFloat := AGclNode.Price;
  714. cdsCustomProjQuantity.AsFloat := AGclNode.Quantity;
  715. cdsCustomProjTotalPrice.AsFloat := AGclNode.TotalPrice;
  716. cdsCustomProjCurGatherQuantity.AsFloat := AGclNode.CurGatherQuantity;
  717. cdsCustomProjCurGatherTotalPrice.AsFloat := AGclNode.CurGatherTotalPrice;
  718. cdsCustomProjEndGatherQuantity.AsFloat := AGclNode.EndGatherQuantity;
  719. cdsCustomProjEndGatherTotalPrice.AsFloat := AGclNode.EndGatherTotalPrice;
  720. cdsCustomProjP_CurGatherQuantity.AsFloat := AGclNode.P_CurGatherQuantity[iProject];
  721. cdsCustomProjP_CurGatherTotalPrice.AsFloat := AGclNode.P_CurGatherTotalPrice[iProject];
  722. cdsCustomProjP_EndGatherQuantity.AsFloat := AGclNode.P_EndGatherQuantity[iProject];
  723. cdsCustomProjP_EndGatherTotalPrice.AsFloat := AGclNode.P_EndGatherTotalPrice[iProject];
  724. cdsCustomProjCurPercent.AsFloat := AGclNode.CurPercent;
  725. cdsCustomProjEndPercent.AsFloat := AGclNode.EndPercent;
  726. cdsCustomProj.Post;
  727. end;
  728. procedure WriteChapterGather(AGclChapter: TGclChapter; const AName: string = '');
  729. begin
  730. cdsCustomProj.Append;
  731. cdsCustomProjProjectID.AsInteger := iProject;
  732. cdsCustomProjProjectName.AsString := sProjectName;
  733. cdsCustomProjChapterID.AsInteger := AGclChapter.ChapterID;
  734. cdsCustomProjInnerPartID.AsInteger := 3;
  735. if AName = '' then
  736. cdsCustomProjName.AsString := AGclChapter.Name
  737. else
  738. cdsCustomProjName.AsString := AName;
  739. cdsCustomProjTotalPrice.AsFloat := AGclChapter.TotalPrice;
  740. cdsCustomProjCurGatherTotalPrice.AsFloat := AGclChapter.CurGatherTotalPrice;
  741. cdsCustomProjEndGatherTotalPrice.AsFloat := AGclChapter.EndGatherTotalPrice;
  742. cdsCustomProjP_CurGatherTotalPrice.AsFloat := AGclChapter.P_CurGatherTotalPrice[iProject];
  743. cdsCustomProjP_EndGatherTotalPrice.AsFloat := AGclChapter.P_EndGatherTotalPrice[iProject];
  744. cdsCustomProjCurPercent.AsFloat := AGclChapter.CurPercent;
  745. cdsCustomProjEndPercent.AsFloat := AGclChapter.EndPercent;
  746. cdsCustomProj.Post;
  747. end;
  748. procedure WriteGclChapterData(AGclChapter: TGclChapter);
  749. var
  750. iGcl: Integer;
  751. begin
  752. if AGclChapter.GclNodeCount = 0 then Exit;
  753. WriteChapterName(AGclChapter);
  754. for iGcl := 0 to AGclChapter.GclNodeCount - 1 do
  755. WriteGclNodeData(AGclChapter.GclNode[iGcl], AGclChapter.ChapterID);
  756. WriteChapterGather(AGclChapter, Format('%s 小计', [AGclChapter.ChapterName]));
  757. end;
  758. begin
  759. for iProject := 0 to FGclControl.ProjectCount - 1 do
  760. begin
  761. sProjectName := FGclControl.ProjectName[iProject];
  762. for iChapter := 0 to FGclControl.GclChapterCount - 1 do
  763. WriteGclChapterData(FGclControl.GclChapter[iChapter]);
  764. WriteChapterGather(FGclControl.GclChapterGather, '第100章至第900章 合计');
  765. end;
  766. end;
  767. procedure TrmHaBaiCustomizedData.WriteReport4_1;
  768. var
  769. iProject, iChapter, iSerial: Integer;
  770. sProjectName: string;
  771. procedure WriteGclNodeData(AGclNode: TGclNode; AChapterID: Integer);
  772. begin
  773. cdsCustomProj.Append;
  774. cdsCustomProjProjectID.AsInteger := iProject;
  775. cdsCustomProjProjectName.AsString := sProjectName;
  776. cdsCustomProjChapterID.AsInteger := AChapterID;
  777. cdsCustomProjInnerPartID.AsInteger := 2;
  778. cdsCustomProjIndexCode.AsString := AGclNode.IndexCode;
  779. cdsCustomProjB_Code.AsString := AGclNode.B_Code;
  780. cdsCustomProjName.AsString := AGclNode.Name;
  781. cdsCustomProjUnits.AsString := AGclNode.Units;
  782. cdsCustomProjPrice.AsFloat := AGclNode.Price;
  783. cdsCustomProjQuantity.AsFloat := AGclNode.Quantity;
  784. cdsCustomProjTotalPrice.AsFloat := AGclNode.TotalPrice;
  785. cdsCustomProjCurGatherQuantity.AsFloat := AGclNode.CurGatherQuantity;
  786. cdsCustomProjCurGatherTotalPrice.AsFloat := AGclNode.CurGatherTotalPrice;
  787. cdsCustomProjEndGatherQuantity.AsFloat := AGclNode.EndGatherQuantity;
  788. cdsCustomProjEndGatherTotalPrice.AsFloat := AGclNode.EndGatherTotalPrice;
  789. cdsCustomProjP_CurGatherQuantity.AsFloat := AGclNode.P_CurGatherQuantity[iProject];
  790. cdsCustomProjP_CurGatherTotalPrice.AsFloat := AGclNode.P_CurGatherTotalPrice[iProject];
  791. cdsCustomProjP_EndGatherQuantity.AsFloat := AGclNode.P_EndGatherQuantity[iProject];
  792. cdsCustomProjP_EndGatherTotalPrice.AsFloat := AGclNode.P_EndGatherTotalPrice[iProject];
  793. cdsCustomProjCurPercent.AsFloat := AGclNode.CurPercent;
  794. cdsCustomProjEndPercent.AsFloat := AGclNode.EndPercent;
  795. cdsCustomProj.Post;
  796. end;
  797. procedure WriteGclChapterData(AGclChapter: TGclChapter);
  798. var
  799. iGcl: Integer;
  800. begin
  801. if AGclChapter.GclNodeCount = 0 then Exit;
  802. for iGcl := 0 to AGclChapter.GclNodeCount - 1 do
  803. WriteGclNodeData(AGclChapter.GclNode[iGcl], AGclChapter.ChapterID);
  804. end;
  805. procedure WriteChapterGather(AGclChapter: TGclChapter; const AName: string = '');
  806. begin
  807. cdsCustomProj.Append;
  808. cdsCustomProjProjectID.AsInteger := iProject;
  809. cdsCustomProjProjectName.AsString := sProjectName;
  810. cdsCustomProjChapterID.AsInteger := AGclChapter.ChapterID;
  811. cdsCustomProjInnerPartID.AsInteger := 3;
  812. if AName = '' then
  813. cdsCustomProjName.AsString := AGclChapter.Name
  814. else
  815. cdsCustomProjName.AsString := AName;
  816. cdsCustomProjTotalPrice.AsFloat := AGclChapter.TotalPrice;
  817. cdsCustomProjCurGatherTotalPrice.AsFloat := AGclChapter.CurGatherTotalPrice;
  818. cdsCustomProjEndGatherTotalPrice.AsFloat := AGclChapter.EndGatherTotalPrice;
  819. cdsCustomProjP_CurGatherTotalPrice.AsFloat := AGclChapter.P_CurGatherTotalPrice[iProject];
  820. cdsCustomProjP_EndGatherTotalPrice.AsFloat := AGclChapter.P_EndGatherTotalPrice[iProject];
  821. cdsCustomProjCurPercent.AsFloat := AGclChapter.CurPercent;
  822. cdsCustomProjEndPercent.AsFloat := AGclChapter.EndPercent;
  823. cdsCustomProj.Post;
  824. end;
  825. procedure ResortSerialNo;
  826. var
  827. iSerialNo, iProject: Integer;
  828. begin
  829. iSerialNo := 1;
  830. cdsCustomProj.First;
  831. iProject := cdsCustomProjProjectID.AsInteger;
  832. while not cdsCustomProj.Eof do
  833. begin
  834. if iProject <> cdsCustomProjProjectID.AsInteger then
  835. begin
  836. iProject := cdsCustomProjProjectID.AsInteger;
  837. iSerialNo := 1;
  838. end;
  839. cdsCustomProj.Edit;
  840. cdsCustomProjSerialNo.AsInteger := iSerialNo;
  841. cdsCustomProj.Post;
  842. Inc(iSerialNo);
  843. cdsCustomProj.Next;
  844. end;
  845. end;
  846. begin
  847. for iProject := 0 to FGclControl.ProjectCount - 1 do
  848. begin
  849. sProjectName := FGclControl.ProjectName[iProject];
  850. for iChapter := 0 to FGclControl.GclChapterCount - 1 do
  851. WriteGclChapterData(FGclControl.GclChapter[iChapter]);
  852. WriteChapterGather(FGclControl.GclChapterGather, '第100章至第900章 合计');
  853. end;
  854. ResortSerialNo;
  855. end;
  856. procedure TrmHaBaiCustomizedData.WriteFlowData;
  857. procedure AddNodeData(ANode: TMeasureBillsIDTreeNode);
  858. var
  859. vRec: TsdDataRecord;
  860. begin
  861. cdsCustom14.Append;
  862. cdsCustom14IndexCode.AsString := ANode.Rec.IndexCode.AsString;
  863. cdsCustom14B_Code.AsString := ANode.Rec.B_Code.AsString;
  864. cdsCustom14Name.AsString := ANode.Rec.Name.AsString;
  865. cdsCustom14Units.AsString := ANode.Rec.Units.AsString;
  866. cdsCustom14Price.AsFloat := ANode.Rec.Price.AsFloat;
  867. cdsCustom14Quantity.AsFloat := ANode.StageRec.GatherQuantity.AsFloat;
  868. cdsCustom14TotalPrice.AsFloat := ANode.StageRec.GatherTotalPrice.AsFloat;
  869. with FProjectData.PhaseData.ZJJLData do
  870. begin
  871. vRec := sddZJJL.FindKey('idxBillsID', ANode.ID);
  872. if Assigned(vRec) then
  873. cdsCustom14CertificateCode.AsString := vRec.ValueByName('CertificateCode').AsString;
  874. end;
  875. cdsCustom14.Post;
  876. end;
  877. var
  878. iIndex: Integer;
  879. vNode: TMeasureBillsIDTreeNode;
  880. begin
  881. for iIndex := 0 to FProjectData.BillsMeasureData.BillsMeasureTree.Count - 1 do
  882. begin
  883. vNode := TMeasureBillsIDTreeNode(FProjectData.BillsMeasureData.BillsMeasureTree.Items[iIndex]);
  884. if (not vNode.HasChildren) and (vNode.Rec.B_Code.AsString <> '') and
  885. Assigned(vNode.StageRec) and (vNode.StageRec.GatherTotalPrice.AsFloat <> 0) then
  886. AddNodeData(vNode);
  887. end;
  888. end;
  889. function TrmHaBaiCustomizedData.AssignAssistantData(
  890. AhbGatherType: THaBaiGatherType): TDataSet;
  891. begin
  892. Result := nil;
  893. if (AhbGatherType = hbgt_CS) and (FhbGatherType = hbgt_CS) then
  894. Result := cdsCustomCS_2;
  895. end;
  896. procedure TrmHaBaiCustomizedData.WriteReportCounterSign;
  897. procedure WriteCounterSign1;
  898. var
  899. i: Integer;
  900. PayNode: TPayNode;
  901. begin
  902. cdsCustomCS_1.Append;
  903. cdsCustomCS_1PulsPayName.AsString := '本期完成金额';
  904. cdsCustomCS_1PulsPayTotalPrice.AsFloat := FDealPayControl.CompletePayNode.CurTotalPrice;
  905. cdsCustomCS_1.Post;
  906. for i := 0 to FDealPayControl.PlusPayCount - 1 do
  907. begin
  908. PayNode := FDealPayControl.PlusPayNode[i];
  909. cdsCustomCS_1.Append;
  910. cdsCustomCS_1PulsPayName.AsString := PayNode.Name;
  911. cdsCustomCS_1PulsPayTotalPrice.AsFloat := PayNode.CurTotalPrice;
  912. cdsCustomCS_1.Post;
  913. end;
  914. cdsCustomCS_1.Append;
  915. cdsCustomCS_1PulsPayName.AsString := '迟付款利息';
  916. cdsCustomCS_1.Post;
  917. cdsCustomCS_1.First;
  918. for i := 0 to FDealPayControl.MinusPayCount - 1 do
  919. begin
  920. PayNode := FDealPayControl.MinusPayNode[i];
  921. if cdsCustomCS_1.Eof then
  922. cdsCustomCS_1.Append
  923. else
  924. cdsCustomCS_1.Edit;
  925. cdsCustomCS_1MinusPayName.AsString := PayNode.Name;
  926. cdsCustomCS_1MinusPayTotalPrice.AsFloat := PayNode.CurTotalPrice;
  927. cdsCustomCS_1.Post;
  928. cdsCustomCS_1.Next;
  929. end;
  930. end;
  931. procedure WriteCounterSign2;
  932. begin
  933. cdsCustomCS_2.Append;
  934. cdsCustomCS_2DealTotalPrice.AsFloat := FDealTotalPrice;
  935. cdsCustomCS_2EndCompleteTotalPrice.AsFloat := FDealPayControl.CompletePayNode.EndTotalPrice;
  936. cdsCustomCS_2PreCompleteTotalPrice.AsFloat := FDealPayControl.CompletePayNode.PreTotalPrice;
  937. cdsCustomCS_2CurPayTotalPrice.AsFloat := FDealPayControl.GatherPayNode.CurTotalPrice;
  938. cdsCustomCS_2.Post;
  939. end;
  940. begin
  941. WriteCounterSign1;
  942. WriteCounterSign2;
  943. end;
  944. { TGclNode }
  945. procedure TGclNode.Calculate;
  946. var
  947. i: Integer;
  948. begin
  949. // 金额模式下不重算
  950. if CalcType <> 0 then Exit;
  951. FTotalPrice := FPrice * FQuantity;
  952. FCurGatherTotalPrice := FPrice * FCurGatherQuantity;
  953. FEndGatherTotalPrice := FPrice * FEndGatherQuantity;
  954. FPreGatherTotalPrice := FPrice * FPreGatherQuantity;
  955. for i := 0 to FProjectCount - 1 do
  956. begin
  957. FP_TotalPrice[i] := FPrice * FP_Quantity[i];
  958. FP_CurGatherTotalPrice[i] := FPrice * FP_CurGatherQuantity[i];
  959. FP_EndGatherTotalPrice[i] := FPrice * FP_EndGatherQuantity[i];
  960. end;
  961. end;
  962. constructor TGclNode.Create(AProjectCount: Integer);
  963. begin
  964. FProjectCount := AProjectCount;
  965. SetLength(FP_Quantity, FProjectCount);
  966. SetLength(FP_TotalPrice, FProjectCount);
  967. SetLength(FP_CurGatherQuantity, FProjectCount);
  968. SetLength(FP_CurGatherTotalPrice, FProjectCount);
  969. SetLength(FP_EndGatherQuantity, FProjectCount);
  970. SetLength(FP_EndGatherTotalPrice, FProjectCount);
  971. end;
  972. function TGclNode.GetCurPercent: Double;
  973. begin
  974. if TotalPrice <> 0 then
  975. Result := CurGatherTotalPrice/TotalPrice*100
  976. else
  977. Result := 0;
  978. end;
  979. function TGclNode.GetEndPercent: Double;
  980. begin
  981. if TotalPrice <> 0 then
  982. Result := EndGatherTotalPrice/TotalPrice*100
  983. else
  984. Result := 0;
  985. end;
  986. procedure TGclNode.SetB_Code(const Value: string);
  987. begin
  988. FB_Code := Value;
  989. FIndexCode := B_CodeToIndexCode(FB_Code);
  990. end;
  991. { TGclControl }
  992. function TGclControl.AddGclNode(ANode: TMeasureBillsIDTreeNode; AProjectIndex: Integer): TGclNode;
  993. begin
  994. Result := FindGclNode(ANode.Rec);
  995. if not Assigned(Result) then
  996. Result := NewGclNode(ANode.Rec);
  997. with ANode.Rec do
  998. begin
  999. Result.Quantity := Result.Quantity + Quantity.AsFloat;
  1000. Result.TotalPrice := Result.TotalPrice + TotalPrice.AsFloat;
  1001. Result.P_Quantity[AProjectIndex] := Result.P_Quantity[AProjectIndex] + Quantity.AsFloat;
  1002. Result.P_TotalPrice[AProjectIndex] := Result.P_TotalPrice[AProjectIndex] + TotalPrice.AsFloat;
  1003. end;
  1004. if Assigned(ANode.StageRec) then
  1005. with ANode.StageRec do
  1006. begin
  1007. Result.CurGatherQuantity := Result.CurGatherQuantity + GatherQuantity.AsFloat;
  1008. Result.CurGatherTotalPrice := Result.CurGatherTotalPrice + GatherTotalPrice.AsFloat;
  1009. Result.P_CurGatherQuantity[AProjectIndex] := Result.P_CurGatherQuantity[AProjectIndex] + GatherQuantity.AsFloat;
  1010. Result.P_CurGatherTotalPrice[AProjectIndex] := Result.P_CurGatherTotalPrice[AProjectIndex] + GatherTotalPrice.AsFloat;
  1011. Result.EndGatherQuantity := Result.EndGatherQuantity + EndGatherQuantity.AsFloat;
  1012. Result.EndGatherTotalPrice := Result.EndGatherTotalPrice + EndGatherTotalPrice.AsFloat;
  1013. Result.P_EndGatherQuantity[AProjectIndex] := Result.P_EndGatherQuantity[AProjectIndex] + EndGatherQuantity.AsFloat;
  1014. Result.P_EndGatherTotalPrice[AProjectIndex] := Result.P_EndGatherTotalPrice[AProjectIndex] + EndGatherTotalPrice.AsFloat;
  1015. Result.PreGatherQuantity := Result.PreGatherQuantity + PreGatherQuantity.AsFloat;
  1016. Result.PreGatherTotalPrice := Result.PreGatherTotalPrice + PreGatherTotalPrice.AsFloat;
  1017. end;
  1018. end;
  1019. function TGclControl.B_CodeToChapter(const AB_Code: string): Integer;
  1020. var
  1021. sgs: TStrings;
  1022. iFirst, iSecond: Integer;
  1023. begin
  1024. Result := 0;
  1025. sgs := TStringList.Create;
  1026. try
  1027. sgs.Delimiter := '-';
  1028. sgs.DelimitedText := AB_Code;
  1029. iFirst := StrToIntDef(sgs.Strings[0], 0);
  1030. Result := Trunc(iFirst/100);
  1031. if (Result >= 90) and (Result < 100) then
  1032. Result := 9;
  1033. finally
  1034. sgs.Free;
  1035. end;
  1036. end;
  1037. procedure TGclControl.CalculateChapterGather;
  1038. var
  1039. iIndex, iProject: Integer;
  1040. vGclChapter: TGclChapter;
  1041. begin
  1042. FGclChapterGather.TotalPrice := 0;
  1043. FGclChapterGather.CurGatherTotalPrice := 0;
  1044. FGclChapterGather.EndGatherTotalPrice := 0;
  1045. FGclChapterGather.PreGatherTotalPrice := 0;
  1046. for iProject := 0 to FProjectCount - 1 do
  1047. begin
  1048. FGclChapterGather.P_TotalPrice[iProject] := 0;
  1049. FGclChapterGather.P_CurGatherTotalPrice[iProject] := 0;
  1050. FGclChapterGather.P_EndGatherTotalPrice[iProject] := 0;
  1051. end;
  1052. for iIndex := 0 to FGclChapters.Count - 1 do
  1053. begin
  1054. vGclChapter := TGclChapter(FGclChapters.Items[iIndex]);
  1055. with FGclChapterGather do
  1056. begin
  1057. TotalPrice := TotalPrice + vGclChapter.TotalPrice;
  1058. CurGatherTotalPrice := CurGatherTotalPrice + vGclChapter.CurGatherTotalPrice;
  1059. EndGatherTotalPrice := EndGatherTotalPrice + vGclChapter.EndGatherTotalPrice;
  1060. PreGatherTotalPrice := PreGatherTotalPrice + vGclChapter.PreGatherTotalPrice;
  1061. for iProject := 0 to FProjectCount - 1 do
  1062. begin
  1063. P_TotalPrice[iProject] := P_TotalPrice[iProject] + vGclChapter.P_TotalPrice[iProject];
  1064. P_CurGatherTotalPrice[iProject] := P_CurGatherTotalPrice[iProject] + vGclChapter.P_CurGatherTotalPrice[iProject];
  1065. P_EndGatherTotalPrice[iProject] := P_EndGatherTotalPrice[iProject] + vGclChapter.P_EndGatherTotalPrice[iProject];
  1066. end;
  1067. end;
  1068. end;
  1069. end;
  1070. constructor TGclControl.Create(AProjectCount: Integer; AIsHaBai: Boolean);
  1071. function CreateGclChapter(AChapterID: Integer; const AName: string): TGclChapter;
  1072. begin
  1073. Result := TGclChapter.Create(AChapterID, AName, FProjectCount);
  1074. FGclChapters.Add(Result);
  1075. end;
  1076. begin
  1077. FProjectCount := AProjectCount;
  1078. SetLength(FProjectName, AProjectCount);
  1079. FGclNodes := TList.Create;
  1080. FGclChapters := TList.Create;
  1081. CreateGclChapter(1, '总 则');
  1082. CreateGclChapter(2, '路 基');
  1083. CreateGclChapter(3, '路 面');
  1084. CreateGclChapter(4, '桥梁、涵洞工程');
  1085. CreateGclChapter(5, '隧 道');
  1086. CreateGclChapter(6, '安全设计及预埋管线');
  1087. CreateGclChapter(7, '绿化及环境保护工程');
  1088. if AIsHaBai then
  1089. begin
  1090. CreateGclChapter(8, '房建工程');
  1091. CreateGclChapter(9, '机电工程');
  1092. end
  1093. else
  1094. begin
  1095. CreateGclChapter(8, '机电工程');
  1096. CreateGclChapter(9, '房建工程');
  1097. end;
  1098. FOtherGcl := TGclChapter.Create(19, '非标准清单', FProjectCount);
  1099. FGclChapterGather := TGclChapter.Create(20, '第100章至900章合计', FProjectCount);
  1100. end;
  1101. destructor TGclControl.Destroy;
  1102. begin
  1103. FOtherGcl.Free;
  1104. FGclChapterGather.Free;
  1105. ClearObjects(FGclChapters);
  1106. FGclChapters.Free;
  1107. ClearObjects(FGclNodes);
  1108. FGclNodes.Free;
  1109. end;
  1110. function TGclControl.FindGclNode(ARec: TBillsRecord): TGclNode;
  1111. var
  1112. iIndex: Integer;
  1113. vGclNode: TGclNode;
  1114. bSameCode, bSameName, bSameUnits, bSamePrice: Boolean;
  1115. begin
  1116. Result := nil;
  1117. for iIndex := 0 to FGclNodes.Count - 1 do
  1118. begin
  1119. vGclNode := TGclNode(FGclNodes.Items[iIndex]);
  1120. if (vGclNode.B_Code = ARec.B_Code.AsString) and
  1121. (vGclNode.Name = ARec.Name.AsString) and
  1122. (vGclNode.Units = ARec.Units.AsString) and
  1123. (vGclNode.Price = ARec.Price.AsFloat) and
  1124. (vGclNode.CalcType = ARec.CalcType.AsInteger)then
  1125. begin
  1126. Result := vGclNode;
  1127. Break;
  1128. end;
  1129. end;
  1130. end;
  1131. function TGclControl.FindGclChapter(AChapterID: Integer): TGclChapter;
  1132. var
  1133. iIndex: Integer;
  1134. vChapter: TGclChapter;
  1135. begin
  1136. Result := nil;
  1137. for iIndex := 0 to FGclChapters.Count - 1 do
  1138. begin
  1139. vChapter := TGclChapter(FGclChapters.Items[iIndex]);
  1140. if vChapter.ChapterID = AChapterID then
  1141. begin
  1142. Result := vChapter;
  1143. Break;
  1144. end;
  1145. end;
  1146. end;
  1147. function TGclControl.GetGclChapter(AIndex: Integer): TGclChapter;
  1148. begin
  1149. Result := TGclChapter(FGclChapters.Items[AIndex]);
  1150. end;
  1151. function TGclControl.GetGclChapterCount: Integer;
  1152. begin
  1153. Result := FGclChapters.Count;
  1154. end;
  1155. procedure TGclControl.LinkGclChapter(AGclNode: TGclNode);
  1156. var
  1157. iChapterID: Integer;
  1158. vChapter: TGclChapter;
  1159. begin
  1160. iChapterID := B_CodeToChapter(AGclNode.B_Code);
  1161. vChapter := FindGclChapter(iChapterID);
  1162. if Assigned(vChapter) then
  1163. vChapter.AddGclNode(AGclNode)
  1164. else
  1165. FOtherGcl.AddGclNode(AGclNode);
  1166. end;
  1167. function TGclControl.NewGclNode(ARec: TBillsRecord): TGclNode;
  1168. begin
  1169. Result := TGclNode.Create(FProjectCount);
  1170. FGclNodes.Add(Result);
  1171. Result.B_Code := ARec.B_Code.AsString;
  1172. Result.Name := ARec.Name.AsString;
  1173. Result.Units := ARec.Units.AsString;
  1174. Result.Price := ARec.Price.AsFloat;
  1175. Result.CalcType := ARec.CalcType.AsInteger;
  1176. LinkGclChapter(Result);
  1177. end;
  1178. procedure TGclControl.Calculate;
  1179. var
  1180. i: Integer;
  1181. begin
  1182. for i := 0 to GclChapterCount - 1 do
  1183. GclChapter[i].CalculateChapter;
  1184. CalculateChapterGather;
  1185. end;
  1186. procedure TGclControl.ReCalculateTotalPrice;
  1187. var
  1188. iGcl: Integer;
  1189. begin
  1190. for iGcl := 0 to FGclNodes.Count - 1 do
  1191. TGclNode(FGclNodes[iGcl]).Calculate;
  1192. end;
  1193. function TGclControl.AddGclNode(ARec: TBillsRecord; AStageRec: TStageRecord;
  1194. AProjectIndex: Integer): TGclNode;
  1195. begin
  1196. Result := FindGclNode(ARec);
  1197. if not Assigned(Result) then
  1198. Result := NewGclNode(ARec);
  1199. with ARec do
  1200. begin
  1201. Result.Quantity := Result.Quantity + Quantity.AsFloat;
  1202. Result.TotalPrice := Result.TotalPrice + TotalPrice.AsFloat;
  1203. Result.P_Quantity[AProjectIndex] := Result.P_Quantity[AProjectIndex] + Quantity.AsFloat;
  1204. Result.P_TotalPrice[AProjectIndex] := Result.P_TotalPrice[AProjectIndex] + TotalPrice.AsFloat;
  1205. end;
  1206. if Assigned(AStageRec) then
  1207. with AStageRec do
  1208. begin
  1209. Result.CurGatherQuantity := Result.CurGatherQuantity + GatherQuantity.AsFloat;
  1210. Result.CurGatherTotalPrice := Result.CurGatherTotalPrice + GatherTotalPrice.AsFloat;
  1211. Result.P_CurGatherQuantity[AProjectIndex] := Result.P_CurGatherQuantity[AProjectIndex] + GatherQuantity.AsFloat;
  1212. Result.P_CurGatherTotalPrice[AProjectIndex] := Result.P_CurGatherTotalPrice[AProjectIndex] + GatherTotalPrice.AsFloat;
  1213. Result.EndGatherQuantity := Result.EndGatherQuantity + EndGatherQuantity.AsFloat;
  1214. Result.EndGatherTotalPrice := Result.EndGatherTotalPrice + EndGatherTotalPrice.AsFloat;
  1215. Result.P_EndGatherQuantity[AProjectIndex] := Result.P_EndGatherQuantity[AProjectIndex] + EndGatherQuantity.AsFloat;
  1216. Result.P_EndGatherTotalPrice[AProjectIndex] := Result.P_EndGatherTotalPrice[AProjectIndex] + EndGatherTotalPrice.AsFloat;
  1217. Result.PreGatherQuantity := Result.PreGatherQuantity + PreGatherQuantity.AsFloat;
  1218. Result.PreGatherTotalPrice := Result.PreGatherTotalPrice + PreGatherTotalPrice.AsFloat;
  1219. end;
  1220. end;
  1221. { TGclChapter }
  1222. procedure TGclChapter.AddGclNode(AGclNode: TGclNode);
  1223. begin
  1224. FGclNodes.Add(AGclNode);
  1225. end;
  1226. procedure TGclChapter.CalculateChapter;
  1227. var
  1228. iIndex, iProject: Integer;
  1229. vGclNode: TGclNode;
  1230. begin
  1231. FTotalPrice := 0;
  1232. FCurGatherTotalPrice := 0;
  1233. FEndGatherTotalPrice := 0;
  1234. FPreGatherTotalPrice := 0;
  1235. for iProject := 0 to FProjectCount - 1 do
  1236. begin
  1237. FP_TotalPrice[iProject] := 0;
  1238. FP_CurGatherTotalPrice[iProject] := 0;
  1239. FP_EndGatherTotalPrice[iProject] := 0;
  1240. end;
  1241. for iIndex := 0 to FGclNodes.Count - 1 do
  1242. begin
  1243. vGclNode := TGclNode(FGclNodes.Items[iIndex]);
  1244. FTotalPrice := FTotalPrice + vGclNode.TotalPrice;
  1245. FCurGatherTotalPrice := FCurGatherTotalPrice + vGclNode.FCurGatherTotalPrice;
  1246. FEndGatherTotalPrice := FEndGatherTotalPrice + vGclNode.FEndGatherTotalPrice;
  1247. FPreGatherTotalPrice := FPreGatherTotalPrice + vGclNode.FPreGatherTotalPrice;
  1248. for iProject := 0 to FProjectCount - 1 do
  1249. begin
  1250. FP_TotalPrice[iProject] := FP_TotalPrice[iProject] + vGclNode.P_TotalPrice[iProject];
  1251. FP_CurGatherTotalPrice[iProject] := FP_CurGatherTotalPrice[iProject] + vGclNode.P_CurGatherTotalPrice[iProject];
  1252. FP_EndGatherTotalPrice[iProject] := FP_EndGatherTotalPrice[iProject] + vGclNode.P_EndGatherTotalPrice[iProject];
  1253. end;
  1254. end;
  1255. end;
  1256. constructor TGclChapter.Create(AChapterID: Integer; const AName: string;
  1257. AProjectCount: Integer);
  1258. begin
  1259. FGclNodes := TList.Create;
  1260. FChapterID := AChapterID;
  1261. if FChapterID < 19 then
  1262. begin
  1263. FChapterBegin := FChapterID * 100;
  1264. FChapterEnd := FChapterBegin + 99;
  1265. FChapterName := Format('第%d章', [FChapterBegin]);
  1266. end;
  1267. FName := AName;
  1268. FProjectCount := AProjectCount;
  1269. SetLength(FP_TotalPrice, FProjectCount);
  1270. SetLength(FP_CurGatherTotalPrice, FProjectCount);
  1271. SetLength(FP_EndGatherTotalPrice, FProjectCount);
  1272. end;
  1273. destructor TGclChapter.Destroy;
  1274. begin
  1275. FGclNodes.Free;
  1276. inherited;
  1277. end;
  1278. function TGclChapter.GetCurPercent: Double;
  1279. begin
  1280. if TotalPrice <> 0 then
  1281. Result := CurGatherTotalPrice/TotalPrice*100
  1282. else
  1283. Result := 0;
  1284. end;
  1285. function TGclChapter.GetEndPercent: Double;
  1286. begin
  1287. if TotalPrice <> 0 then
  1288. Result := EndGatherTotalPrice/TotalPrice*100
  1289. else
  1290. Result := 0;
  1291. end;
  1292. function TGclChapter.GetGclNode(AIndex: Integer): TGclNode;
  1293. begin
  1294. Result := TGclNode(FGclNodes.Items[AIndex]);
  1295. end;
  1296. function TGclChapter.GetGclNodeCount: Integer;
  1297. begin
  1298. Result := FGclNodes.Count;
  1299. end;
  1300. { TDealPayControl }
  1301. function TDealPayControl.AddMinusPayNode(const AName: string): TPayNode;
  1302. begin
  1303. Result := FindMinusPayNode(AName);
  1304. if not Assigned(Result) then
  1305. Result := NewMinusPayNode(AName);
  1306. end;
  1307. function TDealPayControl.AddPayNode(const AName: string;
  1308. AIsMinus: Boolean): TPayNode;
  1309. begin
  1310. if AIsMinus then
  1311. Result := AddMinusPayNode(AName)
  1312. else
  1313. Result := AddPlusPayNode(AName);
  1314. end;
  1315. function TDealPayControl.AddPlusPayNode(const AName: string): TPayNode;
  1316. begin
  1317. Result := FindPlusPayNode(AName);
  1318. if not Assigned(Result) then
  1319. Result := NewPlusPayNode(AName);
  1320. end;
  1321. procedure TDealPayControl.CalculateAll;
  1322. begin
  1323. CalculateGather(FPlusGather, FPlusPayNodes);
  1324. CalculateGather(FMinusGather, FMinusPayNodes);
  1325. end;
  1326. procedure TDealPayControl.CalculateGather(AGather: TPayNode; ANodes: TList);
  1327. var
  1328. i: Integer;
  1329. vPayNode: TPayNode;
  1330. begin
  1331. AGather.CurTotalPrice := 0;
  1332. AGather.EndTotalPrice := 0;
  1333. AGather.PreTotalPrice := 0;
  1334. for i := 0 to ANodes.Count - 1 do
  1335. begin
  1336. vPayNode := TPayNode(ANodes.Items[i]);
  1337. AGather.CurTotalPrice := AGather.CurTotalPrice + vPayNode.CurTotalPrice;
  1338. AGather.EndTotalPrice := AGather.EndTotalPrice + vPayNode.EndTotalPrice;
  1339. AGather.PreTotalPrice := AGather.PreTotalPrice + vPayNode.PreTotalPrice;
  1340. end;
  1341. end;
  1342. constructor TDealPayControl.Create;
  1343. begin
  1344. FPlusPayNodes := TList.Create;
  1345. FMinusPayNodes := TList.Create;
  1346. FPlusGather := TPayNode.Create;
  1347. FMinusGather := TPayNode.Create;
  1348. FGatherPayNode := TPayNode.Create;
  1349. FGatherPayNode.Name := '本期应付';
  1350. FCompletePayNode :=TPayNode.Create;
  1351. FCompletePayNode.Name := '本期完成计量';
  1352. end;
  1353. destructor TDealPayControl.Destroy;
  1354. begin
  1355. FCompletePayNode.Free;
  1356. FGatherPayNode.Free;
  1357. FMinusGather.Free;
  1358. FPlusGather.Free;
  1359. ClearObjects(FMinusPayNodes);
  1360. FMinusPayNodes.Free;
  1361. ClearObjects(FPlusPayNodes);
  1362. FPlusPayNodes.Free;
  1363. inherited;
  1364. end;
  1365. function TDealPayControl.FindMinusPayNode(const AName: string): TPayNode;
  1366. var
  1367. iIndex: Integer;
  1368. vPayNode: TPayNode;
  1369. begin
  1370. Result := nil;
  1371. for iIndex := 0 to FMinusPayNodes.Count -1 do
  1372. begin
  1373. vPayNode := TPayNode(FMinusPayNodes.Items[iIndex]);
  1374. if (vPayNode.Name = AName) then
  1375. begin
  1376. Result := vPayNode;
  1377. Break;
  1378. end;
  1379. end;
  1380. end;
  1381. function TDealPayControl.FindPlusPayNode(const AName: string): TPayNode;
  1382. var
  1383. iIndex: Integer;
  1384. vPayNode: TPayNode;
  1385. begin
  1386. Result := nil;
  1387. for iIndex := 0 to FPlusPayNodes.Count -1 do
  1388. begin
  1389. vPayNode := TPayNode(FPlusPayNodes.Items[iIndex]);
  1390. if (vPayNode.Name = AName) then
  1391. begin
  1392. Result := vPayNode;
  1393. Break;
  1394. end;
  1395. end;
  1396. end;
  1397. function TDealPayControl.GetMinusPayCount: Integer;
  1398. begin
  1399. Result := FMinusPayNodes.Count;
  1400. end;
  1401. function TDealPayControl.GetMinusPayNode(AIndex: Integer): TPayNode;
  1402. begin
  1403. Result := TPayNode(FMinusPayNodes.Items[AIndex]);
  1404. end;
  1405. function TDealPayControl.GetPlusPayCount: Integer;
  1406. begin
  1407. Result := FPlusPayNodes.Count;
  1408. end;
  1409. function TDealPayControl.GetPlusPayNode(AIndex: Integer): TPayNode;
  1410. begin
  1411. Result := TPayNode(FPlusPayNodes.Items[AIndex]);
  1412. end;
  1413. function TDealPayControl.NewMinusPayNode(const AName: string): TPayNode;
  1414. begin
  1415. Result := TPayNode.Create;
  1416. FMinusPayNodes.Add(Result);
  1417. Result.Name := AName;
  1418. Result.IsMinus := True;
  1419. end;
  1420. function TDealPayControl.NewPlusPayNode(const AName: string): TPayNode;
  1421. begin
  1422. Result := TPayNode.Create;
  1423. FPlusPayNodes.Add(Result);
  1424. Result.Name := AName;
  1425. Result.IsMinus := False;
  1426. end;
  1427. end.