rmBGBillsGatherDm.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. unit rmBGBillsGatherDm;
  2. interface
  3. uses
  4. SysUtils, Classes, DB, DBClient, rmSelectProjectFrm, ProjectData,
  5. BillsTree, sdDB;
  6. type
  7. TBGBills = class
  8. private
  9. FIndexCode: string;
  10. FB_Code: string;
  11. FName: string;
  12. FUnits: string;
  13. FPrice: Double;
  14. FQuantity: Double;
  15. FTotalPrice: Double;
  16. FCurQuantity: Double;
  17. FCurTotalPrice: Double;
  18. FPreQuantity: Double;
  19. FPreTotalPrice: Double;
  20. FEndQuantity: Double;
  21. FEndTotalPrice: Double;
  22. procedure SetB_Code(const Value: string);
  23. function GetPercent: Double;
  24. public
  25. procedure Calcualte;
  26. property B_Code: string read FB_Code write SetB_Code;
  27. property IndexCode: string read FIndexCode;
  28. property Name: string read FName write FName;
  29. property Units: string read FUnits write FUnits;
  30. property Price: Double read FPrice write FPrice;
  31. property Quantity: Double read FQuantity write FQuantity;
  32. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  33. property CurQuantity: Double read FCurQuantity write FCurQuantity;
  34. property CurTotalPrice: Double read FCurTotalPrice;
  35. property PreQuantity: Double read FPreQuantity write FPreQuantity;
  36. property PreTotalPrice: Double read FPreTotalPrice;
  37. property EndQuantity: Double read FEndQuantity;
  38. property EndTotalPrice: Double read FEndTotalPrice;
  39. property Percent: Double read GetPercent;
  40. end;
  41. TBGLData = class
  42. private
  43. FBGLCode: string;
  44. FBGBillsList: TList;
  45. function GetBGBills(AIndex: Integer): TBGBills;
  46. function GetBGBillsCount: Integer;
  47. public
  48. constructor Create(const ACode: string);
  49. destructor Destroy; override;
  50. function AddBGBills: TBGBills;
  51. function FindBGBills(const AB_Code: string): TBGBills;
  52. procedure Calculate;
  53. property BGLCode: string read FBGLCode;
  54. property BGBills[AIndex: Integer]: TBGBills read GetBGBills;
  55. property BGBillsCount: Integer read GetBGBillsCount;
  56. end;
  57. TTenderData = class
  58. private
  59. FSerialNo: Integer;
  60. FID: Integer;
  61. FName: String;
  62. FBGLs: TList;
  63. FTotalPrice: Double;
  64. FCurTotalPrice: Double;
  65. FPreTotalPrice: Double;
  66. FEndTotalPrice: Double;
  67. function GetBGLCount: Integer;
  68. function GetBGLData(AIndex: Integer): TBGLData;
  69. function GetPercent: Double;
  70. public
  71. constructor Create(ASerialNo, AID: Integer; const AName: string);
  72. destructor Destroy; override;
  73. procedure Calculate;
  74. function AddBGL(const ACode: string): TBGLData;
  75. function FindBGL(const ACode: string): TBGLData;
  76. property SerialNo: Integer read FSerialNo;
  77. property ID: Integer read FID;
  78. property Name: string read FName;
  79. property BGL[AIndex: Integer]: TBGLData read GetBGLData;
  80. property BGLCount: Integer read GetBGLCount;
  81. property TotalPrice: Double read FTotalPrice;
  82. property CurTotalPrice: Double read FCurTotalPrice;
  83. property PreTotalPrice: Double read FPreTotalPrice;
  84. property EndTotalPrice: Double read FEndTotalPrice;
  85. property Percent: Double read GetPercent;
  86. end;
  87. TGatherData = class
  88. private
  89. FTenders: TList;
  90. FTotalPrice: Double;
  91. FCurTotalPrice: Double;
  92. FPreTotalPrice: Double;
  93. FEndTotalPrice: Double;
  94. function GetTender(AIndex: Integer): TTenderData;
  95. function GetTenderCount: Integer;
  96. function GetPercent: Double;
  97. public
  98. constructor Create;
  99. destructor Destroy; override;
  100. function AddTender(AIndex, AID: Integer; const AName: string): TTenderData;
  101. procedure Calculate;
  102. property Tender[AIndex: Integer]: TTenderData read GetTender;
  103. property TenderCount: Integer read GetTenderCount;
  104. property TotalPrice: Double read FTotalPrice;
  105. property CurTotalPrice: Double read FCurTotalPrice;
  106. property PreTotalPrice: Double read FPreTotalPrice;
  107. property EndTotalPrice: Double read FEndTotalPrice;
  108. property Percent: Double read GetPercent;
  109. end;
  110. TrmBGBillsGatherData = class(TDataModule)
  111. cdsBGBills: TClientDataSet;
  112. cdsBGBillsTenderID: TIntegerField;
  113. cdsBGBillsPartID: TIntegerField;
  114. cdsBGBillsIndexCode: TWideStringField;
  115. cdsBGBillsB_Code: TWideStringField;
  116. cdsBGBillsName: TWideStringField;
  117. cdsBGBillsUnits: TWideStringField;
  118. cdsBGBillsPrice: TFloatField;
  119. cdsBGBillsQuantity: TFloatField;
  120. cdsBGBillsTotalPrice: TFloatField;
  121. cdsBGBillsCurQuantity: TFloatField;
  122. cdsBGBillsCurTotalPrice: TFloatField;
  123. cdsBGBillsPreQuantity: TFloatField;
  124. cdsBGBillsPreTotalPrice: TFloatField;
  125. cdsBGBillsEndQuantity: TFloatField;
  126. cdsBGBillsEndTotalPrice: TFloatField;
  127. cdsBGBillsPercent: TFloatField;
  128. cdsBGBillsBGLCode: TWideStringField;
  129. private
  130. FGatherData: TGatherData;
  131. FProjectName: string;
  132. FProjectData: TProjectData;
  133. procedure BeforeGather;
  134. procedure AfterGather;
  135. procedure OpenProjectData(AProject: TSelectProject; AProjectIndex: Integer);
  136. procedure FreeProjectData;
  137. procedure GatherBGBills(ABGL: TBGLData; ABGLID: Integer);
  138. procedure GatherBGL(ATenderData: TTenderData);
  139. procedure GatherMeasureData(ATenderData: TTenderData);
  140. procedure GatherProject(AProject: TSelectProject; AProjectIndex: Integer);
  141. procedure CalculateGatherData;
  142. procedure WriteData;
  143. public
  144. function AssignData(AProjects: TList): TDataSet;
  145. end;
  146. implementation
  147. uses
  148. ZhAPI, UtilMethods, DateUtils, Globals, BGLDm, mDataRecord;
  149. {$R *.dfm}
  150. { TGatherData }
  151. function TGatherData.AddTender(AIndex, AID: Integer;
  152. const AName: string): TTenderData;
  153. begin
  154. Result := TTenderData.Create(AIndex, AID, AName);
  155. FTenders.Add(Result);
  156. end;
  157. procedure TGatherData.Calculate;
  158. var
  159. i: Integer;
  160. begin
  161. FTotalPrice := 0;
  162. FCurTotalPrice := 0;
  163. FPreTotalPrice := 0;
  164. FEndTotalPrice := 0;
  165. for i := 0 to TenderCount - 1 do
  166. begin
  167. Tender[i].Calculate;
  168. FTotalPrice := FTotalPrice + Tender[i].TotalPrice;
  169. FCurTotalPrice := FCurTotalPrice + Tender[i].CurTotalPrice;
  170. FPreTotalPrice := FPreTotalPrice + Tender[i].PreTotalPrice;
  171. FEndTotalPrice := FEndTotalPrice + Tender[i].EndTotalPrice;
  172. end;
  173. end;
  174. constructor TGatherData.Create;
  175. begin
  176. FTenders := TList.Create;
  177. end;
  178. destructor TGatherData.Destroy;
  179. begin
  180. ClearObjects(FTenders);
  181. FTenders.Free;
  182. inherited;
  183. end;
  184. function TGatherData.GetPercent: Double;
  185. begin
  186. if FTotalPrice <> 0 then
  187. Result := CommonRoundTo(FEndTotalPrice / FTotalPrice * 100, -2)
  188. else
  189. Result := 0;
  190. end;
  191. function TGatherData.GetTender(AIndex: Integer): TTenderData;
  192. begin
  193. Result := TTenderData(FTenders[AIndex]);
  194. end;
  195. function TGatherData.GetTenderCount: Integer;
  196. begin
  197. Result := FTenders.Count;
  198. end;
  199. { TTenderData }
  200. function TTenderData.AddBGL(const ACode: string): TBGLData;
  201. begin
  202. Result := TBGLData.Create(ACode);
  203. FBGLs.Add(Result);
  204. end;
  205. procedure TTenderData.Calculate;
  206. var
  207. i, j: Integer;
  208. vBGL: TBGLData;
  209. begin
  210. FTotalPrice := 0;
  211. FPreTotalPrice := 0;
  212. FCurTotalPrice := 0;
  213. FEndTotalPrice := 0;
  214. for i := 0 to BGLCount - 1 do
  215. begin
  216. vBGL := BGL[i];
  217. vBGL.Calculate;
  218. for j := 0 to vBGL.BGBillsCount - 1 do
  219. begin
  220. FTotalPrice := FTotalPrice + vBGL.BGBills[j].TotalPrice;
  221. FCurTotalPrice := FCurTotalPrice + vBGL.BGBills[j].CurTotalPrice;
  222. FPreTotalPrice := FPreTotalPrice + vBGL.BGBills[j].PreTotalPrice;
  223. FEndTotalPrice := FEndTotalPrice + vBGL.BGBills[j].EndTotalPrice;
  224. end;
  225. end;
  226. end;
  227. constructor TTenderData.Create(ASerialNo, AID: Integer; const AName: string);
  228. begin
  229. FSerialNo := ASerialNo;
  230. FID := AID;
  231. FName := AName;
  232. FBGLs := TList.Create;
  233. end;
  234. destructor TTenderData.Destroy;
  235. begin
  236. ClearObjects(FBGLs);
  237. FBGLs.Free;
  238. inherited;
  239. end;
  240. function TTenderData.FindBGL(const ACode: string): TBGLData;
  241. var
  242. i: Integer;
  243. begin
  244. Result := nil;
  245. for i := 0 to BGLCount - 1 do
  246. begin
  247. if (ACode = BGL[i].BGLCode) then
  248. begin
  249. Result := BGL[i];
  250. Break;
  251. end;
  252. end;
  253. end;
  254. function TTenderData.GetBGLCount: Integer;
  255. begin
  256. Result := FBGLs.Count;
  257. end;
  258. function TTenderData.GetBGLData(AIndex: Integer): TBGLData;
  259. begin
  260. Result := TBGLData(FBGLs[AIndex]);
  261. end;
  262. function TTenderData.GetPercent: Double;
  263. begin
  264. if FTotalPrice <> 0 then
  265. Result := CommonRoundTo(FEndTotalPrice / FTotalPrice * 100, -2)
  266. else
  267. Result := 0;
  268. end;
  269. { TBGLData }
  270. function TBGLData.AddBGBills: TBGBills;
  271. begin
  272. Result := TBGBills.Create;
  273. FBGBillsList.Add(Result);
  274. end;
  275. procedure TBGLData.Calculate;
  276. var
  277. i: Integer;
  278. begin
  279. for i := 0 to BGBillsCount - 1 do
  280. BGBills[i].Calcualte;
  281. end;
  282. constructor TBGLData.Create(const ACode: string);
  283. begin
  284. FBGLCode := ACode;
  285. FBGBillsList := TList.Create;
  286. end;
  287. destructor TBGLData.Destroy;
  288. begin
  289. ClearObjects(FBGBillsList);
  290. FBGBillsList.Free;
  291. inherited;
  292. end;
  293. function TBGLData.FindBGBills(const AB_Code: string): TBGBills;
  294. var
  295. i: Integer;
  296. begin
  297. Result := nil;
  298. for i := 0 to BGBillsCount - 1 do
  299. begin
  300. if (AB_Code = BGBills[i].B_Code) then
  301. begin
  302. Result := BGBills[i];
  303. Break;
  304. end;
  305. end;
  306. end;
  307. function TBGLData.GetBGBills(AIndex: Integer): TBGBills;
  308. begin
  309. Result := TBGBills(FBGBillsList[AIndex]);
  310. end;
  311. function TBGLData.GetBGBillsCount: Integer;
  312. begin
  313. Result := FBGBillsList.Count;
  314. end;
  315. { TrmBGBillsGatherData }
  316. procedure TrmBGBillsGatherData.AfterGather;
  317. begin
  318. cdsBGBills.EnableControls;
  319. FGatherData.Free;
  320. end;
  321. function TrmBGBillsGatherData.AssignData(AProjects: TList): TDataSet;
  322. var
  323. iProject: Integer;
  324. SelectProject: TSelectProject;
  325. begin
  326. BeforeGather;
  327. try
  328. for iProject := 0 to AProjects.Count - 1 do
  329. GatherProject(TSelectProject(AProjects.Items[iProject]), iProject);
  330. CalculateGatherData;
  331. WriteData;
  332. finally
  333. Result := cdsBGBills;
  334. AfterGather;
  335. end;
  336. end;
  337. procedure TrmBGBillsGatherData.BeforeGather;
  338. begin
  339. FGatherData := TGatherData.Create;
  340. cdsBGBills.DisableControls;
  341. cdsBGBills.Active := True;
  342. cdsBGBills.EmptyDataSet;
  343. end;
  344. procedure TrmBGBillsGatherData.CalculateGatherData;
  345. begin
  346. FGatherData.Calculate;
  347. end;
  348. procedure TrmBGBillsGatherData.FreeProjectData;
  349. begin
  350. if not Assigned(OpenProjectManager.FindProjectData(FProjectData.ProjectID)) then
  351. FProjectData.Free;
  352. end;
  353. procedure TrmBGBillsGatherData.GatherBGBills(ABGL: TBGLData;
  354. ABGLID: Integer);
  355. var
  356. vBGBills: TBGBills;
  357. begin
  358. with FProjectData.BGLData do
  359. begin
  360. cdsBGBills.Filter := 'BGID = ' + IntToStr(ABGLID);
  361. cdsBGBills.Filtered := True;
  362. try
  363. cdsBGBills.First;
  364. while not cdsBGBills.Eof do
  365. begin
  366. vBGBills := ABGL.AddBGBills;
  367. vBGBills.B_Code := cdsBGBillsB_Code.AsString;
  368. vBGBills.Name := cdsBGBillsName.AsString;
  369. vBGBills.Units := cdsBGBillsUnits.AsString;
  370. vBGBills.Price := cdsBGBillsPrice.AsFloat;
  371. vBGBills.Quantity := cdsBGBillsQuantity.AsFloat;
  372. vBGBills.TotalPrice := cdsBGBillsTotalPrice.AsFloat;
  373. cdsBGBills.Next;
  374. end;
  375. finally
  376. cdsBGBills.Filtered := False;
  377. end;
  378. end;
  379. end;
  380. procedure TrmBGBillsGatherData.GatherBGL(ATenderData: TTenderData);
  381. var
  382. vBGL: TBGLData;
  383. begin
  384. with FProjectData.BGLData do
  385. begin
  386. cdsBGL.First;
  387. while not cdsBGL.Eof do
  388. begin
  389. vBGL := ATenderData.AddBGL(cdsBGLCode.AsString);
  390. GatherBGBills(vBGL, cdsBGLID.AsInteger);
  391. cdsBGL.Next;
  392. end;
  393. end;
  394. end;
  395. procedure TrmBGBillsGatherData.GatherMeasureData(ATenderData: TTenderData);
  396. procedure GatherCur(ANode: TMeasureBillsIDTreeNode);
  397. var
  398. sgsCode, sgsNum: TStrings;
  399. i: Integer;
  400. sCode: string;
  401. fNumber: Double;
  402. vBGL: TBGLData;
  403. vBGBills: TBGBills;
  404. begin
  405. sgsCode := TStringList.Create;
  406. sgsNum := TStringList.Create;
  407. try
  408. sgsCode.Delimiter := ';';
  409. sgsNum.Delimiter := ';';
  410. sgsCode.DelimitedText := ANode.StageRec.QcBGLCode.AsString;
  411. sgsNum.DelimitedText := ANode.StageRec.QcBGLNum.AsString;
  412. for i := 0 to sgsCode.Count - 1 do
  413. begin
  414. sCode := sgsCode[i];
  415. fNumber := StrToFloatDef(sgsNum[i], 0);
  416. vBGL := ATenderData.FindBGL(sCode);
  417. if Assigned(vBGL) then
  418. begin
  419. vBGBills := vBGL.FindBGBills(ANode.Rec.B_Code.AsString);
  420. if Assigned(vBGBills) then
  421. vBGBills.CurQuantity := vBGBills.CurQuantity + fNumber;
  422. end;
  423. end;
  424. finally
  425. sgsCode.Free;
  426. sgsNum.Free;
  427. end;
  428. end;
  429. procedure GatherPre(ANode: TMeasureBillsIDTreeNode);
  430. var
  431. sgsCode, sgsNum: TStrings;
  432. i: Integer;
  433. sCode: string;
  434. fNumber: Double;
  435. vBGL: TBGLData;
  436. vBGBills: TBGBills;
  437. begin
  438. sgsCode := TStringList.Create;
  439. sgsNum := TStringList.Create;
  440. try
  441. sgsCode.Delimiter := ';';
  442. sgsNum.Delimiter := ';';
  443. sgsCode.DelimitedText := ANode.StageRec.PreQcBGLCode.AsString;
  444. sgsNum.DelimitedText := ANode.StageRec.PreQcBGLNum.AsString;
  445. for i := 0 to sgsCode.Count - 1 do
  446. begin
  447. sCode := sgsCode[i];
  448. fNumber := StrToFloatDef(sgsNum[i], 0);
  449. vBGL := ATenderData.FindBGL(sCode);
  450. if Assigned(vBGL) then
  451. begin
  452. vBGBills := vBGL.FindBGBills(ANode.Rec.B_Code.AsString);
  453. if Assigned(vBGBills) then
  454. vBGBills.PreQuantity := vBGBills.PreQuantity + fNumber;
  455. end;
  456. end;
  457. finally
  458. sgsCode.Free;
  459. sgsNum.Free;
  460. end;
  461. end;
  462. var
  463. i: Integer;
  464. vNode: TMeasureBillsIDTreeNode;
  465. begin
  466. for i := 0 to FProjectData.BillsMeasureData.BillsMeasureTree.Count - 1 do
  467. begin
  468. vNode := TMeasureBillsIDTreeNode(FProjectData.BillsMeasureData.BillsMeasureTree.Items[i]);
  469. if (vNode.HasChildren) or (not Assigned(vNode.StageRec)) then Continue;
  470. if (vNode.StageRec.QcBGLCode.AsString <> '') then
  471. GatherCur(vNode);
  472. if (vNode.StageRec.PreQcBGLCode.AsString <> '') then
  473. GatherPre(vNode);
  474. end;
  475. end;
  476. procedure TrmBGBillsGatherData.GatherProject(AProject: TSelectProject;
  477. AProjectIndex: Integer);
  478. var
  479. vTenderData: TTenderData;
  480. begin
  481. OpenProjectData(AProject, AProjectIndex);
  482. try
  483. vTenderData := FGatherData.AddTender(AProjectIndex, AProject.ProjectID, FProjectName);
  484. GatherBGL(vTenderData);
  485. GatherMeasureData(vTenderData);
  486. finally
  487. FreeProjectData;
  488. end;
  489. end;
  490. procedure TrmBGBillsGatherData.OpenProjectData(AProject: TSelectProject;
  491. AProjectIndex: Integer);
  492. var
  493. Rec: TsdDataRecord;
  494. begin
  495. FProjectData := OpenProjectManager.FindProjectData(AProject.ProjectID);
  496. Rec := ProjectManager.sddProjectsInfo.FindKey('idxID', AProject.ProjectID);
  497. if not Assigned(FProjectData) then
  498. begin
  499. FProjectData := TProjectData.Create;
  500. FProjectData.OpenForReport3(GetMyProjectsFilePath + Rec.ValueByName('FileName').AsString);
  501. end;
  502. FProjectName := Rec.ValueByName('Name').AsString;
  503. end;
  504. procedure TrmBGBillsGatherData.WriteData;
  505. procedure WriteBGLData(ATenderID: Integer; ABGL: TBGLData);
  506. var
  507. i: Integer;
  508. vBills: TBGBills;
  509. begin
  510. for i := 0 to ABGL.BGBillsCount - 1 do
  511. begin
  512. vBills := ABGL.BGBills[i];
  513. cdsBGBills.Append;
  514. cdsBGBillsTenderID.AsInteger := ATenderID;
  515. cdsBGBillsPartID.AsInteger := 2;
  516. cdsBGBillsIndexCode.AsString := vBills.IndexCode;
  517. cdsBGBillsB_Code.AsString := vBills.B_Code;
  518. cdsBGBillsName.AsString := vBills.Name;
  519. cdsBGBillsUnits.AsString := vBills.Units;
  520. cdsBGBillsPrice.AsFloat := vBills.Price;
  521. cdsBGBillsQuantity.AsFloat := vBills.Quantity;
  522. cdsBGBillsTotalPrice.AsFloat := vBills.TotalPrice;
  523. cdsBGBillsCurQuantity.AsFloat := vBills.CurQuantity;
  524. cdsBGBillsCurTotalPrice.AsFloat := vBills.CurTotalPrice;
  525. cdsBGBillsPreQuantity.AsFloat := vBills.PreQuantity;
  526. cdsBGBillsPreTotalPrice.AsFloat := vBills.PreTotalPrice;
  527. cdsBGBillsEndQuantity.AsFloat := vBills.EndQuantity;
  528. cdsBGBillsEndTotalPrice.AsFloat := vBills.EndTotalPrice;
  529. cdsBGBillsPercent.AsFloat := vBills.Percent;
  530. cdsBGBillsBGLCode.AsString := ABGL.BGLCode;
  531. cdsBGBills.Post;
  532. end;
  533. end;
  534. procedure WriteTenderData(ATender: TTenderData);
  535. var
  536. iBGL: Integer;
  537. begin
  538. cdsBGBills.Append;
  539. cdsBGBillsTenderID.AsInteger := ATender.SerialNo;
  540. cdsBGBillsPartID.AsInteger := 1;
  541. cdsBGBillsName.AsString := ATender.Name;
  542. cdsBGBills.Post;
  543. for iBGL := 0 to ATender.BGLCount - 1 do
  544. WriteBGLData(ATender.SerialNo, ATender.BGL[iBGL]);
  545. cdsBGBills.Append;
  546. cdsBGBillsTenderID.AsInteger := ATender.SerialNo;
  547. cdsBGBillsPartID.AsInteger := 3;
  548. cdsBGBillsName.AsString := 'С¼Æ';
  549. cdsBGBillsTotalPrice.AsFloat := ATender.TotalPrice;
  550. cdsBGBillsCurTotalPrice.AsFloat := ATender.CurTotalPrice;
  551. cdsBGBillsPreTotalPrice.AsFloat := ATender.PreTotalPrice;
  552. cdsBGBillsEndTotalPrice.AsFloat := ATender.EndTotalPrice;
  553. cdsBGBillsPercent.AsFloat := ATender.Percent;
  554. cdsBGBills.Post;
  555. end;
  556. procedure WriteGatherData;
  557. begin
  558. cdsBGBills.Append;
  559. cdsBGBillsTenderID.AsInteger := FGatherData.TenderCount + 1;
  560. cdsBGBillsName.AsString := 'ºÏ¼Æ';
  561. cdsBGBillsTotalPrice.AsFloat := FGatherData.TotalPrice;
  562. cdsBGBillsCurTotalPrice.AsFloat := FGatherData.CurTotalPrice;
  563. cdsBGBillsPreTotalPrice.AsFloat := FGatherData.PreTotalPrice;
  564. cdsBGBillsEndTotalPrice.AsFloat := FGatherData.EndTotalPrice;
  565. cdsBGBillsPercent.AsFloat := FGatherData.Percent;
  566. cdsBGBills.Post;
  567. end;
  568. var
  569. i: Integer;
  570. begin
  571. for i := 0 to FGatherData.TenderCount - 1 do
  572. WriteTenderData(FGatherData.Tender[i]);
  573. WriteGatherData;
  574. end;
  575. { TBGBills }
  576. procedure TBGBills.Calcualte;
  577. begin
  578. FCurTotalPrice := FCurQuantity * FPrice;
  579. FPreTotalPrice := FPreQuantity * FPrice;
  580. FEndQuantity := FCurQuantity + FPreQuantity;
  581. FEndTotalPrice := FEndQuantity * FPrice;
  582. end;
  583. function TBGBills.GetPercent: Double;
  584. begin
  585. if FTotalPrice <> 0 then
  586. Result := CommonRoundTo(FEndTotalPrice / FTotalPrice * 100, -2)
  587. else
  588. Result := 0;
  589. end;
  590. procedure TBGBills.SetB_Code(const Value: string);
  591. begin
  592. FB_Code := Value;
  593. FIndexCode := B_CodeToIndexCode(FB_Code);
  594. end;
  595. end.