BillsGatherDm.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. unit BillsGatherDm;
  2. interface
  3. uses
  4. SysUtils, Classes, DB, DBClient, sdIDTree, sdDB, sdProvider,
  5. GclBillsGatherModel;
  6. type
  7. TBillsGatherData = class(TDataModule)
  8. smpGclBills: TsdMemoryProvider;
  9. sddGclBills: TsdDataSet;
  10. sdvGclBills: TsdDataView;
  11. smpDetailGclBills: TsdMemoryProvider;
  12. sddDetailGclBills: TsdDataSet;
  13. sdvDetailGclBills: TsdDataView;
  14. smpDetailDealBills: TsdMemoryProvider;
  15. sddDetailDealBills: TsdDataSet;
  16. sdvDetailDealBills: TsdDataView;
  17. smpDetailBGLBills: TsdMemoryProvider;
  18. sddDetailBGLBills: TsdDataSet;
  19. sdvDetailBGLBills: TsdDataView;
  20. procedure sdvGclBillsCurrentChanged(ARecord: TsdDataRecord);
  21. procedure sdvDetailGclBillsFilterRecord(ARecord: TsdDataRecord;
  22. var Allow: Boolean);
  23. procedure sdvGclBillsGetText(var Text: String; ARecord: TsdDataRecord;
  24. AValue: TsdValue; AColumn: TsdViewColumn; DisplayText: Boolean);
  25. private
  26. FProjectData: TObject;
  27. procedure WriteGatherRecord(AGcls, AXmjs: TList; AGather: TGatherNode);
  28. function GetMainBillsTree: TsdIDTree;
  29. public
  30. constructor Create(AProjectData: TObject);
  31. destructor Destroy; override;
  32. procedure RefreshBills;
  33. function GetAllBillsJson: string;
  34. property ProjectData: TObject read FProjectData;
  35. property MainBillsTree: TsdIDTree read GetMainBillsTree;
  36. end;
  37. implementation
  38. uses
  39. ProjectData, PhaseData, StageDm, BillsDm, UtilMethods, superobject,
  40. ZhAPI, BillsCompileDm, DealBillsDm, BGLDm, BillsTree, BillsMeasureDm;
  41. {$R *.dfm}
  42. { TBillsGatherData }
  43. constructor TBillsGatherData.Create(AProjectData: TObject);
  44. begin
  45. inherited Create(nil);
  46. FProjectData := AProjectData;
  47. sddGclBills.Open;
  48. if not Assigned(sddGclBills.FindIndex('idxIndexCode')) then
  49. sddGclBills.AddIndex('idxIndexCode', 'IndexCode');
  50. sdvGclBills.Open;
  51. sdvGclBills.IndexName := 'idxIndexCode';
  52. sddDetailGclBills.Open;
  53. if not Assigned(sddDetailGclBills.FindIndex('idxSerialNo')) then
  54. sddDetailGclBills.AddIndex('idxSerialNo', 'BillsID;TreeSerialNo');
  55. if not Assigned(sddDetailGclBills.FindIndex('idxRelaBills')) then
  56. sddDetailGclBills.AddIndex('idxRelaBills', 'RelaBillsID');
  57. sdvDetailGclBills.Open;
  58. sdvDetailGclBills.IndexName := 'idxSerialNo';
  59. sddDetailDealBills.Open;
  60. if not Assigned(sddDetailDealBills.FindIndex('idxDeal')) then
  61. sddDetailDealBills.AddIndex('idxDeal', 'DealID');
  62. sdvDetailDealBills.Open;
  63. sdvDetailDealBills.IndexName := 'idxDeal';
  64. sddDetailBGLBills.Open;
  65. if not Assigned(sddDetailBGLBills.FindIndex('idxBGL')) then
  66. sddDetailBGLBills.AddIndex('idxBGL', 'BGLID');
  67. sdvDetailBGLBills.Open;
  68. sdvDetailBGLBills.IndexName := 'idxBGL';
  69. end;
  70. destructor TBillsGatherData.Destroy;
  71. begin
  72. inherited;
  73. end;
  74. function TBillsGatherData.GetMainBillsTree: TsdIDTree;
  75. begin
  76. Result := TProjectData(FProjectData).BillsMeasureData.BillsMeasureTree;
  77. end;
  78. procedure TBillsGatherData.RefreshBills;
  79. var
  80. vGather: TGclGatherModel;
  81. begin
  82. vGather := TGclGatherModel.Create(FProjectData);
  83. try
  84. vGather.GatherDeal := True;
  85. vGather.GatherBGL := True;
  86. vGather.WriteGatherData := WriteGatherRecord;
  87. vGather.Execute;
  88. finally
  89. vGather.Free;
  90. end;
  91. end;
  92. procedure TBillsGatherData.WriteGatherRecord(AGcls, AXmjs: TList; AGather: TGatherNode);
  93. var
  94. sCurB_Code, sCurName, sCurUnits, sCurPrice: string;
  95. bHasCurrrent: Boolean;
  96. procedure DisableAndClearDataSet(ADataSet: TsdDataSet);
  97. begin
  98. ADataSet.DisableControls;
  99. ADataSet.BeginUpdate;
  100. ADataSet.DeleteAll;
  101. end;
  102. procedure EnableDataSet(ADataSet: TsdDataSet);
  103. begin
  104. ADataSet.EndUpdate;
  105. ADataSet.EnableControls;
  106. end;
  107. procedure BeforeWrite;
  108. begin
  109. bHasCurrrent := Assigned(sdvGclBills.Current);
  110. if Assigned(sdvGclBills.Current) then
  111. begin
  112. sCurB_Code := sdvGclBills.Current.ValueByName('B_Code').AsString;
  113. sCurName := sdvGclBills.Current.ValueByName('Name').AsString;
  114. sCurUnits := sdvGclBills.Current.ValueByName('Units').AsString;
  115. sCurPrice := sdvGclBills.Current.ValueByName('Price').AsString;
  116. end;
  117. sdvDetailGclBills.Filtered := False;
  118. sdvDetailDealBills.Filtered := False;
  119. sdvDetailBGLBills.Filtered := False;
  120. DisableAndClearDataSet(sddGclBills);
  121. DisableAndClearDataSet(sddDetailGclBills);
  122. DisableAndClearDataSet(sddDetailDealBills);
  123. DisableAndClearDataSet(sddDetailBGLBills);
  124. end;
  125. function FindCurrentRecord: TsdDataRecord;
  126. var
  127. i: Integer;
  128. Rec: TsdDataRecord;
  129. begin
  130. Result := nil;
  131. for i := 0 to sddGclBills.RecordCount - 1 do
  132. begin
  133. Rec := sddGclBills.Records[i];
  134. if SameText(sCurB_Code, Rec.ValueByName('B_Code').AsString) and
  135. SameText(sCurName, Rec.ValueByName('Name').AsString) and
  136. SameText(sCurUnits, Rec.ValueByName('Units').AsString) and
  137. SameText(sCurPrice, Rec.ValueByName('Price').AsString) then
  138. begin
  139. Result := Rec;
  140. Break;
  141. end;
  142. end;
  143. end;
  144. procedure AfterWrite;
  145. var
  146. Rec: TsdDataRecord;
  147. begin
  148. EnableDataSet(sddDetailBGLBills);
  149. EnableDataSet(sddDetailDealBills);
  150. EnableDataSet(sddDetailGclBills);
  151. EnableDataSet(sddGclBills);
  152. if bHasCurrrent then
  153. Rec := FindCurrentRecord;
  154. if not Assigned(Rec) and (sdvGclBills.RecordCount > 0) then
  155. Rec := sdvGclBills.Records[0];
  156. sdvGclBills.LocateInControl(Rec);
  157. sdvDetailGclBills.Filtered := True;
  158. sdvDetailDealBills.Filtered := True;
  159. sdvDetailBGLBills.Filtered := True;
  160. end;
  161. procedure WriteDetailDealNode(AGclNode: TGclNode);
  162. var
  163. iDeal: Integer;
  164. vDeal: TDetailDealNode;
  165. Rec: TsdDataRecord;
  166. begin
  167. for iDeal := 0 to AGclNode.DetailDealCount - 1 do
  168. begin
  169. vDeal := AGclNode.DetailDeal[iDeal];
  170. Rec := sddDetailDealBills.Add;
  171. Rec.ValueByName('ID').AsInteger := vDeal.ID;
  172. Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
  173. Rec.ValueByName('DealID').AsInteger := vDeal.DealID;
  174. Rec.ValueByName('B_Code').AsString := AGclNode.B_Code;
  175. Rec.ValueByName('Name').AsString := AGclNode.Name;
  176. Rec.ValueByName('Units').AsString := AGclNode.Units;
  177. Rec.ValueByName('Price').AsFloat := AGclNode.Price;
  178. Rec.ValueByName('Quantity').AsFloat := vDeal.Quantity;
  179. Rec.ValueByName('TotalPrice').AsFloat := vDeal.TotalPrice;
  180. end;
  181. end;
  182. procedure WriteDetailBGLNode(AGclNode: TGclNode);
  183. var
  184. iBGL: Integer;
  185. vBGL: TDetailBGLNode;
  186. Rec: TsdDataRecord;
  187. begin
  188. for iBGL := 0 to AGclNode.DetailBGLCount - 1 do
  189. begin
  190. vBGL := AGclNode.DetailBGL[iBGL];
  191. Rec := sddDetailBGLBills.Add;
  192. Rec.ValueByName('ID').AsInteger := vBGL.ID;
  193. Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
  194. Rec.ValueByName('BGBillsID').AsInteger := vBGL.BGBillsID;
  195. Rec.ValueByName('BGLID').AsInteger := vBGL.BGLID;
  196. Rec.ValueByName('BGLCode').AsString := vBGL.BGLCode;
  197. Rec.ValueByName('BGLName').AsString := vBGL.BGLName;
  198. Rec.ValueByName('BGLApprovalCode').AsString := vBGL.BGLApprovalCode;
  199. Rec.ValueByName('BGLDrawingCode').AsString := vBGL.BGLDrawingCode;
  200. Rec.ValueByName('Quantity').AsFloat := vBGL.Quantity;
  201. Rec.ValueByName('TotalPrice').AsFloat := vBGL.TotalPrice;
  202. end;
  203. end;
  204. procedure WriteDetailGclNode(AGclNode: TGclNode);
  205. var
  206. iDetailGcl: Integer;
  207. vDetailGcl: TDetailGclNode;
  208. Rec: TsdDataRecord;
  209. begin
  210. for iDetailGcl := 0 to AGclNode.DetailGclCount -1 do
  211. begin
  212. vDetailGcl := AGclNode.DetailGcl[iDetailGcl];
  213. Rec := sddDetailGclBills.Add;
  214. Rec.ValueByName('ID').AsInteger := vDetailGcl.ID;
  215. Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
  216. Rec.ValueByName('TreeSerialNo').AsInteger := vDetailGcl.TreeSerialNo;
  217. Rec.ValueByName('RelaBillsID').AsInteger := vDetailGcl.BillsID;
  218. if Assigned(vDetailGcl.LeafXmj) then
  219. begin
  220. Rec.ValueByName('LeafXmjID').AsInteger := vDetailGcl.LeafXmj.ID;
  221. Rec.ValueByName('XmjCode').AsString := vDetailGcl.LeafXmj.XmjCode;
  222. Rec.ValueByName('XmjName').AsString := vDetailGcl.LeafXmj.XmjName;
  223. Rec.ValueByName('XmjUnits').AsString := vDetailGcl.LeafXmj.XmjUnits;
  224. Rec.ValueByName('NameDanWei').AsString := vDetailGcl.LeafXmj.NameDanWei;
  225. Rec.ValueByName('NameFenXiang').AsString := vDetailGcl.LeafXmj.NameFenXiang;
  226. Rec.ValueByName('NameFenBu').AsString := vDetailGcl.LeafXmj.NameFenBu;
  227. Rec.ValueByName('NameUnit').AsString := vDetailGcl.LeafXmj.NameUnit;
  228. Rec.ValueByName('Peg').AsString := vDetailGcl.LeafXmj.Peg;
  229. Rec.ValueByName('Position').AsString := vDetailGcl.LeafXmj.Position;
  230. Rec.ValueByName('DrawingCode').AsString := vDetailGcl.LeafXmj.DrawingCode;
  231. end;
  232. Rec.ValueByName('Quantity').AsFloat := vDetailGcl.Quantity;
  233. Rec.ValueByName('TotalPrice').AsFloat := vDetailGcl.TotalPrice;
  234. Rec.ValueByName('CurDealQuantity').AsFloat := vDetailGcl.CurDealQuantity;
  235. Rec.ValueByName('CurDealTotalPrice').AsFloat := vDetailGcl.CurDealTotalPrice;
  236. Rec.ValueByName('CurQcQuantity').AsFloat := vDetailGcl.CurQcQuantity;
  237. Rec.ValueByName('CurQcTotalPrice').AsFloat := vDetailGcl.CurQcTotalPrice;
  238. Rec.ValueByName('CurGatherQuantity').AsFloat := vDetailGcl.CurGatherQuantity;
  239. Rec.ValueByName('CurGatherTotalPrice').AsFloat := vDetailGcl.CurGatherTotalPrice;
  240. Rec.ValueByName('PreDealQuantity').AsFloat := vDetailGcl.PreDealQuantity;
  241. Rec.ValueByName('PreDealTotalPrice').AsFloat := vDetailGcl.PreDealTotalPrice;
  242. Rec.ValueByName('PreQcQuantity').AsFloat := vDetailGcl.PreQcQuantity;
  243. Rec.ValueByName('PreQcTotalPrice').AsFloat := vDetailGcl.PreQcTotalPrice;
  244. Rec.ValueByName('PreGatherQuantity').AsFloat := vDetailGcl.PreGatherQuantity;
  245. Rec.ValueByName('PreGatherTotalPrice').AsFloat := vDetailGcl.PreGatherTotalPrice;
  246. Rec.ValueByName('EndDealQuantity').AsFloat := vDetailGcl.EndDealQuantity;
  247. Rec.ValueByName('EndDealTotalPrice').AsFloat := vDetailGcl.EndDealTotalPrice;
  248. Rec.ValueByName('EndQcQuantity').AsFloat := vDetailGcl.EndQcQuantity;
  249. Rec.ValueByName('EndQcTotalPrice').AsFloat := vDetailGcl.EndQcTotalPrice;
  250. Rec.ValueByName('EndGatherQuantity').AsFloat := vDetailGcl.EndGatherQuantity;
  251. Rec.ValueByName('EndGatherTotalPrice').AsFloat := vDetailGcl.EndGatherTotalPrice;
  252. Rec.ValueByName('Percent').AsFloat := vDetailGcl.Percent;
  253. Rec.ValueByName('AddDealQuantity').AsFloat := vDetailGcl.AddDealQuantity;
  254. Rec.ValueByName('AddDealTotalPrice').AsFloat := vDetailGcl.AddDealTotalPrice;
  255. Rec.ValueByName('AddQcQuantity').AsFloat := vDetailGcl.AddQcQuantity;
  256. Rec.ValueByName('AddQcTotalPrice').AsFloat := vDetailGcl.AddQcTotalPrice;
  257. Rec.ValueByName('AddGatherQuantity').AsFloat := vDetailGcl.AddGatherQuantity;
  258. Rec.ValueByName('AddGatherTotalPrice').AsFloat := vDetailGcl.AddGatherTotalPrice;
  259. end;
  260. end;
  261. procedure WriteGclNode(AGclNode: TGclNode);
  262. var
  263. Rec: TsdDataRecord;
  264. begin
  265. Rec := sddGclBills.Add;
  266. Rec.ValueByName('ID').AsInteger := AGclNode.ID;
  267. Rec.ValueByName('IndexCode').AsString := AGclNode.IndexCode;
  268. Rec.ValueByName('B_Code').AsString := AGclNode.B_Code;
  269. Rec.ValueByName('Name').AsString := AGclNode.Name;
  270. Rec.ValueByName('Units').AsString := AGclNode.Units;
  271. Rec.ValueByName('Price').AsFloat := AGclNode.Price;
  272. Rec.ValueByName('DealQuantity').AsFloat := AGclNode.DealQuantity;
  273. Rec.ValueByName('DealTotalPrice').AsFloat := AGclNode.DealTotalPrice;
  274. Rec.ValueByName('BGLQuantity').AsFloat := AGclNode.BGLQuantity;
  275. Rec.ValueByName('BGLTotalPrice').AsFloat := AGclNode.BGLTotalPrice;
  276. Rec.ValueByName('Quantity').AsFloat := AGclNode.Quantity;
  277. Rec.ValueByName('TotalPrice').AsFloat := AGclNode.TotalPrice;
  278. Rec.ValueByName('CurDealQuantity').AsFloat := AGclNode.CurDealQuantity;
  279. Rec.ValueByName('CurDealTotalPrice').AsFloat := AGclNode.CurDealTotalPrice;
  280. Rec.ValueByName('CurQcQuantity').AsFloat := AGclNode.CurQcQuantity;
  281. Rec.ValueByName('CurQcTotalPrice').AsFloat := AGclNode.CurQcTotalPrice;
  282. Rec.ValueByName('CurGatherQuantity').AsFloat := AGclNode.CurGatherQuantity;
  283. Rec.ValueByName('CurGatherTotalPrice').AsFloat := AGclNode.CurGatherTotalPrice;
  284. Rec.ValueByName('PreDealQuantity').AsFloat := AGclNode.PreDealQuantity;
  285. Rec.ValueByName('PreDealTotalPrice').AsFloat := AGclNode.PreDealTotalPrice;
  286. Rec.ValueByName('PreQcQuantity').AsFloat := AGclNode.PreQcQuantity;
  287. Rec.ValueByName('PreQcTotalPrice').AsFloat := AGclNode.PreQcTotalPrice;
  288. Rec.ValueByName('PreGatherQuantity').AsFloat := AGclNode.PreGatherQuantity;
  289. Rec.ValueByName('PreGatherTotalPrice').AsFloat := AGclNode.PreGatherTotalPrice;
  290. Rec.ValueByName('EndDealQuantity').AsFloat := AGclNode.EndDealQuantity;
  291. Rec.ValueByName('EndDealTotalPrice').AsFloat := AGclNode.EndDealTotalPrice;
  292. Rec.ValueByName('EndQcQuantity').AsFloat := AGclNode.EndQcQuantity;
  293. Rec.ValueByName('EndQcTotalPrice').AsFloat := AGclNode.EndQcTotalPrice;
  294. Rec.ValueByName('EndGatherQuantity').AsFloat := AGclNode.EndGatherQuantity;
  295. Rec.ValueByName('EndGatherTotalPrice').AsFloat := AGclNode.EndGatherTotalPrice;
  296. Rec.ValueByName('AddDealQuantity').AsFloat := AGclNode.AddDealQuantity;
  297. Rec.ValueByName('AddDealTotalPrice').AsFloat := AGclNode.AddDealTotalPrice;
  298. Rec.ValueByName('AddQcQuantity').AsFloat := AGclNode.AddQcQuantity;
  299. Rec.ValueByName('AddQcTotalPrice').AsFloat := AGclNode.AddQcTotalPrice;
  300. Rec.ValueByName('AddGatherQuantity').AsFloat := AGclNode.AddGatherQuantity;
  301. Rec.ValueByName('AddGatherTotalPrice').AsFloat := AGclNode.AddGatherTotalPrice;
  302. Rec.ValueByName('Deal_BGLQuantity').AsFloat := AGclNode.Deal_BGLQuantity;
  303. Rec.ValueByName('Deal_BGLTotalPrice').AsFloat := AGclNode.Deal_BGLTotalPrice;
  304. Rec.ValueByName('Deal_BGLPercent').AsFloat := AGclNode.Deal_BGLPercent;
  305. WriteDetailGclNode(AGclNode);
  306. WriteDetailDealNode(AGclNode);
  307. WriteDetailBGLNode(AGclNode);
  308. end;
  309. procedure WriteGatherNode(AGather: TGatherNode);
  310. var
  311. Rec: TsdDataRecord;
  312. begin
  313. Rec := sddGclBills.Add;
  314. Rec.ValueByName('ID').AsInteger := AGather.ID;
  315. Rec.ValueByName('IndexCode').AsString := ' ';
  316. Rec.ValueByName('Name').AsString := 'ºÏ¼Æ';
  317. Rec.ValueByName('DealTotalPrice').AsFloat := AGather.DealTotalPrice;
  318. Rec.ValueByName('BGLTotalPrice').AsFloat := AGather.BGLTotalPrice;
  319. Rec.ValueByName('TotalPrice').AsFloat := AGather.TotalPrice;
  320. Rec.ValueByName('CurDealTotalPrice').AsFloat := AGather.CurDealTotalPrice;
  321. Rec.ValueByName('CurQcTotalPrice').AsFloat := AGather.CurQcTotalPrice;
  322. Rec.ValueByName('CurGatherTotalPrice').AsFloat := AGather.CurGatherTotalPrice;
  323. Rec.ValueByName('PreDealTotalPrice').AsFloat := AGather.PreDealTotalPrice;
  324. Rec.ValueByName('PreQcTotalPrice').AsFloat := AGather.PreQcTotalPrice;
  325. Rec.ValueByName('PreGatherTotalPrice').AsFloat := AGather.PreGatherTotalPrice;
  326. Rec.ValueByName('EndDealTotalPrice').AsFloat := AGather.EndDealTotalPrice;
  327. Rec.ValueByName('EndQcTotalPrice').AsFloat := AGather.EndQcTotalPrice;
  328. Rec.ValueByName('EndGatherTotalPrice').AsFloat := AGather.EndGatherTotalPrice;
  329. Rec.ValueByName('AddDealTotalPrice').AsFloat := AGather.AddDealTotalPrice;
  330. Rec.ValueByName('AddQcTotalPrice').AsFloat := AGather.AddQcTotalPrice;
  331. Rec.ValueByName('AddGatherTotalPrice').AsFloat := AGather.AddGatherTotalPrice;
  332. Rec.ValueByName('Deal_BGLTotalPrice').AsFloat := AGather.Deal_BGLTotalPrice;
  333. Rec.ValueByName('Deal_BGLPercent').AsFloat := AGather.Deal_BGLPercent;
  334. end;
  335. var
  336. iGcl: Integer;
  337. vGclNode: TGclNode;
  338. begin
  339. BeforeWrite;
  340. try
  341. for iGcl := 0 to AGcls.Count - 1 do
  342. begin
  343. vGclNode := TGclNode(AGcls.Items[iGcl]);
  344. WriteGclNode(vGclNode);
  345. end;
  346. WriteGatherNode(AGather);
  347. finally
  348. AfterWrite;
  349. end;
  350. end;
  351. procedure TBillsGatherData.sdvGclBillsCurrentChanged(
  352. ARecord: TsdDataRecord);
  353. begin
  354. sdvDetailGclBills.RefreshFilter;
  355. sdvDetailDealBills.RefreshFilter;
  356. sdvDetailBGLBills.RefreshFilter;
  357. end;
  358. procedure TBillsGatherData.sdvDetailGclBillsFilterRecord(
  359. ARecord: TsdDataRecord; var Allow: Boolean);
  360. begin
  361. if Assigned(ARecord) and Assigned(sdvGclBills.Current) then
  362. Allow := ARecord.ValueByName('BillsID').AsInteger = sdvGclBills.Current.ValueByName('ID').AsInteger
  363. else
  364. Allow := False;
  365. end;
  366. procedure TBillsGatherData.sdvGclBillsGetText(var Text: String;
  367. ARecord: TsdDataRecord; AValue: TsdValue; AColumn: TsdViewColumn;
  368. DisplayText: Boolean);
  369. begin
  370. if Assigned(AValue) and (AValue.Field.DataType = ftFloat) and (AValue.AsFloat = 0) then
  371. Text := '';
  372. end;
  373. function TBillsGatherData.GetAllBillsJson: string;
  374. function GetBillsJson(Rec: TsdDataRecord): ISuperObject;
  375. begin
  376. Result := SO;
  377. Result.S['lnum'] := Rec.ValueByName('B_Code').AsString;
  378. Result.S['lname'] := Rec.ValueByName('Name').AsString;
  379. Result.S['unit'] := Rec.ValueByName('Units').AsString;
  380. Result.D['unitprice'] := Rec.ValueByName('Price').AsFloat;
  381. //Result.D['amount'] := Rec.ValueByName('DealQuantity').AsFloat;
  382. Result.D['amount'] := Rec.ValueByName('Quantity').AsFloat;
  383. end;
  384. var
  385. vJa, vJbills: ISuperObject;
  386. i: Integer;
  387. Rec: TsdDataRecord;
  388. begin
  389. vJa := SA([]);
  390. try
  391. for i := 0 to sddGclBills.RecordCount - 1 do
  392. begin
  393. Rec := sddGclBills.Records[i];
  394. vJa.AsArray.Add(GetBillsJson(Rec));
  395. end;
  396. finally
  397. Result := vJa.AsJSon;
  398. end;
  399. end;
  400. end.