BillsCompileFme.pas 21 KB

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