BillsMeasureDm.pas 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  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: TBillsIDTree;
  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: TBillsIDTreeNode);
  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: TBillsIDTree 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;
  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 := TBillsIDTree.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. FFormulaCalc := TFormulaCalc.Create(FBillsMeasureTree);
  86. FFormulaCalc.OnGetValue := OnGetCardinalNum;
  87. end;
  88. destructor TBillsMeasureData.Destroy;
  89. begin
  90. FFormulaCalc.Free;
  91. FBillsMeasureTree.Free;
  92. inherited;
  93. end;
  94. procedure TBillsMeasureData.Open;
  95. begin
  96. sdvBillsMeasure.DataSet := TProjectData(FProjectData).BillsData.sddBills;
  97. sdvBillsMeasure.Open;
  98. end;
  99. procedure TBillsMeasureData.ReConnectTree;
  100. begin
  101. FBillsMeasureTree.DataView := nil;
  102. FBillsMeasureTree.DataView := sdvBillsMeasure;
  103. FBillsMeasureTree.Link(TProjectData(FProjectData).BillsCompileData.BillsCompileTree, True);
  104. end;
  105. procedure TBillsMeasureData.ResetPhaseStageLink;
  106. begin
  107. with TProjectData(FProjectData).PhaseData do
  108. begin
  109. sdvBillsMeasure.Columns.FindColumn('CurDealQuantity').LookupDataSet := StageData.sddStage;
  110. sdvBillsMeasure.Columns.FindColumn('CurDealTotalPrice').LookupDataSet := StageData.sddStage;
  111. sdvBillsMeasure.Columns.FindColumn('CurQcQuantity').LookupDataSet := StageData.sddStage;
  112. sdvBillsMeasure.Columns.FindColumn('CurQcTotalPrice').LookupDataSet := StageData.sddStage;
  113. sdvBillsMeasure.Columns.FindColumn('CurQcBGLCode').LookupDataSet := StageData.sddStage;
  114. sdvBillsMeasure.Columns.FindColumn('CurPcQuantity').LookupDataSet := StageData.sddStage;
  115. sdvBillsMeasure.Columns.FindColumn('CurPcTotalPrice').LookupDataSet := StageData.sddStage;
  116. sdvBillsMeasure.Columns.FindColumn('CurPcBGLCode').LookupDataSet := StageData.sddStage;
  117. sdvBillsMeasure.Columns.FindColumn('CurGatherQuantity').LookupDataSet := StageData.sddStage;
  118. sdvBillsMeasure.Columns.FindColumn('CurGatherTotalPrice').LookupDataSet := StageData.sddStage;
  119. sdvBillsMeasure.Columns.FindColumn('EndDealQuantity').LookupDataSet := StageData.sddStage;
  120. sdvBillsMeasure.Columns.FindColumn('EndDealTotalPrice').LookupDataSet := StageData.sddStage;
  121. sdvBillsMeasure.Columns.FindColumn('EndQcQuantity').LookupDataSet := StageData.sddStage;
  122. sdvBillsMeasure.Columns.FindColumn('EndQcTotalPrice').LookupDataSet := StageData.sddStage;
  123. sdvBillsMeasure.Columns.FindColumn('EndPcQuantity').LookupDataSet := StageData.sddStage;
  124. sdvBillsMeasure.Columns.FindColumn('EndPcTotalPrice').LookupDataSet := StageData.sddStage;
  125. sdvBillsMeasure.Columns.FindColumn('EndGatherQuantity').LookupDataSet := StageData.sddStage;
  126. sdvBillsMeasure.Columns.FindColumn('EndGatherTotalPrice').LookupDataSet := StageData.sddStage;
  127. sdvBillsMeasure.Columns.FindColumn('PM_PreTotalPrice').LookupDataSet := StageData.sddStage;
  128. sdvBillsMeasure.Columns.FindColumn('PM_TotalPrice').LookupDataSet := StageData.sddStage;
  129. end;
  130. end;
  131. procedure TBillsMeasureData.sdvBillsMeasureAfterOpen(Sender: TObject);
  132. begin
  133. FBillsMeasureTree.Active := True;
  134. end;
  135. procedure TBillsMeasureData.sdvBillsMeasureAfterAddRecord(
  136. ARecord: TsdDataRecord);
  137. begin
  138. ARecord.ValueByName('IsMeasureAdd').AsBoolean := True;
  139. end;
  140. procedure TBillsMeasureData.sdvBillsMeasureGetText(var Text: String;
  141. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  142. DisplayText: Boolean);
  143. function GetQuantityValueOrFormula(const AQtyType: string): string;
  144. begin
  145. with AValue.Owner do
  146. begin
  147. if ValueByName(AQtyType + 'Flag').AsInteger = 1 then
  148. Result := ValueByName(AQtyType + 'Formula').AsString
  149. else
  150. Result := Text;
  151. end;
  152. end;
  153. function GetTotalPriceValueOrFormula(const AQtyType: string): string;
  154. begin
  155. with AValue.Owner do
  156. begin
  157. if ValueByName(AQtyType + 'Formula').AsString <> '' then
  158. Result := ValueByName(AQtyType + 'Formula').AsString
  159. else
  160. Result := Text;
  161. end;
  162. end;
  163. procedure GetDisplayText(var AText: string; AValue: TsdValue;
  164. AColumn: TsdViewColumn);
  165. var
  166. stnNode: TsdIDTreeNode;
  167. begin
  168. if Assigned(AValue) and (AValue.DataType = ftFloat) and (AValue.AsFloat = 0) then
  169. begin
  170. Text := '';
  171. Exit;
  172. end;
  173. // 所有本期数据,当节点为父节点时,不显示值(实际上需要计算其中的金额值,但又不能显示)
  174. // 有病。每天都在变。
  175. if not ShowParentData and (Pos('Cur', AColumn.FieldName) > 0) and (Pos('Gather', AColumn.FieldName) = 0) then
  176. begin
  177. stnNode := BillsMeasureTree.FindNode(AValue.Owner.ValueByName('BillsID').AsInteger);
  178. if stnNode.HasChildren then
  179. Text := '';
  180. end;
  181. end;
  182. procedure GetEditText(var AText: string; AValue: TsdValue;
  183. AColumn: TsdViewColumn);
  184. begin
  185. if SameText(AColumn.FieldName, 'Quantity') then
  186. Text := GetQuantityValueOrFormula('Qty')
  187. else if SameText(AColumn.FieldName, 'CurDealQuantity') then
  188. Text := GetQuantityValueOrFormula('Deal')
  189. else if SameText(AColumn.FieldName, 'CurQcQuantity') then
  190. Text := GetQuantityValueOrFormula('Qc')
  191. else if SameText(AColumn.FieldName, 'CurPcQuantity') then
  192. Text := GetQuantityValueOrFormula('Pc')
  193. else if SameText(AColumn.FieldName, 'CurDealTotalPrice') then
  194. Text := GetTotalPriceValueOrFormula('Deal')
  195. else if SameText(AColumn.FieldName, 'CurQcTotalPrice') then
  196. Text := GetTotalPriceValueOrFormula('Qc')
  197. else if SameText(AColumn.FieldName, 'CurPcTotalPrice') then
  198. Text := GetTotalPriceValueOrFormula('Pc');
  199. end;
  200. var
  201. fPercent: Double;
  202. begin
  203. if not Assigned(AValue) then Exit;
  204. if DisplayText then
  205. GetDisplayText(Text, AValue, AColumn)
  206. else
  207. GetEditText(Text, AValue, AColumn);
  208. end;
  209. procedure TBillsMeasureData.sdvBillsMeasureSetText(var Text: String;
  210. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  211. var Allow: Boolean);
  212. function GetBillsID: Integer;
  213. begin
  214. if Pos('Cur', AColumn.FieldName) = 1 then
  215. Result := AValue.Owner.ValueByName('BillsID').AsInteger
  216. else
  217. Result := ARecord.ValueByName('ID').AsInteger;
  218. end;
  219. procedure CheckLockedData;
  220. begin
  221. if SameText(AColumn.FieldName, 'Code') or
  222. SameText(AColumn.FieldName, 'B_Code') or
  223. SameText(AColumn.FieldName, 'Name') or
  224. SameText(AColumn.FieldName, 'Units') or
  225. SameText(AColumn.FieldName, 'Price') then
  226. if ARecord.ValueByName('LockedInfo').AsBoolean then
  227. DataSetErrorMessage(Allow, '清单信息已被锁定,不允许修改编号、名称、单位、清单单价!');
  228. if not Allow then Exit;
  229. if SameText(AColumn.FieldName, 'NewPrice') then
  230. if ARecord.ValueByName('LockedNewPrice').AsBoolean then
  231. DataSetErrorMessage(Allow, '变更单价已被锁定,不允许修改!');
  232. end;
  233. procedure CheckNodeWritable;
  234. var
  235. vNode: TBillsIDTreeNode;
  236. iCreatePhase: Integer;
  237. begin
  238. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
  239. iCreatePhase := vNode.Rec.ValueByName('CreatePhaseID').AsInteger;
  240. if vNode.ID = iPriceMarginID then
  241. DataSetErrorMessage(Allow, sBills_PMHint);
  242. if SameText('B_Code', AColumn.FieldName) or
  243. SameText('Name', AColumn.FieldName) or
  244. SameText('Units', AColumn.FieldName) then
  245. if vNode.Rec.ValueByName('AddQcQuantity').AsFloat <> 0 then
  246. DataSetErrorMessage(Allow, '该清单已进行过变更,不可修改清单编号、名称、单位!');
  247. if not Allow then Exit;
  248. if SameText('Price', AColumn.FieldName) then
  249. if vNode.Rec.ValueByName('AddGatherTotalPrice').AsFloat <> 0 then
  250. DataSetErrorMessage(Allow, '该清单已经计量,不可修改清单单价!');
  251. if not Allow then Exit;
  252. if SameText('NewPrice', AColumn.FieldName) then
  253. if vNode.Rec.ValueByName('AddPcTotalPrice').AsFloat <> 0 then
  254. DataSetErrorMessage(Allow, '该清单已经计量,不可修改清单变更单价!');
  255. if not Allow then Exit;
  256. if vNode.HasChildren then
  257. begin
  258. if Text = '' then
  259. Exit
  260. else if ((Pos('Quantity', AColumn.FieldName) > 0) and (Pos('Dgn', AColumn.FieldName) <=0)) or
  261. (Pos('TotalPrice', AColumn.FieldName) > 0) then
  262. DataSetErrorMessage(Allow, '该清单有子计算项,不能直接修改!')
  263. else if (Pos('Price', AColumn.FieldName) > 0) then
  264. DataSetErrorMessage(Allow, '仅最底层清单可输入单价!');
  265. end
  266. else
  267. begin
  268. // 目前仅允许本期合同计量,可直接输入金额
  269. if SameText('CurDealTotalPrice', AColumn.FieldName) then
  270. begin
  271. if not vNode.TotalPriceEnable then
  272. DataSetErrorMessage(Allow, '该清单不可直接输入金额,如需直接输入金额,请先清空所有数量、单价!');
  273. end
  274. else if SameText('CurDealQuantity', AColumn.FieldName) or
  275. SameText('CurQcQuantity', AColumn.FieldName) or
  276. SameText('CurPcQuantity', AColumn.FieldName) or
  277. SameText('Price', AColumn.FieldName) then
  278. begin
  279. if not vNode.CountPriceEnable then
  280. DataSetErrorMessage(Allow, '该清单不可输入数量单价,如需使用数量×单价计算,请先清空所有直接输入的金额!');
  281. end;
  282. end;
  283. if not Allow then Exit;
  284. // 变更清单允许填写本期合同计量,按超计论
  285. {if vNode.Rec.ValueByName('IsMeasureAdd').AsBoolean and (iCreatePhase > 0) and
  286. (SameText('CurDealQuantity', AColumn.FieldName) or
  287. SameText('CurDealTotalPrice', AColumn.FieldName)) then
  288. DataSetErrorMessage(Allow, Format('该清单为第%d期新增清单,不可填写本期合同计量数据!', [iCreatePhase]));}
  289. end;
  290. procedure SetQuantity(const AField: string);
  291. var
  292. vNode: TBillsIDTreeNode;
  293. begin
  294. // 变更应选择变更令
  295. if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
  296. Allow := SelectAndUpdateBGL(GetBillsID, AValue.Owner, StrToFloatDef(Text, 0), AField);
  297. if not Allow then Exit;
  298. if CheckStringNull(Text) or CheckNumeric(Text) then
  299. begin
  300. AValue.Owner.ValueByName(AField + 'Flag').AsInteger := 0;
  301. AValue.Owner.ValueByName(AField + 'Formula').AsString := '';
  302. Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)));
  303. end
  304. else
  305. begin
  306. AValue.Owner.ValueByName(AField + 'Flag').AsInteger := 1;
  307. AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
  308. Text := FloatToStr(QuantityRoundTo(EvaluateExprs(Text)));
  309. end;
  310. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
  311. if vNode.Rec.CalcType.AsInteger <> 0 then
  312. vNode.Rec.CalcType.AsInteger := 0;
  313. end;
  314. procedure SetTotalPrice(const AField: string);
  315. var
  316. vNode: TBillsIDTreeNode;
  317. begin
  318. // 变更应选择变更令
  319. if SameText(AField , 'Qc') or SameText(AField , 'Pc') then
  320. Allow := SelectAndUpdateBGL(GetBillsID, AValue.Owner, StrToFloatDef(Text, 0), AField);
  321. if not Allow then Exit;
  322. AValue.Owner.ValueByName(AField + 'Flag').AsInteger := 2;
  323. AValue.Owner.ValueByName(AField + 'Quantity').AsString := '';
  324. if CheckStringNull(Text) or CheckNumeric(Text) then
  325. begin
  326. AValue.Owner.ValueByName(AField + 'Formula').AsString := '';
  327. Text := FloatToStr(TotalPriceRoundTo(StrToFloatDef(Text, 0)));
  328. end
  329. else
  330. begin
  331. AValue.Owner.ValueByName(AField + 'Formula').AsString := Text;
  332. Text := FloatToStr(TotalPriceRoundTo(EvaluateExprs(Text)));
  333. end;
  334. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(GetBillsID));
  335. if vNode.Rec.CalcType.AsInteger <> 1 then
  336. vNode.Rec.CalcType.AsInteger := 1;
  337. end;
  338. procedure DoCurChanged;
  339. begin
  340. if SameText(AColumn.FieldName, 'CurDealQuantity') then
  341. SetQuantity('Deal')
  342. else if SameText(AColumn.FieldName, 'CurQcQuantity') then
  343. SetQuantity('Qc')
  344. else if SameText(AColumn.FieldName, 'CurPcQuantity') then
  345. SetQuantity('Pc')
  346. else if SameText(AColumn.FieldName, 'CurDealTotalPrice') then
  347. SetTotalPrice('Deal')
  348. else if SameText(AColumn.FieldName, 'CurQcTotalPrice') then
  349. SetTotalPrice('Qc')
  350. else if SameText(AColumn.FieldName, 'CurPcTotalPrice') then
  351. SetTotalPrice('Pc')
  352. else if (Pos('DgnQuantity', AColumn.FieldName) > 0) or
  353. SameText(AColumn.FieldName, 'Quantity') then
  354. Text := FloatToStr(QuantityRoundTo(StrToFloatDef(Text, 0)))
  355. else if SameText(AColumn.FieldName, 'NewPrice') or
  356. SameText(AColumn.FieldName, 'Price') then
  357. Text := FloatToStr(PriceRoundTo(StrToFloatDef(Text, 0)));
  358. end;
  359. function CheckValidData: Boolean;
  360. begin
  361. Result := (AValue.AsString <> Text);
  362. if (Pos('Quantity', AColumn.FieldName) > 0) or
  363. (Pos('Price', AColumn.FieldName) > 0) then
  364. begin
  365. if (AValue.AsFloat = 0) and (Text = '') then
  366. Result := False;
  367. end;
  368. end;
  369. begin
  370. if not Assigned(AValue) then Exit;
  371. // 修改后数据与原数据相同则不提交
  372. if not CheckValidData then
  373. Allow := False;
  374. if not Allow then Exit;
  375. CheckLockedData;
  376. if not Allow then Exit;
  377. CheckNodeWritable;
  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;
  383. end;
  384. procedure TBillsMeasureData.sdvBillsMeasureNeedLookupRecord(
  385. ARecord: TsdDataRecord; AColumn: TsdViewColumn; ANewText: String);
  386. function CheckNeedAddPhaseRecord(ANode: TBillsIDTreeNode): 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: TBillsIDTreeNode;
  504. begin
  505. vNode := TBillsIDTreeNode(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(TBillsIDTreeNode(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. stnNode: TsdIDTreeNode;
  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. stnNode := BillsMeasureTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger);
  725. CalcAddDgnPrice(stnNode);
  726. end;
  727. end;
  728. procedure TBillsMeasureData.ExpandCurPhase;
  729. var
  730. iIndex: Integer;
  731. stnNode: TsdIDTreeNode;
  732. StageRec: TStageRecord;
  733. begin
  734. for iIndex := 0 to BillsMeasureTree.Count - 1 do
  735. begin
  736. stnNode := BillsMeasureTree.Items[iIndex];
  737. StageRec := TBillsIDTreeNode(stnNode).StageRec;
  738. if (stnNode.ParentID <> -1) then
  739. if Assigned(StageRec) then
  740. stnNode.Expanded := StageRec.GatherTotalPrice.AsFloat <> 0
  741. else
  742. stnNode.Expanded := False;
  743. end;
  744. end;
  745. procedure TBillsMeasureData.UpdateBGLInfo(ABillsID: Integer;
  746. ARec: TsdDataRecord; const AType: string);
  747. var
  748. stnNode: TsdIDTreeNode;
  749. begin
  750. stnNode := BillsMeasureTree.FindNode(ABillsID);
  751. if not Assigned(stnNode) then Exit;
  752. stnNode.Rec.ValueByName('Add' + AType + 'BGLCode').AsString :=
  753. ARec.ValueByName('End' + AType + 'BGLCode').AsString;
  754. stnNode.Rec.ValueByName('Add' + AType + 'BGLNum').AsString :=
  755. ARec.ValueByName('End' + AType + 'BGLNum').AsString;
  756. end;
  757. function TBillsMeasureData.SelectAndUpdateBGL(ABillsID: Integer;
  758. ARec: TsdDataRecord; ANewValue: Double; const AType: string): Boolean;
  759. var
  760. AOrgBGL, ANewBGL: TBGLSelectInfo;
  761. ACurNode: TsdIDTreeNode;
  762. procedure UpdateBGL;
  763. begin
  764. ARec.ValueByName(AType + 'BGLCode').AsString := ANewBGL.MergedCode;
  765. ARec.ValueByName(AType + 'BGLNum').AsString := ANewBGL.MergedNum;
  766. TProjectData(ProjectData).BGLData.ApplyBGL(AOrgBGL, ANewBGL);
  767. end;
  768. begin
  769. Result := True;
  770. ACurNode := BillsMeasureTree.FindNode(ABillsID);
  771. AOrgBGL := TBGLSelectInfo.Create(ACurNode.Rec,
  772. ARec.ValueByName(AType + 'Quantity').AsFloat, True);
  773. AOrgBGL.MergedCode := ARec.ValueByName(AType + 'BGLCode').AsString;
  774. AOrgBGL.MergedNum := ARec.ValueByName(AType + 'BGLNum').AsString;
  775. ANewBGL := TBGLSelectInfo.Create(ACurNode.Rec, ANewValue, False);
  776. try
  777. if ANewBGL.TotalNum <> 0 then
  778. begin
  779. Result := SelectBGL(AOrgBGL, ANewBGL, ProjectData);
  780. if Result then
  781. UpdateBGL;
  782. end
  783. else
  784. UpdateBGL;
  785. StageData.UpdateBGLInfo(ARec, AType);
  786. UpdateBGLInfo(ABillsID, ARec, AType);
  787. finally
  788. AOrgBGL.Free;
  789. ANewBGL.Free;
  790. end;
  791. end;
  792. procedure TBillsMeasureData.Close;
  793. begin
  794. sdvBillsMeasure.Close;
  795. end;
  796. procedure TBillsMeasureData.CalcAddCompleteRate(ANode: TsdIDTreeNode);
  797. var
  798. fDividend, fDivisor: Double;
  799. begin
  800. with ANode.Rec do
  801. begin
  802. fDividend := ValueByName('AddGatherTotalPrice').AsFloat;
  803. fDivisor := ValueByName('TotalPrice').AsFloat + ValueByName('AddQcTotalPrice').AsFloat
  804. + ValueByName('AddPcTotalPrice').AsFloat;
  805. if fDivisor <> 0 then
  806. ValueByName('AddCompleteRate').AsFloat := AdvRoundTo(fDividend/fDivisor*100)
  807. else
  808. ValueByName('AddCompleteRate').Clear;
  809. end;
  810. end;
  811. procedure TBillsMeasureData.CalcAddDgnPrice(ANode: TsdIDTreeNode);
  812. var
  813. fDividend, fDivisor: Double;
  814. begin
  815. with ANode.Rec do
  816. begin
  817. fDividend := ValueByName('AddGatherTotalPrice').AsFloat;
  818. fDivisor := ValueByName('DealDgnQuantity1').AsFloat + ValueByName('CDgnQuantity1').AsFloat;
  819. if fDivisor <> 0 then
  820. ValueByName('AddDgnPrice').AsFloat := AdvRoundTo(fDividend/fDivisor);
  821. end;
  822. end;
  823. procedure TBillsMeasureData.SetOnRecChange(const Value: TRecChangeEvent);
  824. begin
  825. FOnRecChange := Value;
  826. end;
  827. procedure TBillsMeasureData.sdvBillsMeasureCurrentChanged(
  828. ARecord: TsdDataRecord);
  829. begin
  830. if Assigned(FOnRecChange) then
  831. FOnRecChange(ARecord);
  832. end;
  833. procedure TBillsMeasureData.ResetTreeNodeStageRec;
  834. var
  835. i: Integer;
  836. vNode: TBillsIDTreeNode;
  837. begin
  838. if not StageData.Active then Exit;
  839. for i := 0 to BillsMeasureTree.Count - 1 do
  840. begin
  841. vNode := TBillsIDTreeNode(BillsMeasureTree.Items[i]);
  842. vNode.StageRec := StageData.StageRecord(vNode.ID);
  843. end;
  844. end;
  845. procedure TBillsMeasureData.UpdateRecordPM(ABillsID: Integer;
  846. ADiffer: Double);
  847. var
  848. stnNode: TBillsIDTreeNode;
  849. begin
  850. stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
  851. if not Assigned(stnNode) then Exit;
  852. stnNode.Rec.PM_AddTotalPrice.AsFloat := stnNode.Rec.PM_AddTotalPrice.AsFloat + ADiffer;
  853. UpdateRecordPM(stnNode.ParentID, ADiffer);
  854. end;
  855. procedure TBillsMeasureData.CalculateNode(ANode: TBillsIDTreeNode);
  856. begin
  857. if Assigned(ANode.StageRec) then
  858. begin
  859. if not ANode.HasChildren then
  860. begin
  861. ANode.Rec.AddDealQuantity.AsFloat := ANode.StageRec.EndDealQuantity.AsFloat;
  862. ANode.Rec.AddQcQuantity.AsFloat := ANode.StageRec.EndQcQuantity.AsFloat;
  863. ANode.Rec.AddQcBGLCode.AsString := ANode.StageRec.EndQcBGLCode.AsString;
  864. ANode.Rec.AddQcBGLNum.AsString := ANode.StageRec.EndQcBGLNum.AsString;
  865. ANode.Rec.AddPcQuantity.AsFloat := ANode.StageRec.EndPcQuantity.AsFloat;
  866. ANode.Rec.AddPcBGLCode.AsString := ANode.StageRec.EndPcBGLCode.AsString;
  867. ANode.Rec.AddPcBGLNum.AsString := ANode.StageRec.EndPcBGLNum.AsString;
  868. ANode.Rec.AddGatherQuantity.AsFloat := ANode.StageRec.EndGatherQuantity.AsFloat;
  869. end;
  870. ANode.Rec.AddDealTotalPrice.AsFloat := ANode.StageRec.EndDealTotalPrice.AsFloat;
  871. ANode.Rec.AddQcTotalPrice.AsFloat := ANode.StageRec.EndQcTotalPrice.AsFloat;
  872. ANode.Rec.AddPcTotalPrice.AsFloat := ANode.StageRec.EndPcTotalPrice.AsFloat;
  873. ANode.Rec.AddGatherTotalPrice.AsFloat := ANode.StageRec.EndGatherTotalPrice.AsFloat;
  874. ANode.Rec.PM_AddTotalPrice.AsFloat := ANode.StageRec.PM_PreTotalPrice.AsFloat + ANode.StageRec.PM_TotalPrice.AsFloat;
  875. end;
  876. end;
  877. procedure TBillsMeasureData.UpdateGather(ABillsID: Integer;
  878. ADiffer: Double);
  879. var
  880. stnNode: TBillsIDTreeNode;
  881. begin
  882. stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
  883. if not Assigned(stnNode) then Exit;
  884. with stnNode.Rec do
  885. AddDifferValue(AddGatherTotalPrice, ADiffer);
  886. UpdateGather(stnNode.ParentID, ADiffer);
  887. end;
  888. end.