ExcelImport.pas 16 KB

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