BillsMeasureDm.pas 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  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. vNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(AValue.Owner.ValueByName('ID').AsInteger));
  716. if TProjectData(FProjectData).PhaseData.Active then
  717. begin
  718. if AValue.FieldName = 'Price' then
  719. StageData.ReCalculate(AValue.Owner.ValueByName('ID').AsInteger);
  720. if AValue.FieldName = 'NewPrice' then
  721. StageData.ReCalculate(AValue.Owner.ValueByName('ID').AsInteger);
  722. end;
  723. if Pos('DgnQuantity1', AValue.FieldName) > 0 then
  724. CalcAddDgnPrice(vNode);
  725. if (AValue.FieldName = 'Code') then
  726. BillsMeasureTree.RecodeChildrenCode(vNode, VarToStrDef(AValue.OldValue, ''), AValue.AsString)
  727. else if (AValue.FieldName = 'B_Code') then
  728. BillsMeasureTree.RecodeChildrenB_Code(vNode, VarToStrDef(AValue.OldValue, ''), AValue.AsString);
  729. end;
  730. procedure TBillsMeasureData.ExpandCurPhase;
  731. var
  732. iIndex: Integer;
  733. stnNode: TsdIDTreeNode;
  734. StageRec: TStageRecord;
  735. begin
  736. for iIndex := 0 to BillsMeasureTree.Count - 1 do
  737. begin
  738. stnNode := BillsMeasureTree.Items[iIndex];
  739. StageRec := TMeasureBillsIDTreeNode(stnNode).StageRec;
  740. if (stnNode.ParentID <> -1) then
  741. if Assigned(StageRec) then
  742. stnNode.Expanded := StageRec.GatherTotalPrice.AsFloat <> 0
  743. else
  744. stnNode.Expanded := False;
  745. end;
  746. end;
  747. procedure TBillsMeasureData.UpdateBGLInfo(ABillsID: Integer;
  748. ARec: TsdDataRecord; const AType: string);
  749. var
  750. stnNode: TsdIDTreeNode;
  751. begin
  752. stnNode := BillsMeasureTree.FindNode(ABillsID);
  753. if not Assigned(stnNode) then Exit;
  754. stnNode.Rec.ValueByName('Add' + AType + 'BGLCode').AsString :=
  755. ARec.ValueByName('End' + AType + 'BGLCode').AsString;
  756. stnNode.Rec.ValueByName('Add' + AType + 'BGLNum').AsString :=
  757. ARec.ValueByName('End' + AType + 'BGLNum').AsString;
  758. end;
  759. function TBillsMeasureData.SelectAndUpdateBGL(ABillsID: Integer;
  760. ARec: TsdDataRecord; ANewValue: Double; const AType: string): Boolean;
  761. var
  762. AOrgBGL, ANewBGL: TBGLSelectInfo;
  763. ACurNode: TsdIDTreeNode;
  764. procedure UpdateBGL;
  765. begin
  766. ARec.ValueByName(AType + 'BGLCode').AsString := ANewBGL.MergedCode;
  767. ARec.ValueByName(AType + 'BGLNum').AsString := ANewBGL.MergedNum;
  768. TProjectData(ProjectData).BGLData.ApplyBGL(AOrgBGL, ANewBGL);
  769. end;
  770. begin
  771. Result := True;
  772. ACurNode := BillsMeasureTree.FindNode(ABillsID);
  773. AOrgBGL := TBGLSelectInfo.Create(ACurNode.Rec,
  774. ARec.ValueByName(AType + 'Quantity').AsFloat, True);
  775. AOrgBGL.MergedCode := ARec.ValueByName(AType + 'BGLCode').AsString;
  776. AOrgBGL.MergedNum := ARec.ValueByName(AType + 'BGLNum').AsString;
  777. ANewBGL := TBGLSelectInfo.Create(ACurNode.Rec, ANewValue, False);
  778. try
  779. if ANewBGL.TotalNum <> 0 then
  780. begin
  781. Result := SelectBGL(AOrgBGL, ANewBGL, ProjectData);
  782. if Result then
  783. UpdateBGL;
  784. end
  785. else
  786. UpdateBGL;
  787. StageData.UpdateBGLInfo(ARec, AType);
  788. UpdateBGLInfo(ABillsID, ARec, AType);
  789. finally
  790. AOrgBGL.Free;
  791. ANewBGL.Free;
  792. end;
  793. end;
  794. procedure TBillsMeasureData.Close;
  795. begin
  796. sdvBillsMeasure.Close;
  797. end;
  798. procedure TBillsMeasureData.CalcAddCompleteRate(ANode: TsdIDTreeNode);
  799. var
  800. fDividend, fDivisor: Double;
  801. begin
  802. with ANode.Rec do
  803. begin
  804. fDividend := ValueByName('AddGatherTotalPrice').AsFloat;
  805. fDivisor := ValueByName('TotalPrice').AsFloat + ValueByName('AddQcTotalPrice').AsFloat
  806. + ValueByName('AddPcTotalPrice').AsFloat;
  807. if fDivisor <> 0 then
  808. ValueByName('AddCompleteRate').AsFloat := AdvRoundTo(fDividend/fDivisor*100)
  809. else
  810. ValueByName('AddCompleteRate').Clear;
  811. end;
  812. end;
  813. procedure TBillsMeasureData.CalcAddDgnPrice(ANode: TsdIDTreeNode);
  814. var
  815. fDividend, fDivisor: Double;
  816. begin
  817. with ANode.Rec do
  818. begin
  819. fDividend := ValueByName('AddGatherTotalPrice').AsFloat;
  820. fDivisor := ValueByName('DealDgnQuantity1').AsFloat + ValueByName('CDgnQuantity1').AsFloat;
  821. if fDivisor <> 0 then
  822. ValueByName('AddDgnPrice').AsFloat := AdvRoundTo(fDividend/fDivisor);
  823. end;
  824. end;
  825. procedure TBillsMeasureData.SetOnRecChange(const Value: TRecChangeEvent);
  826. begin
  827. FOnRecChange := Value;
  828. end;
  829. procedure TBillsMeasureData.sdvBillsMeasureCurrentChanged(
  830. ARecord: TsdDataRecord);
  831. begin
  832. if Assigned(FOnRecChange) then
  833. FOnRecChange(ARecord);
  834. end;
  835. procedure TBillsMeasureData.ResetTreeNodeStageRec;
  836. var
  837. i: Integer;
  838. vNode: TMeasureBillsIDTreeNode;
  839. begin
  840. if not StageData.Active then Exit;
  841. for i := 0 to BillsMeasureTree.Count - 1 do
  842. begin
  843. vNode := TMeasureBillsIDTreeNode(BillsMeasureTree.Items[i]);
  844. vNode.StageRec := StageData.StageRecord(vNode.ID);
  845. end;
  846. end;
  847. procedure TBillsMeasureData.UpdateRecordPM(ABillsID: Integer;
  848. ADiffer: Double);
  849. var
  850. stnNode: TBillsIDTreeNode;
  851. begin
  852. stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
  853. if not Assigned(stnNode) then Exit;
  854. stnNode.Rec.PM_AddTotalPrice.AsFloat := stnNode.Rec.PM_AddTotalPrice.AsFloat + ADiffer;
  855. UpdateRecordPM(stnNode.ParentID, ADiffer);
  856. end;
  857. procedure TBillsMeasureData.CalculateNode(ANode: TMeasureBillsIDTreeNode);
  858. begin
  859. if Assigned(ANode.StageRec) then
  860. begin
  861. if not ANode.HasChildren then
  862. begin
  863. ANode.Rec.AddDealQuantity.AsFloat := ANode.StageRec.EndDealQuantity.AsFloat;
  864. ANode.Rec.AddQcQuantity.AsFloat := ANode.StageRec.EndQcQuantity.AsFloat;
  865. ANode.Rec.AddQcBGLCode.AsString := ANode.StageRec.EndQcBGLCode.AsString;
  866. ANode.Rec.AddQcBGLNum.AsString := ANode.StageRec.EndQcBGLNum.AsString;
  867. ANode.Rec.AddPcQuantity.AsFloat := ANode.StageRec.EndPcQuantity.AsFloat;
  868. ANode.Rec.AddPcBGLCode.AsString := ANode.StageRec.EndPcBGLCode.AsString;
  869. ANode.Rec.AddPcBGLNum.AsString := ANode.StageRec.EndPcBGLNum.AsString;
  870. ANode.Rec.AddGatherQuantity.AsFloat := ANode.StageRec.EndGatherQuantity.AsFloat;
  871. end;
  872. ANode.Rec.AddDealTotalPrice.AsFloat := ANode.StageRec.EndDealTotalPrice.AsFloat;
  873. ANode.Rec.AddQcTotalPrice.AsFloat := ANode.StageRec.EndQcTotalPrice.AsFloat;
  874. ANode.Rec.AddPcTotalPrice.AsFloat := ANode.StageRec.EndPcTotalPrice.AsFloat;
  875. ANode.Rec.AddGatherTotalPrice.AsFloat := ANode.StageRec.EndGatherTotalPrice.AsFloat;
  876. ANode.Rec.PM_AddTotalPrice.AsFloat := ANode.StageRec.PM_PreTotalPrice.AsFloat + ANode.StageRec.PM_TotalPrice.AsFloat;
  877. end;
  878. end;
  879. procedure TBillsMeasureData.UpdateGather(ABillsID: Integer;
  880. ADiffer: Double);
  881. var
  882. stnNode: TBillsIDTreeNode;
  883. begin
  884. stnNode := TBillsIDTreeNode(BillsMeasureTree.FindNode(ABillsID));
  885. if not Assigned(stnNode) then Exit;
  886. with stnNode.Rec do
  887. AddDifferValue(AddGatherTotalPrice, ADiffer);
  888. UpdateGather(stnNode.ParentID, ADiffer);
  889. end;
  890. end.