rmZhongKaiDm.pas 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. unit rmZhongKaiDm;
  2. // 中开定制报表
  3. interface
  4. uses
  5. SysUtils, Classes, DB, DBClient, ProjectData, mDataRecord, sdDB,
  6. rmSelectProjectFrm, BillsTree;
  7. type
  8. TGclNode = class
  9. private
  10. FB_Code: string;
  11. FIndexCode: string;
  12. FName: string;
  13. FUnits: string;
  14. FPrice: Double;
  15. FCalcType: Integer;
  16. FCTotalPrice: Double;
  17. FCurGatherQuantity: Double;
  18. FCurGatherTotalPrice: Double;
  19. FEndGatherQuantity: Double;
  20. FEndGatherTotalPrice: Double;
  21. FPreGatherQuantity: Double;
  22. FPreGatherTotalPrice: Double;
  23. FEndPqcQuantity: Double;
  24. FEndPqcTotalPrice: Double;
  25. FEndPqcaTotalPrice: Double;
  26. FEndMqcQuantity: Double;
  27. FEndMqcTotalPrice: Double;
  28. FEndMqcaTotalPrice: Double;
  29. FEndQcQuantity: Double;
  30. FEndQcTotalPrice: Double;
  31. FEndQcaTotalPrice: Double;
  32. FDealQuantity: Double;
  33. FDealTotalPrice: Double;
  34. procedure SetB_Code(const Value: string);
  35. public
  36. property B_Code: string read FB_Code write SetB_Code;
  37. property IndexCode: string read FIndexCode;
  38. property Name: string read FName write FName;
  39. property Units: string read FUnits write FUnits;
  40. property Price: Double read FPrice write FPrice;
  41. property CalcType: Integer read FCalcType write FCalcType;
  42. property CurGatherQuantity: Double read FCurGatherQuantity write FCurGatherQuantity;
  43. property CurGatherTotalPrice: Double read FCurGatherTotalPrice write FCurGatherTotalPrice;
  44. property EndGatherQuantity: Double read FEndGatherQuantity write FEndGatherQuantity;
  45. property EndGatherTotalPrice: Double read FEndGatherTotalPrice write FEndGatherTotalPrice;
  46. property PreGatherQuantity: Double read FPreGatherQuantity write FPreGatherQuantity;
  47. property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
  48. property EndPqcQuantity: Double read FEndPqcQuantity write FEndPqcQuantity;
  49. property EndPqcTotalPrice: Double read FEndPqcTotalPrice write FEndPqcTotalPrice;
  50. property EndPqcaTotalPrice: Double read FEndPqcaTotalPrice write FEndPqcaTotalPrice;
  51. property EndMqcQuantity: Double read FEndMqcQuantity write FEndMqcQuantity;
  52. property EndMqcTotalPrice: Double read FEndMqcTotalPrice write FEndMqcTotalPrice;
  53. property EndMqcaTotalPrice: Double read FEndMqcaTotalPrice write FEndMqcaTotalPrice;
  54. property EndQcQuantity: Double read FEndQcQuantity write FEndQcQuantity;
  55. property EndQcTotalPrice: Double read FEndQcTotalPrice write FEndQcTotalPrice;
  56. property EndQcaTotalPrice: Double read FEndQcaTotalPrice write FEndQcaTotalPrice;
  57. property DealQuantity: Double read FDealQuantity write FDealQuantity;
  58. property DealTotalPrice: Double read FDealTotalPrice write FDealTotalPrice;
  59. end;
  60. TGclChapter = class
  61. private
  62. FGclNodes: TList;
  63. FChapterID: Integer;
  64. FChapterBegin: Integer;
  65. FChapterEnd: Integer;
  66. FChapterName: string;
  67. FName: string;
  68. FTotalPrice: Double;
  69. FCTotalPrice: Double;
  70. FGTotalPrice: Double;
  71. FCurGatherTotalPrice: Double;
  72. FEndGatherTotalPrice: Double;
  73. FPreGatherTotalPrice: Double;
  74. FEndPqcTotalPrice: Double;
  75. FEndPqcaTotalPrice: Double;
  76. FEndMqcTotalPrice: Double;
  77. FEndMqcaTotalPrice: Double;
  78. FEndQcTotalPrice: Double;
  79. FEndQcaTotalPrice: Double;
  80. FDealTotalPrice: Double;
  81. function GetCurPercent: Double;
  82. function GetEndPercent: Double;
  83. function GetPrePercent: Double;
  84. function GetGclNodeCount: Integer;
  85. function GetGclNode(AIndex: Integer): TGclNode;
  86. public
  87. constructor Create(AID: Integer; AName: string);
  88. destructor Destroy; override;
  89. procedure AddGclNode(AGclNode: TGclNode);
  90. procedure CalculateChapter;
  91. property ChapterID: Integer read FChapterID;
  92. property ChapterBegin: Integer read FChapterBegin;
  93. property ChapterEnd: Integer read FChapterEnd;
  94. property ChapterName: string read FChapterName;
  95. property Name: string read FName;
  96. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  97. property CTotalPrice: Double read FCTotalPrice write FCTotalPrice;
  98. property GTotalPrice: Double read FGTotalPrice write FGTotalPrice;
  99. property CurGatherTotalPrice: Double read FCurGatherTotalPrice write FCurGatherTotalPrice;
  100. property EndGatherTotalPrice: Double read FEndGatherTotalPrice write FEndGatherTotalPrice;
  101. property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
  102. property CurPercent: Double read GetCurPercent;
  103. property EndPercent: Double read GetEndPercent;
  104. property PrePercent: Double read GetPrePercent;
  105. property EndPqcTotalPrice: Double read FEndPqcTotalPrice write FEndPqcTotalPrice;
  106. property EndPqcaTotalPrice: Double read FEndPqcaTotalPrice write FEndPqcaTotalPrice;
  107. property EndMqcTotalPrice: Double read FEndMqcTotalPrice write FEndMqcTotalPrice;
  108. property EndMqcaTotalPrice: Double read FEndMqcaTotalPrice write FEndMqcaTotalPrice;
  109. property EndQcTotalPrice: Double read FEndQcTotalPrice write FEndQcTotalPrice;
  110. property EndQcaTotalPrice: Double read FEndQcaTotalPrice write FEndQcaTotalPrice;
  111. property DealTotalPrice: Double read FDealTotalPrice write FDealTotalPrice;
  112. property GclNodeCount: Integer read GetGclNodeCount;
  113. property GclNode[AIndex: Integer]: TGclNode read GetGclNode;
  114. end;
  115. TGclControl = class
  116. private
  117. FGclNodes: TList;
  118. FGclChapters: TList;
  119. FOtherGcl: TGclChapter;
  120. FGclChapterGather: TGclChapter;
  121. function FindGclChapter(const AB_Code: string): TGclChapter;
  122. procedure LinkGclChapter(AGclNode: TGclNode);
  123. procedure CalculateChapterGather;
  124. function FindGclNode(ARec: TBillsRecord): TGclNode;
  125. function NewGclNode(ARec: TBillsRecord): TGclNode;
  126. function FindDealGclNode(ADealRec: TsdDataRecord): TGclNode;
  127. function NewDealGclNode(ADealRec: TsdDataRecord): TGclNode;
  128. function GetGclChapterCount: Integer;
  129. function GetGclChapter(AIndex: Integer): TGclChapter;
  130. public
  131. constructor Create;
  132. destructor Destroy; override;
  133. function AddGclNode(ARec: TBillsRecord; AStageRec: TStageRecord): TGclNode;
  134. procedure AddDealData(ARec: TsdDataRecord);
  135. procedure Calculate;
  136. property GclChapterCount: Integer read GetGclChapterCount;
  137. property GclChapter[AIndex: Integer]: TGclChapter read GetGclChapter;
  138. property OtherGcl: TGclChapter read FOtherGcl;
  139. property GclChapterGather: TGclChapter read FGclChapterGather;
  140. end;
  141. TPayNode = class
  142. private
  143. FName: string;
  144. FTotalPrice: Double;
  145. FCurTotalPrice: Double;
  146. FEndTotalPrice: Double;
  147. FPreTotalPrice: Double;
  148. function GetCurPercent: Double;
  149. function GetEndPercent: Double;
  150. function GetPrePercent: Double;
  151. public
  152. constructor Create(const AName: string);
  153. property Name: string read FName;
  154. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  155. property CurTotalPrice: Double read FCurTotalPrice write FCurTotalPrice;
  156. property EndTotalPrice: Double read FEndTotalPrice write FEndTotalPrice;
  157. property PreTotalPrice: Double read FPreTotalPrice write FPreTotalPrice;
  158. property CurPercent: Double read GetCurPercent;
  159. property EndPercent: Double read GetEndPercent;
  160. property PrePercent: Double read GetPrePercent;
  161. end;
  162. TDealPayControl = class
  163. private
  164. FPreCalc: TPayNode;
  165. FTiaoPeiJin: TPayNode;
  166. FHeJi: TPayNode;
  167. FJiaGeTiaoZheng: TPayNode;
  168. FSuoPeiJinE: TPayNode;
  169. FLinShiYongDi: TPayNode;
  170. FBaoXianFei: TPayNode;
  171. FZongJi: TPayNode;
  172. FOtherPays: TList;
  173. FZhiFu: TPayNode;
  174. function FindOtherPayNode(const AName: string): TPayNode;
  175. function NewOtherPayNode(const AName: string): TPayNode;
  176. function GetOtherPay(AIndex: Integer): TPayNode;
  177. function GetOtherPayCount: Integer;
  178. public
  179. constructor Create;
  180. destructor Destroy; override;
  181. function FindPayNode(const AName: string): TPayNode;
  182. procedure CalculateAll;
  183. property PreCalc: TPayNode read FPreCalc;
  184. property TiaoPeiJin: TPayNode read FTiaoPeiJin;
  185. property HeJi: TPayNode read FHeJi;
  186. property JiaGeTiaoZheng: TPayNode read FJiaGeTiaoZheng;
  187. property SuoPeiJinE: TPayNode read FSuoPeiJinE;
  188. property LinShiYongDi: TPayNode read FLinShiYongDi;
  189. property BaoXianFei: TPayNode read FBaoXianFei;
  190. property ZongJi: TPayNode read FZongJi;
  191. property OtherPay[AIndex: Integer]: TPayNode read GetOtherPay;
  192. property OtherPayCount: Integer read GetOtherPayCount;
  193. property ZhiFu: TPayNode read FZhiFu;
  194. end;
  195. TZhongKaiGatherType = (zkgt2, zkgt3);
  196. TrmZhongKaiData = class(TDataModule)
  197. cdsCustom2: TClientDataSet;
  198. cdsCustom2ChapterID: TIntegerField;
  199. cdsCustom2Chapter: TWideStringField;
  200. cdsCustom2Name: TWideStringField;
  201. cdsCustom2TotalPrice: TFloatField;
  202. cdsCustom2CTotalPrice: TFloatField;
  203. cdsCustom2GTotalPrice: TFloatField;
  204. cdsCustom2EndGatherTotalPrice: TFloatField;
  205. cdsCustom2EndPercent: TFloatField;
  206. cdsCustom2PreGatherTotalPrice: TFloatField;
  207. cdsCustom2PrePercent: TFloatField;
  208. cdsCustom2CurGatherTotalPrice: TFloatField;
  209. cdsCustom2CurPercent: TFloatField;
  210. cdsCustom3: TClientDataSet;
  211. cdsCustom3ChapterID: TIntegerField;
  212. cdsCustom3IndexCode: TWideStringField;
  213. cdsCustom3B_Code: TWideStringField;
  214. cdsCustom3Name: TWideStringField;
  215. cdsCustom3Units: TWideStringField;
  216. cdsCustom3Price: TFloatField;
  217. cdsCustom3DealQuantity: TFloatField;
  218. cdsCustom3DealTotalPrice: TFloatField;
  219. cdsCustom3EndMqcQuantity: TFloatField;
  220. cdsCustom3EndMqcTotalPrice: TFloatField;
  221. cdsCustom3EndMqcaTotalPrice: TFloatField;
  222. cdsCustom3EndPqcQuantity: TFloatField;
  223. cdsCustom3EndPqcTotalPrice: TFloatField;
  224. cdsCustom3EndPqcaTotalPrice: TFloatField;
  225. cdsCustom3EndQcQuantity: TFloatField;
  226. cdsCustom3EndQcTotalPrice: TFloatField;
  227. cdsCustom3EndQcaTotalPrice: TFloatField;
  228. cdsCustom3GQuantity: TFloatField;
  229. cdsCustom3GTotalPrice: TFloatField;
  230. cdsCustom3EndGatherQuantity: TFloatField;
  231. cdsCustom3EndGatherTotalPrice: TFloatField;
  232. cdsCustom3PreGatherQuantity: TFloatField;
  233. cdsCustom3PreGatherTotalPrice: TFloatField;
  234. cdsCustom3CurGatherQuantity: TFloatField;
  235. cdsCustom3CurGatherTotalPrice: TFloatField;
  236. private
  237. FzkGatherType: TZhongKaiGatherType;
  238. FIsNewOpen: Boolean;
  239. FProjectData: TProjectData;
  240. FGclControl: TGclControl;
  241. FDealPayControl: TDealPayControl;
  242. procedure BeforeGather(AProjectCount: Integer);
  243. procedure AfterGather;
  244. procedure OpenProjectData(AProject: TSelectProject);
  245. procedure FreeProjectData;
  246. procedure FilterGcl;
  247. procedure FilterDealPay;
  248. procedure FilterDealBills;
  249. procedure GatherProject(AProject: TSelectProject);
  250. procedure WriteReport2;
  251. procedure WriteReport3;
  252. procedure WriteData;
  253. public
  254. function AssignData(AProjects: TList; AzkGatherType: TZhongKaiGatherType): TDataSet;
  255. end;
  256. implementation
  257. uses
  258. UtilMethods, ZhAPI, Globals, DealBillsDm;
  259. {$R *.dfm}
  260. { TGclControl }
  261. procedure TGclControl.AddDealData(ARec: TsdDataRecord);
  262. var
  263. vGclNode: TGclNode;
  264. begin
  265. vGclNode := FindDealGclNode(ARec);
  266. if not Assigned(vGclNode) then
  267. vGclNode := NewDealGclNode(ARec);
  268. vGclNode.DealQuantity := vGclNode.DealQuantity + ARec.ValueByName('Quantity').AsFloat;
  269. vGclNode.DealTotalPrice := vGclNode.DealTotalPrice + ARec.ValueByName('TotalPrice').AsFloat;
  270. end;
  271. function TGclControl.AddGclNode(ARec: TBillsRecord;
  272. AStageRec: TStageRecord): TGclNode;
  273. begin
  274. Result := FindGclNode(ARec);
  275. if not Assigned(Result) then
  276. Result := NewGclNode(ARec);
  277. if Assigned(AStageRec) then
  278. begin
  279. Result.CurGatherQuantity := Result.CurGatherQuantity + AStageRec.GatherQuantity.AsFloat;
  280. Result.CurGatherTotalPrice := Result.CurGatherTotalPrice + AStageRec.GatherTotalPrice.AsFloat;
  281. Result.EndGatherQuantity := Result.EndGatherQuantity + AStageRec.EndGatherQuantity.AsFloat;
  282. Result.EndGatherTotalPrice := Result.EndGatherTotalPrice + AStageRec.EndGatherTotalPrice.AsFloat;
  283. Result.PreGatherQuantity := Result.PreGatherQuantity + AStageRec.PreGatherQuantity.AsFloat;
  284. Result.PreGatherTotalPrice := Result.PreGatherTotalPrice + AStageRec.PreGatherTotalPrice.AsFloat;
  285. end;
  286. end;
  287. procedure TGclControl.Calculate;
  288. var
  289. i: Integer;
  290. begin
  291. for i := 0 to FGclChapters.Count - 1 do
  292. GclChapter[i].CalculateChapter;
  293. OtherGcl.CalculateChapter;
  294. CalculateChapterGather;
  295. end;
  296. procedure TGclControl.CalculateChapterGather;
  297. var
  298. iIndex, iProject: Integer;
  299. vGclChapter: TGclChapter;
  300. begin
  301. FGclChapterGather.TotalPrice := 0;
  302. FGclChapterGather.CurGatherTotalPrice := 0;
  303. FGclChapterGather.EndGatherTotalPrice := 0;
  304. FGclChapterGather.PreGatherTotalPrice := 0;
  305. for iIndex := 0 to FGclChapters.Count - 1 do
  306. begin
  307. vGclChapter := TGclChapter(FGclChapters.Items[iIndex]);
  308. with FGclChapterGather do
  309. begin
  310. TotalPrice := TotalPrice + vGclChapter.TotalPrice;
  311. CTotalPrice := CTotalPrice + vGclChapter.CTotalPrice;
  312. CurGatherTotalPrice := CurGatherTotalPrice + vGclChapter.CurGatherTotalPrice;
  313. EndGatherTotalPrice := EndGatherTotalPrice + vGclChapter.EndGatherTotalPrice;
  314. PreGatherTotalPrice := PreGatherTotalPrice + vGclChapter.PreGatherTotalPrice;
  315. end;
  316. end;
  317. with FGclChapterGather do
  318. begin
  319. TotalPrice := TotalPrice + OtherGcl.TotalPrice;
  320. CTotalPrice := CTotalPrice + OtherGcl.CTotalPrice;
  321. CurGatherTotalPrice := CurGatherTotalPrice + OtherGcl.CurGatherTotalPrice;
  322. EndGatherTotalPrice := EndGatherTotalPrice + OtherGcl.EndGatherTotalPrice;
  323. PreGatherTotalPrice := PreGatherTotalPrice + OtherGcl.PreGatherTotalPrice;
  324. end;
  325. end;
  326. constructor TGclControl.Create;
  327. function CreateGclChapter(AChapterID: Integer; const AName: string; ATotalPrice: Double): TGclChapter;
  328. begin
  329. Result := TGclChapter.Create(AChapterID, AName);
  330. Result.TotalPrice := ATotalPrice;
  331. FGclChapters.Add(Result);
  332. end;
  333. begin
  334. FGclNodes := TList.Create;
  335. FGclChapters := TList.Create;
  336. CreateGclChapter(1, '总则', 381525229);
  337. CreateGclChapter(2, '路基工程', 1514953910);
  338. CreateGclChapter(3, '路面工程', 796118656);
  339. CreateGclChapter(4, '桥梁、涵洞工程', 4912677553);
  340. CreateGclChapter(5, '隧道工程', 0);
  341. CreateGclChapter(6, '安全设施及预埋管线', 165165432);
  342. CreateGclChapter(7, '绿化及环境保护工程', 163726129);
  343. CreateGclChapter(8, '机电工程', 273752856);
  344. CreateGclChapter(9, '附属区房建工程', 160025390);
  345. FOtherGcl := TGclChapter.Create(19, '未计入章节清单合计');
  346. FOtherGcl.TotalPrice := 0;
  347. FGclChapterGather := TGclChapter.Create(20, '小计');
  348. FGclChapterGather.TotalPrice := 8367944755;
  349. end;
  350. destructor TGclControl.Destroy;
  351. begin
  352. FGclChapterGather.Free;
  353. FOtherGcl.Free;
  354. ClearObjects(FGclChapters);
  355. FGclChapters.Free;
  356. ClearObjects(FGclNodes);
  357. FGclNodes.Free;
  358. inherited;
  359. end;
  360. function TGclControl.FindDealGclNode(ADealRec: TsdDataRecord): TGclNode;
  361. var
  362. iIndex: Integer;
  363. vGclNode: TGclNode;
  364. begin
  365. Result := nil;
  366. for iIndex := 0 to FGclNodes.Count - 1 do
  367. begin
  368. vGclNode := TGclNode(FGclNodes.Items[iIndex]);
  369. if (vGclNode.B_Code = ADealRec.ValueByName('B_Code').AsString) and
  370. (vGclNode.Name = ADealRec.ValueByName('Name').AsString) and
  371. (vGclNode.Units = ADealRec.ValueByName('Units').AsString) and
  372. (vGclNode.Price = ADealRec.ValueByName('Price').AsFloat) then
  373. begin
  374. Result := vGclNode;
  375. Break;
  376. end;
  377. end;
  378. end;
  379. function TGclControl.FindGclChapter(const AB_Code: string): TGclChapter;
  380. function GetFirstLevelCode: string;
  381. var
  382. sgs: TStrings;
  383. begin
  384. sgs := TStringList.Create;
  385. sgs.Delimiter := '-';
  386. sgs.DelimitedText := AB_Code;
  387. if sgs.Count > 0 then
  388. Result := sgs.Strings[0]
  389. else
  390. Result := '';
  391. sgs.Free;
  392. end;
  393. var
  394. iFirst, iIndex: Integer;
  395. vChapter: TGclChapter;
  396. begin
  397. iFirst := StrToIntDef(GetFirstLevelCode, 0);
  398. Result := nil;
  399. for iIndex := 0 to FGclChapters.Count - 1 do
  400. begin
  401. vChapter := TGclChapter(FGclChapters.Items[iIndex]);
  402. if (iFirst >= vChapter.ChapterBegin) and (iFirst <= vChapter.ChapterEnd) then
  403. begin
  404. Result := vChapter;
  405. Break;
  406. end;
  407. end;
  408. end;
  409. function TGclControl.FindGclNode(ARec: TBillsRecord): TGclNode;
  410. var
  411. iIndex: Integer;
  412. vGclNode: TGclNode;
  413. bSameCode, bSameName, bSameUnits, bSamePrice: Boolean;
  414. begin
  415. Result := nil;
  416. for iIndex := 0 to FGclNodes.Count - 1 do
  417. begin
  418. vGclNode := TGclNode(FGclNodes.Items[iIndex]);
  419. if (vGclNode.B_Code = ARec.B_Code.AsString) and
  420. (vGclNode.Name = ARec.Name.AsString) and
  421. (vGclNode.Units = ARec.Units.AsString) and
  422. (vGclNode.Price = ARec.Price.AsFloat) then
  423. begin
  424. Result := vGclNode;
  425. Break;
  426. end;
  427. end;
  428. end;
  429. function TGclControl.GetGclChapter(AIndex: Integer): TGclChapter;
  430. begin
  431. Result := TGclChapter(FGclChapters.Items[AIndex]);
  432. end;
  433. function TGclControl.GetGclChapterCount: Integer;
  434. begin
  435. Result := FGclChapters.Count;
  436. end;
  437. procedure TGclControl.LinkGclChapter(AGclNode: TGclNode);
  438. var
  439. vChapter: TGclChapter;
  440. begin
  441. vChapter := FindGclChapter(AGclNode.B_Code);
  442. if Assigned(vChapter) then
  443. vChapter.AddGclNode(AGclNode)
  444. else
  445. FOtherGcl.AddGclNode(AGclNode);
  446. end;
  447. function TGclControl.NewDealGclNode(ADealRec: TsdDataRecord): TGclNode;
  448. begin
  449. Result := TGclNode.Create;
  450. FGclNodes.Add(Result);
  451. Result.B_Code := ADealRec.ValueByName('B_Code').AsString;
  452. Result.Name := ADealRec.ValueByName('Name').AsString;
  453. Result.Units := ADealRec.ValueByName('Units').AsString;
  454. Result.Price := ADealRec.ValueByName('Price').AsFloat;
  455. LinkGclChapter(Result);
  456. end;
  457. function TGclControl.NewGclNode(ARec: TBillsRecord): TGclNode;
  458. begin
  459. Result := TGclNode.Create;
  460. FGclNodes.Add(Result);
  461. Result.B_Code := ARec.B_Code.AsString;
  462. Result.Name := ARec.Name.AsString;
  463. Result.Units := ARec.Units.AsString;
  464. Result.Price := ARec.Price.AsFloat;
  465. Result.CalcType := ARec.CalcType.AsInteger;
  466. LinkGclChapter(Result);
  467. end;
  468. { TGclChapter }
  469. procedure TGclChapter.AddGclNode(AGclNode: TGclNode);
  470. begin
  471. FGclNodes.Add(AGclNode);
  472. end;
  473. procedure TGclChapter.CalculateChapter;
  474. var
  475. iIndex: Integer;
  476. vGclNode: TGclNode;
  477. begin
  478. FCTotalPrice := 0;
  479. FCurGatherTotalPrice := 0;
  480. FEndGatherTotalPrice := 0;
  481. FPreGatherTotalPrice := 0;
  482. FEndPqcTotalPrice := 0;
  483. FEndPqcaTotalPrice := 0;
  484. FEndMqcTotalPrice := 0;
  485. FEndMqcaTotalPrice := 0;
  486. FEndQcTotalPrice := 0;
  487. FEndQcaTotalPrice := 0;
  488. FDealTotalPrice := 0;
  489. for iIndex := 0 to FGclNodes.Count - 1 do
  490. begin
  491. vGclNode := TGclNode(FGclNodes.Items[iIndex]);
  492. FCTotalPrice := FCTotalPrice + vGclNode.EndQcTotalPrice;
  493. FCurGatherTotalPrice := FCurGatherTotalPrice + vGclNode.FCurGatherTotalPrice;
  494. FEndGatherTotalPrice := FEndGatherTotalPrice + vGclNode.FEndGatherTotalPrice;
  495. FPreGatherTotalPrice := FPreGatherTotalPrice + vGclNode.FPreGatherTotalPrice;
  496. FEndPqcTotalPrice := FEndPqcTotalPrice + vGclNode.FEndPqcTotalPrice;
  497. FEndPqcaTotalPrice := FEndPqcaTotalPrice + vGclNode.FEndPqcaTotalPrice;
  498. FEndMqcTotalPrice := FEndMqcTotalPrice + vGclNode.FEndMqcTotalPrice;
  499. FEndMqcaTotalPrice := FEndMqcaTotalPrice + vGclNode.FEndMqcaTotalPrice;
  500. FEndQcTotalPrice := FEndQcTotalPrice + vGclNode.FEndQcTotalPrice;
  501. FEndQcaTotalPrice := FEndQcaTotalPrice + vGclNode.FEndQcaTotalPrice;
  502. FDealTotalPrice := FDealTotalPrice + vGclNode.FDealTotalPrice;
  503. end;
  504. FGTotalPrice := FTotalPrice + FCTotalPrice;
  505. end;
  506. constructor TGclChapter.Create(AID: Integer; AName: string);
  507. begin
  508. FChapterID := AID;
  509. FName := AName;
  510. if FChapterID < 19 then
  511. begin
  512. FChapterBegin := FChapterID * 100;
  513. FChapterEnd := FChapterBegin + 99;
  514. FChapterName := IntToStr(FChapterBegin);
  515. end;
  516. FGclNodes := TList.Create;
  517. end;
  518. destructor TGclChapter.Destroy;
  519. begin
  520. FGclNodes.Free;
  521. inherited;
  522. end;
  523. function TGclChapter.GetCurPercent: Double;
  524. begin
  525. if FGTotalPrice = 0 then
  526. Result := 0
  527. else
  528. Result := FCurGatherTotalPrice / FGTotalPrice * 100;
  529. end;
  530. function TGclChapter.GetEndPercent: Double;
  531. begin
  532. if FGTotalPrice = 0 then
  533. Result := 0
  534. else
  535. Result := FEndGatherTotalPrice / FGTotalPrice * 100;
  536. end;
  537. function TGclChapter.GetGclNode(AIndex: Integer): TGclNode;
  538. begin
  539. Result := TGclNode(FGclNodes.Items[AIndex]);
  540. end;
  541. function TGclChapter.GetGclNodeCount: Integer;
  542. begin
  543. Result := FGclNodes.Count;
  544. end;
  545. function TGclChapter.GetPrePercent: Double;
  546. begin
  547. if FGTotalPrice = 0 then
  548. Result := 0
  549. else
  550. Result := FPreGatherTotalPrice / FGTotalPrice * 100;
  551. end;
  552. { TrmZhongKaiData }
  553. procedure TrmZhongKaiData.AfterGather;
  554. begin
  555. FDealPayControl.Free;
  556. FGclControl.Free;
  557. end;
  558. function TrmZhongKaiData.AssignData(AProjects: TList;
  559. AzkGatherType: TZhongKaiGatherType): TDataSet;
  560. var
  561. iProject: Integer;
  562. begin
  563. FzkGatherType := AzkGatherType;
  564. BeforeGather(AProjects.Count);
  565. try
  566. for iProject := 0 to AProjects.Count - 1 do
  567. GatherProject(TSelectProject(AProjects.Items[iProject]));
  568. FGclControl.Calculate;
  569. WriteData;
  570. finally
  571. AfterGather;
  572. case FzkGatherType of
  573. zkgt2: Result := cdsCustom2;
  574. zkgt3: Result := cdsCustom3;
  575. end;
  576. end;
  577. end;
  578. procedure TrmZhongKaiData.BeforeGather(AProjectCount: Integer);
  579. begin
  580. cdsCustom2.DisableControls;
  581. cdsCustom2.Active := True;
  582. cdsCustom2.EmptyDataSet;
  583. cdsCustom3.DisableControls;
  584. cdsCustom3.Active := True;
  585. cdsCustom3.EmptyDataSet;
  586. FGclControl := TGclControl.Create;
  587. FDealPayControl := TDealPayControl.Create;
  588. end;
  589. procedure TrmZhongKaiData.FilterGcl;
  590. function FindStage(AID: Integer; AList: TList): TStageRecord;
  591. var
  592. i: Integer;
  593. Rec: TStageRecord;
  594. begin
  595. Result := nil;
  596. for i := 0 to AList.Count - 1 do
  597. begin
  598. Rec := TStageRecord(AList.Items[i]);
  599. if Rec.BillsID.AsInteger = AID then
  600. begin
  601. Result := Rec;
  602. Break;
  603. end;
  604. end;
  605. end;
  606. procedure FilterNewOpened;
  607. var
  608. vList: TList;
  609. i: Integer;
  610. GclNode: TGclNode;
  611. Rec: TBillsRecord;
  612. StageRec: TStageRecord;
  613. begin
  614. vList := TList.Create;
  615. try
  616. with FProjectData.PhaseData.StageData do
  617. begin
  618. for i := 0 to sddStage.RecordCount - 1 do
  619. vList.Add(sddStage.Records[i]);
  620. end;
  621. FProjectData.BillsData.sddBills.DisableControls;
  622. FProjectData.PhaseData.StageData.sddStage.DisableControls;
  623. with FProjectData.BillsData do
  624. begin
  625. for i := 0 to sddBills.RecordCount - 1 do
  626. begin
  627. Rec := TBillsRecord(sddBills.Records[i]);
  628. if Rec.IsLeaf.AsBoolean and (Rec.B_Code.AsString <> '') then
  629. begin
  630. StageRec := FindStage(Rec.ID.AsInteger, vList);
  631. GclNode := FGclControl.AddGclNode(Rec, StageRec);
  632. vList.Remove(StageRec);
  633. end;
  634. end;
  635. end;
  636. finally
  637. vList.Free;
  638. end;
  639. end;
  640. procedure FilterOrg;
  641. var
  642. i: Integer;
  643. vNode: TMeasureBillsIDTreeNode;
  644. GclNode: TGclNode;
  645. StageRec: TStageRecord;
  646. begin
  647. with FProjectData.BillsMeasureData do
  648. begin
  649. for i := 0 to BillsMeasureTree.Count - 1 do
  650. begin
  651. vNode := TMeasureBillsIDTreeNode(BillsMeasureTree.Items[i]);
  652. if not vNode.HasChildren and (vNode.Rec.B_Code.AsString <> '') then
  653. GclNode := FGclControl.AddGclNode(vNode.Rec, vNode.StageRec);
  654. end;
  655. end;
  656. end;
  657. begin
  658. if FIsNewOpen then
  659. FilterNewOpened
  660. else
  661. FilterOrg;
  662. end;
  663. procedure TrmZhongKaiData.FilterDealPay;
  664. var
  665. sCurField, sPreField, sEndField: string;
  666. procedure GatherCommonDealPay;
  667. var
  668. iRec: Integer;
  669. Rec, StageRec: TsdDataRecord;
  670. DealPay: TPayNode;
  671. begin
  672. with FProjectData.DealPaymentData do
  673. begin
  674. for iRec := 0 to sddDealPayment.RecordCount - 1 do
  675. begin
  676. Rec := sddDealPayment.Records[iRec];
  677. if SameText(Rec.ValueByName('Name').AsString, '本期完成计量') or
  678. SameText(Rec.ValueByName('Name').AsString, '本期应付') or
  679. SameText(Rec.ValueByName('Name').AsString, '本期实付') then
  680. Continue;
  681. if FProjectData.PhaseData.Active then
  682. StageRec := FProjectData.PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger)
  683. else
  684. StageRec := nil;
  685. DealPay := FDealPayControl.FindPayNode(Rec.ValueByName('Name').AsString);
  686. if Assigned(StageRec) then
  687. begin
  688. DealPay.CurTotalPrice := DealPay.CurTotalPrice + StageRec.ValueByName(sCurField).AsFloat;
  689. DealPay.PreTotalPrice := DealPay.PreTotalPrice + StageRec.ValueByName(sPreField).AsFloat;
  690. DealPay.EndTotalPrice := DealPay.EndTotalPrice + StageRec.ValueByName(sEndField).AsFloat;
  691. end;
  692. end;
  693. end;
  694. end;
  695. procedure GatherZhiFu;
  696. var
  697. Rec, StageRec: TsdDataRecord;
  698. begin
  699. Rec := FProjectData.DealPaymentData.DealPayRecord('本期应付');
  700. if FProjectData.PhaseData.Active then
  701. StageRec := FProjectData.PhaseData.PhasePayData.PayRecord(Rec.ValueByName('ID').AsInteger)
  702. else
  703. StageRec := nil;
  704. if not Assigned(StageRec) then Exit;
  705. with FDealPayControl.ZhiFu do
  706. begin
  707. CurTotalPrice := CurTotalPrice + StageRec.ValueByName(sCurField).AsFloat;
  708. PreTotalPrice := PreTotalPrice + StageRec.ValueByName(sPreField).AsFloat;
  709. EndTotalPrice := EndTotalPrice + StageRec.ValueByName(sEndField).AsFloat;
  710. end;
  711. end;
  712. begin
  713. sCurField := 'TotalPrice' + IntToStr(FProjectData.PhaseData.AuditCount);
  714. sPreField := 'PreTotalPrice' + IntToStr(FProjectData.PhaseData.AuditCount);
  715. sEndField := 'EndTotalPrice' + IntToStr(FProjectData.PhaseData.AuditCount);
  716. GatherCommonDealPay;
  717. GatherZhiFu;
  718. FDealPayControl.CalculateAll;
  719. end;
  720. procedure TrmZhongKaiData.FreeProjectData;
  721. begin
  722. if FIsNewOpen then
  723. FProjectData.Free;
  724. end;
  725. procedure TrmZhongKaiData.GatherProject(AProject: TSelectProject);
  726. begin
  727. OpenProjectData(AProject);
  728. try
  729. if FzkGatherType in [zkgt2, zkgt3] then
  730. FilterGcl;
  731. if FzkGatherType = zkgt2 then
  732. FilterDealPay;
  733. if FzkGatherType = zkgt3 then
  734. FilterDealBills;
  735. finally
  736. FreeProjectData;
  737. end;
  738. end;
  739. procedure TrmZhongKaiData.OpenProjectData(AProject: TSelectProject);
  740. var
  741. Rec: TsdDataRecord;
  742. begin
  743. FIsNewOpen := False;
  744. FProjectData := OpenProjectManager.FindProjectData(AProject.ProjectID);
  745. Rec := ProjectManager.sddProjectsInfo.FindKey('idxID', AProject.ProjectID);
  746. if not Assigned(FProjectData) then
  747. begin
  748. FProjectData := TProjectData.Create;
  749. FProjectData.OpenForReport4(GetMyProjectsFilePath + Rec.ValueByName('FileName').AsString);
  750. FIsNewOpen := True;
  751. end;
  752. end;
  753. procedure TrmZhongKaiData.WriteData;
  754. begin
  755. case FzkGatherType of
  756. zkgt2: WriteReport2;
  757. zkgt3: WriteReport3;
  758. end;
  759. end;
  760. procedure TrmZhongKaiData.WriteReport2;
  761. procedure WriteGclChapter(AGclChapter: TGclChapter);
  762. begin
  763. cdsCustom2.Append;
  764. cdsCustom2ChapterID.AsInteger := AGclChapter.ChapterID;
  765. cdsCustom2Chapter.AsString := AGclChapter.ChapterName;
  766. cdsCustom2Name.AsString := AGclChapter.Name;
  767. cdsCustom2TotalPrice.AsFloat := AGclChapter.TotalPrice;
  768. cdsCustom2CTotalPrice.AsFloat := AGclChapter.CTotalPrice;
  769. cdsCustom2GTotalPrice.AsFloat := AGclChapter.GTotalPrice;
  770. cdsCustom2EndGatherTotalPrice.AsFloat := AGclChapter.EndGatherTotalPrice;
  771. cdsCustom2EndPercent.AsFloat := AGclChapter.EndPercent;
  772. cdsCustom2PreGatherTotalPrice.AsFloat := AGclChapter.PreGatherTotalPrice;
  773. cdsCustom2PrePercent.AsFloat := AGclChapter.PrePercent;
  774. cdsCustom2CurGatherTotalPrice.AsFloat := AGclChapter.CurGatherTotalPrice;
  775. cdsCustom2CurPercent.AsFloat := AGclChapter.CurPercent;
  776. cdsCustom2.Post;
  777. end;
  778. procedure WritePayNode(APayNode: TPayNode);
  779. begin
  780. cdsCustom2.Append;
  781. cdsCustom2Name.AsString := APayNode.Name;
  782. cdsCustom2TotalPrice.AsFloat := APayNode.TotalPrice;
  783. cdsCustom2CurGatherTotalPrice.AsFloat := APayNode.CurTotalPrice;
  784. cdsCustom2PreGatherTotalPrice.AsFloat := APayNode.PreTotalPrice;
  785. cdsCustom2EndGatherTotalPrice.AsFloat := APayNode.EndTotalPrice;
  786. cdsCustom2.Post;
  787. end;
  788. var
  789. iIndex: Integer;
  790. begin
  791. for iIndex := 0 to FGclControl.GclChapterCount - 1 do
  792. WriteGclChapter(FGclControl.GclChapter[iIndex]);
  793. if FGclControl.OtherGcl.GclNodeCount > 0 then
  794. WriteGclChapter(FGclControl.OtherGcl);
  795. WriteGclChapter(FGclControl.GclChapterGather);
  796. WritePayNode(FDealPayControl.TiaoPeiJin);
  797. WritePayNode(FDealPayControl.HeJi);
  798. WritePayNode(FDealPayControl.JiaGeTiaoZheng);
  799. WritePayNode(FDealPayControl.SuoPeiJinE);
  800. WritePayNode(FDealPayControl.LinShiYongDi);
  801. WritePayNode(FDealPayControl.BaoXianFei);
  802. WritePayNode(FDealPayControl.ZongJi);
  803. for iIndex := 0 to FDealPayControl.OtherPayCount - 1 do
  804. WritePayNode(FDealPayControl.OtherPay[iIndex]);
  805. WritePayNode(FDealPayControl.ZhiFu);
  806. end;
  807. procedure TrmZhongKaiData.WriteReport3;
  808. procedure WriteGclNode(AGclNode: TGclNode; AChapterID: Integer);
  809. begin
  810. cdsCustom3.Append;
  811. cdsCustom3ChapterID.AsInteger := AChapterID;
  812. cdsCustom3IndexCode.AsString := AGclNode.IndexCode;
  813. cdsCustom3B_Code.AsString := AGclNode.B_Code;
  814. cdsCustom3Name.AsString := AGclNode.Name;
  815. cdsCustom3Units.AsString := AGclNode.Units;
  816. cdsCustom3Price.AsFloat := AGclNode.Price;
  817. cdsCustom3DealQuantity.AsFloat := AGclNode.DealQuantity;
  818. cdsCustom3DealTotalPrice.AsFloat := AGclNode.DealTotalPrice;
  819. cdsCustom3EndMqcQuantity.AsFloat := AGclNode.EndMqcQuantity;
  820. cdsCustom3EndMqcTotalPrice.AsFloat := AGclNode.EndMqcTotalPrice;
  821. cdsCustom3EndMqcaTotalPrice.AsFloat := AGclNode.EndMqcaTotalPrice;
  822. cdsCustom3EndPqcQuantity.AsFloat := AGclNode.EndPqcQuantity;
  823. cdsCustom3EndPqcTotalPrice.AsFloat := AGclNode.EndPqcTotalPrice;
  824. cdsCustom3EndPqcaTotalPrice.AsFloat := AGclNode.EndPqcaTotalPrice;
  825. cdsCustom3EndQcQuantity.AsFloat := AGclNode.EndQcQuantity;
  826. cdsCustom3EndQcTotalPrice.AsFloat := AGclNode.EndQcTotalPrice;
  827. cdsCustom3EndQcaTotalPrice.AsFloat := AGclNode.EndQcaTotalPrice;
  828. cdsCustom3GQuantity.AsFloat := cdsCustom3DealQuantity.AsFloat + cdsCustom3EndQcQuantity.AsFloat;
  829. cdsCustom3GTotalPrice.AsFloat := cdsCustom3DealTotalPrice.AsFloat + cdsCustom3EndQcaTotalPrice.AsFloat;
  830. cdsCustom3EndGatherQuantity.AsFloat := AGclNode.EndGatherQuantity;
  831. cdsCustom3EndGatherTotalPrice.AsFloat := AGclNode.EndGatherTotalPrice;
  832. cdsCustom3PreGatherQuantity.AsFloat := AGclNode.PreGatherQuantity;
  833. cdsCustom3PreGatherTotalPrice.AsFloat := AGclNode.PreGatherTotalPrice;
  834. cdsCustom3CurGatherQuantity.AsFloat := AGclNode.CurGatherQuantity;
  835. cdsCustom3CurGatherTotalPrice.AsFloat := AGclNode.CurGatherTotalPrice;
  836. cdsCustom3.Post;
  837. end;
  838. procedure WriteChapter(AGclChapter: TGclChapter; const AName: string = '');
  839. var
  840. i: Integer;
  841. begin
  842. cdsCustom3.Append;
  843. cdsCustom3ChapterID.AsInteger := AGclChapter.ChapterID;
  844. if AGclChapter.ChapterName <> '' then
  845. cdsCustom3B_Code.AsString := AGclChapter.ChapterName + '章';
  846. if AName = '' then
  847. cdsCustom3Name.AsString := AGclChapter.Name
  848. else
  849. cdsCustom3Name.AsString := AName;
  850. cdsCustom3DealTotalPrice.AsFloat := AGclChapter.DealTotalPrice;
  851. cdsCustom3EndMqcTotalPrice.AsFloat := AGclChapter.EndMqcTotalPrice;
  852. cdsCustom3EndMqcaTotalPrice.AsFloat := AGclChapter.EndMqcaTotalPrice;
  853. cdsCustom3EndPqcTotalPrice.AsFloat := AGclChapter.EndPqcTotalPrice;
  854. cdsCustom3EndPqcaTotalPrice.AsFloat := AGclChapter.EndPqcaTotalPrice;
  855. cdsCustom3EndQcTotalPrice.AsFloat := AGclChapter.EndQcTotalPrice;
  856. cdsCustom3EndQcaTotalPrice.AsFloat := AGclChapter.EndQcaTotalPrice;
  857. cdsCustom3GTotalPrice.AsFloat := cdsCustom3DealTotalPrice.AsFloat + cdsCustom3EndQcaTotalPrice.AsFloat;
  858. cdsCustom3EndGatherTotalPrice.AsFloat := AGclChapter.EndGatherTotalPrice;
  859. cdsCustom3PreGatherTotalPrice.AsFloat := AGclChapter.PreGatherTotalPrice;
  860. cdsCustom3CurGatherTotalPrice.AsFloat := AGclChapter.CurGatherTotalPrice;
  861. cdsCustom3.Post;
  862. for i := 0 to AGclChapter.GclNodeCount - 1 do
  863. WriteGclNode(AGclChapter.GclNode[i], AGclChapter.ChapterID);
  864. end;
  865. var
  866. iIndex: Integer;
  867. begin
  868. for iIndex := 0 to FGclControl.GclChapterCount - 1 do
  869. WriteChapter(FGclControl.GclChapter[iIndex]);
  870. if FGclControl.OtherGcl.GclNodeCount > 0 then
  871. WriteChapter(FGclControl.OtherGcl);
  872. WriteChapter(FGclControl.GclChapterGather, '合计');
  873. end;
  874. procedure TrmZhongKaiData.FilterDealBills;
  875. var
  876. i: Integer;
  877. Rec: TsdDataRecord;
  878. begin
  879. with FProjectData.DealBillsData do
  880. begin
  881. for i := 0 to sddDealBills.RecordCount - 1 do
  882. begin
  883. Rec := sddDealBills.Records[i];
  884. end;
  885. end;
  886. end;
  887. { TGclNode }
  888. procedure TGclNode.SetB_Code(const Value: string);
  889. begin
  890. FB_Code := Value;
  891. FIndexCode := B_CodeToIndexCode(FB_Code);
  892. end;
  893. { TPayNode }
  894. constructor TPayNode.Create(const AName: string);
  895. begin
  896. FName := AName;
  897. end;
  898. function TPayNode.GetCurPercent: Double;
  899. begin
  900. if TotalPrice = 0 then
  901. Result := 0
  902. else
  903. Result := CurTotalPrice / TotalPrice * 100;
  904. end;
  905. function TPayNode.GetEndPercent: Double;
  906. begin
  907. if TotalPrice = 0 then
  908. Result := 0
  909. else
  910. Result := EndTotalPrice / TotalPrice * 100;
  911. end;
  912. function TPayNode.GetPrePercent: Double;
  913. begin
  914. if TotalPrice = 0 then
  915. Result := 0
  916. else
  917. Result := PreTotalPrice / TotalPrice * 100;
  918. end;
  919. { TDealPayControl }
  920. function TDealPayControl.FindPayNode(const AName: string): TPayNode;
  921. begin
  922. if Pos(FTiaoPeiJin.Name, AName) > 0 then
  923. Result := FTiaoPeiJin
  924. else if Pos(FJiaGeTiaoZheng.Name, AName) > 0 then
  925. Result := FJiaGeTiaoZheng
  926. else if Pos(FSuoPeiJinE.Name, AName) > 0 then
  927. Result := FSuoPeiJinE
  928. else if Pos(FLinShiYongDi.Name, AName) > 0 then
  929. Result := FLinShiYongDi
  930. else if Pos(FBaoXianFei.Name, AName) > 0 then
  931. Result := FBaoXianFei
  932. else
  933. Result := FindOtherPayNode(AName);
  934. if not Assigned(Result) then
  935. Result := NewOtherPayNode(AName);
  936. end;
  937. procedure TDealPayControl.CalculateAll;
  938. procedure CalculateHeJi;
  939. begin
  940. FHeJi.TotalPrice := FPreCalc.TotalPrice + FTiaoPeiJin.TotalPrice;
  941. FHeJi.CurTotalPrice := FPreCalc.CurTotalPrice + FTiaoPeiJin.CurTotalPrice;
  942. FHeJi.EndTotalPrice := FPreCalc.EndTotalPrice + FTiaoPeiJin.EndTotalPrice;
  943. FHeJi.PreTotalPrice := FPreCalc.PreTotalPrice + FTiaoPeiJin.PreTotalPrice;
  944. end;
  945. procedure CalculateZongJi;
  946. begin
  947. FZongJi.TotalPrice := FHeJi.TotalPrice + FJiaGeTiaoZheng.TotalPrice +
  948. FSuoPeiJinE.TotalPrice + FLinShiYongDi.TotalPrice + FBaoXianFei.TotalPrice;
  949. FZongJi.CurTotalPrice := FHeJi.CurTotalPrice + FJiaGeTiaoZheng.CurTotalPrice +
  950. FSuoPeiJinE.CurTotalPrice + FLinShiYongDi.CurTotalPrice + FBaoXianFei.CurTotalPrice;
  951. FZongJi.EndTotalPrice := FHeJi.EndTotalPrice + FJiaGeTiaoZheng.EndTotalPrice +
  952. FSuoPeiJinE.EndTotalPrice + FLinShiYongDi.EndTotalPrice + FBaoXianFei.EndTotalPrice;
  953. FZongJi.PreTotalPrice := FHeJi.PreTotalPrice + FJiaGeTiaoZheng.PreTotalPrice +
  954. FSuoPeiJinE.PreTotalPrice + FLinShiYongDi.PreTotalPrice + FBaoXianFei.PreTotalPrice;
  955. end;
  956. begin
  957. CalculateHeJi;
  958. CalculateZongJi;
  959. end;
  960. constructor TDealPayControl.Create;
  961. begin
  962. FPreCalc := TPayNode.Create('小计');
  963. FTiaoPeiJin := TPayNode.Create('调配金');
  964. FHeJi := TPayNode.Create('合计');
  965. FJiaGeTiaoZheng := TPayNode.Create('价格调整');
  966. FSuoPeiJinE := TPayNode.Create('索赔金额');
  967. FLinShiYongDi := TPayNode.Create('临时用地');
  968. FBaoXianFei := TPayNode.Create('保险费');
  969. FZongJi := TPayNode.Create('总计');
  970. FOtherPays := TList.Create;
  971. FZhiFu := TPayNode.Create('支付');
  972. end;
  973. destructor TDealPayControl.Destroy;
  974. begin
  975. FZhiFu.Free;
  976. ClearObjects(FOtherPays);
  977. FOtherPays.Free;
  978. FZongJi.Free;
  979. FBaoXianFei.Free;
  980. FLinShiYongDi.Free;
  981. FSuoPeiJinE.Free;
  982. FJiaGeTiaoZheng.Free;
  983. FHeJi.Free;
  984. FTiaoPeiJin.Free;
  985. FPreCalc.Free;
  986. inherited;
  987. end;
  988. function TDealPayControl.FindOtherPayNode(const AName: string): TPayNode;
  989. var
  990. i: Integer;
  991. vPayNode: TPayNode;
  992. begin
  993. Result := nil;
  994. for i := 0 to FOtherPays.Count - 1 do
  995. begin
  996. vPayNode := TPayNode(FOtherPays.Items[i]);
  997. if (vPayNode.Name = AName) then
  998. begin
  999. Result := vPayNode;
  1000. Break;
  1001. end;
  1002. end;
  1003. end;
  1004. function TDealPayControl.GetOtherPay(AIndex: Integer): TPayNode;
  1005. begin
  1006. Result := TPayNode(FOtherPays.Items[AIndex]);
  1007. end;
  1008. function TDealPayControl.GetOtherPayCount: Integer;
  1009. begin
  1010. Result := FOtherPays.Count;
  1011. end;
  1012. function TDealPayControl.NewOtherPayNode(const AName: string): TPayNode;
  1013. begin
  1014. Result := TPayNode.Create(AName);
  1015. FOtherPays.Add(Result);
  1016. end;
  1017. end.