ProjectData.pas 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  1. unit ProjectData;
  2. interface
  3. uses
  4. Connections, BillsDm, PhaseData, UpdateDataBase, ZhAPI, ProjectProperty,
  5. PhaseCompareDm, DealPaymentDm, SearchDm, DealBillsDm, MainDataListDm,
  6. BillsGatherDm, BGLDm, StaffDm, BillsCompileDm, BillsMeasureDm,
  7. BillsBookmarkDm, UpFileManageUnit,
  8. Classes, SysUtils, ADODB, sdDB, Checker;
  9. type
  10. TProjectData = class
  11. private
  12. // 临时文件夹,解压项目后存放文件的文件夹
  13. FTempFolder: string;
  14. // 项目管理界面看到的项目名称
  15. FProjectName: string;
  16. FFileName: string;
  17. FProjectID: Integer;
  18. FConnection: TEncryptConnection;
  19. FUpdator: TUpdateProjectDB;
  20. FIsNewFile: Boolean;
  21. FBillsData: TBillsData;
  22. FBillsCompileData: TBillsCompileData;
  23. FBillsMeasureData: TBillsMeasureData;
  24. FBillsBookmarkData: TBillsBookmarkData;
  25. FDealBillsData: TDealBillsData;
  26. FProjProperties: TProjProperties;
  27. FPhaseIndex: Integer;
  28. FPhaseData: TPhaseData;
  29. FPhaseCompareData: TPhaseCompareData;
  30. FBillsGatherData: TBillsGatherData;
  31. FDealPaymentData: TDealPaymentData;
  32. FBGLData: TBGLData;
  33. FStaffData: TStaffData;
  34. FSearchData: TSearchData;
  35. FMainListData: TMainListData;
  36. FCanUnlockInfo: Boolean;
  37. FWebID: Integer;
  38. FWebOwnerID: Integer;
  39. FWebAuthorID: Integer;
  40. FAuthorHasSubmited: Boolean;
  41. FProjectReadOnly: Boolean;
  42. FAttachmentData: TUpFiles;
  43. FCheckers: TCheckers;
  44. {For Open}
  45. procedure UpdateProjectDataBase;
  46. procedure CheckNewFile(AConnection: TADOConnection);
  47. procedure OpenLastPhaseData;
  48. procedure UpdateOldData;
  49. procedure SaveInfoToManager;
  50. procedure ExecuteSql(const ASql: string);
  51. // 备份0号台账的历史数据
  52. procedure CopyLedgerHistoryData(AAudit: Integer);
  53. // 备份各期的截止本期累计完成数据
  54. procedure CopyPhaseCompleteData;
  55. procedure SetPhaseIndexSimple(AIndex: Integer);
  56. // 锁定数据 -- Sql语句方式(使用时注意相应的DataMoudle应处于关闭状态)
  57. procedure LockBillsBaseData;
  58. procedure LockDealPaymentData;
  59. procedure LockBGLData;
  60. procedure UpdatePhaseData;
  61. procedure CloseAllData;
  62. procedure OpenAllData;
  63. function GetMainFileName: string;
  64. procedure SetPhaseIndex(const Value: Integer);
  65. function GetTempPath: string;
  66. function GetProjectFileName: string;
  67. function GetAllowInsert: Boolean;
  68. function GetBaseDataReadOnly: Boolean;
  69. function GetADOConnection: TADOConnection;
  70. procedure SetCheckers(const Value: TCheckers);
  71. function GetStageDataReadOnly: Boolean;
  72. public
  73. constructor Create;
  74. destructor Destroy; override;
  75. procedure Open(AProjRec: TsdDataRecord);
  76. procedure Save;
  77. //----------------------- Begin ---后台打开 ------------------------
  78. {总说明:
  79. 为节省内存使用,对不同的后台打开分别写不同的方法
  80. 按需使用,稍有不同,则新增后台打开方法
  81. 变更(新增)方法须同步变更(新增)注释
  82. }
  83. {OpenForSubmit: ProjProperties, StaffData}
  84. procedure OpenForSubmit(const AFileName: string);
  85. procedure SaveAsForSubmit(const AFileName: string);
  86. {OpenForReply: ProjProperties, StaffData, PhaseData}
  87. procedure OpenForReply(const AFileName: string);
  88. procedure SaveForReply(const AFileName: string);
  89. {OpenForReceive: ProjProperties, StaffData, PhaseData, StageData}
  90. procedure OpenForReceive(const AFileName: string);
  91. procedure SaveForReceive(const AFileName: string);
  92. {SimpleOpen: 仅打开数据库[项目+最后一期],不打开除属性以外的任何数据表(项目属性都是通过Sql语句修改)}
  93. procedure SimpleOpen(const AFileName: string);
  94. procedure SimpleSaveAs(const AFileName: string);
  95. {OpenForReport: BillsData, BillsCompileData, DealPaymentData, BGLData 报表仅读取数据不做任何修改}
  96. procedure OpenForReport(const AFileName: string);
  97. {OpenForReport2: OpenForReport的基础上打开最后一期数据}
  98. procedure OpenForReport2(const AFileName: string);
  99. {OpenForReport3: OpenForReport2的基础上打开最后一个审核人数据,打开BillsMeasureTree不打开BillsCompileTree,链接BillsMeasureTree跟StageData}
  100. procedure OpenForReport3(const AFileName: string);
  101. //----------------------- End ---后台打开 ------------------------
  102. procedure SaveLastestPhaseMainData;
  103. procedure CreateNewPhase;
  104. {重设所有LookUpDataset连接}
  105. procedure ResetPhaseDataLink;
  106. {重设所有DataView小数位数显示}
  107. procedure ResetFloatDigitView;
  108. {锁定数据}
  109. // 上报
  110. procedure LockedDataForSubmit;
  111. // 终审批复
  112. procedure LockedDataForReply;
  113. {创建审核数据}
  114. procedure UpdateDataForReceive;
  115. // 上报文件:
  116. { 返回值:
  117. 1. True 文件检验结果正确,生成文件
  118. 2. False 文件检验结果错误,不生成文件}
  119. function SubmitProject(const AFileName: string = ''): Boolean;
  120. // 批复文件: 返回值含义同上报
  121. function ReplyProject(const AFileName: string = ''): Boolean;
  122. // json文件:清单
  123. procedure ExportJson_Bills(const AFileName: string);
  124. procedure ExportJson_Common(const AFileName: string);
  125. // 断开所有树的链接
  126. procedure DisConnectTree;
  127. // 重新连接所有的树
  128. procedure ReConnectTree;
  129. {For Reports: 复制当期的全部数据到项目数据中}
  130. procedure CopyPhaseData;
  131. procedure CalculateAll;
  132. function CheckDataBaseInfo(APhaseCount, AAuditStatus: Integer): Boolean;
  133. procedure ImportCloudTenderFile(const AFileName: string);
  134. function CheckPassword: Boolean;
  135. function CurUserIsOwner: Boolean;
  136. function CurUserIsAuthor: Boolean;
  137. function CurUserIsChecker: Boolean;
  138. property BillsData: TBillsData read FBillsData;
  139. property BillsCompileData: TBillsCompileData read FBillsCompileData;
  140. property BillsMeasureData: TBillsMeasureData read FBillsMeasureData;
  141. property BillsBookmarkData: TBillsBookmarkData read FBillsBookmarkData;
  142. property DealBillsData: TDealBillsData read FDealBillsData;
  143. property PhaseIndex: Integer read FPhaseIndex write SetPhaseIndex;
  144. property PhaseData: TPhaseData read FPhaseData;
  145. property ProjProperties: TProjProperties read FProjProperties;
  146. property PhaseCompareData: TPhaseCompareData read FPhaseCompareData;
  147. property BillsGatherData: TBillsGatherData read FBillsGatherData;
  148. property DealPaymentData: TDealPaymentData read FDealPaymentData;
  149. property BGLData: TBGLData read FBGLData;
  150. property StaffData: TStaffData read FStaffData;
  151. property SearchData: TSearchData read FSearchData;
  152. property MainListData: TMainListData read FMainListData;
  153. property AttachmentData: TUpFiles read FAttachmentData; // 附件
  154. // 台账、合同支付
  155. property AllowInsert: Boolean read GetAllowInsert;
  156. property BaseDataReadOnly: Boolean read GetBaseDataReadOnly;
  157. property StageDataReadOnly: Boolean read GetStageDataReadOnly;
  158. property CanUnlockInfo: Boolean read FCanUnlockInfo write FCanUnlockInfo;
  159. property ProjectName: string read FProjectName;
  160. // 磁盘上存储该项目的文件名称
  161. property FileName: string read FFileName;
  162. property ProjectID: Integer read FProjectID;
  163. property MainFileName: string read GetMainFileName;
  164. property TempPath: string read GetTempPath;
  165. property ADOConnection: TADOConnection read GetADOConnection;
  166. property WebID: Integer read FWebID;
  167. property WebOwnerID: Integer read FWebOwnerID;
  168. property WebAuthorID: Integer read FWebAuthorID;
  169. property AuthorHasSubmited: Boolean read FAuthorHasSubmited write FAuthorHasSubmited;
  170. property ProjectReadOnly: Boolean read FProjectReadOnly;
  171. property Checkers: TCheckers read FCheckers write SetCheckers;
  172. end;
  173. implementation
  174. uses UtilMethods, Globals, ProjectCommands, sdIDTree, StageDm,
  175. ZJJLDm, PHPWebDm, XMLDoc, XMLIntf, ConstUnit, PasswordInputFrm,
  176. mProgressProFrm;
  177. { TProjectData }
  178. procedure TProjectData.CheckNewFile(AConnection: TADOConnection);
  179. var
  180. FTableList: TStringList;
  181. begin
  182. FTableList := TStringList.Create;
  183. try
  184. AConnection.GetTableNames(FTableList);
  185. FIsNewFile := FTableList.Count = 0;
  186. finally
  187. FTableList.Free;
  188. end;
  189. end;
  190. procedure TProjectData.CopyLedgerHistoryData(AAudit: Integer);
  191. const
  192. sSql = 'Select ID as BillsID, Quantity, TotalPrice, QtyFlag, QtyFormula ' +
  193. 'Into LedgerHistory%d '+
  194. 'From Bills';
  195. begin
  196. ExecuteSql(Format(sSql, [AAudit]));
  197. end;
  198. constructor TProjectData.Create;
  199. begin
  200. FCheckers := TCheckers.Create;
  201. FTempFolder := GenerateTempFolder(GetTempFilePath);
  202. FConnection := TEncryptConnection.Create;
  203. FUpdator := TUpdateProjectDB.Create;
  204. FProjProperties := TProjProperties.Create(Self);
  205. FBillsData := TBillsData.Create(Self);
  206. FBillsCompileData := TBillsCompileData.Create(Self);
  207. FBillsMeasureData := TBillsMeasureData.Create(Self);
  208. FBillsBookmarkData := TBillsBookmarkData.Create(Self);
  209. FDealBillsData := TDealBillsData.Create(Self);
  210. FPhaseData := TPhaseData.Create(Self);
  211. FPhaseCompareData := TPhaseCompareData.Create(Self);
  212. FBillsGatherData := TBillsGatherData.Create(Self);
  213. FDealPaymentData := TDealPaymentData.Create(Self);
  214. FBGLData := TBGLData.Create(Self);
  215. FStaffData := TStaffData.Create(Self);
  216. FSearchData := TSearchData.Create(Self);
  217. FMainListData := TMainListData.Create(Self);
  218. FAttachmentData := TUpFiles.Create;
  219. FPhaseIndex := 0;
  220. end;
  221. procedure TProjectData.CreateNewPhase;
  222. var
  223. sPhaseFileName: string;
  224. begin
  225. FBillsData.LockedBaseData;
  226. FProjProperties.PhaseCount := FProjProperties.PhaseCount + 1;
  227. FProjProperties.AuditStatus := 0;
  228. FStaffData.UpdateDataForNewPhase;
  229. sPhaseFileName := Format('%s\Phase%d.dat', [TempPath, FProjProperties.PhaseCount]);
  230. CopyFileOrFolder(GetEmptyDataBaseFileName, sPhaseFileName);
  231. end;
  232. destructor TProjectData.Destroy;
  233. begin
  234. FCheckers.Free;
  235. FMainListData.Free;
  236. FSearchData.Free;
  237. FStaffData.Free;
  238. FBGLData.Free;
  239. FDealPaymentData.Free;
  240. FPhaseCompareData.Free;
  241. FPhaseData.Free;
  242. FProjProperties.Free;
  243. FDealBillsData.Free;
  244. FBillsBookmarkData.Free;
  245. FBillsMeasureData.Free;
  246. FBillsCompileData.Free;
  247. FBillsData.Free;
  248. FAttachmentData.Free;
  249. FUpdator.Free;
  250. FConnection.Free;
  251. DeleteFileOrFolder(FTempFolder);
  252. inherited;
  253. end;
  254. function TProjectData.GetBaseDataReadOnly: Boolean;
  255. begin
  256. if FProjProperties.PhaseCount = 0 then
  257. Result := False
  258. else
  259. Result := not AllowInsert;
  260. end;
  261. function TProjectData.GetAllowInsert: Boolean;
  262. begin
  263. if FPhaseData.Active then
  264. Result := FPhaseData.AllowInsert
  265. else
  266. Result := True;
  267. end;
  268. function TProjectData.GetMainFileName: string;
  269. begin
  270. Result := TempPath + 'Main.dat';
  271. end;
  272. function TProjectData.GetProjectFileName: string;
  273. begin
  274. Result := GetMyProjectsFilePath + FProjectName;
  275. end;
  276. function TProjectData.GetTempPath: string;
  277. begin
  278. Result := FTempFolder + '\';
  279. end;
  280. procedure TProjectData.LockedDataForReply;
  281. begin
  282. LockBillsBaseData;
  283. LockDealPaymentData;
  284. FPhaseData.PhaseProperty.FinalAudit := True;
  285. // 有顺序限制,谨慎修改
  286. FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
  287. FProjProperties.AuditStatus := -1;
  288. FProjProperties.FinalAuditCount := FProjProperties.PhaseCount;
  289. FStaffData.LockedDataForReply;
  290. LockBGLData;
  291. end;
  292. procedure TProjectData.LockedDataForSubmit;
  293. begin
  294. LockBillsBaseData;
  295. LockDealPaymentData;
  296. FProjProperties.AuditCompany := FStaffData.FinalStaffCompany;
  297. FStaffData.LockedDataForAudit;
  298. LockBGLData;
  299. end;
  300. procedure TProjectData.Open(AProjRec: TsdDataRecord);
  301. begin
  302. {Open规则:在打开Phase或者设置PhaseIndex时,会设置多个LookUpDataset,
  303. 故要求须在BillsData、DealPayment打开之后}
  304. FProjectName := AProjRec.ValueByName('Name').AsString;
  305. FFileName := GetMyProjectsFilePath + AProjRec.ValueByName('FileName').AsString;
  306. FProjectID := AProjRec.ValueByName('ID').AsInteger;
  307. FWebID := AProjRec.ValueByName('WebID').AsInteger;
  308. FWebOwnerID := AProjRec.ValueByName('WebOwnerID').AsInteger;
  309. FWebAuthorID := AProjRec.ValueByName('WebAuthorID').AsInteger;
  310. FAttachmentData.ProjectData := Self;
  311. FAttachmentData.LoadDatas;
  312. UpdateSysProgress(5, '正在打开项目');
  313. UnZipFile(FileName, TempPath);
  314. UpdateSysProgress(10, '正在打开项目');
  315. FConnection.Open(MainFileName);
  316. CheckNewFile(FConnection.Connection);
  317. UpdateSysProgress(15, '正在升级文件');
  318. UpdateProjectDataBase;
  319. UpdateSysProgress(20, '正在读取数据');
  320. FProjProperties.Open(FConnection.Connection);
  321. if FIsNewFile then
  322. FProjProperties.UpdateFlag := 1;
  323. UpdateOldData;
  324. ResetFloatDigitView;
  325. UpdateSysProgress(25, '正在读取数据');
  326. FBillsData.Open(FConnection.Connection);
  327. if FIsNewFile then
  328. FBillsData.InitBills;
  329. FBillsCompileData.Open;
  330. FBillsMeasureData.Open;
  331. UpdateSysProgress(65, '正在读取数据');
  332. FBillsBookmarkData.Open;
  333. UpdateSysProgress(70, '正在读取数据');
  334. FDealBillsData.Open(FConnection.Connection);
  335. UpdateSysProgress(80, '正在读取数据');
  336. FDealPaymentData.Open(FConnection.Connection);
  337. if FIsNewFile then
  338. FDealPaymentData.Init;
  339. UpdateSysProgress(90, '正在读取数据');
  340. OpenLastPhaseData;
  341. UpdateSysProgress(140, '正在读取数据');
  342. FBGLData.Open(FConnection.Connection);
  343. UpdateSysProgress(160, '正在读取数据');
  344. FStaffData.Open(FConnection.Connection);
  345. UpdateSysProgress(180, '正在读取数据');
  346. //FBillsGatherData.RefreshBills;
  347. FMainListData.Open(FConnection.Connection);
  348. UpdateSysProgress(200, '就绪');
  349. end;
  350. procedure TProjectData.OpenLastPhaseData;
  351. begin
  352. if ProjProperties.PhaseCount = 0 then Exit;
  353. FPhaseIndex := ProjProperties.PhaseCount;
  354. FProjProperties.PhaseIndex := FPhaseIndex;
  355. FPhaseData.Open(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
  356. ResetPhaseDataLink;
  357. end;
  358. procedure TProjectData.Save;
  359. begin
  360. UpdateSysProgress(5, '正在保存数据');
  361. SaveLastestPhaseMainData;
  362. if FPhaseData.Active then
  363. FPhaseData.Save;
  364. UpdateSysProgress(20, '正在保存数据');
  365. FMainListData.Save;
  366. FDealPaymentData.Save;
  367. UpdateSysProgress(40, '正在保存数据');
  368. FStaffData.Save;
  369. UpdateSysProgress(50, '正在保存数据');
  370. FBGLData.Save;
  371. UpdateSysProgress(60, '正在保存数据');
  372. FDealBillsData.Save;
  373. UpdateSysProgress(80, '正在保存数据');
  374. FBillsCompileData.ReLockBaseData;
  375. UpdateSysProgress(85, '正在保存数据');
  376. FBillsData.Save;
  377. UpdateSysProgress(170, '正在保存数据');
  378. FProjProperties.Save;
  379. UpdateSysProgress(180, '正在保存数据');
  380. FConnection.Save;
  381. UpdateSysProgress(190, '正在保存数据');
  382. ZipFolder(FTempFolder, FileName);
  383. SaveInfoToManager;
  384. UpdateSysProgress(200, '就绪');
  385. ProjectManager.AddSaveTenderBackup(FProjectID);
  386. end;
  387. procedure TProjectData.SaveInfoToManager;
  388. var
  389. InfoRec, PhaseRec: TsdDataRecord;
  390. begin
  391. InfoRec := ProjectManager.sddProjectsInfo.FindKey('idxID', FProjectID);
  392. PhaseRec := MainListData.GetPhaseMainRecord(ProjProperties.PhaseCount);
  393. InfoRec.ValueByName('DealTotalPrice').AsFloat := FBillsData.Settlement[DealIndex];
  394. InfoRec.ValueByName('Deal_BGLTotalPrice').AsFloat := FBillsData.Settlement[DealIndex] + FBGLData.AllBGLTotalPrice;
  395. InfoRec.ValueByName('PhaseTotalPrice').AsFloat := PhaseRec.ValueByName('GatherTotalPrice').AsFloat;
  396. InfoRec.ValueByName('EndDealTotalPrice').AsFloat := PhaseRec.ValueByName('EndDealTotalPrice').AsFloat;
  397. InfoRec.ValueByName('EndChangeTotalPrice').AsFloat :=
  398. PhaseRec.ValueByName('EndQcTotalPrice').AsFloat + PhaseRec.ValueByName('EndPcTotalPrice').AsFloat;
  399. InfoRec.ValueByName('EndTotalPrice').AsFloat := PhaseRec.ValueByName('EndGatherTotalPrice').AsFloat;
  400. InfoRec.ValueByName('PreTotalPrice').AsFloat := PhaseRec.ValueByName('PreGatherTotalPrice').AsFloat;
  401. InfoRec.ValueByName('PhasePay').AsFloat := PhaseRec.ValueByName('PhasePay').AsFloat;
  402. InfoRec.ValueByName('PhaseCount').AsInteger := FProjProperties.PhaseCount;
  403. InfoRec.ValueByName('AuditStatus').AsInteger := FProjProperties.AuditStatus;
  404. ProjectManager.Save;
  405. end;
  406. procedure TProjectData.SetPhaseIndex(const Value: Integer);
  407. function GetPhaseFileName: string;
  408. begin
  409. Result := Format('%s\Phase%d.dat', [TempPath, FPhaseIndex]);
  410. end;
  411. procedure ReCreatePhaseData;
  412. begin
  413. if FPhaseData.Active then
  414. FPhaseData.Save;
  415. FPhaseData.Free;
  416. FPhaseData := TPhaseData.Create(Self);
  417. end;
  418. begin
  419. SaveLastestPhaseMainData;
  420. FPhaseIndex := Value;
  421. ProjProperties.PhaseIndex := FPhaseIndex;
  422. ReCreatePhaseData;
  423. FPhaseData.Open(GetPhaseFileName);
  424. ResetPhaseDataLink;
  425. //BillsGatherData.RefreshBills;
  426. end;
  427. procedure TProjectData.SetPhaseIndexSimple(AIndex: Integer);
  428. begin
  429. FPhaseIndex := AIndex;
  430. if FPhaseData.Active then
  431. FPhaseData.SimpleSave;
  432. FPhaseData.Free;
  433. FPhaseData := TPhaseData.Create(Self);
  434. FPhaseData.SimpleOpen(Format('%s\Phase%d.dat', [TempPath, FPhaseIndex]));
  435. end;
  436. procedure TProjectData.UpdateProjectDataBase;
  437. begin
  438. FUpdator.Update(FConnection);
  439. end;
  440. procedure TProjectData.ResetPhaseDataLink;
  441. begin
  442. BillsMeasureData.ResetPhaseStageLink;
  443. BillsMeasureData.ResetTreeNodeStageRec;
  444. DealPaymentData.ResetPhaseLink;
  445. BillsBookmarkData.ResetPhaseStageLink;
  446. end;
  447. procedure TProjectData.SimpleOpen(const AFileName: string);
  448. begin
  449. FProjectID := -1;
  450. UnZipFile(AFileName, TempPath);
  451. FConnection.Open(MainFileName);
  452. FProjProperties.Open(FConnection.Connection);
  453. if ProjProperties.PhaseCount > 0 then
  454. begin
  455. FPhaseIndex := ProjProperties.PhaseCount;
  456. FPhaseData.SimpleOpen(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
  457. end;
  458. end;
  459. procedure TProjectData.SimpleSaveAs(const AFileName: string);
  460. begin
  461. if FPhaseData.Active then
  462. FPhaseData.SimpleSave;
  463. FProjProperties.Save;
  464. FConnection.Save;
  465. ZipFolder(FTempFolder, AFileName);
  466. end;
  467. procedure TProjectData.UpdateDataForReceive;
  468. begin
  469. UpdatePhaseData;
  470. end;
  471. procedure TProjectData.UpdatePhaseData;
  472. var
  473. iPhase: Integer;
  474. begin
  475. FProjProperties.AuditStatus := FProjProperties.AuditStatus + 1;
  476. for iPhase := FProjProperties.FinalAuditCount + 1 to FProjProperties.PhaseCount do
  477. begin
  478. SetPhaseIndexSimple(iPhase);
  479. PhaseData.CreateNewAuditData;
  480. StaffData.UpdateDataForNewAudit;
  481. end;
  482. end;
  483. function TProjectData.ReplyProject(const AFileName: string = ''): Boolean;
  484. var
  485. Replyor: TReplyProject;
  486. begin
  487. Replyor := TReplyProject.Create(FProjectName, FFileName, FProjectID);
  488. try
  489. if AFileName = '' then
  490. Result := Replyor.Execute
  491. else
  492. Result := Replyor.ExportTo(AFileName);
  493. finally
  494. Replyor.Free;
  495. end;
  496. end;
  497. function TProjectData.SubmitProject(const AFileName: string = ''): Boolean;
  498. var
  499. Submitor :TSubmitProject;
  500. begin
  501. Submitor := TSubmitProject.Create(FProjectName, FFileName, FProjectID);
  502. try
  503. if AFileName = '' then
  504. Result := Submitor.Execute
  505. else
  506. Result := Submitor.ExportTo(AFileName);
  507. finally
  508. Submitor.Free;
  509. end;
  510. end;
  511. procedure TProjectData.ExportJson_Bills(const AFileName: string);
  512. function GetProjectName: string;
  513. var
  514. vNode: tsdIDTreeNode;
  515. begin
  516. vNode := ProjectManager.ProjectsTree.FindNode(FProjectID).Parent;
  517. Result := vNode.Rec.ValueByName('Name').AsString;
  518. end;
  519. // lkJSON 暂时未找到添加数组结构的办法,官方也没有提供相关的Demo,自己合成。
  520. // lkJSON 合成的长文本自动带有大量“\”转义字符,这点有些烦人。
  521. // 其实这么折腾,还不如自己直接合成。那为什么还要用它?自己写是很容易,但是
  522. // 要自己读JSON,那写起来就很麻烦了。
  523. function BillsStr: string;
  524. var vRec: TsdDataRecord;
  525. i: Integer;
  526. sSplit: string;
  527. function v(AFieldName: string): string;
  528. begin
  529. Result := vRec.ValueByName(AFieldName).AsString;
  530. end;
  531. // 杰哥那头不识别中文,将中文转成URL编码形式
  532. function URLEncode(const S: string; const InQueryString: Boolean): string;
  533. var
  534. Idx: Integer;
  535. begin
  536. Result := '';
  537. for Idx := 1 to Length(S) do
  538. begin
  539. case S[Idx] of
  540. 'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.':
  541. Result := Result + S[Idx];
  542. ' ':
  543. if InQueryString then
  544. Result := Result + '+'
  545. else
  546. Result := Result + '%20';
  547. else
  548. Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2);
  549. end;
  550. end;
  551. end;
  552. begin
  553. for i := 0 to BillsMeasureData.BillsMeasureTree.Count - 1 do
  554. begin
  555. vRec := BillsMeasureData.BillsMeasureTree.Items[i].Rec;
  556. ProgressProRun('导出用于Web展示的清单、汇总数据等... ' + IntToStr(i + 1), 0, pmtEdit);
  557. if i = 0 then
  558. sSplit := ''
  559. else
  560. sSplit := ',';
  561. Result := Result + sSplit + Format('{"Code":"%s","B_Code":"%s","Name":"%s",' +
  562. '"Units":"%s","Price":"%s","Quantity":"%s","TotalPrice":"%s"}',
  563. [v('Code'), v('B_Code'), v('Name'), v('Units'), v('Price'),
  564. v('Quantity'), v('TotalPrice')]);
  565. end;
  566. end;
  567. var
  568. fPhasePay: Double;
  569. vSL: TStringList;
  570. begin
  571. vSL := TStringList.Create;
  572. try
  573. vSL.Text := Format('{"DealTotalPrice":"%s","Bills":[%s]}',
  574. [FloatToStr(FBillsData.Settlement[DealIndex]), AnsiToUtf8(BillsStr)]);
  575. vSL.SaveToFile(AFileName);
  576. finally
  577. vSL.Free;
  578. end;
  579. end;
  580. procedure TProjectData.DisConnectTree;
  581. begin
  582. BillsMeasureData.BillsMeasureTree.Active := False;
  583. BillsCompileData.BillsCompileTree.Active := False;
  584. end;
  585. procedure TProjectData.ReConnectTree;
  586. begin
  587. BillsCompileData.ReConnectTree;
  588. BillsMeasureData.ReConnectTree;
  589. end;
  590. procedure TProjectData.CopyPhaseCompleteData;
  591. const
  592. sInsertSql = 'Insert Into PhaseComplete (BillsID)' +
  593. ' Select ID' +
  594. ' From Bills where Bills.CreatePhaseID = %d';
  595. sUpdateSql = 'Update PhaseComplete Inner Join [Bills]' +
  596. ' On PhaseComplete.BillsID=Bills.ID' +
  597. ' Set PhaseComplete.Quantity%d=Bills.AddGatherQuantity,' +
  598. ' PhaseComplete.TotalPrice%d=Bills.AddGatherTotalPrice';
  599. var
  600. iPhase: Integer;
  601. sSql: string;
  602. begin
  603. for iPhase := FProjProperties.FinalAuditCount + 1 to FProjProperties.PhaseCount do
  604. begin
  605. SetPhaseIndexSimple(iPhase);
  606. // 插入本期新增的数据
  607. sSql := Format(sInsertSql, [iPhase]);
  608. ExecuteSql(sSql);
  609. // 更新所有截止本期完成计量数据
  610. sSql := Format(sInsertSql, [iPhase, iPhase]);
  611. ExecuteSql(sSql);
  612. end;
  613. end;
  614. procedure TProjectData.CopyPhaseData;
  615. procedure DeletePhaseTable;
  616. var
  617. FTableList: TStringList;
  618. iIndex: Integer;
  619. sDeleteTableSql: String;
  620. begin
  621. FTableList := TStringList.Create;
  622. try
  623. FConnection.Connection.GetTableNames(FTableList);
  624. iIndex := 0;
  625. while iIndex < FTableList.Count do
  626. begin
  627. if Pos('P_', FTableList.Strings[iIndex]) = 1 then
  628. begin
  629. sDeleteTableSql := Format('Drop Table %s', [FTableList.Strings[iIndex]]);
  630. ExecuteSql(sDeleteTableSql);
  631. end;
  632. Inc(iIndex);
  633. end;
  634. finally
  635. FTableList.Free;
  636. end;
  637. end;
  638. procedure CopyStageData(const AFileName, ASourceTable, AResultTable: string);
  639. const
  640. sCopySql = 'Select BillsID, DealQuantity, DealTotalPrice, QcQuantity, QcTotalPrice, QcBGLCode, QcBGLNum,' +
  641. ' PcQuantity, PcTotalPrice, PcBGLCode, PcBGLNum, GatherQuantity, GatherTotalPrice,' +
  642. ' EndDealQuantity, EndDealTotalPrice, EndQcQuantity, EndQcTotalPrice,' +
  643. ' EndPcQuantity, EndPcTotalPrice, EndGatherQuantity, EndGatherTotalPrice,' +
  644. ' PreDealQuantity, PreDealTotalPrice, PreQcQuantity, PreQcTotalPrice,' +
  645. ' PrePcQuantity, PrePcTotalPrice, PreGatherQuantity, PreGatherTotalPrice' +
  646. ' Into %s' +
  647. ' From %s' +
  648. ' In ''%s''';
  649. var
  650. sSql: string;
  651. begin
  652. sSql := Format(sCopySql, [AResultTable, ASourceTable, AFileName]);
  653. ExecuteSql(sSql);
  654. end;
  655. procedure CopyEmptyStageData(const AFileName, ASourceTable, AResultTable: string);
  656. const
  657. sCopySql = 'Select BillsID, DealQuantity, DealTotalPrice, QcQuantity, QcTotalPrice, QcBGLCode, QcBGLNum,' +
  658. ' PcQuantity, PcTotalPrice, PcBGLCode, PcBGLNum, GatherQuantity, GatherTotalPrice,' +
  659. ' EndDealQuantity, EndDealTotalPrice, EndQcQuantity, EndQcTotalPrice,' +
  660. ' EndPcQuantity, EndPcTotalPrice, EndGatherQuantity, EndGatherTotalPrice,' +
  661. ' PreDealQuantity, PreDealTotalPrice, PreQcQuantity, PreQcTotalPrice,' +
  662. ' PrePcQuantity, PrePcTotalPrice, PreGatherQuantity, PreGatherTotalPrice' +
  663. ' Into %s' +
  664. ' From %s' +
  665. ' In ''%s''' +
  666. ' Where 1=2';
  667. var
  668. sSql: string;
  669. begin
  670. sSql := Format(sCopySql, [AResultTable, ASourceTable, AFileName]);
  671. ExecuteSql(sSql);
  672. end;
  673. procedure AddSettlementData;
  674. const
  675. sAddSql = 'Insert Into P_Stage (BillsID,' +
  676. ' DealTotalPrice, QcTotalPrice, PcTotalPrice, GatherTotalPrice,' +
  677. ' EndDealTotalPrice, EndQcTotalPrice, EndPcTotalPrice, EndGatherTotalPrice,' +
  678. ' PreDealTotalPrice, PreQcTotalPrice, PrePcTotalPrice, PreGatherTotalPrice)' +
  679. ' Values (-2,'+
  680. ' %f, %f, %f, %f,'+
  681. ' %f, %f, %f, %f,'+
  682. ' %f, %f, %f, %f)';
  683. var
  684. sSql: string;
  685. begin
  686. with PhaseData.StageData do
  687. sSql := Format(sAddSql,
  688. [StageSettlement[1,1], StageSettlement[1,2], StageSettlement[1,3], StageSettlement[1,4],
  689. StageSettlement[2,1], StageSettlement[2,2], StageSettlement[2,3], StageSettlement[2,4],
  690. StageSettlement[3,1], StageSettlement[3,2], StageSettlement[3,3], StageSettlement[3,4]]);
  691. ExecuteSql(sSql);
  692. end;
  693. procedure UpdateZJJLData;
  694. const
  695. sUpdateSql = 'Update P_ZJJL' +
  696. ' Set BGLCode = ''%s'', PegName = ''%s'', FBFXName = ''%s'',' +
  697. ' UnitName = ''%s'', DrawingCode = ''%s''' +
  698. ' Where ID = %d';
  699. var
  700. sSql: string;
  701. ZJJLInfoRec: TZJJLInfoRec;
  702. begin
  703. with PhaseData.ZJJLData do
  704. begin
  705. cdsZJJL.First;
  706. while not cdsZJJL.Eof do
  707. begin
  708. ZJJLInfoRec := GetInfoRec(cdsZJJLBillsID.AsInteger, cdsZJJLType.AsInteger);
  709. sSql := Format(sUpdateSql, [ZJJLInfoRec.BGLCode, ZJJLInfoRec.PegName,
  710. ZJJLInfoRec.FBFXName, ZJJLInfoRec.UnitName, ZJJLInfoRec.DrawingCode,
  711. cdsZJJLID.AsInteger]);
  712. ExecuteSql(sSql);
  713. cdsZJJL.Next;
  714. end;
  715. end;
  716. end;
  717. procedure CopyZJJLBillsData;
  718. var
  719. sSql: string;
  720. begin
  721. sSql := 'Select PZ.ID, B.B_Code, B.Name, B.Units, B.Price, PS.GatherQuantity As Quantity, PS.GatherTotalPrice As TotalPrice' +
  722. ' Into P_ZJJLBills'+
  723. ' From Bills As B, P_Stage As PS, P_ZJJL As PZ' +
  724. ' Where (PZ.BillsID = B.LeafXmjParentID) And (B.ID = PS.BillsID) And (B.IsLeaf=True)';
  725. ExecuteSql(sSql);
  726. end;
  727. procedure CopyZJJLData(const AFileName: string);
  728. var
  729. sSql: string;
  730. begin
  731. sSql := 'Select ID, BillsID, Code, CertificateCode, BillsCode, FormulaMemo, RelaFile,' +
  732. ' '''' As BGLCode, '''' As PegName, '''' As FBFXName, '''' As UnitName, '''' As DrawingCode' +
  733. ' Into P_ZJJL' +
  734. ' From ' + PhaseData.ZJJLData.atZJJL.TableName +
  735. ' In ' + Format('''%s''', [AFileName]);
  736. ExecuteSql(sSql);
  737. // 获取分部分项等实时统计字段值
  738. UpdateZJJLData;
  739. CopyZJJLBillsData;
  740. end;
  741. procedure CopyPhasePayData(const AFileName: string);
  742. const
  743. sCopySql = 'Select ID, TotalPrice%d As CurTotalPrice, EndTotalPrice%d As EndTotalPrice,' +
  744. ' PreTotalPrice%d As PreTotalPrice,' +
  745. ' TotalPrice0, EndTotalPrice0, PreTotalPrice0,' +
  746. ' TotalPrice1, EndTotalPrice1, PreTotalPrice1,' +
  747. ' TotalPrice2, EndTotalPrice2, PreTotalPrice2,' +
  748. ' TotalPrice3, EndTotalPrice3, PreTotalPrice3,' +
  749. ' TotalPrice4, EndTotalPrice4, PreTotalPrice4,' +
  750. ' TotalPrice5, EndTotalPrice5, PreTotalPrice5,' +
  751. ' TotalPrice6, EndTotalPrice6, PreTotalPrice6,' +
  752. ' TotalPrice7, EndTotalPrice7, PreTotalPrice7,' +
  753. ' TotalPrice8, EndTotalPrice8, PreTotalPrice8,' +
  754. ' TotalPrice9, EndTotalPrice9, PreTotalPrice9,' +
  755. ' TotalPrice10, EndTotalPrice10, PreTotalPrice10,' +
  756. ' TotalPrice11, EndTotalPrice11, PreTotalPrice11,' +
  757. ' TotalPrice12, EndTotalPrice12, PreTotalPrice12,' +
  758. ' TotalPrice13, EndTotalPrice13, PreTotalPrice13,' +
  759. ' TotalPrice14, EndTotalPrice14, PreTotalPrice14,' +
  760. ' TotalPrice%d As TotalPrice_F, EndTotalPrice%d As EndTotalPrice_F, PreTotalPrice%d As PreTotalPrice_F' +
  761. ' Into P_PhasePay' +
  762. ' From PhasePay' +
  763. ' In ''%s''';
  764. var
  765. sSql: string;
  766. begin
  767. with PhaseData do
  768. sSql := Format(sCopySql, [StageIndex, StageIndex, StageIndex, StageCount - 1, StageCount - 1, StageCount - 1, AFileName]);
  769. ExecuteSql(sSql);
  770. end;
  771. procedure CopyReportData(const AFileName: string);
  772. const
  773. sCopySql = 'Select Flag, SubFlag, SerialNo, Select1, Result1, Result2' +
  774. ' Into P_ReportData' +
  775. ' From ReportData' +
  776. ' In ''%s''';
  777. begin
  778. ExecuteSql(Format(sCopySql, [AFileName]));
  779. end;
  780. procedure CopyCurPhaseData;
  781. var
  782. sTempFile: string;
  783. i: Integer;
  784. begin
  785. sTempFile := GetTempFileName;
  786. try
  787. SimpleDecrypt(Format('%s\Phase%d.dat', [TempPath, FPhaseIndex]), sTempFile);
  788. // 复制当前阶段数据
  789. CopyStageData(sTempFile, PhaseData.StageData.sdpStage.TableName, 'P_Stage');
  790. // 复制原报、审核、批复数据
  791. // 其中审核、批复数据,如果存在则复制,如果不存在,则创建空表
  792. CopyStageData(sTempFile, 'Refer', 'P_Refer');
  793. for i := 1 to iMaxStageCount - 1 do
  794. if PhaseData.AuditCount >= i then
  795. CopyStageData(sTempFile, PhaseData.StageTableName[i],
  796. 'P_Audit' + IntToStr(i))
  797. else
  798. CopyEmptyStageData(sTempFile, PhaseData.StageTableName[PhaseData.AuditCount],
  799. 'P_Audit' + IntToStr(i));
  800. if PhaseData.StageCount > 1 then
  801. CopyStageData(sTempFile, PhaseData.StageTableName[PhaseData.AuditCount], 'P_Reply')
  802. else
  803. CopyEmptyStageData(sTempFile, PhaseData.StageTableName[PhaseData.AuditCount], 'P_Reply');
  804. AddSettlementData;
  805. CopyZJJLData(sTempFile);
  806. CopyPhasePayData(sTempFile);
  807. CopyReportData(sTempFile);
  808. finally
  809. DeleteFile(sTempFile);
  810. end;
  811. end;
  812. procedure CopyHistoryCompleteData;
  813. const
  814. sCopySql1 = 'Select BillsID, 0 As Quantity1, 0 As TotalPrice1,' +
  815. ' Quantity%d As Quantity2, TotalPrice%d As TotalPrice2' +
  816. ' Into P_Complete' +
  817. ' From PhaseComplete';
  818. sCopySqlN = 'Select BillsID, Quantity%d As Quantity1, TotalPrice%d As TotalPrice1,' +
  819. ' Quantity%d As Quantity2, TotalPrice%d As TotalPrice2' +
  820. ' Into P_Complete' +
  821. ' From PhaseComplete';
  822. sUnionCopySql1 = 'Select BillsID, 0 As Quantity1, 0 As TotalPrice1,' +
  823. ' GatherQuantity As Quantity2, GatherTotalPrice As TotalPrice2' +
  824. ' Into P_Complete' +
  825. ' From P_Stage';
  826. sUnionCopySqlN = 'Select PS.BillsID As BillsID,' +
  827. ' PC.Quantity%d As Quantity1,' +
  828. ' PC.TotalPrice%d As TotalPrice1,' +
  829. ' PC.Quantity%d + PS.GatherQuantity As Quantity2,' +
  830. ' PC.TotalPrice%d + PS.GatherTotalPrice As TotalPrice2' +
  831. ' Into P_Complete' +
  832. ' From PhaseComplete As PC, P_Stage As PS';
  833. var
  834. sSql: string;
  835. begin
  836. if (ProjProperties.FinalAuditCount >= PhaseIndex) then
  837. if PhaseIndex <= 1 then
  838. sSql := Format(sCopySql1, [FPhaseIndex, FPhaseIndex])
  839. else
  840. sSql := Format(sCopySqlN, [PhaseIndex - 1, PhaseIndex - 1, PhaseIndex, PhaseIndex])
  841. else
  842. if PhaseIndex <= 1 then
  843. sSql := sUnionCopySql1
  844. else
  845. sSql := Format(sUnionCopySqlN, [PhaseIndex - 1, PhaseIndex - 1, PhaseIndex - 1, PhaseIndex - 1]);
  846. ExecuteSql(sSql);
  847. end;
  848. procedure UpdateBillsByDealBills;
  849. const
  850. sUpdateSql = 'Update Bills As B, DealBills As D' +
  851. ' Set B.GclDealQuantity = D.Quantity, B.GclDealTotalPrice = D.TotalPrice' +
  852. ' Where (B.B_Code = D.B_Code) and (B.Name = D.Name) and (B.Units = D.Units) and (B.Price = D.Price)';
  853. begin
  854. ExecuteSql(sUpdateSql);
  855. end;
  856. procedure FilterDealBillsByBills;
  857. const
  858. sFilterSql = 'Select D.*' +
  859. ' Into P_FilterDealBills' +
  860. ' From DealBills As D inner join' +
  861. ' (Select D.ID' +
  862. ' From DealBills As D Left join Bills As B' +
  863. ' On (D.B_Code = B.B_Code) and (D.Name = B.Name) and (D.Units = B.Units) and (D.Price = B.Price)' +
  864. ' where B.ID is Null) As R' +
  865. ' On (D.ID = R.ID)';
  866. begin
  867. ExecuteSql(sFilterSql);
  868. end;
  869. procedure CopyCacheReportsData;
  870. begin
  871. // DealBills的数量金额填至Bills中
  872. UpdateBillsByDealBills;
  873. // 过滤DealBills中在Bills中不存在的清单
  874. FilterDealBillsByBills;
  875. end;
  876. begin
  877. Save;
  878. DeletePhaseTable;
  879. CopyCacheReportsData;
  880. if FPhaseIndex > 0 then
  881. CopyCurPhaseData;
  882. FDealPaymentData.UpdateLinkSerialNo;
  883. //CopyHistoryCompleteData;
  884. end;
  885. procedure TProjectData.ExecuteSql(const ASql: string);
  886. var
  887. FQuery: TADOQuery;
  888. begin
  889. FQuery := TADOQuery.Create(nil);
  890. try
  891. FQuery.Connection := FConnection.Connection;
  892. FQuery.SQL.Clear;
  893. FQuery.SQL.Add(ASql);
  894. FQuery.ExecSQL;
  895. finally
  896. FQuery.Free;
  897. end;
  898. end;
  899. function TProjectData.GetADOConnection: TADOConnection;
  900. begin
  901. Result := FConnection.Connection;
  902. end;
  903. procedure TProjectData.ExportJson_Common(const AFileName: string);
  904. var
  905. Rec: TsdDataRecord;
  906. vSL: TStringList;
  907. sBQHTJL, sBQSLBGJL, sJZSQLJWC, sBQWCJL, sLJWCJL, sTotalPrice: string;
  908. begin
  909. vSL := TStringList.Create;
  910. try
  911. Rec := MainListData.GetPhaseMainRecord(ProjProperties.PhaseCount);
  912. sBQHTJL := FloatToStr(Rec.ValueByName('DealTotalPrice').AsFloat); // 本期合同计量
  913. sBQSLBGJL := FloatToStr(Rec.ValueByName('QcTotalPrice').AsFloat); // 本期数量变更计量
  914. sJZSQLJWC := FloatToStr(Rec.ValueByName('PreGatherTotalPrice').AsFloat); // 截止上期累计完成
  915. sBQWCJL := FloatToStr(Rec.ValueByName('GatherTotalPrice').AsFloat); // 本期完成计量
  916. sLJWCJL := FloatToStr(Rec.ValueByName('EndGatherTotalPrice').AsFloat); // 累计完成计量
  917. sTotalPrice := FloatToStr(BillsData.Settlement[0] + Rec.ValueByName('EndQcTotalPrice').AsFloat); // 0号台帐+截止本期累期变更计量
  918. vSL.Text := Format('{"BQHTJL":"%s","BQSLBGJL":"%s","JZSQLJWC":"%s","BQWCJL":"%s","LJWCJL":"%s","TotalPrice":"%s"}',
  919. [sBQHTJL, sBQSLBGJL, sJZSQLJWC, sBQWCJL, sLJWCJL, sTotalPrice]);
  920. vSL.SaveToFile(AFileName);
  921. finally
  922. vSL.Free;
  923. end;
  924. end;
  925. function TProjectData.CurUserIsAuthor: Boolean;
  926. begin
  927. Result := PHPWeb.UserID = WebAuthorID;
  928. end;
  929. function TProjectData.CurUserIsChecker: Boolean;
  930. begin
  931. Result := (PHPWeb.UserID <> WebOwnerID) and (PHPWeb.UserID <> WebAuthorID);
  932. end;
  933. function TProjectData.CurUserIsOwner: Boolean;
  934. begin
  935. Result := PHPWeb.UserID = WebOwnerID;
  936. end;
  937. procedure TProjectData.SaveLastestPhaseMainData;
  938. var
  939. Rec: TsdDataRecord;
  940. begin
  941. if (FPhaseIndex = ProjProperties.PhaseCount) and PhaseData.IsLastStage then
  942. begin
  943. Rec := MainListData.GetPhaseMainRecord(FPhaseIndex);
  944. Rec.ValueByName('DealTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[1, 1];
  945. Rec.ValueByName('QcTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[1, 2];
  946. Rec.ValueByName('PcTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[1, 3];
  947. Rec.ValueByName('GatherTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[1, 4];
  948. Rec.ValueByName('EndDealTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[2, 1];
  949. Rec.ValueByName('EndQcTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[2, 2];
  950. Rec.ValueByName('EndPcTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[2, 3];
  951. Rec.ValueByName('EndGatherTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[2, 4];
  952. Rec.ValueByName('PreDealTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[3, 1];
  953. Rec.ValueByName('PreQcTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[3, 2];
  954. Rec.ValueByName('PrePcTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[3, 3];
  955. Rec.ValueByName('PreGatherTotalPrice').AsFloat := PhaseData.StageData.StageSettlement[3, 4];
  956. Rec.ValueByName('PhasePay').AsFloat := PhaseData.PhasePayData.LastestPhasePay[1];
  957. Rec.ValueByName('EndPhasePay').AsFloat := PhaseData.PhasePayData.LastestPhasePay[2];
  958. Rec.ValueByName('PrePhasePay').AsFloat := PhaseData.PhasePayData.LastestPhasePay[3];
  959. end;
  960. end;
  961. procedure TProjectData.CalculateAll;
  962. begin
  963. FBillsCompileData.CalculateAll;
  964. if not FPhaseData.StageDataReadOnly then
  965. FPhaseData.StageData.CalculateAll;
  966. FBillsMeasureData.CalculateAll;
  967. end;
  968. procedure TProjectData.ImportCloudTenderFile(const AFileName: string);
  969. function GetTempFile(const TempDir: string): string;
  970. var
  971. FXmlDocument: IXMLDocument;
  972. XmlNode, InfoXmlNode: IXMLNode;
  973. ChildNodes: IXMLNodeList;
  974. begin
  975. FXmlDocument := TXMLDocument.Create(nil) as IXMLDocument;
  976. try
  977. FXmlDocument.LoadFromFile(TempDir + '\Info.xml');
  978. FXmlDocument.Options := [doNodeAutoCreate,doNodeAutoIndent,doAutoPrefix,doNamespaceDecl];
  979. XmlNode := FXmlDocument.DocumentElement;
  980. ChildNodes := XmlNode.ChildNodes;
  981. InfoXmlNode := ChildNodes.FindNode('ProjectInfo');
  982. Result := TempDir + '\' + InfoXmlNode.Attributes['FileName'];
  983. finally
  984. FXmlDocument := nil;
  985. end;
  986. end;
  987. procedure ClearAllData;
  988. var
  989. sSql: string;
  990. begin
  991. sSql := 'Delete * From Bills';
  992. ExecuteSql(sSql);
  993. sSql := 'Delete * From DealBills';
  994. ExecuteSql(sSql);
  995. sSql := 'Delete * From ProjProperties';
  996. ExecuteSql(sSql);
  997. sSql := 'Delete * From DealPayment';
  998. ExecuteSql(sSql);
  999. end;
  1000. procedure CopyData(const AFileName: string);
  1001. const
  1002. sBillsSql = 'Insert Into Bills (ID, ParentID, NextSiblingID,' +
  1003. ' Code, B_Code, Name, Units, Alias, Price, NewPrice,' +
  1004. ' OrgQuantity, OrgTotalPrice,' +
  1005. ' DgnQuantity1, DgnQuantity2,'+
  1006. ' Peg, DrawingCode, MemoStr, HasBookMark, MarkMemo)'+
  1007. ' Select ID, ParentID, NextSiblingID,'+
  1008. ' Code, B_Code, Name, Units, Alias, Price, NewPrice,' +
  1009. ' OrgQuantity, OrgTotalPrice,' +
  1010. ' DgnQuantity1, DgnQuantity2,'+
  1011. ' Peg, DrawingCode, MemoStr, HasBookMark, MarkMemo'+
  1012. ' From Bills In ''%s''';
  1013. sDealBillsSql = 'Insert Into DealBills Select * From DealBills In ''%s''';
  1014. sDealPaymentSql = 'Insert Into DealPayment (ID, Name, CalcType, IsMinus,'+
  1015. ' Formula, StartedPrice, SFormula, RangePrice, RFormula)'+
  1016. ' Select ID, Name, CalcType, IsMinus,'+
  1017. ' Formula, StartedPrice, SFormula, RangePrice, RFormula'+
  1018. ' From DealPayment In ''%s''';
  1019. sPropertySql = 'Insert Into ProjProperties'+
  1020. ' Select * From ProjProperties In ''%s'''+
  1021. ' Where (Name <> ''PHASECOUNT'') and (Name <> ''UNLOCKINFOPASSWORD'') and (Name <> ''AUDITSTATUS'')'+
  1022. ' and (Name <> ''FINALAUDITCOUNT'') and (Name <> ''AUDITCOMPANY'') and (Name <> ''UPDATEFLAG'')';
  1023. var
  1024. sSql: string;
  1025. begin
  1026. sSql := Format(sBillsSql, [AFileName]);
  1027. ExecuteSql(sSql);
  1028. sSql := Format(sDealBillsSql, [AFileName]);
  1029. ExecuteSql(sSql);
  1030. sSql := Format(sDealPaymentSql, [AFileName]);
  1031. ExecuteSql(sSql);
  1032. sSql := Format(sPropertySql, [AFileName]);
  1033. ExecuteSql(sSql);
  1034. end;
  1035. function CreateTempSourceFile: string;
  1036. var
  1037. TempDir, TempDir2: string;
  1038. begin
  1039. TempDir := GenerateTempFolder(GetTempPath);
  1040. UnZipFile(AFileName, TempDir);
  1041. try
  1042. TempDir2 := GenerateTempFolder(GetTempPath);
  1043. try
  1044. UnZipFile(GetTempFile(TempDir), TempDir2);
  1045. Result := GetTempFileName;
  1046. SimpleDecrypt(TempDir2 + '\Main.dat', Result);
  1047. finally
  1048. DeleteFileOrFolder(TempDir2);
  1049. end;
  1050. finally
  1051. DeleteFileOrFolder(TempDir);
  1052. end;
  1053. end;
  1054. procedure BeforeCopyData;
  1055. begin
  1056. DisConnectTree;
  1057. CloseAllData;
  1058. end;
  1059. procedure EndCopyData;
  1060. begin
  1061. OpenAllData;
  1062. ReConnectTree;
  1063. FProjProperties.UpdateFlag := 1;
  1064. BillsCompileData.CalculateAll;
  1065. end;
  1066. function CheckFile: Boolean;
  1067. var
  1068. TempDir: string;
  1069. Proj: TProjectData;
  1070. begin
  1071. TempDir := GenerateTempFolder(GetTempPath);
  1072. UnZipFile(AFileName, TempDir);
  1073. try
  1074. Proj := TProjectData.Create;
  1075. Proj.SimpleOpen(GetTempFile(TempDir));
  1076. Result := Proj.ProjProperties.UpdateFlag = 1;
  1077. finally
  1078. Proj.Free;
  1079. DeleteFileOrFolder(TempDir);
  1080. end;
  1081. end;
  1082. var
  1083. sTemMainFile: string;
  1084. begin
  1085. sTemMainFile := CreateTempSourceFile;
  1086. BeforeCopyData;
  1087. try
  1088. ClearAllData;
  1089. CopyData(sTemMainFile);
  1090. finally
  1091. EndCopyData;
  1092. DeleteFileOrFolder(sTemMainFile);
  1093. end;
  1094. end;
  1095. function TProjectData.CheckPassword: Boolean;
  1096. var
  1097. sPassword: string;
  1098. begin
  1099. if ProjProperties.UnlockInfoPassword = '' then
  1100. Result := True
  1101. else
  1102. begin
  1103. Result := InputPassword(sPassword);
  1104. if Result then
  1105. begin
  1106. Result := sPassword = ProjProperties.UnlockInfoPassword;
  1107. if not Result then ErrorMessage('您输入的密码不正确!');
  1108. end;
  1109. end;
  1110. end;
  1111. procedure TProjectData.SetCheckers(const Value: TCheckers);
  1112. begin
  1113. FCheckers := Value;
  1114. end;
  1115. procedure TProjectData.OpenForSubmit(const AFileName: string);
  1116. begin
  1117. FProjectID := -1;
  1118. UnZipFile(AFileName, TempPath);
  1119. FConnection.Open(MainFileName);
  1120. FProjProperties.Open(FConnection.Connection);
  1121. FStaffData.Open(FConnection.Connection);
  1122. end;
  1123. procedure TProjectData.SaveAsForSubmit(const AFileName: string);
  1124. begin
  1125. FStaffData.Save;
  1126. FProjProperties.Save;
  1127. FConnection.Save;
  1128. ZipFolder(FTempFolder, AFileName);
  1129. end;
  1130. procedure TProjectData.LockBillsBaseData;
  1131. const
  1132. sLockInfoSql = 'Update Bills Set LockedInfo = True, LockedLevel = True';
  1133. sLockNPSql = 'Update Bills Set LockedNewPrice = True Where NewPrice <> 0';
  1134. begin
  1135. ExecuteSql(sLockInfoSql);
  1136. ExecuteSql(sLockNPSql);
  1137. end;
  1138. procedure TProjectData.LockDealPaymentData;
  1139. const
  1140. sLockDealSql = 'Update DealPayment Set Locked = True';
  1141. sLockFormulaSql = 'Update DealPayment Set LockedFormula = True Where (Formula <> '''')';
  1142. begin
  1143. ExecuteSql(sLockDealSql);
  1144. ExecuteSql(sLockFormulaSql);
  1145. end;
  1146. procedure TProjectData.LockBGLData;
  1147. const
  1148. sBGSql = 'Update BGL Set Locked = True';
  1149. sBGBillsSql = 'Update BGBills Set Locked = True';
  1150. begin
  1151. ExecuteSql(sBGSql);
  1152. ExecuteSql(sBGBillsSql);
  1153. end;
  1154. procedure TProjectData.OpenForReport(const AFileName: string);
  1155. begin
  1156. FProjectID := -1;
  1157. UnZipFile(AFileName, TempPath);
  1158. FConnection.Open(MainFileName);
  1159. UpdateProjectDataBase;
  1160. FProjProperties.Open(FConnection.Connection);
  1161. UpdateOldData;
  1162. FBillsData.Open(FConnection.Connection);
  1163. FBillsCompileData.Open;
  1164. FDealPaymentData.Open(FConnection.Connection);
  1165. FBGLData.Open(FConnection.Connection);
  1166. end;
  1167. procedure TProjectData.OpenForReply(const AFileName: string);
  1168. begin
  1169. FProjectID := -1;
  1170. UnZipFile(AFileName, TempPath);
  1171. FConnection.Open(MainFileName);
  1172. FProjProperties.Open(FConnection.Connection);
  1173. if ProjProperties.PhaseCount > 0 then
  1174. begin
  1175. FPhaseIndex := ProjProperties.PhaseCount;
  1176. FPhaseData.SimpleOpen(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
  1177. end;
  1178. FStaffData.Open(FConnection.Connection);
  1179. end;
  1180. procedure TProjectData.SaveForReply(const AFileName: string);
  1181. begin
  1182. FStaffData.Save;
  1183. if FPhaseData.Active then
  1184. FPhaseData.SimpleSave;
  1185. FProjProperties.Save;
  1186. FConnection.Save;
  1187. ZipFolder(FTempFolder, AFileName);
  1188. end;
  1189. procedure TProjectData.OpenForReceive(const AFileName: string);
  1190. begin
  1191. FProjectID := -1;
  1192. UnZipFile(AFileName, TempPath);
  1193. FConnection.Open(MainFileName);
  1194. FProjProperties.Open(FConnection.Connection);
  1195. if ProjProperties.PhaseCount > 0 then
  1196. begin
  1197. FPhaseIndex := ProjProperties.PhaseCount;
  1198. FPhaseData.SimpleOpen(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
  1199. end;
  1200. FStaffData.Open(FConnection.Connection);
  1201. end;
  1202. procedure TProjectData.SaveForReceive(const AFileName: string);
  1203. begin
  1204. FStaffData.Save;
  1205. if FPhaseData.Active then
  1206. FPhaseData.SimpleSave;
  1207. FProjProperties.Save;
  1208. FConnection.Save;
  1209. ZipFolder(FTempFolder, AFileName);
  1210. end;
  1211. procedure TProjectData.CloseAllData;
  1212. begin
  1213. FBillsData.Close;
  1214. FBillsCompileData.Close;
  1215. FBillsMeasureData.Close;
  1216. FDealBillsData.Close;
  1217. FDealPaymentData.Close;
  1218. FBGLData.Close;
  1219. FStaffData.Close;
  1220. FMainListData.Close;
  1221. end;
  1222. procedure TProjectData.OpenAllData;
  1223. begin
  1224. FProjProperties.Open(FConnection.Connection);
  1225. FBillsData.Open(FConnection.Connection);
  1226. FBillsCompileData.Open;
  1227. FBillsMeasureData.Open;
  1228. FDealBillsData.Open(FConnection.Connection);
  1229. FDealPaymentData.Open(FConnection.Connection);
  1230. FBGLData.Open(FConnection.Connection);
  1231. FStaffData.Open(FConnection.Connection);
  1232. FMainListData.Open(FConnection.Connection);
  1233. end;
  1234. procedure TProjectData.UpdateOldData;
  1235. procedure UpdateBills_OrgData;
  1236. const
  1237. sUpdateSql = 'Update Bills Set OrgQuantity = Quantity, OrgTotalPrice = TotalPrice';
  1238. begin
  1239. ExecuteSql(sUpdateSql);
  1240. end;
  1241. begin
  1242. if ProjProperties.UpdateFlag = 1 then Exit;
  1243. ProjProperties.UpdateFlag := 1;
  1244. UpdateBills_OrgData;
  1245. end;
  1246. procedure TProjectData.ResetFloatDigitView;
  1247. procedure SetBillsCompileDigit;
  1248. begin
  1249. with FBillsCompileData.sdvBillsCompile do
  1250. begin
  1251. Columns.FindColumn('OrgQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1252. Columns.FindColumn('MisQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1253. Columns.FindColumn('OthQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1254. Columns.FindColumn('Quantity').DisplayFormat := FProjProperties.QuantityFormat;
  1255. Columns.FindColumn('DgnQuantity1').DisplayFormat := FProjProperties.QuantityFormat;
  1256. Columns.FindColumn('DgnQuantity2').DisplayFormat := FProjProperties.QuantityFormat;
  1257. Columns.FindColumn('OrgTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1258. Columns.FindColumn('MisTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1259. Columns.FindColumn('OthTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1260. Columns.FindColumn('TotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1261. Columns.FindColumn('Price').DisplayFormat := FProjProperties.PriceFormat;
  1262. Columns.FindColumn('DgnPrice').DisplayFormat := FProjProperties.PriceFormat;
  1263. Columns.FindColumn('OrgQuantity').EditFormat := FProjProperties.QuantityFormat;
  1264. Columns.FindColumn('MisQuantity').EditFormat := FProjProperties.QuantityFormat;
  1265. Columns.FindColumn('OthQuantity').EditFormat := FProjProperties.QuantityFormat;
  1266. Columns.FindColumn('Quantity').EditFormat := FProjProperties.QuantityFormat;
  1267. Columns.FindColumn('DgnQuantity1').EditFormat := FProjProperties.QuantityFormat;
  1268. Columns.FindColumn('DgnQuantity2').EditFormat := FProjProperties.QuantityFormat;
  1269. Columns.FindColumn('OrgTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1270. Columns.FindColumn('MisTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1271. Columns.FindColumn('OthTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1272. Columns.FindColumn('TotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1273. Columns.FindColumn('Price').EditFormat := FProjProperties.PriceFormat;
  1274. Columns.FindColumn('DgnPrice').EditFormat := FProjProperties.PriceFormat;
  1275. end;
  1276. end;
  1277. procedure SetBillsMeasureDigit;
  1278. begin
  1279. with FBillsMeasureData.sdvBillsMeasure do
  1280. begin
  1281. Columns.FindColumn('Quantity').DisplayFormat := FProjProperties.QuantityFormat;
  1282. Columns.FindColumn('CurDealQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1283. Columns.FindColumn('CurQcQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1284. Columns.FindColumn('CurPcQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1285. Columns.FindColumn('CurGatherQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1286. Columns.FindColumn('EndDealQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1287. Columns.FindColumn('EndQcQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1288. Columns.FindColumn('EndPcQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1289. Columns.FindColumn('EndGatherQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1290. Columns.FindColumn('AddDealQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1291. Columns.FindColumn('AddQcQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1292. Columns.FindColumn('AddPcQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1293. Columns.FindColumn('AddGatherQuantity').DisplayFormat := FProjProperties.QuantityFormat;
  1294. Columns.FindColumn('DealDgnQuantity1').DisplayFormat := FProjProperties.QuantityFormat;
  1295. Columns.FindColumn('DealDgnQuantity2').DisplayFormat := FProjProperties.QuantityFormat;
  1296. Columns.FindColumn('CDgnQuantity1').DisplayFormat := FProjProperties.QuantityFormat;
  1297. Columns.FindColumn('CDgnQuantity2').DisplayFormat := FProjProperties.QuantityFormat;
  1298. Columns.FindColumn('TotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1299. Columns.FindColumn('CurDealTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1300. Columns.FindColumn('CurQcTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1301. Columns.FindColumn('CurPcTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1302. Columns.FindColumn('CurGatherTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1303. Columns.FindColumn('EndDealTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1304. Columns.FindColumn('EndQcTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1305. Columns.FindColumn('EndPcTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1306. Columns.FindColumn('EndGatherTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1307. Columns.FindColumn('AddDealTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1308. Columns.FindColumn('AddQcTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1309. Columns.FindColumn('AddPcTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1310. Columns.FindColumn('AddGatherTotalPrice').DisplayFormat := FProjProperties.TotalPriceFormat;
  1311. Columns.FindColumn('Price').DisplayFormat := FProjProperties.PriceFormat;
  1312. Columns.FindColumn('NewPrice').DisplayFormat := FProjProperties.PriceFormat;
  1313. Columns.FindColumn('Quantity').EditFormat := FProjProperties.QuantityFormat;
  1314. Columns.FindColumn('CurDealQuantity').EditFormat := FProjProperties.QuantityFormat;
  1315. Columns.FindColumn('CurQcQuantity').EditFormat := FProjProperties.QuantityFormat;
  1316. Columns.FindColumn('CurPcQuantity').EditFormat := FProjProperties.QuantityFormat;
  1317. Columns.FindColumn('CurGatherQuantity').EditFormat := FProjProperties.QuantityFormat;
  1318. Columns.FindColumn('EndDealQuantity').EditFormat := FProjProperties.QuantityFormat;
  1319. Columns.FindColumn('EndQcQuantity').EditFormat := FProjProperties.QuantityFormat;
  1320. Columns.FindColumn('EndPcQuantity').EditFormat := FProjProperties.QuantityFormat;
  1321. Columns.FindColumn('EndGatherQuantity').EditFormat := FProjProperties.QuantityFormat;
  1322. Columns.FindColumn('AddDealQuantity').EditFormat := FProjProperties.QuantityFormat;
  1323. Columns.FindColumn('AddQcQuantity').EditFormat := FProjProperties.QuantityFormat;
  1324. Columns.FindColumn('AddPcQuantity').EditFormat := FProjProperties.QuantityFormat;
  1325. Columns.FindColumn('AddGatherQuantity').EditFormat := FProjProperties.QuantityFormat;
  1326. Columns.FindColumn('DealDgnQuantity1').EditFormat := FProjProperties.QuantityFormat;
  1327. Columns.FindColumn('DealDgnQuantity2').EditFormat := FProjProperties.QuantityFormat;
  1328. Columns.FindColumn('CDgnQuantity1').EditFormat := FProjProperties.QuantityFormat;
  1329. Columns.FindColumn('CDgnQuantity2').EditFormat := FProjProperties.QuantityFormat;
  1330. Columns.FindColumn('TotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1331. Columns.FindColumn('CurDealTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1332. Columns.FindColumn('CurQcTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1333. Columns.FindColumn('CurPcTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1334. Columns.FindColumn('CurGatherTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1335. Columns.FindColumn('EndDealTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1336. Columns.FindColumn('EndQcTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1337. Columns.FindColumn('EndPcTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1338. Columns.FindColumn('EndGatherTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1339. Columns.FindColumn('AddDealTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1340. Columns.FindColumn('AddQcTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1341. Columns.FindColumn('AddPcTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1342. Columns.FindColumn('AddGatherTotalPrice').EditFormat := FProjProperties.TotalPriceFormat;
  1343. Columns.FindColumn('Price').EditFormat := FProjProperties.PriceFormat;
  1344. Columns.FindColumn('NewPrice').EditFormat := FProjProperties.PriceFormat;
  1345. end;
  1346. end;
  1347. begin
  1348. SetBillsCompileDigit;
  1349. SetBillsMeasureDigit;
  1350. end;
  1351. function TProjectData.GetStageDataReadOnly: Boolean;
  1352. begin
  1353. if FPhaseData.Active then
  1354. Result := FPhaseData.StageDataReadOnly
  1355. else
  1356. Result := True;
  1357. end;
  1358. procedure TProjectData.OpenForReport2(const AFileName: string);
  1359. begin
  1360. FProjectID := -1;
  1361. UnZipFile(AFileName, TempPath);
  1362. FConnection.Open(MainFileName);
  1363. UpdateProjectDataBase;
  1364. FProjProperties.Open(FConnection.Connection);
  1365. UpdateOldData;
  1366. FBillsData.Open(FConnection.Connection);
  1367. FBillsCompileData.Open;
  1368. FDealPaymentData.Open(FConnection.Connection);
  1369. FBGLData.Open(FConnection.Connection);
  1370. if ProjProperties.PhaseCount > 0 then
  1371. begin
  1372. FPhaseIndex := ProjProperties.PhaseCount;
  1373. FPhaseData.SimpleOpen(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
  1374. end;
  1375. end;
  1376. <<<<<<< HEAD
  1377. function TProjectData.CheckDataBaseInfo(APhaseCount, AAuditStatus: Integer): Boolean;
  1378. begin
  1379. Result := (FProjProperties.PhaseCount = APhaseCount)
  1380. and (FProjProperties.AuditStatus = AAuditStatus);
  1381. if Result and (APhaseCount > 0) and (AAuditStatus <> -1) then
  1382. Result := PhaseData.AuditCount = AAuditStatus;
  1383. =======
  1384. procedure TProjectData.OpenForReport3(const AFileName: string);
  1385. begin
  1386. FProjectID := -1;
  1387. UnZipFile(AFileName, TempPath);
  1388. FConnection.Open(MainFileName);
  1389. UpdateProjectDataBase;
  1390. FProjProperties.Open(FConnection.Connection);
  1391. UpdateOldData;
  1392. FBillsData.Open(FConnection.Connection);
  1393. FBillsMeasureData.Open;
  1394. FDealPaymentData.Open(FConnection.Connection);
  1395. FBGLData.Open(FConnection.Connection);
  1396. if ProjProperties.PhaseCount > 0 then
  1397. begin
  1398. FPhaseIndex := ProjProperties.PhaseCount;
  1399. FPhaseData.SimpleOpen2(Format('%sPhase%d.dat', [TempPath, FPhaseIndex]));
  1400. end;
  1401. FBillsMeasureData.ResetTreeNodeStageRec;
  1402. >>>>>>> 3.1.3.3
  1403. end;
  1404. end.