BillsCompileFme.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. unit BillsCompileFme;
  2. interface
  3. uses
  4. BillsCompileDm, UtilMethods, BillsClipboard, sdIDTree, BatchReplaceBillsFrm,
  5. CheckAndClearFrm, DealBillsFrm, BillsPasteSelectFrm,
  6. sdDB, BillsTree, sdIDTreeCells,
  7. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  8. Dialogs, ActnList, sdGridDBA, sdGridTreeDBA, dxBar, ZJGrid, StdCtrls,
  9. ExtCtrls;
  10. type
  11. TBillsCompileFrame = class(TFrame)
  12. pnlExprs: TPanel;
  13. laEdtExprs: TLabeledEdit;
  14. pnlBills: TPanel;
  15. zgBillsCompile: TZJGrid;
  16. dxpmBillsCompile: TdxBarPopupMenu;
  17. stdBillsCompile: TsdGridTreeDBA;
  18. alBillsCompile: TActionList;
  19. actnCalculateLedger: TAction;
  20. actnCopyBillsBlock: TAction;
  21. actnExportGridToExcel: TAction;
  22. actnBatchAddChild: TAction;
  23. actnBatchAddNext: TAction;
  24. actnReorderChildrenCode: TAction;
  25. actnBatchReplaceBillsInfo: TAction;
  26. actnCheckAndClear: TAction;
  27. actnModifiedDealBills: TAction;
  28. actnSetBillsBookmark: TAction;
  29. actnImportGclBillsToXmj: TAction;
  30. actnImportPlaneFxBillsToXmj: TAction;
  31. procedure zgBillsCompileCopy(Sender: TObject; const ABounds: TRect;
  32. var Allow: Boolean);
  33. procedure zgBillsCompilePaste(Sender: TObject; const ABounds: TRect;
  34. var Allow: Boolean);
  35. procedure actnCopyBillsBlockExecute(Sender: TObject);
  36. procedure actnCalculateLedgerExecute(Sender: TObject);
  37. procedure dxpmBillsCompilePopup(Sender: TObject);
  38. procedure zgBillsCompileMouseDown(Sender: TObject;
  39. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  40. procedure zgBillsCompileCellGetColor(Sender: TObject; ACoord: TPoint;
  41. var AColor: TColor);
  42. procedure zgBillsCompileCellGetFont(Sender: TObject; ACoord: TPoint;
  43. AFont: TFont);
  44. procedure laEdtExprsExit(Sender: TObject);
  45. procedure laEdtExprsKeyDown(Sender: TObject; var Key: Word;
  46. Shift: TShiftState);
  47. procedure actnBatchAddChildExecute(Sender: TObject);
  48. procedure actnBatchAddNextExecute(Sender: TObject);
  49. procedure actnBatchAddChildUpdate(Sender: TObject);
  50. procedure actnBatchAddNextUpdate(Sender: TObject);
  51. procedure actnReorderChildrenCodeExecute(Sender: TObject);
  52. procedure actnReorderChildrenCodeUpdate(Sender: TObject);
  53. procedure actnExportGridToExcelExecute(Sender: TObject);
  54. procedure actnBatchReplaceBillsInfoExecute(Sender: TObject);
  55. procedure actnBatchReplaceBillsInfoUpdate(Sender: TObject);
  56. procedure zgBillsCompileCustomPaste(Sender: TObject; ABounds: TRect;
  57. ASourSheet: TZjSheet);
  58. procedure zgBillsCompileKeyDown(Sender: TObject; var Key: Word;
  59. Shift: TShiftState);
  60. procedure actnCheckAndClearExecute(Sender: TObject);
  61. procedure actnModifiedDealBillsExecute(Sender: TObject);
  62. procedure actnModifiedDealBillsUpdate(Sender: TObject);
  63. procedure actnSetBillsBookmarkExecute(Sender: TObject);
  64. procedure actnImportGclBillsToXmjUpdate(Sender: TObject);
  65. procedure actnImportGclBillsToXmjExecute(Sender: TObject);
  66. procedure actnImportPlaneFxBillsToXmjExecute(Sender: TObject);
  67. private
  68. FBillsCompileData: TBillsCompileData;
  69. FShowIDField: Boolean;
  70. FShowDesginQuantity: Boolean;
  71. FOnAfterSetBookmark: TBookmarkRefreshEvent;
  72. FShowAlias: Boolean;
  73. procedure CopyBillsBlock(ANode: TsdIDTreeNode; ABounds: TRect);
  74. procedure PasteBillsBlock(ANode: TsdIDTreeNode; ABounds: TRect);
  75. procedure SetShowIDField(AValue: Boolean);
  76. procedure ExpandMouseDown(AGridCell: TzjCell);
  77. procedure BeginExpandNode;
  78. procedure EndExpandNode;
  79. procedure ResetBaseDataReadOnly(AReadOnly: Boolean);
  80. procedure ResetAllowInsert(AAllow: Boolean);
  81. function CheckExprsColumn: Boolean;
  82. procedure SetShowDesignQuantity(const Value: Boolean);
  83. procedure SetShowAlias(const Value: Boolean);
  84. public
  85. constructor Create(AParent: TFrame; ABillsCompileData: TBillsCompileData);
  86. destructor Destroy; override;
  87. procedure ExpandNodeTo(ALevel: Integer);
  88. procedure ExpandXmjNode;
  89. procedure ExpandPegXmjNode;
  90. procedure RefreshPhase_Stage;
  91. property ShowDesignQuantity: Boolean read FShowDesginQuantity write SetShowDesignQuantity;
  92. Property ShowAlias: Boolean read FShowAlias write SetShowAlias;
  93. property OnAfterSetBookmark: TBookmarkRefreshEvent read FOnAfterSetBookmark write FOnAfterSetBookmark;
  94. property BillsCompileData: TBillsCompileData read FBillsCompileData;
  95. end;
  96. implementation
  97. uses
  98. MainFrm, BatchInsertBillsFrm, ExportExcel, ProjectData, mEncryptEditions,
  99. ExcelImport, DetailExcelImport, mDataRecord;
  100. {$R *.dfm}
  101. { TBillsCompileFrame }
  102. procedure TBillsCompileFrame.CopyBillsBlock(ANode: TsdIDTreeNode;
  103. ABounds: TRect);
  104. var
  105. Clipboard: TBillsClipboard;
  106. begin
  107. Clipboard := TBillsClipboard.Create(FBillsCompileData.BillsData);
  108. try
  109. Clipboard.Copy(ANode, ABounds.Bottom - ABounds.Top);
  110. finally
  111. Clipboard.Free;
  112. end;
  113. end;
  114. procedure TBillsCompileFrame.PasteBillsBlock(ANode: TsdIDTreeNode;
  115. ABounds: TRect);
  116. var
  117. Clipboard: TBillsClipboard;
  118. iPos: Integer;
  119. begin
  120. if SelectBillsPasteType(iPos) then
  121. begin
  122. if iPos = -1 then Exit;
  123. Clipboard := TBillsClipboard.Create(FBillsCompileData.BillsData);
  124. try
  125. Clipboard.Paste(ANode, iPos);
  126. finally
  127. FBillsCompileData.CalculateAll;
  128. Clipboard.Free;
  129. end;
  130. end;
  131. end;
  132. procedure TBillsCompileFrame.zgBillsCompileCopy(Sender: TObject;
  133. const ABounds: TRect; var Allow: Boolean);
  134. var
  135. stnNode: TsdIDTreeNode;
  136. begin
  137. Allow := TZJGrid(Sender).Tag = 0;
  138. if not Allow then
  139. begin
  140. stnNode := stdBillsCompile.IDTree.Items[ABounds.Top - zgBillsCompile.FixedRowCount];
  141. CopyBillsBlock(stnNode, ABounds);
  142. TZJGrid(Sender).Tag := 0;
  143. end;
  144. end;
  145. procedure TBillsCompileFrame.zgBillsCompilePaste(Sender: TObject;
  146. const ABounds: TRect; var Allow: Boolean);
  147. begin
  148. if HasBillsBlockFormat then
  149. begin
  150. Allow := False;
  151. PasteBillsBlock(stdBillsCompile.IDTree.Selected, ABounds);
  152. end;
  153. end;
  154. procedure TBillsCompileFrame.actnCopyBillsBlockExecute(Sender: TObject);
  155. begin
  156. if CheckCompileEdition then
  157. begin
  158. zgBillsCompile.Tag := 1;
  159. zgBillsCompile.CopyToClipboard(zgBillsCompile.Selection.Bounds);
  160. zgBillsCompile.Selection.SelectRow(zgBillsCompile.Selection.Top, zgBillsCompile.Selection.Bottom - 1);
  161. end;
  162. end;
  163. procedure TBillsCompileFrame.actnCalculateLedgerExecute(Sender: TObject);
  164. begin
  165. FBillsCompileData.CalculateAll;
  166. end;
  167. procedure TBillsCompileFrame.dxpmBillsCompilePopup(Sender: TObject);
  168. begin
  169. SetDxBtnAction(actnCalculateLedger, MainForm.dxbtnCalculateLedger);
  170. SetDxBtnAction(actnCopyBillsBlock, MainForm.dxbtnCopyBillsBlock);
  171. SetDxBtnAction(actnBatchAddChild, MainForm.dxbtnBatchAddChild);
  172. SetDxBtnAction(actnBatchAddNext, MainForm.dxbtnBatchAddNext);
  173. SetDxBtnAction(actnReorderChildrenCode, MainForm.dxbtnReorderChildrenCode);
  174. SetDxBtnAction(actnExportGridToExcel, MainForm.dxbtnExportGridToExcel);
  175. SetDxBtnAction(actnBatchReplaceBillsInfo, MainForm.dxbtnBatchReplaceBillsInfo);
  176. SetDxBtnAction(actnCheckAndClear, MainForm.dxbtnCheckAndClear);
  177. SetDxBtnAction(actnModifiedDealBills, MainForm.dxbtnModifyDealBills);
  178. SetDxBtnAction(actnSetBillsBookmark, MainForm.dxbtnSetBookmark);
  179. SetDxBtnAction(actnImportGclBillsToXmj, MainForm.dxbtnImportGclBillsToXmj);
  180. SetDxBtnAction(actnImportPlaneFxBillsToXmj, MainForm.dxbtnImportPlaneFxBillsToXmj);
  181. end;
  182. constructor TBillsCompileFrame.Create(AParent: TFrame;
  183. ABillsCompileData: TBillsCompileData);
  184. begin
  185. inherited Create(AParent);
  186. FBillsCompileData := ABillsCompileData;
  187. stdBillsCompile.IDTree := FBillsCompileData.BillsCompileTree;
  188. with TProjectData(FBillsCompileData.ProjectData) do
  189. stdBillsCompile.Column('LockedInfo').ReadOnly := ProjProperties.PhaseCount > 0;
  190. zgBillsCompile.OnExpandMouseDown := ExpandMouseDown;
  191. end;
  192. destructor TBillsCompileFrame.Destroy;
  193. begin
  194. inherited;
  195. end;
  196. procedure TBillsCompileFrame.zgBillsCompileMouseDown(Sender: TObject;
  197. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  198. begin
  199. if Button = mbRight then
  200. dxpmBillsCompile.PopupFromCursorPos
  201. else
  202. begin
  203. if CheckExprsColumn then
  204. laEdtExprs.Text := zgBillsCompile.CurCell.EditText
  205. else
  206. laEdtExprs.Text := '';
  207. with stdBillsCompile.DataView do
  208. if Assigned(Current) then
  209. laEdtExprs.ReadOnly := Current.ValueByName('LockedInfo').AsBoolean;
  210. end;
  211. end;
  212. procedure TBillsCompileFrame.zgBillsCompileCellGetColor(Sender: TObject;
  213. ACoord: TPoint; var AColor: TColor);
  214. var
  215. stnNode: TBillsIDTreeNode;
  216. iCreatePhaseID: Integer;
  217. begin
  218. if ACoord.Y > stdBillsCompile.IDTree.Count + 2 then Exit;
  219. stnNode := TBillsIDTreeNode(stdBillsCompile.IDTree.Items[ACoord.Y - 3]);
  220. if not Assigned(stnNode) then Exit;
  221. iCreatePhaseID := stnNode.Rec.CreatePhaseID.AsInteger;
  222. if stnNode.ParentID = 1 then
  223. AColor := $00FBCAC4
  224. else if (stnNode.Rec.B_Code.AsString = '') and (stnNode.Level > 0) then
  225. AColor := $00F9E8DF;
  226. // 书签
  227. if stnNode.Rec.HasBookMark.AsBoolean then
  228. AColor := $00CFE2F9;
  229. // 根据节点创建期数底色不同
  230. if iCreatePhaseID > 0 then
  231. begin
  232. // 当前期不存在节点,底色为灰色提示用户
  233. if iCreatePhaseID > TProjectData(FBillsCompileData.ProjectData).PhaseIndex then
  234. AColor := $00D5D5D5
  235. // 当前期新增节点,底色为黄色提示用户
  236. else if iCreatePhaseID = TProjectData(FBillsCompileData.ProjectData).PhaseIndex then
  237. AColor := $00A7FDFD;
  238. end;
  239. end;
  240. procedure TBillsCompileFrame.zgBillsCompileCellGetFont(Sender: TObject;
  241. ACoord: TPoint; AFont: TFont);
  242. begin
  243. if ACoord.X = stdBillsCompile.VisibleCol('IsMeasureAdd') then
  244. AFont.Color := clInactiveCaptionText;
  245. end;
  246. procedure TBillsCompileFrame.laEdtExprsExit(Sender: TObject);
  247. begin
  248. if not TLabeledEdit(Sender).ReadOnly then
  249. if CheckExprsColumn then
  250. zgBillsCompile.CurCell.Text := laEdtExprs.Text;
  251. end;
  252. function TBillsCompileFrame.CheckExprsColumn: Boolean;
  253. var
  254. iCol: Integer;
  255. begin
  256. iCol := zgBillsCompile.CurCol-zgBillsCompile.FixedColCount;
  257. Result := (iCol = stdBillsCompile.VisibleCol('OrgQuantity'))
  258. or (iCol = stdBillsCompile.VisibleCol('MisQuantity'))
  259. or (iCol = stdBillsCompile.VisibleCol('OthQuantity'));
  260. end;
  261. procedure TBillsCompileFrame.laEdtExprsKeyDown(Sender: TObject;
  262. var Key: Word; Shift: TShiftState);
  263. begin
  264. if Key = VK_Return then
  265. begin
  266. zgBillsCompile.SetFocus;
  267. if not TLabeledEdit(Sender).ReadOnly then
  268. if CheckExprsColumn then
  269. zgBillsCompile.CurCell.Text := laEdtExprs.Text;
  270. end;
  271. end;
  272. procedure TBillsCompileFrame.actnBatchAddChildExecute(Sender: TObject);
  273. begin
  274. if CheckCompileEdition then
  275. AddLeafBills(FBillsCompileData, itChild);
  276. end;
  277. procedure TBillsCompileFrame.actnBatchAddNextExecute(Sender: TObject);
  278. begin
  279. if CheckCompileEdition then
  280. AddLeafBills(FBillsCompileData, itNextSibling);
  281. end;
  282. procedure TBillsCompileFrame.actnBatchAddChildUpdate(Sender: TObject);
  283. begin
  284. with stdBillsCompile.IDTree do
  285. TAction(Sender).Enabled := not Selected.HasChildren
  286. and (Selected.Rec.ValueByName('Code').AsString <> '');
  287. end;
  288. procedure TBillsCompileFrame.actnBatchAddNextUpdate(Sender: TObject);
  289. function CheckLastXmj(ANode: TsdIDTreeNode): Boolean;
  290. var
  291. stnChild: TsdIDTreeNode;
  292. begin
  293. Result := ANode.Rec.ValueByName('Code').AsString <> '';
  294. if not ANode.HasChildren then Exit;
  295. stnChild := ANode.FirstChild;
  296. while Result and Assigned(stnChild) do
  297. begin
  298. Result := Result and (stnChild.Rec.ValueByName('B_Code').AsString <> '');
  299. stnChild := stnChild.NextSibling;
  300. end;
  301. end;
  302. begin
  303. with stdBillsCompile.IDTree do
  304. TAction(Sender).Enabled := Assigned(Selected) and CheckLastXmj(Selected);
  305. end;
  306. procedure TBillsCompileFrame.actnReorderChildrenCodeExecute(
  307. Sender: TObject);
  308. begin
  309. if CheckCompileEdition then
  310. if QuestMessage('是否将此节点的所有子项重新自动编号?') then
  311. FBillsCompileData.ReorderChildrenCode(stdBillsCompile.IDTree.Selected);
  312. end;
  313. procedure TBillsCompileFrame.actnReorderChildrenCodeUpdate(
  314. Sender: TObject);
  315. function WithoutGclChild(ANode: TsdIDTreeNode): Boolean;
  316. var
  317. stnChild: TsdIDTreeNode;
  318. begin
  319. Result := ANode.Rec.ValueByName('Code').AsString <> '';
  320. if not ANode.HasChildren then Exit;
  321. stnChild := ANode.FirstChild;
  322. while Result and Assigned(stnChild) do
  323. begin
  324. Result := Result and (stnChild.Rec.ValueByName('B_Code').AsString = '');
  325. stnChild := stnChild.NextSibling;
  326. end;
  327. end;
  328. begin
  329. with TProjectData(FBillsCompileData.ProjectData) do
  330. TAction(Sender).Enabled := ProjProperties.PhaseCount = 0;
  331. with stdBillsCompile.IDTree do
  332. TAction(Sender).Enabled := TAction(Sender).Enabled
  333. and Assigned(Selected) and WithoutGclChild(Selected);
  334. end;
  335. procedure TBillsCompileFrame.actnExportGridToExcelExecute(Sender: TObject);
  336. var
  337. sFileName: string;
  338. ExcelExportor: TExcelExportor;
  339. begin
  340. if SaveFile(sFileName, '.xls') then
  341. begin
  342. ExcelExportor := TExcelExportor.Create;
  343. try
  344. ExcelExportor.ExportToFile(zgBillsCompile, sFileName);
  345. finally
  346. ExcelExportor.Free;
  347. end;
  348. end;
  349. end;
  350. procedure TBillsCompileFrame.actnBatchReplaceBillsInfoExecute(
  351. Sender: TObject);
  352. begin
  353. if CheckCompileEdition then
  354. BatchReplaceBillsInfo(stdBillsCompile.DataView.Current, FBillsCompileData.BillsData);
  355. end;
  356. procedure TBillsCompileFrame.actnBatchReplaceBillsInfoUpdate(
  357. Sender: TObject);
  358. begin
  359. with TProjectData(FBillsCompileData.ProjectData) do
  360. TAction(Sender).Enabled := ProjProperties.PhaseCount = 0;
  361. TAction(Sender).Enabled := TAction(Sender).Enabled
  362. and Assigned(stdBillsCompile.IDTree.Selected)
  363. and (stdBillsCompile.IDTree.Selected.Rec.ValueByName('B_Code').AsString <> '');
  364. end;
  365. procedure TBillsCompileFrame.zgBillsCompileCustomPaste(Sender: TObject;
  366. ABounds: TRect; ASourSheet: TZjSheet);
  367. var
  368. iRow, iCol: Integer;
  369. begin
  370. for iRow := ABounds.Top to ABounds.Bottom - 1 do
  371. begin
  372. if not zgBillsCompile.RowVisible[iRow] then Continue;
  373. for iCol := ABounds.Left to ABounds.Right - 1 do
  374. with TZJGrid(Sender).Cells[iCol, iRow] do
  375. if CanEdit then Text := ASourSheet.Values[iCol - ABounds.Left, iRow - ABounds.Top];
  376. end;
  377. end;
  378. procedure TBillsCompileFrame.SetShowDesignQuantity(const Value: Boolean);
  379. begin
  380. FShowDesginQuantity := Value;
  381. stdBillsCompile.Column('DgnQuantity1').Visible := FShowDesginQuantity;
  382. stdBillsCompile.Column('DgnQuantity2').Visible := FShowDesginQuantity;
  383. stdBillsCompile.Column('DgnPrice').Visible := FShowDesginQuantity;
  384. end;
  385. procedure TBillsCompileFrame.zgBillsCompileKeyDown(Sender: TObject;
  386. var Key: Word; Shift: TShiftState);
  387. begin
  388. // For Inner Test
  389. if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
  390. and (Key in [73, 105]) // 'i', 'i'
  391. and (zgBillsCompile.CurCol = 1) then
  392. SetShowIDField(not FShowIDField);
  393. end;
  394. procedure TBillsCompileFrame.SetShowIDField(AValue: Boolean);
  395. begin
  396. FShowIDField := AValue;
  397. stdBillsCompile.Column('ID').Visible := AValue;
  398. stdBillsCompile.Column('ParentID').Visible := AValue;
  399. stdBillsCompile.Column('NextSiblingID').Visible := AValue;
  400. end;
  401. procedure TBillsCompileFrame.actnCheckAndClearExecute(Sender: TObject);
  402. begin
  403. ShowCheckAndClearForm(FBillsCompileData);
  404. end;
  405. procedure TBillsCompileFrame.actnModifiedDealBillsExecute(Sender: TObject);
  406. var
  407. DealBillsForm: TDealBillsForm;
  408. begin
  409. with TProjectData(FBillsCompileData.ProjectData) do
  410. DealBillsForm := TDealBillsForm.Create(DealBillsData);
  411. try
  412. DealBillsForm.ShowModal;
  413. finally
  414. DealBillsForm.Free;
  415. end;
  416. end;
  417. procedure TBillsCompileFrame.actnModifiedDealBillsUpdate(Sender: TObject);
  418. begin
  419. TAction(Sender).Enabled := TProjectData(FBillsCompileData.ProjectData).CanUnlockInfo;
  420. end;
  421. procedure TBillsCompileFrame.actnSetBillsBookmarkExecute(Sender: TObject);
  422. var
  423. Rec: TBillsRecord;
  424. begin
  425. Rec := TBillsRecord(stdBillsCompile.IDTree.Selected.Rec);
  426. if Rec.HasBookMark.AsBoolean then
  427. begin
  428. Rec.HasBookMark.AsBoolean := False;
  429. Rec.MarkMemo.AsString := '';
  430. end
  431. else
  432. Rec.HasBookMark.AsBoolean := True;
  433. TProjectData(FBillsCompileData.ProjectData).BillsBookmarkData.RefreshBillsBookmark;
  434. if Assigned(FOnAfterSetBookmark) then
  435. FOnAfterSetBookmark(Rec.HasBookMark.AsBoolean);
  436. zgBillsCompile.InvalidateRow(zgBillsCompile.CurRow);
  437. end;
  438. procedure TBillsCompileFrame.SetShowAlias(const Value: Boolean);
  439. begin
  440. FShowAlias := Value;
  441. stdBillsCompile.Column('Alias').Visible := FShowAlias;
  442. end;
  443. procedure TBillsCompileFrame.actnImportGclBillsToXmjUpdate(
  444. Sender: TObject);
  445. begin
  446. with stdBillsCompile.IDTree do
  447. TAction(Sender).Enabled := not Selected.HasChildren and (Selected.Rec.ValueByName('Code').AsString <> '');
  448. end;
  449. procedure TBillsCompileFrame.actnImportGclBillsToXmjExecute(
  450. Sender: TObject);
  451. var
  452. sFileName: string;
  453. Importor: TGclBillsExcelImport;
  454. begin
  455. if SelectFile(sFileName, '.xls') then
  456. begin
  457. Importor := TGclBillsExcelImport.Create(TProjectData(FBillsCompileData.ProjectData));
  458. try
  459. Importor.ParentID := stdBillsCompile.IDTree.Selected.ID;
  460. Importor.ImportFile(sFileName);
  461. finally
  462. Importor.Free;
  463. end;
  464. end;
  465. end;
  466. procedure TBillsCompileFrame.ExpandNodeTo(ALevel: Integer);
  467. begin
  468. BeginExpandNode;
  469. try
  470. FBillsCompileData.ExpandNodeTo(ALevel);
  471. finally
  472. EndExpandNode;
  473. end;
  474. end;
  475. procedure TBillsCompileFrame.ExpandXmjNode;
  476. begin
  477. BeginExpandNode;
  478. try
  479. FBillsCompileData.ExpandXmjNode;
  480. finally
  481. EndExpandNode;
  482. end;
  483. end;
  484. procedure TBillsCompileFrame.BeginExpandNode;
  485. begin
  486. zgBillsCompile.BeginUpdate;
  487. zgBillsCompile.OnCellGetColor := nil;
  488. BeginUpdateWindow(zgBillsCompile.Handle);
  489. stdBillsCompile.DisableControl;
  490. end;
  491. procedure TBillsCompileFrame.EndExpandNode;
  492. begin
  493. stdBillsCompile.EnableControl;
  494. EndUpdateWindow(zgBillsCompile.Handle);
  495. zgBillsCompile.OnCellGetColor := zgBillsCompileCellGetColor;
  496. zgBillsCompile.EndUpdate;
  497. end;
  498. procedure TBillsCompileFrame.RefreshPhase_Stage;
  499. begin
  500. with TProjectData(FBillsCompileData.ProjectData) do
  501. begin
  502. ResetBaseDataReadOnly(BaseDataReadOnly);
  503. ResetAllowInsert(AllowInsert);
  504. end;
  505. end;
  506. procedure TBillsCompileFrame.ResetAllowInsert(AAllow: Boolean);
  507. begin
  508. if AAllow then
  509. stdBillsCompile.Options := stdBillsCompile.Options + [aoAllowInsert]
  510. else
  511. stdBillsCompile.Options := stdBillsCompile.Options - [aoAllowInsert];
  512. end;
  513. procedure TBillsCompileFrame.ResetBaseDataReadOnly(AReadOnly: Boolean);
  514. begin
  515. stdBillsCompile.Column('Code').ReadOnly := AReadOnly;
  516. stdBillsCompile.Column('B_Code').ReadOnly := AReadOnly;
  517. stdBillsCompile.Column('Name').ReadOnly := AReadOnly;
  518. stdBillsCompile.Column('Units').ReadOnly := AReadOnly;
  519. stdBillsCompile.Column('Price').ReadOnly := AReadOnly;
  520. stdBillsCompile.Column('DrawingCode').ReadOnly := AReadOnly;
  521. end;
  522. procedure TBillsCompileFrame.actnImportPlaneFxBillsToXmjExecute(
  523. Sender: TObject);
  524. var
  525. sFileName: string;
  526. Importor: TPlaneFxBillsExcelImport;
  527. begin
  528. if SelectFile(sFileName, '.xls') then
  529. begin
  530. Importor := TPlaneFxBillsExcelImport.Create(TProjectData(FBillsCompileData.ProjectData));
  531. try
  532. Importor.ParentID := stdBillsCompile.IDTree.Selected.ID;
  533. Importor.ImportFile(sFileName);
  534. finally
  535. Importor.Free;
  536. end;
  537. end;
  538. end;
  539. procedure TBillsCompileFrame.ExpandPegXmjNode;
  540. begin
  541. BeginExpandNode;
  542. try
  543. FBillsCompileData.ExpandPegXmjNode;
  544. finally
  545. EndExpandNode;
  546. end;
  547. end;
  548. procedure TBillsCompileFrame.ExpandMouseDown(AGridCell: TzjCell);
  549. procedure CommonExpand(vNode: TsdIDTreeNode);
  550. begin
  551. AGridCell.Grid.BeginUpdate;
  552. vNode.Expanded := not vNode.Expanded;
  553. AGridCell.Grid.EndUpdate;
  554. AGridCell.Grid.InvalidateView(AGridCell.ViewRect);
  555. end;
  556. procedure QuikExpand(vNode: TsdIDTreeNode);
  557. begin
  558. Screen.Cursor := crHourGlass;
  559. BeginExpandNode;
  560. try
  561. vNode.Expanded := not vNode.Expanded;
  562. finally
  563. EndExpandNode;
  564. Screen.Cursor := crDefault;
  565. end;
  566. end;
  567. var
  568. stnNode: TsdIDTreeNode;
  569. begin
  570. stnNode := TsdIDTreeCell(AGridCell).TreeNode;
  571. if stnNode.PosterityCount > 10000 then
  572. QuikExpand(stnNode)
  573. else
  574. CommonExpand(stnNode);
  575. end;
  576. end.