MainFrm.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  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. procedure FormCreate(Sender: TObject);
  147. procedure FormDestroy(Sender: TObject);
  148. procedure jtsProjectsChange(Sender: TObject; NewTab: Integer;
  149. var AllowChange: Boolean);
  150. procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  151. procedure jtsProjectsMouseDown(Sender: TObject; Button: TMouseButton;
  152. Shift: TShiftState; X, Y: Integer);
  153. procedure actnCloseProjectExecute(Sender: TObject);
  154. procedure actnCloseProjectUpdate(Sender: TObject);
  155. procedure actnNewPhaseExecute(Sender: TObject);
  156. procedure actnProjectPropertiesUpdate(Sender: TObject);
  157. procedure actnProjectPropertiesExecute(Sender: TObject);
  158. procedure actnSaveProjectExecute(Sender: TObject);
  159. procedure actnNewAuditExecute(Sender: TObject);
  160. procedure actnNewPhaseUpdate(Sender: TObject);
  161. procedure actnOptionsExecute(Sender: TObject);
  162. procedure actnImportExcelExecute(Sender: TObject);
  163. procedure actnReplyExecute(Sender: TObject);
  164. procedure actnSubmitExecute(Sender: TObject);
  165. procedure dxBarManagerShowToolbarsPopup(Sender: TdxBarManager;
  166. PopupItemLinks: TdxBarItemLinks);
  167. procedure actnSubmitUpdate(Sender: TObject);
  168. procedure actnImportExcelUpdate(Sender: TObject);
  169. procedure actnUnlockInfoUpdate(Sender: TObject);
  170. procedure actnUnlockInfoExecute(Sender: TObject);
  171. procedure dxbtnAboutClick(Sender: TObject);
  172. procedure dxLoginCloudClick(Sender: TObject);
  173. procedure dxManageAccountClick(Sender: TObject);
  174. procedure dxbtnAuthorizeDogClick(Sender: TObject);
  175. procedure actnImportBillsPriceExecute(Sender: TObject);
  176. procedure actnImportDealBillsExecute(Sender: TObject);
  177. procedure tAutoSaveTimer(Sender: TObject);
  178. procedure actnExportExcelExecute(Sender: TObject);
  179. procedure dxSyncClick(Sender: TObject);
  180. procedure actnExportCloudTenderFileExecute(Sender: TObject);
  181. procedure actnExportCloudTenderFileUpdate(Sender: TObject);
  182. procedure actnImportCloudTenderFileExecute(Sender: TObject);
  183. procedure actnImportCloudTenderFileUpdate(Sender: TObject);
  184. procedure actnExportFxBillsExcelExecute(Sender: TObject);
  185. procedure dxseBatchInsertKeyDown(Sender: TObject; var Key: Word;
  186. Shift: TShiftState);
  187. procedure actnReplyUpdate(Sender: TObject);
  188. private
  189. FProjectManagerFrame: TProjectManagerFrame;
  190. FProjectFrames: TList;
  191. procedure UpdateProgressBar(APosition: Integer);
  192. procedure UpdateProgressHint(const AHint: string);
  193. procedure CreateProjectView(ARec: TsdDataRecord);
  194. procedure LocateProjectView(AIndex: Integer);
  195. procedure DeleteProjectView(AIndex: Integer);
  196. procedure ResetProcessView(AIndex: Integer);
  197. procedure ChangeLeftSideGlobalView(AIndex: Integer);
  198. function GetCurProjectFrame: TProjectFrame;
  199. procedure ResetAutoSave;
  200. public
  201. procedure UpdateProgress(APos: Integer; const AHint: string);
  202. procedure LocateProject(AProjectID: Integer);
  203. function HasOpened(AProjectID: Integer): Boolean;
  204. procedure OpenProject(ARec: TsdDataRecord);
  205. property CurProjectFrame: TProjectFrame read GetCurProjectFrame;
  206. property ProjectManagerFrame: TProjectManagerFrame read FProjectManagerFrame;
  207. end;
  208. var
  209. MainForm: TMainForm;
  210. implementation
  211. uses
  212. ProjectProperty, ConstUnit, PHPWebDm, Math, ShellAPI,
  213. FindUserFrm, ImportExcelHintFrm, ConfigDoc, ExportExcel,
  214. ProjectCommands, BillsCompileDm;
  215. {$R *.dfm}
  216. {$R MeasureIcons.RES}
  217. procedure TMainForm.FormCreate(Sender: TObject);
  218. procedure CreateProjectManagerFrame;
  219. begin
  220. FProjectManagerFrame := TProjectManagerFrame.Create(nil);
  221. AlignControl(FProjectManagerFrame, jpsMainProjectsManager, alClient);
  222. end;
  223. procedure SetHintFont;
  224. begin
  225. if G_IsCloud then
  226. begin
  227. Screen.HintFont.Size := 11;
  228. Screen.HintFont.Name := 'Microsoft YaHei';
  229. end
  230. else
  231. begin
  232. Screen.HintFont.Name := 'SmartSimSun';
  233. Screen.HintFont.Size := 9;
  234. end;
  235. end;
  236. function GetSoftName: string;
  237. begin
  238. if _ModuleType = mtCompile then
  239. Result := '纵横公路工程0号台账软件'
  240. else if _ModuleType = mtAll then
  241. Result := '纵横公路工程结算决算计量一体化软件';
  242. end;
  243. function GetVersionName: string;
  244. begin
  245. Result := '';
  246. if _IsGuangDong then
  247. Result := Result + '广东';
  248. if _ModuleType = mtAll then
  249. begin
  250. if G_IsCloud then
  251. Result := Result + '云'
  252. else if _IsEncrypt then
  253. Result := Result + '专业'
  254. else
  255. Result := Result + '学习';
  256. end;
  257. if Result <> '' then
  258. Result := Result + '版';
  259. end;
  260. procedure InitialForVersions;
  261. var
  262. sPic: string;
  263. begin
  264. if G_IsCloud then
  265. begin
  266. dxbtnNewProject.Visible := ivNever;
  267. dxbtnNewSubProject.Visible := ivNever;
  268. dxbtnReceiveProject.Visible := ivNever;
  269. dxbtnNewPhase.Visible := ivNever;
  270. dxUser.Visible := ivAlways;
  271. dxUser.Caption := PHPWeb.RealName;
  272. lblAccount.Caption := PHPWeb.RealName;
  273. lblMail.Caption := Format('(%s)', [PHPWeb.Account]);
  274. if Trim(PHPWeb.Company) <> '' then
  275. lblCompany.Caption := PHPWeb.Company
  276. else
  277. lblCompany.Caption := '我的单位';
  278. if Trim(PHPWeb.Role) <> '' then
  279. lblRole.Caption := PHPWeb.Role
  280. else
  281. lblRole.Caption := '我的职称';
  282. // 每次登录都下载到本地,再从本地读入显示。以保证图片实时更新。
  283. sPic := PHPWeb.UserPath + '0_' + IntToStr(PHPWeb.UserID) + '.jpg';
  284. if PHPWeb.DownFile(PHPWeb.UserImageURL, sPic) then
  285. if FileExists(sPic) then
  286. imgUserImage.Picture.LoadFromFile(sPic);
  287. end
  288. else
  289. begin
  290. dxUser.Visible := ivNever;
  291. dxbtnReceiveProject.Visible := ivAlways;
  292. end;
  293. MainForm.Caption := GetSoftName + GetVersionName;
  294. end;
  295. begin
  296. CreateProjectManagerFrame;
  297. FProjectFrames := TList.Create;
  298. InitialForVersions;
  299. SetHintFont;
  300. ResetAutoSave;
  301. end;
  302. procedure TMainForm.UpdateProgress(APos: Integer; const AHint: string);
  303. begin
  304. UpdateProgressBar(APos);
  305. UpdateProgressHint(AHint);
  306. Application.ProcessMessages;
  307. end;
  308. procedure TMainForm.UpdateProgressBar(APosition: Integer);
  309. begin
  310. if APosition < ProgressBar.Max then
  311. ProgressBar.Position := APosition
  312. else
  313. ProgressBar.Position := ProgressBar.Min;
  314. end;
  315. procedure TMainForm.UpdateProgressHint(const AHint: string);
  316. begin
  317. dxStatusBar.Panels[0].Text := AHint;
  318. end;
  319. procedure TMainForm.FormDestroy(Sender: TObject);
  320. begin
  321. ClearObjects(FProjectFrames);
  322. FProjectFrames.Free;
  323. FProjectManagerFrame.Free;
  324. end;
  325. procedure TMainForm.OpenProject(ARec: TsdDataRecord);
  326. begin
  327. if not HasOpened(ARec.ValueByName('ID').AsInteger) then
  328. CreateProjectView(ARec)
  329. else
  330. LocateProject(ARec.ValueByName('ID').AsInteger);
  331. end;
  332. function TMainForm.HasOpened(AProjectID: Integer): Boolean;
  333. begin
  334. Result := OpenProjectManager.ProjectIndex(AProjectID) <> -1;
  335. end;
  336. procedure TMainForm.LocateProject(AProjectID: Integer);
  337. begin
  338. jtsProjects.TabIndex := OpenProjectManager.ProjectIndex(AProjectID) + 1;
  339. if jpsMain.ActivePage <> jpsMainProjects then
  340. jpsMain.ActivePage := jpsMainProjects;
  341. end;
  342. procedure TMainForm.CreateProjectView(ARec: TsdDataRecord);
  343. function CreateNewProjectPage: TJimPage;
  344. begin
  345. Result := TJimPage.Create(jpsProjects);
  346. Result.Pages := jpsProjects;
  347. jpsProjects.ActivePage := Result;
  348. end;
  349. function CreateNewProjectTab(const ATabName: string; APage: TJimPage): Integer;
  350. begin
  351. Result := jtsProjects.Tabs.AddObject(ATabName, APage);
  352. jtsProjects.TabIndex := Result;
  353. end;
  354. procedure CreateProjectFrame(AProjectData: TProjectData; APage: TJimPage);
  355. var
  356. ProjectFrame: TProjectFrame;
  357. begin
  358. ProjectFrame := TProjectFrame.Create(AProjectData);
  359. FProjectFrames.Add(ProjectFrame);
  360. ProjectFrame.Parent := APage;
  361. ProjectFrame.Align := alClient;
  362. end;
  363. var
  364. jimPage: TJimPage;
  365. begin
  366. jpsMain.ActivePage := jpsMainProjects;
  367. jimPage := CreateNewProjectPage;
  368. CreateNewProjectTab(ARec.ValueByName('Name').AsString, jimPage);
  369. CreateProjectFrame(OpenProjectManager.Open(ARec), jimPage);
  370. ProjectManager.AddOpenTenderBackup(ARec.ValueByName('ID').AsInteger);
  371. end;
  372. procedure TMainForm.jtsProjectsChange(Sender: TObject; NewTab: Integer;
  373. var AllowChange: Boolean);
  374. begin
  375. LocateProjectView(NewTab - 1);
  376. ResetProcessView(NewTab);
  377. end;
  378. procedure TMainForm.LocateProjectView(AIndex: Integer);
  379. begin
  380. if AIndex >= 0 then
  381. begin
  382. jpsMain.ActivePage := jpsMainProjects;
  383. jpsProjects.ActivePage := TJimPage(jtsProjects.Tabs.Objects[AIndex + 1]);
  384. OpenProjectManager.CurProjectIndex := AIndex;
  385. ChangeLeftSideGlobalView(AIndex);
  386. end
  387. else
  388. jpsMain.ActivePage := jpsMainProjectsManager;
  389. end;
  390. procedure TMainForm.ChangeLeftSideGlobalView(AIndex: Integer);
  391. begin
  392. if (AIndex >= 0) and (AIndex < FProjectFrames.Count) then
  393. TProjectFrame(FProjectFrames[AIndex]).ResetAssistantView;
  394. end;
  395. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  396. begin
  397. try
  398. OpenProjectManager.SaveAll;
  399. except
  400. end;
  401. end;
  402. procedure TMainForm.jtsProjectsMouseDown(Sender: TObject;
  403. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  404. begin
  405. if Button = mbRight then
  406. dxpmTabSet.PopupFromCursorPos;
  407. end;
  408. procedure TMainForm.actnCloseProjectExecute(Sender: TObject);
  409. begin
  410. OpenProjectManager.CurProjectData.Save;
  411. DeleteProjectView(jtsProjects.TabIndex - 1);
  412. LocateProjectView(jtsProjects.TabIndex - 1);
  413. ResetProcessView(jtsProjects.TabIndex);
  414. end;
  415. procedure TMainForm.actnCloseProjectUpdate(Sender: TObject);
  416. begin
  417. TAction(Sender).Enabled := jtsProjects.Tabs.Count > 1;
  418. end;
  419. procedure TMainForm.DeleteProjectView(AIndex: Integer);
  420. begin
  421. TProjectFrame(FProjectFrames[AIndex]).Free;
  422. FProjectFrames.Delete(AIndex);
  423. OpenProjectManager.Delete(AIndex);
  424. jpsProjects.Pages.Delete(AIndex);
  425. jtsProjects.Tabs.Delete(AIndex + 1);
  426. end;
  427. procedure TMainForm.actnNewPhaseExecute(Sender: TObject);
  428. begin
  429. TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1]).CreateNewPhase;
  430. end;
  431. procedure TMainForm.actnProjectPropertiesUpdate(Sender: TObject);
  432. begin
  433. TAction(Sender).Enabled := jtsProjects.TabIndex > 0;
  434. end;
  435. procedure TMainForm.actnProjectPropertiesExecute(Sender: TObject);
  436. begin
  437. ModifyProjectProperties(TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1]));
  438. end;
  439. procedure TMainForm.actnSaveProjectExecute(Sender: TObject);
  440. begin
  441. OpenProjectManager.CurProjectData.Save;
  442. end;
  443. procedure TMainForm.actnNewAuditExecute(Sender: TObject);
  444. begin
  445. TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1]).CreateNewAudit;
  446. end;
  447. procedure TMainForm.actnNewPhaseUpdate(Sender: TObject);
  448. begin
  449. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  450. if TAction(Sender).Enabled then
  451. with CurProjectFrame.ProjectData do
  452. TAction(Sender).Enabled := TAction(Sender).Enabled and (ProjProperties.AuditStatus = -1);
  453. end;
  454. function TMainForm.GetCurProjectFrame: TProjectFrame;
  455. begin
  456. if jtsProjects.TabIndex > 0 then
  457. Result := TProjectFrame(FProjectFrames[jtsProjects.TabIndex - 1])
  458. else
  459. Result := nil;
  460. end;
  461. procedure TMainForm.actnOptionsExecute(Sender: TObject);
  462. begin
  463. ModifiedOptions;
  464. ResetAutoSave;
  465. end;
  466. procedure TMainForm.actnImportExcelExecute(Sender: TObject);
  467. var
  468. sFileName: string;
  469. Importor: TBillsEdtExcelImport;
  470. bWithLevelCode, bWithoutGclBills: Boolean;
  471. begin
  472. if HintAndImportTypeSelect(bWithLevelCode, bWithoutGclBills) then
  473. begin
  474. if SelectFile(sFileName, '.xls') then
  475. begin
  476. Importor := TBillsEdtExcelImport.Create(CurProjectFrame.ProjectData);
  477. try
  478. Importor.WithLevelCode := bWithLevelCode;
  479. Importor.WithoutGclBills := bWithoutGclBills;
  480. Importor.ImportFile(sFileName);
  481. finally
  482. Importor.Free;
  483. end;
  484. end;
  485. end;
  486. end;
  487. procedure TMainForm.ResetProcessView(AIndex: Integer);
  488. begin
  489. dxBarManager.Bars[2].Visible := AIndex > 0;
  490. if G_IsCloud then
  491. dxBarManager.Bars[2].Visible := False;
  492. end;
  493. procedure TMainForm.actnReplyExecute(Sender: TObject); // 批复
  494. begin
  495. if not CurProjectFrame.CheckCanReport then Exit;
  496. Screen.Cursor := crHourGlass;
  497. try
  498. CurProjectFrame.ProjectData.Save;
  499. {$O-}
  500. CurProjectFrame.ProjectData.ReplyProject;
  501. {$O+}
  502. finally
  503. Screen.Cursor := crDefault;
  504. end;
  505. end;
  506. procedure TMainForm.actnSubmitExecute(Sender: TObject); // 上报
  507. begin
  508. if not CurProjectFrame.CheckCanReport then Exit;
  509. Screen.Cursor := crHourGlass;
  510. try
  511. CurProjectFrame.ProjectData.Save;
  512. {$O-}
  513. CurProjectFrame.ProjectData.SubmitProject;
  514. {$O+}
  515. finally
  516. Screen.Cursor := crDefault;
  517. end;
  518. end;
  519. procedure TMainForm.dxBarManagerShowToolbarsPopup(Sender: TdxBarManager;
  520. PopupItemLinks: TdxBarItemLinks);
  521. begin
  522. // 取消菜单栏右键菜单
  523. PopupItemLinks.Clear;
  524. end;
  525. procedure TMainForm.actnSubmitUpdate(Sender: TObject);
  526. begin
  527. with CurProjectFrame.ProjectData do
  528. TAction(Sender).Enabled := (ProjProperties.PhaseCount > 0) and
  529. ((ProjProperties.AuditStatus >= 0) and (ProjProperties.AuditStatus < iMaxStageCount-1));
  530. end;
  531. procedure TMainForm.actnImportExcelUpdate(Sender: TObject);
  532. begin
  533. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  534. if TAction(Sender).Enabled then
  535. with CurProjectFrame.ProjectData do
  536. TAction(Sender).Enabled := TAction(Sender).Enabled and (PhaseIndex < 1);
  537. end;
  538. procedure TMainForm.actnUnlockInfoUpdate(Sender: TObject);
  539. begin
  540. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  541. end;
  542. procedure TMainForm.actnUnlockInfoExecute(Sender: TObject);
  543. begin
  544. CurProjectFrame.UnLockData;
  545. end;
  546. procedure TMainForm.dxbtnAboutClick(Sender: TObject);
  547. begin
  548. ShowAboutForm;
  549. end;
  550. procedure TMainForm.dxLoginCloudClick(Sender: TObject);
  551. begin
  552. ShellExecute(Application.Handle, nil, PChar(PHPWeb.LoginCloudURL), nil, nil, SW_SHOWNORMAL);
  553. end;
  554. procedure TMainForm.dxManageAccountClick(Sender: TObject);
  555. begin
  556. ShellExecute(Application.Handle, nil, PChar(PHPWeb.PassportURL), nil, nil, SW_SHOWNORMAL);
  557. end;
  558. procedure TMainForm.dxbtnAuthorizeDogClick(Sender: TObject);
  559. begin
  560. Authorize;
  561. end;
  562. procedure TMainForm.actnImportBillsPriceExecute(Sender: TObject);
  563. var
  564. sFileName: string;
  565. Importor: TBillsPriceExcelImport;
  566. begin
  567. if SelectFile(sFileName, '.xls') then
  568. begin
  569. Importor := TBillsPriceExcelImport.Create(CurProjectFrame.ProjectData);
  570. try
  571. Importor.ImportFile(sFileName);
  572. finally
  573. Importor.Free;
  574. end;
  575. end;
  576. end;
  577. procedure TMainForm.actnImportDealBillsExecute(Sender: TObject);
  578. var
  579. sFileName: string;
  580. Importor: TDealBillsExcelImport;
  581. begin
  582. if SelectFile(sFileName, '.xls') then
  583. begin
  584. Importor := TDealBillsExcelImport.Create(CurProjectFrame.ProjectData);
  585. try
  586. Importor.ImportFile(sFileName);
  587. finally
  588. Importor.Free;
  589. end;
  590. end;
  591. end;
  592. procedure TMainForm.tAutoSaveTimer(Sender: TObject);
  593. begin
  594. Screen.Cursor := crHourGlass;
  595. try
  596. OpenProjectManager.SaveAll;
  597. finally
  598. screen.Cursor := crDefault;
  599. end;
  600. end;
  601. procedure TMainForm.ResetAutoSave;
  602. begin
  603. with SupportManager.ConfigInfo do
  604. begin
  605. tAutoSave.Interval := AutoSaveInterval * 60 * 1000;
  606. tAutoSave.Enabled := AutoSave;
  607. end;
  608. end;
  609. procedure TMainForm.actnExportExcelExecute(Sender: TObject);
  610. var
  611. sFileName: string;
  612. Exportor: TIDTreeExcelExportor;
  613. begin
  614. if SaveFile(sFileName, '.xls') then
  615. begin
  616. Exportor := TIDTreeExcelExportor.Create;
  617. try
  618. Exportor.DefineCol(@ciLedger, Length(ciLedger));
  619. Exportor.HasLevelCode := True;
  620. Exportor.ExportToFile(CurProjectFrame.ProjectData.BillsCompileData.BillsCompileTree, sFileName);
  621. finally
  622. Exportor.Free;
  623. end;
  624. end;
  625. end;
  626. procedure TMainForm.dxSyncClick(Sender: TObject);
  627. begin
  628. Screen.Cursor := crHourGlass;
  629. try
  630. FProjectManagerFrame.DoBatchReceiveAllOnline;
  631. finally
  632. Screen.Cursor := crDefault;
  633. end;
  634. end;
  635. procedure TMainForm.actnExportCloudTenderFileExecute(Sender: TObject);
  636. var
  637. sFileName: string;
  638. Exportor: TTenderExport;
  639. Rec: TsdDataRecord;
  640. begin
  641. // 导出前先保存
  642. CurProjectFrame.ProjectData.Save;
  643. // 导出云版专用
  644. sFileName := SupportManager.ConfigInfo.OutputPath + CurProjectFrame.ProjectData.ProjectName;
  645. if SaveFile(sFileName, '.ctf') then
  646. begin
  647. if FileExists(sFileName) and not QuestMessage(Format('存在同名文件“%s”,是否替换?', [ExtractFileName(sFileName)])) then
  648. Exit;
  649. Screen.Cursor := crHourGlass;
  650. try
  651. Rec := ProjectManagerFrame.Rec(CurProjectFrame.ProjectData.ProjectID);
  652. Exportor := TTenderExport.Create(Rec, sFileName);
  653. try
  654. Exportor.Execute;
  655. finally
  656. Exportor.Free;
  657. end;
  658. finally
  659. Screen.Cursor := crDefault;
  660. end;
  661. end;
  662. end;
  663. procedure TMainForm.actnExportCloudTenderFileUpdate(Sender: TObject);
  664. begin
  665. // 仅打开的项目可以导出云版专用格式,且该项目没有进行计量
  666. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  667. if TAction(Sender).Enabled then
  668. TAction(Sender).Enabled := CurProjectFrame.ProjectData.ProjProperties.PhaseCount = 0;
  669. end;
  670. procedure TMainForm.actnImportCloudTenderFileExecute(Sender: TObject);
  671. var
  672. sFileName: string;
  673. begin
  674. if SelectFile(sFileName, '.ctf') then
  675. begin
  676. CurProjectFrame.ProjectData.ImportCloudTenderFile(sFileName);
  677. CurProjectFrame.RefreshColumnDisplay;
  678. end;
  679. end;
  680. procedure TMainForm.actnImportCloudTenderFileUpdate(Sender: TObject);
  681. begin
  682. TAction(Sender).Enabled := (jtsProjects.Tabs.Count > 1) and Assigned(CurProjectFrame);
  683. if TAction(Sender).Enabled then
  684. TAction(Sender).Enabled := CurProjectFrame.ProjectData.ProjProperties.PhaseCount = 0;
  685. end;
  686. procedure TMainForm.actnExportFxBillsExcelExecute(Sender: TObject);
  687. var
  688. sFileName: string;
  689. Exportor: TIDTreeExcelExportor;
  690. begin
  691. if SaveFile(sFileName, '.xls') then
  692. begin
  693. Exportor := TIDTreeExcelExportor.Create;
  694. try
  695. Exportor.DefineCol(@ciFxBills, Length(ciFxBills));
  696. Exportor.ExportToFile(CurProjectFrame.ProjectData.BillsCompileData.BillsCompileTree, sFileName);
  697. finally
  698. Exportor.Free;
  699. end;
  700. end;
  701. end;
  702. procedure TMainForm.dxseBatchInsertKeyDown(Sender: TObject; var Key: Word;
  703. Shift: TShiftState);
  704. var
  705. i: Integer;
  706. begin
  707. if Key = 13 then
  708. begin
  709. for i := 1 to dxseBatchInsert.IntValue do
  710. ZjDbaInsert.ExecuteTarget(CurProjectFrame.BillsCompileFrame.zgBillsCompile);
  711. end;
  712. end;
  713. procedure TMainForm.actnReplyUpdate(Sender: TObject);
  714. begin
  715. with CurProjectFrame.ProjectData do
  716. TAction(Sender).Enabled := (ProjProperties.PhaseCount > 0);
  717. end;
  718. end.