ExcelImport.pas 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. unit ExcelImport;
  2. interface
  3. uses
  4. Classes, SMXLS, SMCells, ProjectData, MCacheTree, ZhAPI, sdDB,
  5. Forms, Controls, ProgressHintFrm, mDataRecord;
  6. type
  7. TExcelImport = class
  8. private
  9. FMSExcel: TMSExcel;
  10. FProjectData: TProjectData;
  11. FProgresssHintFrom: TProgressHintForm;
  12. procedure BeginImport; virtual; abstract;
  13. procedure EndImport; virtual; abstract;
  14. procedure Import; virtual; abstract;
  15. function GetCellValue(ASheet: TSpreadSheet; ACol, ARow: Integer): Variant;
  16. function GetCellTrimText(ASheet: TSpreadSheet; ACol, ARow: Integer): string;
  17. public
  18. constructor Create(AProjectData: TProjectData);
  19. destructor Destroy; override;
  20. procedure ImportFile(const AExcelFile: string);
  21. property MSExcel: TMSExcel read FMSExcel;
  22. end;
  23. TBillsExcelImport = class(TExcelImport)
  24. private
  25. FCacheTree: TBillsCacheTree;
  26. FCurRow: Integer;
  27. FLevelCol: Integer;
  28. FCodeCol: Integer;
  29. FB_CodeCol: Integer;
  30. FNameCol: Integer;
  31. FUnitsCol: Integer;
  32. FFixedIDCol: Integer;
  33. FCanDeleteCol: Integer;
  34. procedure BeginImport; override;
  35. procedure EndImport; override;
  36. procedure LoadColumnsFromHead(ASheet: TSpreadSheet);
  37. procedure LoadNodes(ASheet: TSpreadSheet);
  38. procedure LoadNode(ASheet: TSpreadSheet);
  39. procedure WriteNode(ADataSet: TsdDataSet; ANode: TBillsCacheNode);
  40. procedure WriteNodes(ADataSet: TsdDataSet);
  41. procedure Import; override;
  42. public
  43. procedure ImportToTree(ACacheTree: TBillsCacheTree; const sFileName: string);
  44. end;
  45. // 代码中注释部分为导入[无层次编号]的0号台账Excel
  46. TBillsEdtExcelImport = class(TExcelImport)
  47. private
  48. FCacheTree: TBillsCacheTree;
  49. FCurRow: Integer;
  50. FIsFirstPart: Boolean;
  51. FWithLevelCode: Boolean;
  52. FWithoutGclBills: Boolean;
  53. FBaseTree: TBillsCacheTree;
  54. FFixedIDNodes: TList;
  55. FCodeCol: Integer;
  56. FB_CodeCol: Integer;
  57. FNameCol: Integer;
  58. FUnitsCol: Integer;
  59. FPriceCol: Integer;
  60. FQuantityCol: Integer;
  61. FDgnQuantity1Col: Integer;
  62. FDgnQuantity2Col: Integer;
  63. FDrawingCol: Integer;
  64. FMemoCol: Integer;
  65. FLevelCol: Integer;
  66. procedure CheckFixedIDNodes;
  67. procedure BeginImport; override;
  68. procedure EndImport; override;
  69. function GetFixedIDNode(AID: Integer): TBillsCacheNode;
  70. function GetFixedID(ACode, AName: string): Integer;
  71. procedure LoadBaseTree(ATree: TBillsCacheTree);
  72. procedure LoadColumnsFromHead(ASheet: TSpreadSheet);
  73. procedure LoadNodes(ASheet: TSpreadSheet);
  74. procedure LoadNode(ASheet: TSpreadSheet);
  75. procedure WriteNode(ADataSet: TsdDataSet; ANode: TBillsCacheNode);
  76. procedure WriteNodes(ADataSet: TsdDataSet);
  77. procedure Import; override;
  78. public
  79. property WithLevelCode: Boolean read FWithLevelCode write FWithLevelCode;
  80. property WithoutGclBills: Boolean read FWithoutGclBills write FWithoutGclBills;
  81. end;
  82. implementation
  83. uses Variants, CacheTree, SysUtils, UtilMethods, sdDataSet, BillsDm,
  84. DealBillsDm, SheetSelectFrm, ADODB, Math, ConstUnit;
  85. { TExcelImport }
  86. constructor TExcelImport.Create(AProjectData: TProjectData);
  87. begin
  88. FProjectData := AProjectData;
  89. FMSExcel := TMSExcel.Create(nil);
  90. end;
  91. destructor TExcelImport.Destroy;
  92. begin
  93. FMSExcel.Free;
  94. inherited;
  95. end;
  96. function TExcelImport.GetCellTrimText(ASheet: TSpreadSheet; ACol,
  97. ARow: Integer): string;
  98. begin
  99. Result := Trim(VarToStrDef(GetCellValue(ASheet, ACol, ARow), ''));
  100. end;
  101. function TExcelImport.GetCellValue(ASheet: TSpreadSheet;
  102. ACol, ARow: Integer): Variant;
  103. begin
  104. Result := Null;
  105. if ACol <> -1 then
  106. Result := ASheet.Cells.GetValue(ACol, ARow);
  107. end;
  108. procedure TExcelImport.ImportFile(const AExcelFile: string);
  109. begin
  110. BeginImport;
  111. try
  112. FMSExcel.LoadFromFile(AExcelFile);
  113. Import;
  114. finally
  115. EndImport;
  116. end;
  117. end;
  118. { TBillsExcelImport }
  119. procedure TBillsExcelImport.BeginImport;
  120. begin
  121. FCurRow := 0;
  122. FCacheTree := TBillsCacheTree.Create;
  123. FCacheTree.AutoSort := True;
  124. end;
  125. procedure TBillsExcelImport.EndImport;
  126. begin
  127. FCacheTree.Free;
  128. end;
  129. procedure TBillsExcelImport.Import;
  130. begin
  131. LoadColumnsFromHead(FMSExcel.Sheets.Spreadsheet(0));
  132. LoadNodes(FMSExcel.Sheets.Spreadsheet(0));
  133. WriteNodes(FProjectData.BillsData.sddBills);
  134. end;
  135. procedure TBillsExcelImport.ImportToTree(ACacheTree: TBillsCacheTree;
  136. const sFileName: string);
  137. var
  138. sChar: Char;
  139. begin
  140. FCurRow := 0;
  141. FCacheTree := ACacheTree;
  142. sChar := FCacheTree.SeparateChar;
  143. FCacheTree.SeparateChar := '.';
  144. FCacheTree.NewNodeID := Max(FCacheTree.NewNodeID, 101);
  145. MSExcel.LoadFromFile(sFileName);
  146. LoadColumnsFromHead(FMSExcel.Sheets.Spreadsheet(0));
  147. LoadNodes(FMSExcel.Sheets.Spreadsheet(0));
  148. FCacheTree.SeparateChar := sChar;
  149. end;
  150. procedure TBillsExcelImport.LoadColumnsFromHead(ASheet: TSpreadSheet);
  151. var
  152. iCol: Integer;
  153. sColName: string;
  154. begin
  155. for iCol := 0 to ASheet.Cells.UsedRowCount do
  156. begin
  157. sColName := VarToStrDef(ASheet.Cells.GetValue(iCol, FCurRow), '');
  158. if sColName = '层次编号' then
  159. FLevelCol := iCol
  160. else if sColName = '项目节编号' then
  161. FCodeCol := iCol
  162. else if sColName = '清单子目号' then
  163. FB_CodeCol := iCol
  164. else if sColName = '名称' then
  165. FNameCol := iCol
  166. else if sColName = '单位' then
  167. begin
  168. FUnitsCol := iCol;
  169. FFixedIDCol := iCol + 1;
  170. FCanDeleteCol := iCol + 2;
  171. end;
  172. end;
  173. Inc(FCurRow);
  174. end;
  175. procedure TBillsExcelImport.LoadNode(ASheet: TSpreadSheet);
  176. var
  177. sLevelCode: string;
  178. iFixedID: Integer;
  179. Node: TBillsCacheNode;
  180. vValue: Variant;
  181. begin
  182. sLevelCode := GetCellTrimText(ASheet, FLevelCol, FCurRow);
  183. if sLevelCode = '' then Exit;
  184. iFixedID := StrToIntDef(GetCellTrimText(ASheet, FFixedIDCol, FCurRow), -1);
  185. Node := FCacheTree.AddNodeByCode(sLevelCode, iFixedID);
  186. Node.Code := GetCellTrimText(ASheet, FCodeCol, FCurRow);
  187. Node.B_Code := GetCellTrimText(ASheet, FB_CodeCol, FCurRow);
  188. Node.Name := GetCellTrimText(ASheet, FNameCol, FCurRow);
  189. Node.Units := GetCellTrimText(ASheet, FUnitsCol, FCurRow);
  190. Node.CanDelete := VarToIntDef(GetCellValue(ASheet, FCanDeleteCol, FCurRow), 0) = 0;
  191. end;
  192. procedure TBillsExcelImport.LoadNodes(ASheet: TSpreadSheet);
  193. begin
  194. while FCurRow < ASheet.Cells.UsedRowCount do
  195. begin
  196. LoadNode(ASheet);
  197. Inc(FCurRow);
  198. end;
  199. end;
  200. procedure TBillsExcelImport.WriteNode(ADataSet: TsdDataSet;
  201. ANode: TBillsCacheNode);
  202. var
  203. Rec: TBillsRecord;
  204. begin
  205. Rec := TBillsRecord(ADataSet.Add);
  206. Rec.ID.AsInteger := ANode.ID;
  207. Rec.ParentID.AsInteger := ANode.ParentID;
  208. Rec.NextSiblingID.AsInteger := ANode.NextSiblingID;
  209. Rec.Code.AsString := ANode.Code;
  210. Rec.B_Code.AsString := ANode.B_Code;
  211. Rec.Name.AsString := ANode.Name;
  212. Rec.Units.AsString := ANode.Units;
  213. //Rec.ValueByName('LockedLevel').AsBoolean := ANode.CanDelete;
  214. end;
  215. procedure TBillsExcelImport.WriteNodes(ADataSet: TsdDataSet);
  216. var
  217. i: Integer;
  218. begin
  219. for i := 0 to FCacheTree.CacheNodes.Count - 1 do
  220. WriteNode(ADataSet, TBillsCacheNode(FCacheTree.CacheNodes[i]));
  221. end;
  222. { TBillsEdtExcelImport }
  223. procedure TBillsEdtExcelImport.BeginImport;
  224. begin
  225. Screen.Cursor := crHourGlass;
  226. ShowProgressHint('导入Excel数据', 100, '读取Excel数据', 100);
  227. FCurRow := 0;
  228. FIsFirstPart := True;
  229. FCacheTree := TBillsCacheTree.Create;
  230. FCacheTree.NewNodeID := 101;
  231. // 以层次编号为依据,分隔用'.',以项目节、清单编号为依据,分隔用'-'
  232. if WithLevelCode then
  233. FCacheTree.SeparateChar := '.'
  234. else
  235. FCacheTree.SeparateChar := '-';
  236. FCacheTree.AutoSort := True;
  237. FProjectData.DisConnectTree;
  238. FProjectData.BillsData.DisableEvents;
  239. FBaseTree := TBillsCacheTree.Create;
  240. FBaseTree.NewNodeID := 101;
  241. FBaseTree.SeparateChar := '.';
  242. FFixedIDNodes := TList.Create;
  243. end;
  244. procedure TBillsEdtExcelImport.EndImport;
  245. begin
  246. // For Test
  247. // FCacheTree.SaveTreeToFile('E:\Tree.txt');
  248. if FWithLevelCode then
  249. CheckFixedIDNodes;
  250. FFixedIDNodes.Free;
  251. FBaseTree.Free;
  252. FProjectData.BillsData.EnableEvents;
  253. FProjectData.ReConnectTree;
  254. FCacheTree.Free;
  255. FProjectData.BillsCompileData.CalculateAll;
  256. CloseProgressHint;
  257. Screen.Cursor := crDefault;
  258. end;
  259. function TBillsEdtExcelImport.GetFixedIDNode(AID: Integer): TBillsCacheNode;
  260. var
  261. i: Integer;
  262. Node: TBillsCacheNode;
  263. begin
  264. Result := nil;
  265. for i := 0 to FFixedIDNodes.Count - 1 do
  266. begin
  267. Node := TBillsCacheNode(FFixedIDNodes.Items[i]);
  268. if (AID = Node.ID) then
  269. begin
  270. Result := Node;
  271. Break;
  272. end;
  273. end;
  274. end;
  275. function TBillsEdtExcelImport.GetFixedID(ACode, AName: string): Integer;
  276. var
  277. i: Integer;
  278. Node: TBillsCacheNode;
  279. begin
  280. Result := -1;
  281. for i := 0 to FBaseTree.CacheNodes.Count - 1 do
  282. begin
  283. Node := TBillsCacheNode(FBaseTree.CacheNodes.Items[i]);
  284. if (Node.Code = ACode) and (Node.Name = AName) then
  285. begin
  286. if Node.ID < 100 then
  287. Result := Node.ID;
  288. Break;
  289. end;
  290. end;
  291. end;
  292. procedure TBillsEdtExcelImport.Import;
  293. begin
  294. if WithLevelCode then
  295. LoadBaseTree(FBaseTree)
  296. else
  297. LoadBaseTree(FCacheTree);
  298. LoadColumnsFromHead(FMSExcel.Sheets.Spreadsheet(0));
  299. LoadNodes(FMSExcel.Sheets.Spreadsheet(0));
  300. WriteNodes(FProjectData.BillsData.sddBills);
  301. end;
  302. procedure TBillsEdtExcelImport.LoadBaseTree(ATree: TBillsCacheTree);
  303. var
  304. BaseImportor: TBillsExcelImport;
  305. begin
  306. BaseImportor := TBillsExcelImport.Create(nil);
  307. try
  308. BaseImportor.ImportToTree(ATree, GetTemplateBillsFileName);
  309. finally
  310. BaseImportor.Free;
  311. end;
  312. end;
  313. procedure TBillsEdtExcelImport.LoadColumnsFromHead(ASheet: TSpreadSheet);
  314. var
  315. iCol: Integer;
  316. sColName: string;
  317. begin
  318. FCodeCol := -1;
  319. FB_CodeCol := -1;
  320. FNameCol := -1;
  321. FUnitsCol := -1;
  322. FPriceCol := -1;
  323. FQuantityCol := -1;
  324. FDgnQuantity1Col := -1;
  325. FDgnQuantity2Col := -1;
  326. FDrawingCol := -1;
  327. FMemoCol := -1;
  328. for iCol := 0 to ASheet.Cells.UsedRowCount do
  329. begin
  330. sColName := VarToStrDef(ASheet.Cells.GetValue(iCol, FCurRow), '');
  331. if (sColName = '预算项目节') or (sColName = '项目节编号') then
  332. FCodeCol := iCol
  333. else if (sColName = '清单子目号') or (sColName = '清单编号') then
  334. FB_CodeCol := iCol
  335. else if sColName = '名称' then
  336. FNameCol := iCol
  337. else if sColName = '单位' then
  338. FUnitsCol := iCol
  339. else if sColName = '单价' then
  340. FPriceCol := iCol
  341. else if (sColName = '清单数量') or (sColName = '工程量') or (sColName = '数量') then
  342. FQuantityCol := iCol
  343. else if (sColName = '设计数量1') or (sColName = '数量1') then
  344. FDgnQuantity1Col := iCol
  345. else if (sColName = '设计数量2') or (sColName = '数量2') then
  346. FDgnQuantity2Col := iCol
  347. else if sColName = '图号' then
  348. FDrawingCol := iCol
  349. else if sColName = '备注' then
  350. FMemoCol := iCol
  351. else if sColName = '层次编号' then
  352. FLevelCol := iCol;
  353. end;
  354. Inc(FCurRow);
  355. end;
  356. procedure TBillsEdtExcelImport.LoadNode(ASheet: TSpreadSheet);
  357. var
  358. sLevelCode, sCode, sB_Code, sName: string;
  359. Node: TBillsCacheNode;
  360. vValue: Variant;
  361. iFixedID: Integer;
  362. begin
  363. sLevelCode := GetCellTrimText(ASheet, FLevelCol, FCurRow);
  364. sCode := GetCellTrimText(ASheet, FCodeCol, FCurRow);
  365. sB_Code := GetCellTrimText(ASheet, FB_CodeCol, FCurRow);
  366. sName := GetCellTrimText(ASheet, FNameCol, FCurRow);
  367. // 含层次编号时,层次编号为空不导入
  368. // 不含层次编号时,仅导入第一部分,且项目节编号、清单编号均未空时不导入
  369. if WithLevelCode then
  370. begin
  371. if sLevelCode = '' then Exit;
  372. end
  373. else
  374. begin
  375. if ((sCode = '') and (sB_Code = '')) or SameText(sCode, '2') or
  376. (Pos('第二部分', sName) > 0) then
  377. begin
  378. FIsFirstPart := False;
  379. Exit;
  380. end;
  381. end;
  382. if (sCode = '') and FWithoutGclBills then Exit;
  383. // 含层次编号时,以层次编号为依据新增节点;反之以项目节编号为依据新增节点
  384. if not WithLevelCode then
  385. begin
  386. if (sCode <> '') then
  387. Node := FCacheTree.AddNodeByCode(sCode, -1)
  388. else
  389. Node := FCacheTree.AddLeafBillsNode(sB_Code);
  390. end
  391. else
  392. begin
  393. // 1. 从模板树中查询当前节点是否为固定ID,否则为-1
  394. iFixedID := GetFixedID(sCode, sName);
  395. // 2. 从导入树中查询是否添加过该固定ID,防止存在两个固定ID节点主键冲突
  396. // 如果已添加过固定ID节点,则其他节点未非固定ID节点
  397. Node := GetFixedIDNode(iFixedID);
  398. if Assigned(Node) then
  399. iFixedID := -1;
  400. // 3. 添加当前节点
  401. Node := FCacheTree.AddNodeByCode(sLevelCode, iFixedID);
  402. // 4. 如果当前添加的节点为固定ID节点,则添加到List中便于2快速查找
  403. if Node.ID < 100 then
  404. FFixedIDNodes.Add(Node);
  405. end;
  406. Node.Code := sCode;
  407. Node.B_Code := sB_Code;
  408. Node.Name := sName;
  409. Node.Units := GetCellTrimText(ASheet, FUnitsCol, FCurRow);
  410. Node.Price := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FPriceCol, FCurRow), ''), 0);
  411. Node.OrgQuantity := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FQuantityCol, FCurRow), ''), 0);
  412. Node.DgnQuantity1 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity1Col, FCurRow), ''), 0);
  413. Node.DgnQuantity2 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity2Col, FCurRow), ''), 0);
  414. Node.DrawingCode := GetCellTrimText(ASheet, FDrawingCol, FCurRow);
  415. Node.MemoStr := GetCellTrimText(ASheet, FMemoCol, FCurRow);
  416. end;
  417. procedure TBillsEdtExcelImport.LoadNodes(ASheet: TSpreadSheet);
  418. var
  419. iPos, iSubPos: Integer;
  420. begin
  421. while (FCurRow < ASheet.Cells.UsedRowCount){ and FIsFirstPart }do
  422. begin
  423. LoadNode(ASheet);
  424. Inc(FCurRow);
  425. iSubPos := FCurRow * 100 div ASheet.Cells.UsedRowCount;
  426. iPos := iSubPos div 2;
  427. UpdateProgressPosition(iPos, iSubPos);
  428. end;
  429. end;
  430. procedure TBillsEdtExcelImport.WriteNode(ADataSet: TsdDataSet;
  431. ANode: TBillsCacheNode);
  432. var
  433. Rec: TBillsRecord;
  434. begin
  435. if ANode.Code <> '' then
  436. UpdateProgressHint('写入读取的Excel数据 ' + ANode.Code)
  437. else if ANode.B_Code <> '' then
  438. UpdateProgressHint('写入读取的Excel数据 ' + ANode.B_Code)
  439. else
  440. UpdateProgressHint('写入读取的Excel数据 ' + ANode.Name);
  441. Rec := TBillsRecord(ADataSet.Add);
  442. Rec.ID.AsInteger := ANode.ID;
  443. Rec.ParentID.AsInteger := ANode.ParentID;
  444. Rec.NextSiblingID.AsInteger := ANode.NextSiblingID;
  445. Rec.Code.AsString := ANode.Code;
  446. Rec.B_Code.AsString := ANode.B_Code;
  447. Rec.Name.AsString := ANode.Name;
  448. Rec.Units.AsString := ANode.Units;
  449. Rec.Price.AsFloat := PriceRoundTo(ANode.Price);
  450. Rec.OrgQuantity.AsFloat := QuantityRoundTo(ANode.OrgQuantity);
  451. Rec.DgnQuantity1.AsFloat := QuantityRoundTo(ANode.DgnQuantity1);
  452. Rec.DgnQuantity2.AsFloat := QuantityRoundTo(ANode.DgnQuantity2);
  453. Rec.DrawingCode.AsString := ANode.DrawingCode;
  454. Rec.MemoStr.AsString := ANode.MemoStr;
  455. end;
  456. procedure TBillsEdtExcelImport.WriteNodes(ADataSet: TsdDataSet);
  457. var
  458. i, iPos, iSubPos: Integer;
  459. begin
  460. UpdateProgressHint('写入读取的Excel数据', True);
  461. UpdateProgressPosition(50, 0);
  462. ADataSet.DeleteAll;
  463. for i := 0 to FCacheTree.CacheNodes.Count - 1 do
  464. begin
  465. WriteNode(ADataSet, TBillsCacheNode(FCacheTree.CacheNodes[i]));
  466. iSubPos := i*100 div FCacheTree.CacheNodes.Count;
  467. iPos := 50 + iSubPos div 2;
  468. UpdateProgressPosition(iPos, iSubPos);
  469. end;
  470. UpdateProgressPosition(100, 100);
  471. end;
  472. procedure TBillsEdtExcelImport.CheckFixedIDNodes;
  473. function GetHintStr(ANode: TBillsCacheNode): string;
  474. begin
  475. Result := '';
  476. if ANode.Code <> '' then
  477. Result := Result + '编号:' + ANode.Code + ';';
  478. if ANode.Name <> '' then
  479. Result := Result + '名称:' + ANode.Name + ';';
  480. end;
  481. function GetInvalidModel(ANoPM: Boolean; ACount: Integer): string;
  482. begin
  483. if ANoPM then
  484. begin
  485. if ACount > 1 then
  486. Result := '价差功能,部分报表'
  487. else
  488. Result := '价差功能'
  489. end
  490. else
  491. Result := '部分报表';
  492. Result := Result + '将不可使用' + #13#10 + '如有疑问,请联系纵横客服,企业QQ:800003850 电话:(0756)3850888';
  493. end;
  494. var
  495. sgs: TStrings;
  496. iBase: Integer;
  497. vBase, vImport: TBillsCacheNode;
  498. sHint: string;
  499. bNoPM: Boolean;
  500. begin
  501. bNoPM := False;
  502. sgs := TStringList.Create;
  503. try
  504. sgs.Add('缺少如下固定清单节点:');
  505. for iBase := 0 to FBaseTree.FixedIDNodes.Count - 1 do
  506. begin
  507. vBase := TBillsCacheNode(FBaseTree.FixedIDNodes.Items[iBase]);
  508. vImport := FCacheTree.FindFixedIDNode(vBase.ID);
  509. if not Assigned(vImport) then
  510. begin
  511. sgs.Add(GetHintStr(vBase));
  512. if vBase.ID = iPriceMarginID then
  513. bNoPM := True;
  514. end;
  515. end;
  516. finally
  517. if sgs.Count > 1 then
  518. begin
  519. sgs.Add(GetInvalidModel(bNoPM, sgs.Count - 1));
  520. WarningMessage(sgs.Text);
  521. end;
  522. sgs.Free;
  523. end;
  524. end;
  525. end.