MainFrm.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. unit MainFrm;
  2. interface
  3. uses
  4. // Uses Units Please Try This Category
  5. // View
  6. ProjectManagerFme, ProjectFme, ProjectPropertiesFrm, OptionFrm, AboutFrm,
  7. AuthFrm,
  8. // Model & Data & Data Control ...
  9. ProjectData, SupportUnit, Globals, ZhAPI, ExcelImport, ConditionalDefines,
  10. // Controls & Delphi Default ... (Almost By Add Controls)
  11. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  12. Dialogs, cxGraphics, JimPages, ComCtrls, dxStatusBar, cxControls, JimTabs,
  13. dxBar, ImgList, UtilMethods, ZjDbaActns, ActnList, XPStyleActnCtrls, ActnMan,
  14. dxBarExtItems, sdDB, ExtCtrls, jpeg, StdCtrls, CslLabel, pngimage;
  15. type
  16. TMainForm = class(TForm)
  17. dxBarManager: TdxBarManager;
  18. Images: TImageList;
  19. dxsiFile: TdxBarSubItem;
  20. jtsProjects: TJimTabSet;
  21. dxStatusBar: TdxStatusBar;
  22. dxStatusBarContainer2: TdxStatusBarContainerControl;
  23. ProgressBar: TProgressBar;
  24. jpsMain: TJimPages;
  25. jpsMainProjectsManager: TJimPage;
  26. jpsMainProjects: TJimPage;
  27. jpsProjects: TJimPages;
  28. dxsiEdit: TdxBarSubItem;
  29. dxsiHelp: TdxBarSubItem;
  30. dxbtnCopy: TdxBarButton;
  31. dxbtnPaste: TdxBarButton;
  32. dxbtnCut: TdxBarButton;
  33. dxbtnInsert: TdxBarButton;
  34. dxbtnDelete: TdxBarButton;
  35. dxbtnUpMove: TdxBarButton;
  36. dxbtnDownMove: TdxBarButton;
  37. dxbtnUpLevel: TdxBarButton;
  38. dxbtnDownLevel: TdxBarButton;
  39. dxbtnAuthorizeDog: TdxBarButton;
  40. dxbtnAbout: TdxBarButton;
  41. dxbtnNewProject: TdxBarButton;
  42. dxbtnOpenProject: TdxBarButton;
  43. dxbtnDeleteProject: TdxBarButton;
  44. ActionManager1: TActionManager;
  45. ZjDbaInsert: TZjDbaInsert;
  46. ZjDbaDelete: TZjDbaDelete;
  47. ZjDbaUpMove: TZjDbaUpMove;
  48. ZjDbaDownMove: TZjDbaDownMove;
  49. ZjTreeDbaUpLevel: TZjTreeDbaUpLevel;
  50. ZjTreeDbaDownLevel: TZjTreeDbaDownLevel;
  51. ZjGridCopy: TZjGridCopy;
  52. ZjGridPaste: TZjGridPaste;
  53. ZjGridCut: TZjGridCut;
  54. ZjGridRemapedPaste: TZjGridRemapedPaste;
  55. dxpmTabSet: TdxBarPopupMenu;
  56. dxbtnCloseProject: TdxBarButton;
  57. actnCloseProject: TAction;
  58. dxbtnNewPhase: TdxBarButton;
  59. dxbtnCalculateLedger: TdxBarButton;
  60. actnNewPhase: TAction;
  61. dxbtnProjectProperties: TdxBarButton;
  62. actnProjectProperties: TAction;
  63. dxbtnSaveProject: TdxBarButton;
  64. actnSaveProject: TAction;
  65. dxbtnRemapedPaste: TdxBarButton;
  66. dxbtnImportExcel: TdxBarButton;
  67. actnImportExcel: TAction;
  68. dxbtnNewAudit: TdxBarButton;
  69. dxbtnCopyBillsBlock: TdxBarButton;
  70. actnNewAudit: TAction;
  71. dxbtnFinalAudit: TdxBarButton;
  72. dxbtnSubmitProject: TdxBarButton;
  73. dxbtnReceiveProject: TdxBarButton;
  74. dxbtnReplyProject: TdxBarButton;
  75. dxbtnAcceptProject: TdxBarButton;
  76. dxbtnCalculateAll: TdxBarButton;
  77. dxbtnNewSubProject: TdxBarButton;
  78. dxbtnNewTender: TdxBarButton;
  79. dxbtnOptions: TdxBarButton;
  80. actnOptions: TAction;
  81. dxbtnCalculatePhasePay: TdxBarButton;
  82. actnSubmit: TAction;
  83. actnReply: TAction;
  84. dxbtnSubmit: TdxBarButton;
  85. dxbtnReply: TdxBarButton;
  86. dxbtnFirstLevel: TdxBarButton;
  87. dxbtnSecondLevel: TdxBarButton;
  88. dxbtnThirdLevel: TdxBarButton;
  89. dxbtnFourthLevel: TdxBarButton;
  90. dxbtnFifthLevel: TdxBarButton;
  91. dxbtnAllLevel: TdxBarButton;
  92. dxbtnAllXmj: TdxBarButton;
  93. dxbtnExportGridToExcel: TdxBarButton;
  94. dxbtnRefresh: TdxBarButton;
  95. dxbtnUnlockInfo: TdxBarButton;
  96. actnUnlockInfo: TAction;
  97. dxUser: TdxBarSubItem;
  98. pnlUser: TPanel;
  99. lblAccount: TLabel;
  100. lblCompany: TLabel;
  101. lblRole: TLabel;
  102. dxLoginCloud: TdxBarButton;
  103. dxManageAccount: TdxBarButton;
  104. pnl1: TPanel;
  105. imgUserImage: TImage;
  106. lblMail: TLabel;
  107. dxUserContainer: TdxBarControlContainerItem;
  108. dxbtnBatchAddChild: TdxBarButton;
  109. dxbtnBatchAddNext: TdxBarButton;
  110. dxbtnReorderChildrenCode: TdxBarButton;
  111. dxbtnImportBillsPrice: TdxBarButton;
  112. dxsiImportExcel: TdxBarSubItem;
  113. dxbtnImportDealBills: TdxBarButton;
  114. actnImportBillsPrice: TAction;
  115. actnImportDealBills: TAction;
  116. dxbtnBatchReplaceBillsInfo: TdxBarButton;
  117. tAutoSave: TTimer;
  118. dxsiExportExcel: TdxBarSubItem;
  119. dxbtnExportExcel: TdxBarButton;
  120. actnExportExcel: TAction;
  121. dxbtnCurPhase: TdxBarButton;
  122. dxSync: TdxBarButton;
  123. dxbtnBatchWritePos_Reason: TdxBarButton;
  124. dxbtnExportCloudTenderFile: TdxBarButton;
  125. actnExportCloudTenderFile: TAction;
  126. dxtbnImportCloudTenderFile: TdxBarButton;
  127. actnImportCloudTenderFile: TAction;
  128. dxbtnCheckAndClear: TdxBarButton;
  129. dxbtnModifyDealBills: TdxBarButton;
  130. dxbtnLocateBills: TdxBarButton;
  131. dxbtnOpenBackupFolder: TdxBarButton;
  132. dxbtnSetBookmark: TdxBarButton;
  133. dxbtnExportFxBillsExcel: TdxBarButton;
  134. actnExportFxBillsExcel: TAction;
  135. dxseBatchInsert: TdxBarSpinEdit;
  136. actnBatchInsert: TAction;
  137. dxbtnRename: TdxBarButton;
  138. dxbtnImportGclBillsToXmj: TdxBarButton;
  139. dxbtnChangeDealBillsMode: TdxBarButton;
  140. dxsiExpandTo: TdxBarSubItem;
  141. dxbtnLocateBookmark: TdxBarButton;
  142. dxbtnSetDealPayPlan: TdxBarButton;
  143. dxbtnAddDetailGLs: TdxBarButton;
  144. dxbtnCopyDetailGls: TdxBarButton;
  145. dxbtnApplyToSameBills: TdxBarButton;
  146. dxbtnCalculatePriceMargin: TdxBarButton;
  147. dxbtnInsertCol: TdxBarButton;
  148. procedure FormCreate(Sender: TObject);
  149. procedure FormDestroy(Sender: TObject);
  150. procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;
  151. var AllowChange: Boolean);
  152. procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  153. procedure jtsProjectsMouseDown(Sender: TObject; Button: TMouseButton;
  154. Shift: TShiftState; X, Y: Integer);
  155. procedure actnCloseProjectExecute(Sender: TObject);
  156. procedure actnCloseProjectUpdate(Sender: TObject);
  157. procedure actnNewPhaseExecute(Sender: TObject);
  158. procedure actnProjectPropertiesUpdate(Sender: TObject);
  159. procedure actnProjectPropertiesExecute(Sender: TObject);
  160. procedure actnSaveProjectExecute(Sender: TObject);
  161. procedure actnNewAuditExecute(Sender: TObject);
  162. procedure actnNewPhaseUpdate(Sender: TObject);
  163. procedure actnOptionsExecute(Sender: TObject);
  164. procedure actnImportExcelExecute(Sender: TObject);
  165. procedure actnReplyExecute(Sender: TObject);
  166. procedure actnSubmitExecute(Sender: TObject);
  167. procedure dxBarManagerShowToolbarsPopup(Sender: TdxBarManager;
  168. PopupItemLinks: TdxBarItemLinks);
  169. procedure actnSubmitUpdate(Sender: TObject);
  170. procedure actnImportExcelUpdate(Sender: TObject);
  171. procedure actnUnlockInfoUpdate(Sender: TObject);
  172. procedure actnUnlockInfoExecute(Sender: TObject);
  173. procedure dxbtnAboutClick(Sender: TObject);
  174. procedure dxLoginCloudClick(Sender: TObject);
  175. procedure dxManageAccountClick(Sender: TObject);
  176. procedure dxbtnAuthorizeDogClick(Sender: TObject);
  177. procedure actnImportBillsPriceExecute(Sender: TObject);
  178. procedure actnImportDealBillsExecute(Sender: TObject);
  179. procedure tAutoSaveTimer(Sender: TObject);
  180. procedure actnExportExcelExecute(Sender: TObject);
  181. procedure dxSyncClick(Sender: TObject);
  182. procedure actnExportCloudTenderFileExecute(Sender: TObject);
  183. procedure actnExportCloudTenderFileUpdate(Sender: TObject);
  184. procedure actnImportCloudTenderFileExecute(Sender: TObject);
  185. procedure actnImportCloudTenderFileUpdate(Sender: TObject);
  186. procedure actnExportFxBillsExcelExecute(Sender: TObject);
  187. procedure dxseBatchInsertKeyDown(Sender: TObject; var Key: Word;
  188. Shift: TShiftState);
  189. procedure actnReplyUpdate(Sender: TObject);
  190. private
  191. FProjectManagerFrame: TProjectManagerFrame;
  192. FProjectFrames: TList;
  193. procedure UpdateProgressBar(APosition: Integer);
  194. procedure UpdateProgressHint(const AHint: string);
  195. procedure CreateProjectView(ARec: TsdDataRecord);
  196. procedure LocateProjectView(AIndex: Integer);
  197. procedure DeleteProjectView(AIndex: Integer);
  198. procedure ResetProcessView(AIndex: Integer);
  199. procedure ChangeLeftSideGlobalView(AIndex: Integer);
  200. function GetCurProjectFrame: TProjectFrame;
  201. procedure ResetAutoSave;
  202. public
  203. procedure UpdateProgress(APos: Integer; const AHint: string);
  204. procedure LocateProject(AProjectID: Integer);
  205. function HasOpened(AProjectID: Integer): Boolean;
  206. procedure OpenProject(ARec: TsdDataRecord);
  207. property CurProjectFrame: TProjectFrame read GetCurProjectFrame;
  208. property ProjectManagerFrame: TProjectManagerFrame read FProjectManagerFrame;
  209. end;
  210. var
  211. MainForm: TMainForm;
  212. implementation
  213. uses
  214. ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
  215. FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
  216. ProjectCommands, BillsCompileDm;
  217. {$R *.dfm}
  218. {$R MeasureIcons.RES}
  219. procedure TMainForm.FormCreate(Sender: TObject);
  220. procedure CreateProjectManagerFrame;
  221. begin
  222. FProjectManagerFrame := TProjectManagerFrame.Create(nil);
  223. AlignControl(FProjectManagerFrame, jpsMainProjectsManager, alClient);
  224. end;
  225. procedure SetHintFont;
  226. begin
  227. if G_IsCloud then
  228. begin
  229. Screen.HintFont.Size := 11;
  230. Screen.HintFont.Name := 'Microsoft YaHei';
  231. end
  232. else
  233. begin
  234. Screen.HintFont.Name := 'SmartSimSun';
  235. Screen.HintFont.Size := 9;
  236. end;
  237. end;
  238. function GetSoftName: string;
  239. begin
  240. if _ModuleType = mtCompile then
  241. Result := '纵横公路工程0号台账软件'
  242. else if _ModuleType = mtAll then
  243. Result := '纵横公路工程结算决算计量一体化软件';
  244. end;
  245. function GetVersionName: string;
  246. begin
  247. Result := '';
  248. if _IsGuangDong then
  249. Result := Result + '广东';
  250. if _ModuleType = mtAll then
  251. begin
  252. if G_IsTest then
  253. Result := '测试'
  254. else if G_IsCloud then
  255. Result := Result + '云'
  256. else if _IsEncrypt then
  257. Result := Result + '专业'
  258. else
  259. Result := Result + '学习';
  260. end;
  261. if Result <> '' then
  262. Result := Result + '版';
  263. end;
  264. procedure InitialForVersions;
  265. var
  266. sPic: string;
  267. begin
  268. if G_IsCloud then
  269. begin
  270. dxbtnNewProject.Visible := ivNever;
  271. dxbtnNewSubProject.Visible := ivNever;
  272. dxbtnReceiveProject.Visible := ivNever;
  273. dxbtnNewPhase.Visible := ivNever;
  274. dxUser.Visible := ivAlways;
  275. dxUser.Caption := PHPWeb.RealName;
  276. lblAccount.Caption := PHPWeb.RealName;
  277. lblMail.Caption := Format('(%s)', [PHPWeb.Account]);
  278. if Trim(PHPWeb.Company) <> '' then
  279. lblCompany.Caption := PHPWeb.Company
  280. else
  281. lblCompany.Caption := '我的单位';
  282. if Trim(PHPWeb.Role) <> '' then
  283. lblRole.Caption := PHPWeb.Role
  284. else
  285. lblRole.Caption := '我的职称';
  286. // 每次登录都下载到本地,再从本地读入显示。以保证图片实时更新。
  287. sPic := PHPWeb.UserPath + '0_' + IntToStr(PHPWeb.UserID) + '.jpg';
  288. if PHPWeb.DownFile(PHPWeb.UserImageURL, sPic) then
  289. if FileExists(sPic) then
  290. imgUserImage.Picture.LoadFromFile(sPic);
  291. end
  292. else
  293. begin
  294. dxUser.Visible := ivNever;
  295. dxbtnReceiveProject.Visible := ivAlways;
  296. end;
  297. MainForm.Caption := GetSoftName + GetVersionName;
  298. end;
  299. begin
  300. CreateProjectManagerFrame;
  301. FProjectFrames := TList.Create;
  302. InitialForVersions;
  303. SetHintFont;
  304. ResetAutoSave;
  305. end;
  306. procedure TMainForm.UpdateProgress(APos: Integer; const AHint: string);
  307. begin
  308. UpdateProgressBar(APos);
  309. UpdateProgressHint(AHint);
  310. Application.ProcessMessages;
  311. end;
  312. procedure TMainForm.UpdateProgressBar(APosition: Integer);
  313. begin
  314. if APosition < ProgressBar.Max then
  315. ProgressBar.Position := APosition
  316. else
  317. ProgressBar.Position := ProgressBar.Min;
  318. end;
  319. procedure TMainForm.UpdateProgressHint(const AHint: string);
  320. begin
  321. dxStatusBar.Panels[0].Text := AHint;
  322. end;
  323. procedure TMainForm.FormDestroy(Sender: TObject);
  324. begin
  325. ClearObjects(FProjectFrames);
  326. FProjectFrames.Free;
  327. FProjectManagerFrame.Free;
  328. end;
  329. procedure TMainForm.OpenProject(ARec: TsdDataRecord);
  330. begin
  331. if not HasOpened(ARec.ValueByName('ID').AsInteger) then
  332. CreateProjectView(ARec)
  333. else
  334. LocateProject(ARec.ValueByName('ID').AsInteger);
  335. end;
  336. function TMainForm.HasOpened(AProjectID: Integer): Boolean;
  337. begin
  338. Result := OpenProjectManager.ProjectIndex(AProjectID) <> -1;
  339. end;
  340. procedure TMainForm.LocateProject(AProjectID: Integer);
  341. begin
  342. jtsProjects.TabIndex := OpenProjectManager.ProjectIndex(AProjectID) + 1;
  343. if jpsMain.ActivePage <> jpsMainProjects then
  344. jpsMain.ActivePage := jpsMainProjects;
  345. end;
  346. procedure TMainForm.CreateProjectView(ARec: TsdDataRecord);
  347. function CreateNewProjectPage: TJimPage;
  348. begin
  349. Result := TJimPage.Create(jpsProjects);
  350. Result.Pages := jpsProjects;
  351. jpsProjects.ActivePage := Result;
  352. end;
  353. function CreateNewProjectTab(const ATabName: string; APage: TJimPage): Integer;
  354. begin
  355. Result := jtsProjects.Tabs.AddObject(ATabName, APage);
  356. jtsProjects.TabIndex := Result;
  357. end;
  358. procedure CreateProjectFrame(AProjectData: TProjectData; APage: TJimPage);
  359. var
  360. ProjectFrame: TProjectFrame;
  361. begin
  362. ProjectFrame := TProjectFrame.Create(AProjectData);
  363. FProjectFrames.Add(ProjectFrame);
  364. ProjectFrame.Parent := APage;
  365. ProjectFrame.Align := alClient;
  366. end;
  367. var
  368. jimPage: TJimPage;
  369. begin
  370. jpsMain.ActivePage := jpsMainProjects;
  371. jimPage := CreateNewProjectPage;
  372. CreateNewProjectTab(ARec.ValueByName('Name').AsString, jimPage);
  373. CreateProjectFrame(OpenProjectManager.Open(ARec), jimPage);
  374. ProjectManager.AddOpenTenderBackup(ARec.ValueByName('ID').AsInteger);
  375. end;
  376. procedure TMainForm.jtsProjectsChange(Sender: TObject; NewTab: Integer;
  377. var AllowChange: Boolean);
  378. begin
  379. LocateProjectView(NewTab - 1);
  380. ResetProcessView(NewTab);
  381. end;
  382. procedure TMainForm.LocateProjectView(AIndex: Integer);
  383. begin
  384. if AIndex >= 0 then
  385. begin
  386. jpsMain.ActivePage := jpsMainProjects;
  387. jpsProjects.ActivePage := TJimPage(jtsProjects.Tabs.Objects[AIndex + 1]);
  388. OpenProjectManager.CurProjectIndex := AIndex;
  389. ChangeLeftSideGlobalView(AIndex);
  390. end
  391. else
  392. jpsMain.ActivePage := jpsMainProjectsManager;
  393. end;
  394. procedure TMainForm.ChangeLeftSideGlobalView(AIndex: Integer);
  395. begin
  396. if (AIndex >= 0) and (AIndex < FProjectFrames.Count) then
  397. TProjectFrame(FProjectFrames[AIndex]).ResetAssistantView;
  398. end;
  399. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  400. begin
  401. try
  402. OpenProjectManager.SaveAll;
  403. except
  404. end;
  405. end;
  406. procedure TMainForm.jtsProjectsMouseDown(Sender: TObject;
  407. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  408. begin
  409. if Button = mbRight then
  410. dxpmTabSet.PopupFromCursorPos;
  411. end;
  412. procedure TMainForm.actnCloseProjectExecute(Sender: TObject);
  413. begin
  414. OpenProjectManager.CurProjectData.Save;
  415. DeleteProjectView(jtsProjects.TabIndex - 1);
  416. LocateProjectView(jtsProjects.TabIndex - 1);
  417. ResetProcessView(jtsProjects.TabIndex);
  418. end;
  419. procedure TMainForm.actnCloseProjectUpdate(Sender: TObject);
  420. begin
  421. TAction(Sender).Enabled := jtsProjects.Tabs.Count > 1;
  422. end;
  423. procedure TMainForm.DeleteProjectView(AIndex: Integer);
  424. begin
  425. TProjectFrame(FProjectFrames[AIndex]).Free;
  426. FProjectFrames.Delete(AIndex);
  427. OpenProjectManager.Delete(AIndex);
  428. jpsProjects.Pages.Delete(AIndex);
  429. jtsProjects.Tabs.Delete(AIndex + 1);
  430. end;
  431. procedure TMainForm.actnNewPhaseExecute(Sender: TObject);
  432. begin
  433. TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1]).CreateNewPhase;
  434. end;
  435. procedure TMainForm.actnProjectPropertiesUpdate(Sender: TObject);
  436. begin
  437. TAction(Sender).Enabled := jtsProjects.TabIndex > 0;
  438. end;
  439. procedure TMainForm.actnProjectPropertiesExecute(Sender: TObject);
  440. begin
  441. ModifyProjectProperties(TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1]));
  442. end;
  443. procedure TMainForm.actnSaveProjectExecute(Sender: TObject);
  444. begin
  445. OpenProjectManager.CurProjectData.Save;
  446. end;
  447. procedure TMainForm.actnNewAuditExecute(Sender: TObject);
  448. begin
  449. TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1]).CreateNewAudit;
  450. end;
  451. procedure TMainForm.actnNewPhaseUpdate(Sender: TObject);
  452. begin
  453. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  454. if TAction(Sender).Enabled then
  455. with CurProjectFrame.ProjectData do
  456. TAction(Sender).Enabled := TAction(Sender).Enabled and (ProjProperties.AuditStatus = -1);
  457. end;
  458. function TMainForm.GetCurProjectFrame: TProjectFrame;
  459. begin
  460. if jtsProjects.TabIndex > 0 then
  461. Result := TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1])
  462. else
  463. Result := nil;
  464. end;
  465. procedure TMainForm.actnOptionsExecute(Sender: TObject);
  466. begin
  467. ModifiedOptions;
  468. ResetAutoSave;
  469. end;
  470. procedure TMainForm.actnImportExcelExecute(Sender: TObject);
  471. var
  472. sFileName: string;
  473. Importor: TBillsEdtExcelImport;
  474. bWithLevelCode, bWithoutGclBills: Boolean;
  475. begin
  476. if HintAndImportTypeSelect(bWithLevelCode, bWithoutGclBills) then
  477. begin
  478. if SelectFile(sFileName, '.xls') then
  479. begin
  480. Importor := TBillsEdtExcelImport.Create(CurProjectFrame.ProjectData);
  481. try
  482. Importor.WithLevelCode := bWithLevelCode;
  483. Importor.WithoutGclBills := bWithoutGclBills;
  484. Importor.ImportFile(sFileName);
  485. finally
  486. Importor.Free;
  487. end;
  488. end;
  489. end;
  490. end;
  491. procedure TMainForm.ResetProcessView(AIndex: Integer);
  492. begin
  493. dxBarManager.Bars[2].Visible := AIndex > 0;
  494. if G_IsCloud then
  495. dxBarManager.Bars[2].Visible := False;
  496. end;
  497. procedure TMainForm.actnReplyExecute(Sender: TObject); // 批复
  498. begin
  499. if not CurProjectFrame.CheckCanReport then Exit;
  500. Screen.Cursor := crHourGlass;
  501. try
  502. CurProjectFrame.ProjectData.Save;
  503. {$O-}
  504. CurProjectFrame.ProjectData.ReplyProject;
  505. {$O+}
  506. finally
  507. Screen.Cursor := crDefault;
  508. end;
  509. end;
  510. procedure TMainForm.actnSubmitExecute(Sender: TObject); // 上报
  511. begin
  512. if not CurProjectFrame.CheckCanReport then Exit;
  513. Screen.Cursor := crHourGlass;
  514. try
  515. CurProjectFrame.ProjectData.Save;
  516. {$O-}
  517. CurProjectFrame.ProjectData.SubmitProject;
  518. {$O+}
  519. finally
  520. Screen.Cursor := crDefault;
  521. end;
  522. end;
  523. procedure TMainForm.dxBarManagerShowToolbarsPopup(Sender: TdxBarManager;
  524. PopupItemLinks: TdxBarItemLinks);
  525. begin
  526. // 取消菜单栏右键菜单
  527. PopupItemLinks.Clear;
  528. end;
  529. procedure TMainForm.actnSubmitUpdate(Sender: TObject);
  530. begin
  531. with CurProjectFrame.ProjectData do
  532. TAction(Sender).Enabled := (ProjProperties.PhaseCount > 0) and
  533. ((ProjProperties.AuditStatus >= 0) and (ProjProperties.AuditStatus < iMaxStageCount-1));
  534. end;
  535. procedure TMainForm.actnImportExcelUpdate(Sender: TObject);
  536. begin
  537. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  538. if TAction(Sender).Enabled then
  539. with CurProjectFrame.ProjectData do
  540. TAction(Sender).Enabled := TAction(Sender).Enabled and (PhaseIndex < 1);
  541. end;
  542. procedure TMainForm.actnUnlockInfoUpdate(Sender: TObject);
  543. begin
  544. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  545. end;
  546. procedure TMainForm.actnUnlockInfoExecute(Sender: TObject);
  547. begin
  548. CurProjectFrame.UnLockData;
  549. end;
  550. procedure TMainForm.dxbtnAboutClick(Sender: TObject);
  551. begin
  552. ShowAboutForm;
  553. end;
  554. procedure TMainForm.dxLoginCloudClick(Sender: TObject);
  555. begin
  556. ShellExecute(Application.Handle, nil, PChar(PHPWeb.LoginCloudURL), nil, nil, SW_SHOWNORMAL);
  557. end;
  558. procedure TMainForm.dxManageAccountClick(Sender: TObject);
  559. begin
  560. ShellExecute(Application.Handle, nil, PChar(PHPWeb.PassportURL), nil, nil, SW_SHOWNORMAL);
  561. end;
  562. procedure TMainForm.dxbtnAuthorizeDogClick(Sender: TObject);
  563. begin
  564. Authorize;
  565. end;
  566. procedure TMainForm.actnImportBillsPriceExecute(Sender: TObject);
  567. var
  568. sFileName: string;
  569. Importor: TBillsPriceExcelImport;
  570. begin
  571. if SelectFile(sFileName, '.xls') then
  572. begin
  573. Importor := TBillsPriceExcelImport.Create(CurProjectFrame.ProjectData);
  574. try
  575. Importor.ImportFile(sFileName);
  576. finally
  577. Importor.Free;
  578. end;
  579. end;
  580. end;
  581. procedure TMainForm.actnImportDealBillsExecute(Sender: TObject);
  582. var
  583. sFileName: string;
  584. Importor: TDealBillsExcelImport;
  585. begin
  586. if SelectFile(sFileName, '.xls') then
  587. begin
  588. Importor := TDealBillsExcelImport.Create(CurProjectFrame.ProjectData);
  589. try
  590. Importor.ImportFile(sFileName);
  591. finally
  592. Importor.Free;
  593. end;
  594. end;
  595. end;
  596. procedure TMainForm.tAutoSaveTimer(Sender: TObject);
  597. begin
  598. Screen.Cursor := crHourGlass;
  599. try
  600. OpenProjectManager.SaveAll;
  601. finally
  602. screen.Cursor := crDefault;
  603. end;
  604. end;
  605. procedure TMainForm.ResetAutoSave;
  606. begin
  607. with SupportManager.ConfigInfo do
  608. begin
  609. tAutoSave.Interval := AutoSaveInterval * 60 * 1000;
  610. tAutoSave.Enabled := AutoSave;
  611. end;
  612. end;
  613. procedure TMainForm.actnExportExcelExecute(Sender: TObject);
  614. var
  615. sFileName: string;
  616. Exportor: TIDTreeExcelExportor;
  617. begin
  618. if SaveFile(sFileName, '.xls') then
  619. begin
  620. Exportor := TIDTreeExcelExportor.Create;
  621. try
  622. Exportor.DefineCol(@ciLedger, Length(ciLedger));
  623. Exportor.HasLevelCode := True;
  624. Exportor.ExportToFile(CurProjectFrame.ProjectData.BillsCompileData.BillsCompileTree, sFileName);
  625. finally
  626. Exportor.Free;
  627. end;
  628. end;
  629. end;
  630. procedure TMainForm.dxSyncClick(Sender: TObject);
  631. begin
  632. Screen.Cursor := crHourGlass;
  633. try
  634. FProjectManagerFrame.DoBatchReceiveAllOnline;
  635. finally
  636. Screen.Cursor := crDefault;
  637. end;
  638. end;
  639. procedure TMainForm.actnExportCloudTenderFileExecute(Sender: TObject);
  640. var
  641. sFileName: string;
  642. Exportor: TTenderExport;
  643. Rec: TsdDataRecord;
  644. begin
  645. // 导出前先保存
  646. CurProjectFrame.ProjectData.Save;
  647. // 导出云版专用
  648. sFileName := SupportManager.ConfigInfo.OutputPath + CurProjectFrame.ProjectData.ProjectName;
  649. if SaveFile(sFileName, '.ctf') then
  650. begin
  651. if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
  652. Exit;
  653. Screen.Cursor := crHourGlass;
  654. try
  655. Rec := ProjectManagerFrame.Rec(CurProjectFrame.ProjectData.ProjectID);
  656. Exportor := TTenderExport.Create(Rec, sFileName);
  657. try
  658. Exportor.Execute;
  659. finally
  660. Exportor.Free;
  661. end;
  662. finally
  663. Screen.Cursor := crDefault;
  664. end;
  665. end;
  666. end;
  667. procedure TMainForm.actnExportCloudTenderFileUpdate(Sender: TObject);
  668. begin
  669. // 仅打开的项目可以导出云版专用格式,且该项目没有进行计量
  670. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  671. if TAction(Sender).Enabled then
  672. TAction(Sender).Enabled := CurProjectFrame.ProjectData.ProjProperties.PhaseCount = 0;
  673. end;
  674. procedure TMainForm.actnImportCloudTenderFileExecute(Sender: TObject);
  675. var
  676. sFileName: string;
  677. begin
  678. if SelectFile(sFileName, '.ctf') then
  679. begin
  680. CurProjectFrame.ProjectData.ImportCloudTenderFile(sFileName);
  681. CurProjectFrame.RefreshColumnDisplay;
  682. end;
  683. end;
  684. procedure TMainForm.actnImportCloudTenderFileUpdate(Sender: TObject);
  685. begin
  686. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  687. if TAction(Sender).Enabled then
  688. TAction(Sender).Enabled := CurProjectFrame.ProjectData.ProjProperties.PhaseCount = 0;
  689. end;
  690. procedure TMainForm.actnExportFxBillsExcelExecute(Sender: TObject);
  691. var
  692. sFileName: string;
  693. Exportor: TIDTreeExcelExportor;
  694. begin
  695. if SaveFile(sFileName, '.xls') then
  696. begin
  697. Exportor := TIDTreeExcelExportor.Create;
  698. try
  699. Exportor.DefineCol(@ciFxBills, Length(ciFxBills));
  700. Exportor.ExportToFile(CurProjectFrame.ProjectData.BillsCompileData.BillsCompileTree, sFileName);
  701. finally
  702. Exportor.Free;
  703. end;
  704. end;
  705. end;
  706. procedure TMainForm.dxseBatchInsertKeyDown(Sender: TObject; var Key: Word;
  707. Shift: TShiftState);
  708. var
  709. i: Integer;
  710. begin
  711. if Key = 13 then
  712. begin
  713. for i := 1 to dxseBatchInsert.IntValue do
  714. ZjDbaInsert.ExecuteTarget(CurProjectFrame.BillsCompileFrame.zgBillsCompile);
  715. end;
  716. end;
  717. procedure TMainForm.actnReplyUpdate(Sender: TObject);
  718. begin
  719. with CurProjectFrame.ProjectData do
  720. TAction(Sender).Enabled := (ProjProperties.PhaseCount > 0);
  721. end;
  722. end.