BillsMeasureDm.pas 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. unit BillsMeasureDm;
  2. interface
  3. uses
  4. BillsDm, BillsTree, FormulaCalc, sdIDTree, StageDm,
  5. SysUtils, Classes, sdDB, DB;
  6. type
  7. TBillsMeasureData = class(TDataModule)
  8. sdvBillsMeasure: TsdDataView;
  9. procedure sdvBillsMeasureAfterOpen(Sender: TObject);
  10. procedure sdvBillsMeasureAfterAddRecord(ARecord: TsdDataRecord);
  11. procedure sdvBillsMeasureGetText(var Text: String;
  12. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  13. DisplayText: Boolean);
  14. procedure sdvBillsMeasureSetText(var Text: String;
  15. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  16. var Allow: Boolean);
  17. procedure sdvBillsMeasureNeedLookupRecord(ARecord: TsdDataRecord;
  18. AColumn: TsdViewColumn; ANewText: String);
  19. procedure sdvBillsMeasureAfterClose(Sender: TObject);
  20. procedure sdvBillsMeasureAfterValueChanged(AValue: TsdValue);
  21. procedure sdvBillsMeasureCurrentChanged(ARecord: TsdDataRecord);
  22. private
  23. FProjectData: TObject;
  24. FBillsData: TBillsData;
  25. FBillsMeasureTree: TMeasureBillsIDTree;
  26. FFormulaCalc: TFormulaCalc;
  27. FShowParentData: Boolean;
  28. FOnRecChange: TRecChangeEvent;
  29. function OnGetCardinalNum(const ACardinalNum: string): Double;
  30. procedure CalcAddCompleteRate(ANode: TsdIDTreeNode);
  31. procedure CalcAddDgnPrice(ANode: TsdIDTreeNode);
  32. function SelectAndUpdateBGL(ABillsID: Integer; ARec: TsdDataRecord;
  33. ANewValue: Double; const AType: string): Boolean;
  34. procedure CalculateNode(ANode: TMeasureBillsIDTreeNode);
  35. procedure UpdateRecordGather(ANode: TsdIDTreeNode; AQuantity, ATotalPrice: Double);
  36. function GetStageData: TStageData;
  37. procedure SetOnRecChange(const Value: TRecChangeEvent);
  38. public
  39. constructor Create(AProjectData: TObject);
  40. destructor Destroy; override;
  41. procedure Open;
  42. procedure Close;
  43. procedure ReConnectTree;
  44. procedure CalculateAll;
  45. procedure ResetPhaseStageLink;
  46. procedure ResetTreeNodeStageRec;
  47. procedure ExpandNodeTo(ALevel: Integer);
  48. procedure ExpandXmjNode;
  49. procedure ExpandCurPhase;
  50. function GatherRelaBGL(ANode: TsdIDTreeNode): string;
  51. // 计算 修改各期原报审核数据时,需对累计数据做增量
  52. procedure UpdateRecordDeal(ABillsID: Integer; AQuantity, ATotalPrice: Double);
  53. procedure UpdateRecordQc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
  54. procedure UpdateRecordPc(ABillsID: Integer; AQuantity, ATotalPrice: Double);
  55. procedure UpdateRecordPM(ABillsID: Integer; ADiffer: Double);
  56. procedure UpdateGather(ABillsID: Integer; ADiffer: Double);
  57. procedure UpdateBGLInfo(ABillsID: Integer; ARec: TsdDataRecord; const AType: string);
  58. property ProjectData: TObject read FProjectData;
  59. property BillsData: TBillsData read FBillsData;
  60. property BillsMeasureTree: TMeasureBillsIDTree read FBillsMeasureTree;
  61. property StageData: TStageData read GetStageData;
  62. property ShowParentData: Boolean read FShowParentData write FShowParentData;
  63. property OnRecChange: TRecChangeEvent read FOnRecChange write SetOnRecChange;
  64. end;
  65. implementation
  66. uses
  67. ProjectData, PhaseData, Math, ZhAPI, BillsCommand, BGLSelectFrm,
  68. BGLDm, UtilMethods, mDataRecord, ConstUnit, Variants;
  69. {$R *.dfm}
  70. { TBillsMeasureData }
  71. constructor TBillsMeasureData.Create(AProjectData: TObject);
  72. begin
  73. inherited Create(nil);
  74. FProjectData := AProjectData;
  75. FBillsData := TProjectData(FProjectData).BillsData;
  76. FBillsMeasureTree := TMeasureBillsIDTree.Create;
  77. FBillsMeasureTree.KeyFieldName := 'ID';
  78. FBillsMeasureTree.ParentFieldName := 'ParentID';
  79. FBillsMeasureTree.NextSiblingFieldName := 'NextSiblingID';
  80. FBillsMeasureTree.AutoCreateKeyID := True;
  81. FBillsMeasureTree.AutoExpand := True;
  82. FBillsMeasureTree.DataView := sdvBillsMeasure;
  83. FBillsMeasureTree.SeedID := Max(FBillsMeasureTree.SeedID, 100);
  84. FBillsMeasureTree.Link(TProjectData(FProjectData).BillsCompileData.BillsCompileTree, True);
  85. FBillsMeasureTree.CompileTree := TProjectData(FProjectData).BillsCompileData.BillsCompileTree;
  86. FFormulaCalc := TFormulaCalc.Create(FBillsMeasureTree);
  87. FFormulaCalc.OnGetValue := OnGetCardinalNum;
  88. end;
  89. destructor TBillsMeasureData.Destroy;
  90. begin
  91. FFormulaCalc.Free;
  92. FBillsMeasureTree.Free;
  93. inherited;
  94. end;
  95. procedure TBillsMeasureData.Open;
  96. begin
  97. sdvBillsMeasure.DataSet := TProjectData(FProjectData).BillsData.sddBills;
  98. sdvBillsMeasure.Open;
  99. end;
  100. procedure TBillsMeasureData.ReConnectTree;
  101. begin
  102. FBillsMeasureTree.DataView := nil;
  103. FBillsMeasureTree.DataView := sdvBillsMeasure;
  104. FBillsMeasureTree.Link(TProjectData(FProjectData).BillsCompileData.BillsCompileTree, True);
  105. end;
  106. procedure TBillsMeasureData.ResetPhaseStageLink;
  107. begin
  108. with TProjectData(FProjectData).PhaseData do
  109. begin
  110. sdvBillsMeasure.Columns.FindColumn('CurDealQuantity').LookupDataSet := StageData.sddStage;
  111. sdvBillsMeasure.Columns.FindColumn('CurDealTotalPrice').LookupDataSet := StageData.sddStage;
  112. sdvBillsMeasure.Columns.FindColumn('CurQcQuantity').LookupDataSet := StageData.sddStage;
  113. sdvBillsMeasure.Columns.FindColumn('CurQcTotalPrice').LookupDataSet := StageData.sddStage;
  114. sdvBillsMeasure.Columns.FindColumn('CurQcBGLCode').LookupDataSet := StageData.sddStage;
  115. sdvBillsMeasure.Columns.FindColumn('CurPcQuantity').LookupDataSet := StageData.sddStage;
  116. sdvBillsMeasure.Columns.FindColumn('CurPcTotalPrice').LookupDataSet := StageData.sddStage;
  117. sdvBillsMeasure.Columns.FindColumn('CurPcBGLCode').LookupDataSet := StageData.sddStage;
  118. sdvBillsMeasure.Columns.FindColumn('CurGatherQuantity').LookupDataSet := StageData.sddStage;
  119. sdvBillsMeasure.Columns.FindColumn('CurGatherTotalPrice').LookupDataSet := StageData.sddStage;
  120. sdvBillsMeasure.Columns.FindColumn('EndDealQuantity').LookupDataSet := StageData.sddStage;
  121. sdvBillsMeasure.Columns.FindColumn('EndDealTotalPrice').LookupDataSet := StageData.sddStage;
  122. sdvBillsMeasure.Columns.FindColumn('EndQcQuantity').LookupDataSet := StageData.sddStage;
  123. sdvBillsMeasure.Columns.FindColumn('EndQcTotalPrice').LookupDataSet := StageData.sddStage;
  124. sdvBillsMeasure.Columns.FindColumn('EndPcQuantity').LookupDataSet := StageData.sddStage;
  125. sdvBillsMeasure.Columns.FindColumn('EndPcTotalPrice').LookupDataSet := StageData.sddStage;
  126. sdvBillsMeasure.Columns.FindColumn('EndGatherQuantity').LookupDataSet := StageData.sddStage;
  127. sdvBillsMeasure.Columns.FindColumn('EndGatherTotalPrice').LookupDataSet := StageData.sddStage;
  128. sdvBillsMeasure.Columns.FindColumn('PM_PreTotalPrice').LookupDataSet := StageData.sddStage;
  129. sdvBillsMeasure.Columns.FindColumn('PM_TotalPrice').LookupDataSet := StageData.sddStage;
  130. end;
  131. end;
  132. procedure TBillsMeasureData.sdvBillsMeasureAfterOpen(Sender: TObject);
  133. begin
  134. FBillsMeasureTree.Active := True;
  135. end;
  136. procedure TBillsMeasureData.sdvBillsMeasureAfterAddRecord(
  137. ARecord: TsdDataRecord);
  138. begin
  139. ARecord.ValueByName('IsMeasureAdd').AsBoolean := True;
  140. end;
  141. procedure TBillsMeasureData.sdvBillsMeasureGetText(var Text: String;
  142. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  143. DisplayText: Boolean);
  144. function GetQuantityValueOrFormula(const AQtyType: string): string;
  145. begin
  146. with AValue.Owner do
  147. begin
  148. if ValueByName(AQtyType + 'Flag').AsInteger = 1 then
  149. Result := ValueByName(AQtyType + 'Formula').AsString
  150. else
  151. Result := Text;
  152. end;
  153. end;
  154. function GetTotalPriceValueOrFormula(const AQtyType: string): string;
  155. begin
  156. with AValue.Owner do
  157. begin
  158. if ValueByName(AQtyType + 'Formula').AsString <> '' then
  159. Result := ValueByName(AQtyType + 'Formula').AsString
  160. else
  161. Result := Text;
  162. end;
  163. end;
  164. procedure GetDisplayText(var AText: string; AValue: TsdValue;
  165. AColumn: TsdViewColumn);
  166. var
  167. stnNode: TsdIDTreeNode;
  168. begin
  169. if Assigned(AValue) and (AValue.DataType = ftFloat) and (AValue.AsFloat = 0) then
  170. begin
  171. Text := '';
  172. Exit;
  173. end;
  174. // 所有本期数据,当节点为父节点时,不显示值(实际上需要计算其中的金额值,但又不能显示)
  175. // 有病。每天都在变。
  176. if not ShowParentData and (Pos('Cur', AColumn.FieldName) > 0) and (Pos('Gather', AColumn.FieldName) = 0) then
  177. begin
  178. stnNode := BillsMeasureTree.FindNode(AValue.Owner.ValueByName('BillsID').AsInteger);
  179. if stnNode.HasChildren then
  180. Text := '';
  181. end;
  182. end;
  183. procedure GetEditText(var AText: string; AValue: TsdValue;
  184. AColumn: TsdViewColumn);
  185. begin
  186. if SameText(AColumn.FieldName, 'Quantity') then
  187. Text := GetQuantityValueOrFormula('Qty')
  188. else if SameText(AColumn.FieldName, 'CurDealQuantity') then
  189. Text := GetQuantityValueOrFormula('Deal')
  190. else if SameText(AColumn.FieldName, 'CurQcQuantity') then
  191. Text := GetQuantityValueOrFormula('Qc')
  192. else if SameText(AColumn.FieldName, 'CurPcQuantity') then
  193. Text := GetQuantityValueOrFormula('Pc')
  194. else if SameText(AColumn.FieldName, 'CurDealTotalPrice') then
  195. Text := GetTotalPriceValueOrFormula('Deal')
  196. else if SameText(AColumn.FieldName, 'CurQcTotalPrice') then
  197. Text := GetTotalPriceValueOrFormula('Qc')
  198. else if SameText(AColumn.FieldName, 'CurPcTotalPrice') then
  199. Text := GetTotalPriceValueOrFormula('Pc');
  200. end;
  201. var
  202. fPercent: Double;
  203. begin
  204. if not Assigned(AValue) then Exit;
  205. if DisplayText then
  206. GetDisplayText(Text, AValue, AColumn)
  207. else
  208. GetEditText(Text, AValue, AColumn);
  209. end;
  210. procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
  211. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  212. var Allow: Boolean);
  213. function GetBillsID: Integer;
  214. begin
  215. if Pos('Cur', AColumn.FieldName) = 1 then
  216. Result := AValue.Owner.ValueByName('BillsID').AsInteger
  217. else
  218. Result := ARecord.ValueByName('ID').AsInteger;
  219. end;
  220. procedure CheckLockedData;
  221. begin
  222. if SameText(AColumn.FieldName, 'Code') or
  223. SameText(AColumn.FieldName, 'B_Code') or
  224. SameText(AColumn.FieldName, 'Name') or
  225. SameText(AColumn.FieldName, 'Units') or
  226. SameText(AColumn.FieldName, 'Price') then
  227. if ARecord.ValueByName('LockedInfo').AsBoolean then
  228. DataSetErrorMessage(Allow, '清单信息已被锁定,不允许修改编号、名称、单位、清单单价!');
  229. if not Allow then Exit;
  230. if SameText(AColumn.FieldName, 'NewPrice') then
  231. if ARecord.ValueByName('LockedNewPrice').AsBoolean then
  232. DataSetErrorMessage(Allow, '变更单价已被锁定,不允许修改!');
  233. end;
  234. procedure CheckNodeWritable(ANode: TBillsIDTreeNode);
  235. var
  236. iCreatePhase: Integer;
  237. begin
  238. iCreatePhase := ANode.Rec.ValueByName('CreatePhaseID').AsInteger;
  239. if ANode.ID = iPriceMarginID then
  240. DataSetErrorMessage(Allow, sBills_PMHint);
  241. if SameText('B_Code', AColumn.FieldName) or
  242. SameText('Name', AColumn.FieldName) or
  243. SameText('Units', AColumn.FieldName) then
  244. if ANode.Rec.ValueByName('AddQcQuantity').AsFloat <> 0 then
  245. DataSetErrorMessage(Allow, '该清单已进行过变更,不可修改清单编号、名称、单位!');
  246. if not Allow then Exit;
  247. if SameText('Price', AColumn.FieldName) then
  248. if ANode.Rec.ValueByName('AddGatherTotalPrice').AsFloat <> 0 then
  249. DataSetErrorMessage(Allow, '该清单已经计量,不可修改清单单价!');
  250. if not Allow then Exit;
  251. if SameText('NewPrice', AColumn.FieldName) then
  252. if ANode.Rec.ValueByName('AddPcTotalPrice').AsFloat <> 0 then
  253. DataSetErrorMessage(Allow, '该清单已经计量,不可修改清单变更单价!');
  254. if not Allow then Exit;
  255. if ANode.HasChildren then
  256. begin
  257. if Text = '' then
  258. Exit
  259. else if ((Pos('Quantity', AColumn.FieldName) > 0) and (Pos('Dgn', AColumn.FieldName) <=0)) or
  260. (Pos('TotalPrice', AColumn.FieldName) > 0) then
  261. DataSetErrorMessage(Allow, '该清单有子计算项,不能直接修改!')
  262. else if (Pos('Price', AColumn.FieldName) > 0) then
  263. DataSetErrorMessage(Allow, '仅最底层清单可输入单价!');
  264. end
  265. else
  266. begin
  267. // 目前仅允许本期合同计量,可直接输入金额
  268. if SameText('CurDealTotalPrice', AColumn.FieldName) then
  269. begin
  270. if not ANode.TotalPriceEnable then
  271. DataSetErrorMessage(Allow, '该清单不可直接输入金额,如需直接输入金额,请先清空所有数量、单价!');
  272. end
  273. else if SameText('CurDealQuantity', AColumn.FieldName) or
  274. SameText('CurQcQuantity', AColumn.FieldName) or
  275. SameText('CurPcQuantity', AColumn.FieldName) or
  276. SameText('Price', AColumn.FieldName) then
  277. begin
  278. if not ANode.CountPriceEnable then
  279. DataSetErrorMessage(Allow, '该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
  280. end;
  281. end;
  282. if not Allow then Exit;
  283. // 变更清单允许填写本期合同计量,按超计论
  284. {if vNode.Rec.ValueByName('IsMeasureAdd').AsBoolean and (iCreatePhase > 0) and
  285. (SameText('CurDealQuantity', AColumn.FieldName) or
  286. SameText('CurDealTotalPrice', AColumn.FieldName)) then
  287. DataSetErrorMessage(Allow, Format('该清单为第%d期新增清单,不可填写本期合同计量数据!', [iCreatePhase]));}
  288. end;
  289. procedure SetQuantity(ANode: TBillsIDTreeNode; const AField: string);
  290. var
  291. vNode: TBillsIDTreeNode;
  292. begin
  293. // 变更应选择变更令
  294. if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
  295. Allow := SelectAndUpdateBGL(GetBillsID, AValue.Owner, StrToFloatDef(Text, 0), AField);
  296. if not Allow then Exit;
  297. if CheckStringNull(Text) or CheckNumeric(Text) then
  298. begin
  299. AValue.Owner.ValueByName(AField + 'Flag').AsInteger := 0;
  300. AValue.Owner.ValueByName(AField + 'Formula').AsString := '';
  301. Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)));
  302. end
  303. else
  304. begin
  305. AValue.Owner.ValueByName(AField + 'Flag').AsInteger := 1;
  306. AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
  307. Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
  308. end;
  309. ANode.Rec.SetIntValue(ANode.Rec.CalcType, 0);
  310. end;
  311. procedure SetTotalPrice(ANode: TBillsIDTreeNode; const AField: string);
  312. begin
  313. // 变更应选择变更令
  314. if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
  315. Allow := SelectAndUpdateBGL(GetBillsID, AValue.Owner, StrToFloatDef(Text, 0), AField);
  316. if not Allow then Exit;
  317. AValue.Owner.ValueByName(AField + 'Flag').AsInteger := 2;
  318. AValue.Owner.ValueByName(AField + 'Quantity').AsString := '';
  319. if CheckStringNull(Text) or CheckNumeric(Text) then
  320. begin
  321. AValue.Owner.ValueByName(AField + 'Formula').AsString := '';
  322. Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)));
  323. end
  324. else
  325. begin
  326. AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
  327. Text := FloatToStr(TotalPriceRoundTo(EvaluateExprs(Text)));
  328. end;
  329. ANode.Rec.SetIntValue(ANode.Rec.CalcType, 1);
  330. end;
  331. procedure DoCurChanged(ANode: TBillsIDTreeNode);
  332. begin
  333. if SameText(AColumn.FieldName, 'CurDealQuantity') then
  334. SetQuantity(ANode, 'Deal')
  335. else if SameText(AColumn.FieldName, 'CurQcQuantity') then
  336. SetQuantity(ANode, 'Qc')
  337. else if SameText(AColumn.FieldName, 'CurPcQuantity') then
  338. SetQuantity(ANode, 'Pc')
  339. else if SameText(AColumn.FieldName, 'CurDealTotalPrice') then
  340. SetTotalPrice(ANode, 'Deal')
  341. else if SameText(AColumn.FieldName, 'CurQcTotalPrice') then
  342. SetTotalPrice(ANode, 'Qc')
  343. else if SameText(AColumn.FieldName, 'CurPcTotalPrice') then
  344. SetTotalPrice(ANode, 'Pc')
  345. else if (Pos('DgnQuantity', AColumn.FieldName) > 0) or
  346. SameText(AColumn.FieldName, 'Quantity') then
  347. Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)))
  348. else if SameText(AColumn.FieldName, 'NewPrice') or
  349. SameText(AColumn.FieldName, 'Price') then
  350. Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)))
  351. else if SameText(AColumn.FieldName, 'Code') then
  352. BillsMeasureTree.RecodeChildrenCode(ANode, AValue.AsString, Text)
  353. else if SameText(AColumn.FieldName, 'B_Code') then
  354. BillsMeasureTree.RecodeChildrenB_Code(ANode, AValue.AsString, Text);
  355. end;
  356. function CheckValidData: Boolean;
  357. begin
  358. Result := (AValue.AsString <> Text);
  359. if (Pos('Quantity', AColumn.FieldName) > 0) or
  360. (Pos('Price', AColumn.FieldName) > 0) then
  361. begin
  362. if (AValue.AsFloat = 0) and (Text = '') then
  363. Result := False;
  364. end;
  365. end;
  366. var
  367. vNode: TBillsIDTreeNode;
  368. begin
  369. if not Assigned(AValue) then Exit;
  370. // 修改后数据与原数据相同则不提交
  371. if not CheckValidData then
  372. Allow := False;
  373. if not Allow then Exit;
  374. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
  375. CheckLockedData;
  376. if not Allow then Exit;
  377. CheckNodeWritable(vNode);
  378. if not Allow then Exit;
  379. Text := Trim(Text);
  380. if Pos('=', Text) = 1 then
  381. Text := Copy(Text, 2, Length(Text) - 1);
  382. DoCurChanged(vNode);
  383. end;
  384. procedure TBillsMeasureData.sdvBillsMeasureNeedLookupRecord(
  385. ARecord: TsdDataRecord; AColumn: TsdViewColumn; ANewText: String);
  386. function CheckNeedAddPhaseRecord(ANode: TMeasureBillsIDTreeNode): Boolean;
  387. begin
  388. Result := SameText(AColumn.FieldName, 'CurDealQuantity') or
  389. SameText(AColumn.FieldName, 'CurQcQuantity') or
  390. SameText(AColumn.FieldName, 'CurPcQuantity') or
  391. SameText(AColumn.FieldName, 'CurDealTotalPrice') or
  392. SameText(AColumn.FieldName, 'CurQcTotalPrice') or
  393. SameText(AColumn.FieldName, 'CurPcTotalPrice');
  394. Result := Result and not ANode.HasChildren;
  395. Result := Result and not Assigned(ANode.StageRec);
  396. end;
  397. function HasCardinalNum(AFormula: string): Boolean;
  398. var
  399. iCharIndex: Integer;
  400. begin
  401. Result := False;
  402. iCharIndex := 1;
  403. while ((iCharIndex <= Length(AFormula)) and not Result) do
  404. begin
  405. if AFormula[iCharIndex] in ['A'..'D', 'a'..'d'] then
  406. Result := True;
  407. Inc(iCharIndex);
  408. end;
  409. end;
  410. procedure SetQuantityRec(ANode: TBillsIDTreeNode; APhaseRec: TsdDataRecord; const AType: string);
  411. var
  412. bAllow: Boolean;
  413. begin
  414. bAllow := True;
  415. // 变更应选择变更令
  416. if SameText(AType , 'Qc') or SameText(AType , 'Pc') then
  417. bAllow := SelectAndUpdateBGL(ARecord.ValueByName('ID').AsInteger,
  418. APhaseRec, StrToFloatDef(ANewText, 0), AType);
  419. if bAllow then
  420. begin
  421. if ANode.Rec.CalcType.AsInteger <> 0 then
  422. ANode.Rec.CalcType.AsInteger := 0;
  423. if CheckNumeric(ANewText) then
  424. APhaseRec.ValueByName(AType + 'Quantity').AsFloat := QuantityRoundTo(StrToFloatDef(ANewText, 0))
  425. else
  426. begin
  427. APhaseRec.ValueByName(AType + 'Flag').AsInteger := 1;
  428. APhaseRec.ValueByName(AType + 'Quantity').AsFloat := QuantityRoundTo(EvaluateExprs(ANewText));
  429. APhaseRec.ValueByName(AType + 'Formula').AsString := ANewText;
  430. end;
  431. end;
  432. end;
  433. procedure SetTotalPriceRec(ANode: TBillsIDTreeNode; APhaseRec: TsdDataRecord; const AType: string);
  434. begin
  435. if ANode.Rec.CalcType.AsInteger <> 1 then
  436. ANode.Rec.CalcType.AsInteger := 1;
  437. APhaseRec.ValueByName(AType + 'Flag').AsInteger := 2;
  438. if CheckNumeric(ANewText) then
  439. APhaseRec.ValueByName(AType + 'TotalPrice').AsFloat := TotalPriceRoundTo(StrToFloatDef(ANewText, 0))
  440. else
  441. begin
  442. APhaseRec.ValueByName(AType + 'TotalPrice').AsFloat := TotalPriceRoundTo(EvaluateExprs(ANewText));
  443. APhaseRec.ValueByName(AType + 'Formula').AsString := ANewText;
  444. end;
  445. end;
  446. procedure SetNewRecValue(ANode: TBillsIDTreeNode; APhaseRec: TsdDataRecord);
  447. begin
  448. if SameText(AColumn.FieldName, 'CurDealQuantity') then
  449. SetQuantityRec(ANode, APhaseRec, 'Deal')
  450. else if SameText(AColumn.FieldName, 'CurQcQuantity') then
  451. SetQuantityRec(ANode, APhaseRec, 'Qc')
  452. else if SameText(AColumn.FieldName, 'CurPcQuantity') then
  453. SetQuantityRec(ANode, APhaseRec, 'Pc')
  454. else if SameText(AColumn.FieldName, 'CurDealTotalPrice') then
  455. SetTotalPriceRec(ANode, APhaseRec, 'Deal')
  456. else if SameText(AColumn.FieldName, 'CurQcTotalPrice') then
  457. SetTotalPriceRec(ANode, APhaseRec, 'Qc')
  458. else if SameText(AColumn.FieldName, 'CurPcTotalPrice') then
  459. SetTotalPriceRec(ANode, APhaseRec, 'Pc');
  460. end;
  461. function CheckNodeWritable(ANode: TBillsIDTreeNode): Boolean;
  462. var
  463. iCreatePhase: Integer;
  464. begin
  465. Result := True;
  466. if ANode.ID = iPriceMarginID then
  467. DataSetErrorMessage(Result, sBills_PMHint);
  468. if ANode.HasChildren then
  469. begin
  470. if ANewText = '' then
  471. Result := False
  472. else
  473. DataSetErrorMessage(Result, '该清单有子计算项,不能直接修改!');
  474. end
  475. else
  476. begin
  477. // 目前仅允许本期合同计量,可直接输入金额
  478. if SameText('CurDealTotalPrice', AColumn.FieldName) then
  479. begin
  480. if not ANode.TotalPriceEnable then
  481. DataSetErrorMessage(Result, '该清单不可直接输入金额,如需直接输入金额,请先清空所有数量、单价!');
  482. end
  483. else if SameText('CurDealQuantity', AColumn.FieldName) or
  484. SameText('CurQcQuantity', AColumn.FieldName) or
  485. SameText('CurPcQuantity', AColumn.FieldName) then
  486. begin
  487. if not ANode.CountPriceEnable then
  488. DataSetErrorMessage(Result, '该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
  489. end;
  490. end;
  491. // 变更清单允许填写本期合同计量,按超计论
  492. {iCreatePhase := ANode.Rec.ValueByName('CreatePhaseID').AsInteger;
  493. if ANode.Rec.ValueByName('IsMeasureAdd').AsBoolean and (iCreatePhase > 0) and
  494. (SameText('CurDealQuantity', AColumn.FieldName) or
  495. SameText('CurDealTotalPrice', AColumn.FieldName)) then
  496. begin
  497. ErrorMessage(Format('该清单为第%d期新增清单,不可填写本期合同计量数据!', [iCreatePhase]));
  498. Exit;
  499. end; }
  500. end;
  501. var
  502. NewRec: TStageRecord;
  503. vNode: TMeasureBillsIDTreeNode;
  504. begin
  505. vNode := TMeasureBillsIDTreeNode(BillsMeasureTree.FindNode(ARecord.ValueByName('ID').AsInteger));
  506. if not CheckNodeWritable(vNode) then
  507. Exit;
  508. if CheckNeedAddPhaseRecord(vNode) then
  509. begin
  510. if(Pos('Quantity', AColumn.FieldName) > 0) or (Pos('TotalPrice', AColumn.FieldName) > 0) then
  511. if HasCardinalNum(ANewText) then
  512. raise Exception.Create('公式不可输入参数');
  513. NewRec := StageData.AddStageRecord(ARecord.ValueByName('ID').AsInteger);
  514. vNode.StageRec := NewRec;
  515. SetNewRecValue(vNode, NewRec);
  516. end;
  517. end;
  518. procedure TBillsMeasureData.sdvBillsMeasureAfterClose(Sender: TObject);
  519. begin
  520. FBillsMeasureTree.Active := False;
  521. end;
  522. function TBillsMeasureData.OnGetCardinalNum(
  523. const ACardinalNum: string): Double;
  524. {
  525. function GetTotalPrice(ABillsID: Integer): Double;
  526. var
  527. stnNode: TsdIDTreeNode;
  528. begin
  529. stnNode := FBillsTree.FindNode(ABillsID);
  530. if Assigned(stnNode) then
  531. Result := stnNode.Rec.ValueByName('TotalPrice').AsFloat;
  532. end;
  533. function GetPhaseTotalPrice(ABillsID: Integer; const AType: string): Double;
  534. var
  535. Rec: TsdDataRecord;
  536. begin
  537. Rec := CurPhaseData.PhaseRecord(ABillsID);
  538. if Assigned(Rec) then
  539. Result := Rec.ValueByName(AType + 'TotalPrice').AsFloat;
  540. end;
  541. }
  542. function GetTotalPrice(ANode: TsdIDTreeNode): Double;
  543. var
  544. iChild: Integer;
  545. begin
  546. Result := 0;
  547. if not Assigned(ANode) then Exit;
  548. if ANode.HasChildren then
  549. for iChild := 0 to ANode.ChildCount - 1 do
  550. Result := Result + GetTotalPrice(ANode.ChildNodes[iChild])
  551. else
  552. Result := ANode.Rec.ValueByName('TotalPrice').AsFloat;
  553. end;
  554. function GetPhaseTotalPrice(ANode: TsdIDTreeNode; const AType: string): Double;
  555. var
  556. iChild: Integer;
  557. Rec: TsdDataRecord;
  558. begin
  559. Result := 0;
  560. if not Assigned(ANode) then Exit;
  561. if ANode.HasChildren then
  562. for iChild := 0 to ANode.ChildCount - 1 do
  563. Result := Result + GetPhaseTotalPrice(ANode.ChildNodes[iChild], AType)
  564. else
  565. begin
  566. Rec := StageData.StageRecord(ANode.ID);
  567. if Assigned(Rec) then
  568. Result := Rec.ValueByName(AType + 'TotalPrice').AsFloat;
  569. end;
  570. end;
  571. var
  572. iNodeID: Integer;
  573. begin
  574. Result := 0;
  575. iNodeID := StrToIntDef(Copy(ACardinalNum, 2, Length(ACardinalNum) - 1), -1);
  576. case ACardinalNum[1] of
  577. 'A','a': Result := GetTotalPrice(BillsMeasureTree.FindNode(iNodeID));
  578. 'B','b': Result := GetPhaseTotalPrice(BillsMeasureTree.FindNode(iNodeID), 'Deal');
  579. 'C','c': Result := GetPhaseTotalPrice(BillsMeasureTree.FindNode(iNodeID), 'Qc');
  580. 'D','d': Result := GetPhaseTotalPrice(BillsMeasureTree.FindNode(iNodeID), 'Pc');
  581. {'A','a': Result := GetTotalPrice(iNodeID);
  582. 'B','b': Result := GetPhaseTotalPrice(iNodeID, 'Deal');
  583. 'C','c': Result := GetPhaseTotalPrice(iNodeID, 'Qc');
  584. 'D','d': Result := GetPhaseTotalPrice(iNodeID, 'Pc');}
  585. end;
  586. end;
  587. function TBillsMeasureData.GetStageData: TStageData;
  588. begin
  589. Result := TProjectData(FProjectData).PhaseData.StageData;
  590. end;
  591. procedure TBillsMeasureData.ExpandNodeTo(ALevel: Integer);
  592. begin
  593. BillsMeasureTree.ExpandLevel := ALevel;
  594. end;
  595. procedure TBillsMeasureData.ExpandXmjNode;
  596. var
  597. iIndex: Integer;
  598. stnNode: TBillsIDTreeNode;
  599. begin
  600. for iIndex := 0 to BillsMeasureTree.Count - 1 do
  601. begin
  602. stnNode := TBillsIDTreeNode(BillsMeasureTree.Items[iIndex]);
  603. if (stnNode.ParentID <> -1) then
  604. stnNode.Parent.Expanded := stnNode.Rec.B_Code.AsString = '';
  605. end;
  606. end;
  607. procedure TBillsMeasureData.CalculateAll;
  608. var
  609. //Cacl: TBillsCalculate;
  610. i: Integer;
  611. begin
  612. if not TProjectData(FProjectData).StageDataReadOnly then
  613. for i := 0 to BillsMeasureTree.Count - 1 do
  614. CalculateNode(TMeasureBillsIDTreeNode(BillsMeasureTree.Items[i]));
  615. {Cacl := TBillsCalculate.Create(Self);
  616. try
  617. Cacl.Execute;
  618. finally
  619. Cacl.Free;
  620. end;}
  621. end;
  622. procedure TBillsMeasureData.UpdateRecordDeal(ABillsID: Integer; AQuantity,
  623. ATotalPrice: Double);
  624. var
  625. stnNode: TsdIDTreeNode;
  626. begin
  627. stnNode := BillsMeasureTree.FindNode(ABillsID);
  628. if not Assigned(stnNode) then Exit;
  629. with stnNode.Rec do
  630. begin
  631. if not stnNode.HasChildren then
  632. ValueByName('AddDealQuantity').AsFloat := QuantityRoundTo(
  633. ValueByName('AddDealQuantity').AsFloat + AQuantity);
  634. ValueByName('AddDealTotalPrice').AsFloat := TotalPriceRoundTo(
  635. ValueByName('AddDealTotalPrice').AsFloat + ATotalPrice);
  636. end;
  637. UpdateRecordGather(stnNode, AQuantity, ATotalPrice);
  638. UpdateRecordDeal(stnNode.ParentID, AQuantity, ATotalPrice);
  639. end;
  640. procedure TBillsMeasureData.UpdateRecordPc(ABillsID: Integer; AQuantity,
  641. ATotalPrice: Double);
  642. var
  643. stnNode: TsdIDTreeNode;
  644. begin
  645. stnNode := BillsMeasureTree.FindNode(ABillsID);
  646. if not Assigned(stnNode) then Exit;
  647. with stnNode.Rec do
  648. begin
  649. if not stnNode.HasChildren then
  650. ValueByName('AddPcQuantity').AsFloat := QuantityRoundTo(
  651. ValueByName('AddPcQuantity').AsFloat + AQuantity);
  652. ValueByName('AddPcTotalPrice').AsFloat := TotalPriceRoundTo(
  653. ValueByName('AddPcTotalPrice').AsFloat + ATotalPrice);
  654. end;
  655. UpdateRecordGather(stnNode, 0, ATotalPrice);
  656. UpdateRecordPc(stnNode.ParentID, AQuantity, ATotalPrice);
  657. end;
  658. procedure TBillsMeasureData.UpdateRecordQc(ABillsID: Integer; AQuantity,
  659. ATotalPrice: Double);
  660. var
  661. stnNode: TsdIDTreeNode;
  662. begin
  663. stnNode := BillsMeasureTree.FindNode(ABillsID);
  664. if not Assigned(stnNode) then Exit;
  665. with stnNode.Rec do
  666. begin
  667. if not stnNode.HasChildren then
  668. ValueByName('AddQcQuantity').AsFloat := QuantityRoundTo(
  669. ValueByName('AddQcQuantity').AsFloat + AQuantity);
  670. ValueByName('AddQcTotalPrice').AsFloat := TotalPriceRoundTo(
  671. ValueByName('AddQcTotalPrice').AsFloat + ATotalPrice);
  672. end;
  673. UpdateRecordGather(stnNode, AQuantity, ATotalPrice);
  674. UpdateRecordQc(stnNode.ParentID, AQuantity, ATotalPrice);
  675. end;
  676. procedure TBillsMeasureData.UpdateRecordGather(ANode: TsdIDTreeNode;
  677. AQuantity, ATotalPrice: Double);
  678. begin
  679. with ANode.Rec do
  680. begin
  681. if not ANode.HasChildren then
  682. ValueByName('AddGatherQuantity').AsFloat := QuantityRoundTo(
  683. ValueByName('AddGatherQuantity').AsFloat + AQuantity);
  684. ValueByName('AddGatherTotalPrice').AsFloat := TotalPriceRoundTo(
  685. ValueByName('AddGatherTotalPrice').AsFloat + ATotalPrice);
  686. end;
  687. CalcAddDgnPrice(ANode);
  688. CalcAddCompleteRate(ANode);
  689. end;
  690. function TBillsMeasureData.GatherRelaBGL(ANode: TsdIDTreeNode): string;
  691. var
  692. iChild: Integer;
  693. Rec: TsdDataRecord;
  694. begin
  695. Result := '';
  696. if not Assigned(ANode) then Exit;
  697. if ANode.HasChildren then
  698. begin
  699. for iChild := 0 to ANode.ChildCount - 1 do
  700. Result := MergeRelaBGL(Result, GatherRelaBGL(ANode.ChildNodes[iChild]));
  701. end
  702. else
  703. begin
  704. with TProjectData(FProjectData).PhaseData.StageData do
  705. Rec := StageRecord(ANode.ID);
  706. if Assigned(Rec) then
  707. Result := MergeRelaBGL(Rec.ValueByName('QcBGLCode').AsString, Rec.ValueByName('PcBGLCode').AsString);
  708. end;
  709. end;
  710. procedure TBillsMeasureData.sdvBillsMeasureAfterValueChanged(
  711. AValue: TsdValue);
  712. var
  713. vNode: TBillsIDTreeNode;
  714. begin
  715. if TProjectData(FProjectData).PhaseData.Active then
  716. begin
  717. if AValue.FieldName = 'Price' then
  718. StageData.ReCalculate(AValue.Owner.ValueByName('ID').AsInteger);
  719. if AValue.FieldName = 'NewPrice' then
  720. StageData.ReCalculate(AValue.Owner.ValueByName('ID').AsInteger);
  721. end;
  722. if Pos('DgnQuantity1', AValue.FieldName) > 0 then
  723. begin
  724. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger));
  725. CalcAddDgnPrice(vNode);
  726. end;
  727. if (AValue.FieldName = 'Code') then
  728. begin
  729. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger));
  730. BillsMeasureTree.RecodeChildrenCode(vNode, VarToStrDef(AValue.OldValue, ''), AValue.AsString);
  731. end
  732. else if (AValue.FieldName = 'B_Code') then
  733. begin
  734. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger));
  735. BillsMeasureTree.RecodeChildrenB_Code(vNode, VarToStrDef(AValue.OldValue, ''), AValue.AsString);
  736. end;
  737. end;
  738. procedure TBillsMeasureData.ExpandCurPhase;
  739. var
  740. iIndex: Integer;
  741. stnNode: TsdIDTreeNode;
  742. StageRec: TStageRecord;
  743. begin
  744. for iIndex := 0 to BillsMeasureTree.Count - 1 do
  745. begin
  746. stnNode := BillsMeasureTree.Items[iIndex];
  747. StageRec := TMeasureBillsIDTreeNode(stnNode).StageRec;
  748. if (stnNode.ParentID <> -1) then
  749. if Assigned(StageRec) then
  750. stnNode.Expanded := StageRec.GatherTotalPrice.AsFloat <> 0
  751. else
  752. stnNode.Expanded := False;
  753. end;
  754. end;
  755. procedure TBillsMeasureData.UpdateBGLInfo(ABillsID: Integer;
  756. ARec: TsdDataRecord; const AType: string);
  757. var
  758. stnNode: TsdIDTreeNode;
  759. begin
  760. stnNode := BillsMeasureTree.FindNode(ABillsID);
  761. if not Assigned(stnNode) then Exit;
  762. stnNode.Rec.ValueByName('Add' + AType + 'BGLCode').AsString :=
  763. ARec.ValueByName('End' + AType + 'BGLCode').AsString;
  764. stnNode.Rec.ValueByName('Add' + AType + 'BGLNum').AsString :=
  765. ARec.ValueByName('End' + AType + 'BGLNum').AsString;
  766. end;
  767. function TBillsMeasureData.SelectAndUpdateBGL(ABillsID: Integer;
  768. ARec: TsdDataRecord; ANewValue: Double; const AType: string): Boolean;
  769. var
  770. AOrgBGL, ANewBGL: TBGLSelectInfo;
  771. ACurNode: TsdIDTreeNode;
  772. procedure UpdateBGL;
  773. begin
  774. ARec.ValueByName(AType + 'BGLCode').AsString := ANewBGL.MergedCode;
  775. ARec.ValueByName(AType + 'BGLNum').AsString := ANewBGL.MergedNum;
  776. TProjectData(ProjectData).BGLData.ApplyBGL(AOrgBGL, ANewBGL);
  777. end;
  778. begin
  779. Result := True;
  780. ACurNode := BillsMeasureTree.FindNode(ABillsID);
  781. AOrgBGL := TBGLSelectInfo.Create(ACurNode.Rec,
  782. ARec.ValueByName(AType + 'Quantity').AsFloat, True);
  783. AOrgBGL.MergedCode := ARec.ValueByName(AType + 'BGLCode').AsString;
  784. AOrgBGL.MergedNum := ARec.ValueByName(AType + 'BGLNum').AsString;
  785. ANewBGL := TBGLSelectInfo.Create(ACurNode.Rec, ANewValue, False);
  786. try
  787. if ANewBGL.TotalNum <> 0 then
  788. begin
  789. Result := SelectBGL(AOrgBGL, ANewBGL, ProjectData);
  790. if Result then
  791. UpdateBGL;
  792. end
  793. else
  794. UpdateBGL;
  795. StageData.UpdateBGLInfo(ARec, AType);
  796. UpdateBGLInfo(ABillsID, ARec, AType);
  797. finally
  798. AOrgBGL.Free;
  799. ANewBGL.Free;
  800. end;
  801. end;
  802. procedure TBillsMeasureData.Close;
  803. begin
  804. sdvBillsMeasure.Close;
  805. end;
  806. procedure TBillsMeasureData.CalcAddCompleteRate(ANode: TsdIDTreeNode);
  807. var
  808. fDividend, fDivisor: Double;
  809. begin
  810. with ANode.Rec do
  811. begin
  812. fDividend := ValueByName('AddGatherTotalPrice').AsFloat;
  813. fDivisor := ValueByName('TotalPrice').AsFloat + ValueByName('AddQcTotalPrice').AsFloat
  814. + ValueByName('AddPcTotalPrice').AsFloat;
  815. if fDivisor <> 0 then
  816. ValueByName('AddCompleteRate').AsFloat := AdvRoundTo(fDividend/fDivisor*100)
  817. else
  818. ValueByName('AddCompleteRate').Clear;
  819. end;
  820. end;
  821. procedure TBillsMeasureData.CalcAddDgnPrice(ANode: TsdIDTreeNode);
  822. var
  823. fDividend, fDivisor: Double;
  824. begin
  825. with ANode.Rec do
  826. begin
  827. fDividend := ValueByName('AddGatherTotalPrice').AsFloat;
  828. fDivisor := ValueByName('DealDgnQuantity1').AsFloat + ValueByName('CDgnQuantity1').AsFloat;
  829. if fDivisor <> 0 then
  830. ValueByName('AddDgnPrice').AsFloat := AdvRoundTo(fDividend/fDivisor);
  831. end;
  832. end;
  833. procedure TBillsMeasureData.SetOnRecChange(const Value: TRecChangeEvent);
  834. begin
  835. FOnRecChange := Value;
  836. end;
  837. procedure TBillsMeasureData.sdvBillsMeasureCurrentChanged(
  838. ARecord: TsdDataRecord);
  839. begin
  840. if Assigned(FOnRecChange) then
  841. FOnRecChange(ARecord);
  842. end;
  843. procedure TBillsMeasureData.ResetTreeNodeStageRec;
  844. var
  845. i: Integer;
  846. vNode: TMeasureBillsIDTreeNode;
  847. begin
  848. if not StageData.Active then Exit;
  849. for i := 0 to BillsMeasureTree.Count - 1 do
  850. begin
  851. vNode := TMeasureBillsIDTreeNode(BillsMeasureTree.Items[i]);
  852. vNode.StageRec := StageData.StageRecord(vNode.ID);
  853. end;
  854. end;
  855. procedure TBillsMeasureData.UpdateRecordPM(ABillsID: Integer;
  856. ADiffer: Double);
  857. var
  858. stnNode: TBillsIDTreeNode;
  859. begin
  860. stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
  861. if not Assigned(stnNode) then Exit;
  862. stnNode.Rec.PM_AddTotalPrice.AsFloat := stnNode.Rec.PM_AddTotalPrice.AsFloat + ADiffer;
  863. UpdateRecordPM(stnNode.ParentID, ADiffer);
  864. end;
  865. procedure TBillsMeasureData.CalculateNode(ANode: TMeasureBillsIDTreeNode);
  866. begin
  867. if Assigned(ANode.StageRec) then
  868. begin
  869. if not ANode.HasChildren then
  870. begin
  871. ANode.Rec.AddDealQuantity.AsFloat := ANode.StageRec.EndDealQuantity.AsFloat;
  872. ANode.Rec.AddQcQuantity.AsFloat := ANode.StageRec.EndQcQuantity.AsFloat;
  873. ANode.Rec.AddQcBGLCode.AsString := ANode.StageRec.EndQcBGLCode.AsString;
  874. ANode.Rec.AddQcBGLNum.AsString := ANode.StageRec.EndQcBGLNum.AsString;
  875. ANode.Rec.AddPcQuantity.AsFloat := ANode.StageRec.EndPcQuantity.AsFloat;
  876. ANode.Rec.AddPcBGLCode.AsString := ANode.StageRec.EndPcBGLCode.AsString;
  877. ANode.Rec.AddPcBGLNum.AsString := ANode.StageRec.EndPcBGLNum.AsString;
  878. ANode.Rec.AddGatherQuantity.AsFloat := ANode.StageRec.EndGatherQuantity.AsFloat;
  879. end;
  880. ANode.Rec.AddDealTotalPrice.AsFloat := ANode.StageRec.EndDealTotalPrice.AsFloat;
  881. ANode.Rec.AddQcTotalPrice.AsFloat := ANode.StageRec.EndQcTotalPrice.AsFloat;
  882. ANode.Rec.AddPcTotalPrice.AsFloat := ANode.StageRec.EndPcTotalPrice.AsFloat;
  883. ANode.Rec.AddGatherTotalPrice.AsFloat := ANode.StageRec.EndGatherTotalPrice.AsFloat;
  884. ANode.Rec.PM_AddTotalPrice.AsFloat := ANode.StageRec.PM_PreTotalPrice.AsFloat + ANode.StageRec.PM_TotalPrice.AsFloat;
  885. end;
  886. end;
  887. procedure TBillsMeasureData.UpdateGather(ABillsID: Integer;
  888. ADiffer: Double);
  889. var
  890. stnNode: TBillsIDTreeNode;
  891. begin
  892. stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
  893. if not Assigned(stnNode) then Exit;
  894. with stnNode.Rec do
  895. AddDifferValue(AddGatherTotalPrice, ADiffer);
  896. UpdateGather(stnNode.ParentID, ADiffer);
  897. end;
  898. end.