BillsCompileFme.pas 23 KB

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