BillsCompileFme.pas 21 KB

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