ScPersistentData.pas 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652
  1. {}
  2. {李涛 日期: 2010.5.6}
  3. {节点回收站: 保存已删除的项目节点}
  4. {}
  5. unit ScPersistentData;
  6. interface
  7. uses Classes, DBClient, ScNodeRecycleBinDM, ScBills, Variants, ScBillsDM, sdDB;
  8. type
  9. {****************************************************************************}
  10. {***************************** 数据结构 *************************************}
  11. {****************************************************************************}
  12. {文件信息}
  13. TFileInfo = class(TComponent)
  14. private
  15. FName: string;
  16. FDeleteTime: TDateTime;
  17. published
  18. property Name: string read FName write FName;
  19. property DeleteTime: TDateTime read FDeleteTime write FDeleteTime;
  20. end;
  21. {清单记录}
  22. TBillsRec = class(TComponent)
  23. private
  24. FID: Integer;
  25. FParentID: Integer;
  26. FNextSiblingID: Integer;
  27. FCode: string;
  28. FName: string;
  29. FUnits: string;
  30. FBCode: string;
  31. FDQuantity: Double;
  32. FDQuantity2: Double;
  33. FDPrice: Double;
  34. FFlag: Integer;
  35. FIsPreDefine: Boolean;
  36. FIsLeaf: Boolean;
  37. FCalcKinds: Integer;
  38. FQuantity: Double;
  39. FQuantity2: Double;
  40. FUnitPrice: Double;
  41. FTotalPrice: Double;
  42. FBillsGLJPriceLib: string;
  43. FMemoString: string;
  44. FParentIDChanged: Boolean;
  45. FNextSiblingIDChanged: Boolean;
  46. FOldID: Integer;
  47. published
  48. property ID: Integer read FID write FID;
  49. property ParentID: Integer read FParentID write FParentID;
  50. property NextSiblingID: Integer read FNextSiblingID write FNextSiblingID;
  51. property Code: string read FCode write FCode;
  52. property Name: string read FName write FName;
  53. property Units: string read FUnits write FUnits;
  54. property BCode: string read FBCode write FBCode;
  55. property DQuantity: Double read FDQuantity write FDQuantity;
  56. property DQuantity2: Double read FDQuantity2 write FDQuantity2;
  57. property DPrice: Double read FDPrice write FDPrice;
  58. property IsPreDefine: Boolean read FIsPreDefine write FIsPreDefine;
  59. property Flag: Integer read FFlag write FFlag;
  60. property IsLeaf: Boolean read FIsLeaf write FIsLeaf;
  61. property CalcKinds: Integer read FCalcKinds write FCalcKinds;
  62. property Quantity: Double read FQuantity write FQuantity;
  63. property Quantity2: Double read FQuantity2 write FQuantity2;
  64. property UnitPrice: Double read FUnitPrice write FUnitPrice;
  65. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  66. property BillsGLJPriceLib: string read FBillsGLJPriceLib write FBillsGLJPriceLib;
  67. property MemoString: string read FMemoString write FMemoString;
  68. property ParentIDChanged: Boolean read FParentIDChanged write FParentIDChanged;
  69. property NextSiblingIDChanged: Boolean read FNextSiblingIDChanged write FNextSiblingIDChanged;
  70. end;
  71. TDrawingQuantity = class(TComponent)
  72. private
  73. FBillsID: Integer;
  74. FSerinalNo: Integer;
  75. FName: string;
  76. FUnits: string;
  77. FDQuantity1: Double;
  78. FMemoContext: string;
  79. published
  80. property BillsID: Integer read FBillsID write FBillsID;
  81. property SerinalNo: Integer read FSerinalNo write FSerinalNo;
  82. property Name: string read FName write FName;
  83. property Units: string read FUnits write FUnits;
  84. property DQuantity1: Double read FDQuantity1 write FDQuantity1;
  85. property MemoContext: string read FMemoContext write FMemoContext;
  86. end;
  87. {定额、数量单价}
  88. TRationsRec = class(TComponent)
  89. private
  90. FID: Integer;
  91. FCode: string;
  92. FName: string;
  93. FUnits: string;
  94. FQuantity: Double;
  95. FQuantityXS: Double;
  96. FGetFeeKind: Variant;
  97. FAdjustState: string;
  98. FBillsID: Integer;
  99. FSerialNo: Integer;
  100. FMaskName: string;
  101. FUnitDirectFee: Double;
  102. FCountPriceType: Variant;
  103. FBuildingFee: Double;
  104. FRationProjName: string;
  105. FIsCalcProfit: Boolean;
  106. FCodeForReport: string;
  107. FContent: string;
  108. FLibType: Integer;
  109. FCodeLength: Integer;
  110. FRationProjName2: string;
  111. FName2: string;
  112. FUnit2: string;
  113. FCodeForReport2: string;
  114. FIsCalcEquipmentFee: Boolean;
  115. FIsCalcTax: Boolean;
  116. FRType: Integer;
  117. FLibID: Integer;
  118. FIsMECalc: Boolean;
  119. FUnitPrice: Double;
  120. FRationUnitDirectFee: Double;
  121. FSpecs: string;
  122. FGLJID: Integer;
  123. published
  124. property ID: Integer read FID write FID;
  125. property Code: string read FCode write FCode;
  126. property Name: string read FName write FName;
  127. property Units: string read FUnits write FUnits;
  128. property Quanity: Double read FQuantity write FQuantity;
  129. property QuantityXS: Double read FQuantityXS write FQuantityXS;
  130. property GetFeeKind: Variant read FGetFeeKind write FGetFeeKind;
  131. property AdjustState: string read FAdjustState write FAdjustState;
  132. property BillsID: Integer read FBillsID write FBillsID;
  133. property SerialNo: Integer read FSerialNo write FSerialNo;
  134. property MaskName: string read FMaskName write FMaskName;
  135. property CountPriceType: Variant read FCountPriceType write FCountPriceType;
  136. property UnitDirectFee: Double read FUnitDirectFee write FUnitDirectFee;
  137. property BuildingFee: Double read FBuildingFee write FBuildingFee;
  138. property RationProjName: string read FRationProjName write FRationProjName;
  139. property IsCalcProfit: Boolean read FIsCalcProfit write FIsCalcProfit;
  140. property CodeForReport: string read FCodeForReport write FCodeForReport;
  141. property Content: string read FContent write FContent;
  142. property LibType: Integer read FLibType write FLibType;
  143. property CodeLength: Integer read FCodeLength write FCodeLength;
  144. property RationProjName2: string read FRationProjName2 write FRationProjName2;
  145. property Name2: string read FName2 write FName2;
  146. property Unit2: string read FUnit2 write FUnit2;
  147. property CodeForReport2: string read FCodeForReport2 write FCodeForReport2;
  148. property IsCalcEquipmentFee: Boolean read FIsCalcEquipmentFee write FIsCalcEquipmentFee;
  149. property IsCalcTax: Boolean read FIsCalcTax write FIsCalcTax;
  150. property RType: Integer read FRType write FRType;
  151. property LibID: Integer read FLibID write FLibID;
  152. property Specs: string read FSpecs write FSpecs;
  153. property IsMECalc: Boolean read FIsMECalc write FIsMECalc;
  154. property RationUnitDirectFee: Double read FRationUnitDirectFee write FRationUnitDirectFee;
  155. property UnitPrice: Double read FUnitPrice write FUnitPrice;
  156. property GLJID: Integer read FGLJID write FGLJID;
  157. end;
  158. {工料机}
  159. TGLJRec = class(TComponent)
  160. private
  161. FRGLJID: Integer;
  162. FRQuantity: Double;
  163. FOrgRQuantity: Variant;
  164. FRationPrice: Double;
  165. FFlag: Integer;
  166. FMinorRQ1: Double;
  167. FMinorRQ2: Double;
  168. FMinorRQ3: Double;
  169. FGLJID: Integer;
  170. FRUID: Integer;
  171. FSortParam: Integer;
  172. FCalculateType: Variant;
  173. FUID: Integer;
  174. FCustomQuantity: Variant;
  175. FBudgetPrice: Double;
  176. FQuantity: Double;
  177. FLibID: Integer;
  178. FBillsID: Integer;
  179. FRationsID: Integer;
  180. FGLJType: Variant;
  181. FTenderPrice: Double;
  182. FRationItemQuantity: Double;
  183. FRName: string;
  184. FUnit: string;
  185. FSpecs: string;
  186. FRCode: string;
  187. FCode: string;
  188. FName: string;
  189. FRUnit: string;
  190. FRSpecs: string;
  191. published
  192. property RGLJID: Integer read FRGLJID write FRGLJID;
  193. property RQuantity: Double read FRQuantity write FRQuantity;
  194. property OrgRQuantity: Variant read FOrgRQuantity write FOrgRQuantity;
  195. property RationPrice: Double read FRationPrice write FRationPrice;
  196. property Flag: Integer read FFlag write FFlag;
  197. property MinorRQ1: Double read FMinorRQ1 write FMinorRQ1;
  198. property MinorRQ2: Double read FMinorRQ2 write FMinorRQ2;
  199. property MinorRQ3: Double read FMinorRQ3 write FMinorRQ3;
  200. property GLJID: Integer read FGLJID write FGLJID;
  201. property SortParam: Integer read FSortParam write FSortParam;
  202. property CalculateType: Variant read FCalculateType write FCalculateType;
  203. property CustomQuantity: Variant read FCustomQuantity write FCustomQuantity;
  204. property BudgetPrice: Double read FBudgetPrice write FBudgetPrice;
  205. property Quantity: Double read FQuantity write FQuantity;
  206. property LibID: Integer read FLibID write FLibID;
  207. property BillsID: Integer read FBillsID write FBillsID;
  208. property RationsID: Integer read FRationsID write FRationsID;
  209. property GLJType: Variant read FGLJType write FGLJType;
  210. property TenderPrice: Double read FTenderPrice write FTenderPrice;
  211. property RationItemQuantity: Double read FRationItemQuantity write FRationItemQuantity;
  212. property RCode: string read FRCode write FRCode;
  213. property RName: string read FRName write FRName;
  214. property RSpecs: string read FRSpecs write FRSpecs;
  215. property RUnit: string read FRUnit write FRUnit;
  216. property Code: string read FCode write FCode;
  217. property Name: string read FName write FName;
  218. property Specs: string read FSpecs write FSpecs;
  219. property Units: string read FUnit write FUnit;
  220. end;
  221. {辅助调整}
  222. TFZRec = class(TComponent)
  223. private
  224. FRationID: Integer;
  225. FParamName: string;
  226. FParamIndex: Integer;
  227. FNewValue: Double;
  228. FMinorIndex: Integer;
  229. FBaseValue: Double;
  230. FIncStep: Double;
  231. FRationCode: string;
  232. FRationCode1: Integer;
  233. FRoundDigit: Integer;
  234. FRoundMode: Integer;
  235. published
  236. property RationID: Integer read FRationID write FRationID;
  237. property ParamName: string read FParamName write FParamName;
  238. property ParamIndex: Integer read FParamIndex write FParamIndex;
  239. property NewValue: Double read FNewValue write FNewValue;
  240. property MinorIndex: Integer read FMinorIndex write FMinorIndex;
  241. property BaseValue: Double read FBaseValue write FBaseValue;
  242. property IncStep: Double read FIncStep write FIncStep;
  243. property RationCode: string read FRationCode write FRationCode;
  244. property RationCode1: Integer read FRationCode1 write FRationCode1;
  245. property RoundDigit: Integer read FRoundDigit write FRoundDigit;
  246. property RoundMode: Integer read FRoundMode write FRoundMode;
  247. end;
  248. {配比调整}
  249. TPBRec = class(TComponent)
  250. private
  251. FRationID: Integer;
  252. FCode: string;
  253. FGLJID: Integer;
  254. FProportion: Double;
  255. FRProportion: Double;
  256. published
  257. property RationID: Integer read FRationID write FRationID;
  258. property Code: string read FCode write FCode;
  259. property GLJID: Integer read FGLJID write FGLJID;
  260. property Proportion: Double read FProportion write FProportion;
  261. property RProportion: Double read FRProportion write FRProportion;
  262. end;
  263. {单价调整}
  264. TDJRec = class(TComponent)
  265. private
  266. FOwnerID: Integer;
  267. FGLJID: Integer;
  268. FUnitPrice: Double;
  269. FFlag: Integer;
  270. FGLJCode: Integer;
  271. FLibID: Integer;
  272. published
  273. property OwnerID: Integer read FOwnerID write FOwnerID;
  274. property GLJID: Integer read FGLJID write FGLJID;
  275. property UnitPrice: Double read FUnitPrice write FUnitPrice;
  276. property Flag: Integer read FFlag write FFlag;
  277. property GLJCode: Integer read FGLJCode write FGLJCode;
  278. property LibID: Integer read FLibID write FLibID;
  279. end;
  280. {油石率调整}
  281. TYSRateRec = class(TComponent)
  282. private
  283. FRationID: Integer;
  284. FRYSRate: Double;
  285. FYSRate: Variant;
  286. published
  287. property RationID: Integer read FRationID write FRationID;
  288. property RYSRate: Double read FRYSRate write FRYSRate;
  289. property YSRate: Variant read FYSRate write FYSRate;
  290. end;
  291. {系数调整}
  292. TXSRec = class(TComponent)
  293. private
  294. FRationID: Integer;
  295. FCoeID: Integer;
  296. FSelected: Boolean;
  297. FFlag: Integer;
  298. FData: string;
  299. FCalcOrder: Integer;
  300. FGroupIdx: Integer;
  301. FParam: Integer;
  302. published
  303. property RationID: Integer read FRationID write FRationID;
  304. property CoeID: Integer read FCoeID write FCoeID;
  305. property Selected: Boolean read FSelected write FSelected;
  306. property Flag: Integer read FFlag write FFlag;
  307. property Data: string read FData write FData;
  308. property CalcOrder: Integer read FCalcOrder write FCalcOrder;
  309. property GroupIdx: Integer read FGroupIdx write FGroupIdx;
  310. property Param: Integer read FParam write FParam;
  311. end;
  312. {辅助定额}
  313. TMMrRec = class(TComponent)
  314. private
  315. FRationID: Integer;
  316. FMinorIndex: Integer;
  317. FParamIndex: Integer;
  318. FMinorParam: Double;
  319. FParamName: string;
  320. FMinorName: string;
  321. FBaseValue: Double;
  322. FRoundDigit: Integer;
  323. FRoundMode: Integer;
  324. FIncStep: Double;
  325. FRationCode: string;
  326. FRationIDCode: Integer;
  327. published
  328. property RationID: Integer read FRationID write FRationID;
  329. property MinorIndex: Integer read FMinorIndex write FMinorIndex;
  330. property ParamIndex: Integer read FParamIndex write FParamIndex;
  331. property MinorParam: Double read FMinorParam write FMinorParam;
  332. property ParamName: string read FParamName write FParamName;
  333. property MinorName: string read FMinorName write FMinorName;
  334. property BaseValue: Double read FBaseValue write FBaseValue;
  335. property RoundDigit: Integer read FRoundDigit write FRoundDigit;
  336. property RoundMode: Integer read FRoundMode write FRoundMode;
  337. property IncStep: Double read FIncStep write FIncStep;
  338. property RationCode: string read FRationCode write FRationCode;
  339. property RationIDCode: Integer read FRationIDCode write FRationIDCode;
  340. end;
  341. {辅助工料机}
  342. TMMgRec = class(TComponent)
  343. private
  344. FRationID: Integer;
  345. FMinorIndex: Integer;
  346. FGLJID: Integer;
  347. FGLJCode: string;
  348. FMRQ1: Double;
  349. FMRQ2: Double;
  350. FMRQ3: Double;
  351. published
  352. property RationID: Integer read FRationID write FRationID;
  353. property MinorIndex: Integer read FMinorIndex write FMinorIndex;
  354. property GLJID: Integer read FGLJID write FGLJID;
  355. property GLJCode: string read FGLJCode write FGLJCode;
  356. property MRQ1: Double read FMRQ1 write FMRQ1;
  357. property MRQ2: Double read FMRQ2 write FMRQ2;
  358. property MRQ3: Double read FMRQ3 write FMRQ3;
  359. end;
  360. {公式}
  361. TExprsRec = class(TComponent)
  362. private
  363. FMajorID: Integer;
  364. FMinorID: Integer;
  365. FExprs: String;
  366. FFlag: Integer;
  367. FRecdID: Integer;
  368. FExprsValue: Double;
  369. FExprs1: string;
  370. FExprs2: string;
  371. FExprs3: string;
  372. FExprs4: string;
  373. published
  374. property MajorID: Integer read FMajorID write FMinorID;
  375. property MinorID: Integer read FMinorID write FMinorID;
  376. property Exprs: string read FExprs write FExprs;
  377. property Flag: Integer read FFlag write FFlag;
  378. property RecdID: Integer read FRecdID write FRecdID;
  379. property ExprsValue: Double read FExprsValue write FExprsValue;
  380. property Exprs1: string read FExprs1 write FExprs1;
  381. property Exprs2: string read FExprs2 write FExprs2;
  382. property Exprs3: string read FExprs3 write FExprs3;
  383. property Exprs4: string read FExprs4 write FExprs4;
  384. end;
  385. {文件操作管理}
  386. TFileOpManager = class
  387. private
  388. FFileDir: string;
  389. FBuildProjectFolder: string;
  390. FFullBuildProjectPath: string;
  391. FExtractFileName: string;
  392. FGUID: string;
  393. procedure HandlerSpecialChar(var AText: string);
  394. function RevertSpecialChar(const AText: string): string;
  395. public
  396. procedure ExtractParticularName(const aProjName, aFullBPName, aAlias, aGUID: string);
  397. function GetCurProjectDir: string;
  398. function GetSaveFileName(const ACode, ABCode, AName: string): string;
  399. property FileDir: string read FFileDir write FFileDir;
  400. property ExtractNameWithOutExt: string read FExtractFileName write FExtractFileName;
  401. end;
  402. {****************************************************************************}
  403. {*********************************** 结束 ***********************************}
  404. {****************************************************************************}
  405. TPersistentData = class
  406. private
  407. FMaxBillsID: Integer;
  408. FMaxRationID: Integer;
  409. FMaxDqID: Integer;
  410. FProject: TObject;
  411. FFileInfo: TFileInfo;
  412. FBillsList: TList;
  413. FDQList: TList;
  414. FRationsList: TList;
  415. FGLJList: TList;
  416. FFZList: TList;
  417. FPBList: TList;
  418. FDJList: TList;
  419. FYSRateList: TList;
  420. FXSList: TList;
  421. FMMrList: TList;
  422. FMMgList: TList;
  423. FExprsList: TList;
  424. FNameList: TStringList;
  425. FDeleteNameList: TStringList;
  426. FFileOpManager: TFileOpManager;
  427. procedure ClearAllList;
  428. procedure ClearNameList;
  429. procedure DeleteListFiles;
  430. procedure DeleteNameListFiles;
  431. procedure ShowErrorMessage(const Text: string);
  432. procedure AddNameToList(const AFileName: string);
  433. procedure AddDeleteNameToList(const AFileName: string);
  434. procedure DeleteDQ(ABillsID: Integer);
  435. procedure DeleteRations(ABillsID: Integer);
  436. procedure DeleteGLJs(ARationID: Integer);
  437. procedure DeleteFZ(ARationID: Integer);
  438. procedure DeletePB(ARationID: Integer);
  439. procedure DeleteXS(ARationID: Integer);
  440. procedure DeleteDJ(AID, AType: Integer);
  441. procedure DeleteYSRate(ARationID: Integer);
  442. procedure DeleteMMr(ARationID: Integer);
  443. procedure DeleteMMg(ARationID: Integer);
  444. procedure DeleteExprs(AID, AType: Integer);
  445. procedure DeleteRecordsBasisBillsID(ABillsID: Integer);
  446. procedure CheckClassExists;
  447. function CheckParentNodeExists(AID: Integer; Flag: Integer): Boolean;
  448. procedure ConformStructuralLevel(var AFirstID, ALastNextID: Integer; AParentID: Integer);
  449. function ReturnBillsInside(ARec: TScBillsRecord; AList: TList;
  450. AIsClearQ, AIsNew: Boolean; var AFirstID, ALastNextID: Integer): Integer;
  451. procedure InternalPersistent;
  452. procedure InternalReadPersistent(const AFileName: string; IsReadAll: Boolean);
  453. procedure InternalWriteDB(ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
  454. procedure ReturnBills(AItem: TScBillsItem; AIsClearQ, AIsNew: Boolean);
  455. procedure ReturnDraqQty(aOldBillsID, aNewBillsID: Integer; aIsClearQ: Boolean);
  456. procedure ReturnRations(AOldBillsID, ANewBillsID: Integer; AIsClearQ: Boolean);
  457. procedure ReturnGLJs(AOldBillsID, ANewBillsID, AOldRationID, ANewRationID: Integer);
  458. procedure ReturnFZ(AOldRationID, ANewRationID: Integer);
  459. procedure ReturnPB(AOldRationID, ANewRationID: Integer);
  460. procedure ReturnXS(AOldRationID, ANewRationID: Integer);
  461. procedure ReturnDJ(AOldID, ANewID, AType: Integer);
  462. procedure ReturnYSRate(AOldRationID, ANewRationID: Integer);
  463. procedure ReturnMMr(AOldRationID, ANewRationID: Integer);
  464. procedure ReturnMMg(AOldRationID, ANewRation: Integer);
  465. procedure ReturnRAdjust(AOldRationID, ANewRationID: Integer);
  466. procedure ReturnExprs(AOldID, ANewID, AType: Integer);
  467. function GetFileDir: string;
  468. procedure SetFileDir(const Value: string);
  469. public
  470. constructor Create;
  471. destructor Destroy; override;
  472. procedure Save;
  473. procedure DeleteCurFile(const AFileName: string);
  474. procedure CreateFileInfo(ARecord: TScBillsRecord);
  475. procedure AppendBillsRec(ARecord: TScBillsRecord);
  476. procedure AppendRationsRec(sdRation: TObject);
  477. procedure AppendGLJRec(sdGLJ: TObject);
  478. procedure AppendExprsRec(ARecord: TsdDataRecord);
  479. procedure AppendFZRec(ARecord: TsdDataRecord);
  480. procedure AppendPBRec(ARecord: TsdDataRecord);
  481. procedure AppendXSRec(ARecord: TsdDataRecord);
  482. procedure AppendYSRec(ARecord: TsdDataRecord);
  483. procedure AppendMMrRec(ARecord: TsdDataRecord);
  484. procedure AppendMMgRec(ARecord: TsdDataRecord);
  485. procedure AppendDJRec(ARecord: TsdDataRecord);
  486. procedure AppendDQRec(ARecord: TsdDataRecord);
  487. procedure PersistentObjects;
  488. procedure ReadPersistentObjects(const AFileName: string;
  489. ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
  490. procedure ExtractParticularFileName(const aProjName, aFullBPName, aAlias, aGUID: string);
  491. function CurProjectDir: string;
  492. function CheckFilePathInDelete(const AFileName: string): Boolean;
  493. function ReturnData(const AFileName: string; AItem: TScBillsItem;
  494. AIsClearQ, AIsNew: Boolean): Boolean;
  495. property FileDir: string read GetFileDir write SetFileDir;
  496. property Project: TObject read FProject write FProject;
  497. end;
  498. implementation
  499. uses ScRations, ScGLJ, ScConsts, SysUtils, DB, ScProject, ScExprs,
  500. ScRAdjusts, Windows, ZjIDTree, ScDrawingQuantityDM, ScProjectGLJ, ScUtils;
  501. const
  502. cflParent = 0;
  503. cflPrev = 1;
  504. cflNone = -1;
  505. RestoreBat = 'Pro_BackUp\';
  506. NodeBinFolder = 'NodeRecycleBin\';
  507. MyProject = '我的项目';
  508. cExt = '.pdn';
  509. { TPersistentData }
  510. procedure TPersistentData.AddNameToList(const AFileName: string);
  511. begin
  512. FNameList.Add(AFileName);
  513. end;
  514. procedure TPersistentData.AppendBillsRec(ARecord: TScBillsRecord);
  515. const
  516. sDQuantity = 'DesignQuantity';
  517. sDQuantity2 = 'DesignQuantity2';
  518. sDPrice = 'DesignPrice';
  519. sFlag = 'Flag';
  520. sIsPreDefine = 'IsPreDefine';
  521. sCalcKinds = 'CalcKinds';
  522. sMemoStr = 'MemoStr';
  523. sBillsGLJPriceLib = 'GLJPriceLib';
  524. var
  525. billsRec: TBillsRec;
  526. begin
  527. billsRec := TBillsRec.Create(nil);
  528. billsRec.ID := ARecord.ID.AsInteger;
  529. billsRec.ParentID := ARecord.ParentID.AsInteger;
  530. billsRec.NextSiblingID := ARecord.NextSiblingID.AsInteger;
  531. billsRec.Code := ARecord.Code.AsString;
  532. billsRec.Name := ARecord.Name.AsString;
  533. billsRec.Units := ARecord.Units.AsString;
  534. if TScProject(FProject).IsGuangDong then
  535. begin
  536. billsRec.BCode := ARecord.B_Code.AsString;
  537. end;
  538. billsRec.DQuantity := ARecord.DesignQuantity.AsFloat;
  539. billsRec.DQuantity2 := ARecord.DesignQuantity2.AsFloat;
  540. billsRec.DPrice := ARecord.DesignPrice.AsFloat;
  541. billsRec.Quantity := ARecord.Quantity.AsFloat;
  542. billsRec.Quantity2 := ARecord.Quantity2.AsFloat;
  543. billsRec.UnitPrice := ARecord.UnitPrice.AsFloat;
  544. billsRec.Flag := ARecord.Flag.AsInteger;
  545. billsRec.IsPreDefine := ARecord.IsPreDefine.AsBoolean;
  546. billsRec.IsLeaf := ARecord.IsLeaf.AsBoolean;
  547. billsRec.CalcKinds := ARecord.CalcKinds.AsInteger;
  548. billsRec.TotalPrice := ARecord.TotalPrice.AsFloat;
  549. billsRec.MemoString := ARecord.MemoStr.AsString;
  550. billsRec.BillsGLJPriceLib := ARecord.GLJPriceLib.AsString;
  551. FBillsList.Add(billsRec);
  552. end;
  553. procedure TPersistentData.AppendDJRec(ARecord: TsdDataRecord);
  554. const
  555. scsOwnerID = 'OwnerID';
  556. scsGLJCode = 'GLJCode';
  557. scsPrice = 'Price';
  558. scsFlag = 'Flag';
  559. scsGLJID = 'GLJID';
  560. scsLibID = 'LibID';
  561. var
  562. djRec: TDJRec;
  563. begin
  564. djRec := TDJRec.Create(nil);
  565. with ARecord do
  566. begin
  567. djRec.OwnerID := ValueByName(scsOwnerID).AsInteger;
  568. djRec.GLJID := ValueByName(scsGLJID).AsInteger;
  569. djRec.GLJCode := ValueByName(scsGLJCode).AsInteger;
  570. djRec.UnitPrice := ValueByName(scsPrice).AsFloat;
  571. djRec.LibID := ValueByName(scsLibID).AsInteger;
  572. djRec.Flag := ValueByName(scsFlag).AsInteger;
  573. end;
  574. FDJList.Add(djRec);
  575. end;
  576. procedure TPersistentData.AppendExprsRec(ARecord: TsdDataRecord);
  577. const
  578. scsMajorID = 'MajorID';
  579. scsMinorID = 'MinorID';
  580. scsExprs = 'Exprs';
  581. scsFlag = 'Flag';
  582. scsRecdID = 'RecdID';
  583. scsExprsValue = 'ExprsValue';
  584. scsExprs1 = 'Exprs1';
  585. scsExprs2 = 'Exprs2';
  586. scsExprs3 = 'Exprs3';
  587. scsExprs4 = 'Exprs4';
  588. var
  589. exprsRec: TExprsRec;
  590. begin
  591. exprsRec := TExprsRec.Create(nil);
  592. with ARecord do
  593. begin
  594. exprsRec.MajorID := ValueByName(scsMajorID).AsInteger;
  595. exprsRec.MinorID := ValueByName(scsMinorID).AsInteger;
  596. exprsRec.Exprs := ValueByName(scsExprs).AsString;
  597. exprsRec.Flag := ValueByName(scsFlag).AsInteger;
  598. exprsRec.RecdID := ValueByName(scsRecdID).AsInteger;
  599. exprsRec.ExprsValue := ValueByName(scsExprsValue).AsFloat;
  600. exprsRec.Exprs1 := ValueByName(scsExprs1).AsString;
  601. exprsRec.Exprs2 := ValueByName(scsExprs2).AsString;
  602. exprsRec.Exprs3 := ValueByName(scsExprs3).AsString;
  603. exprsRec.Exprs4 := ValueByName(scsExprs4).AsString;
  604. end;
  605. FExprsList.Add(exprsRec);
  606. end;
  607. procedure TPersistentData.AppendFZRec(ARecord: TsdDataRecord);
  608. const
  609. scsParamName = 'ParamName';
  610. scsParamIndex = 'ParamIndex';
  611. scsRationID = 'RationID';
  612. scsNewValue = 'NewValue';
  613. scsBaseValue = 'BaseValue';
  614. scsIncStep = 'IncStep';
  615. scsRationCode = 'RationCode';
  616. scsRationCode1 = 'RationCode1';
  617. scsMinorIndex = 'MinorIndex';
  618. scsRoundDigit = 'RoundDigit';
  619. scsRoundMode = 'RoundMode';
  620. var
  621. fzRec: TFZRec;
  622. begin
  623. fzRec := TFZRec.Create(nil);
  624. with ARecord do
  625. begin
  626. fzRec.ParamName := ValueByName(scsParamName).AsString;
  627. fzRec.ParamIndex := ValueByName(scsParamIndex).AsInteger;
  628. fzRec.RationID := ValueByName(scsRationID).AsInteger;
  629. fzRec.NewValue := ValueByName(scsNewValue).AsFloat;
  630. fzRec.MinorIndex := ValueByName(scsMinorIndex).AsInteger;
  631. fzRec.BaseValue := ValueByName(scsBaseValue).AsFloat;
  632. fzRec.IncStep := ValueByName(scsIncStep).AsFloat;
  633. fzRec.RationCode := ValueByName(scsRationCode).AsString;
  634. fzRec.RationCode1 := ValueByName(scsRationCode1).AsInteger;
  635. fzRec.RoundDigit := ValueByName(scsRoundDigit).AsInteger;
  636. fzRec.RoundMode := ValueByName(scsRoundMode).AsInteger;
  637. end;
  638. FFZList.Add(fzRec);
  639. end;
  640. procedure TPersistentData.AppendGLJRec(sdGLJ: TObject);
  641. var
  642. gljRec: TGLJRec;
  643. begin
  644. gljRec := TGLJRec.Create(nil);
  645. with TScGLJRecord(sdGLJ) do
  646. begin
  647. gljRec.RationsID := RationID.AsInteger;
  648. gljRec.BillsID := BillsItemID.AsInteger;
  649. gljRec.RGLJID := RGLJID.AsInteger;
  650. gljRec.RQuantity := RQuantity.AsFloat;
  651. gljRec.OrgRQuantity := OrgRQuantity.AsFloat;
  652. gljRec.RationPrice := RationPrice.AsCurrency;
  653. gljRec.Flag := Flag.AsInteger;
  654. gljRec.MinorRQ1 := MinorRQ1.AsFloat;
  655. gljRec.MinorRQ2 := MinorRQ2.AsFloat;
  656. gljRec.MinorRQ3 := MinorRQ3.AsFloat;
  657. gljRec.GLJID := GLJID.AsInteger;
  658. gljRec.SortParam := SortParam.AsInteger;
  659. gljRec.CalculateType := CalculateType.AsInteger;
  660. gljRec.CustomQuantity := CustomQuantity.AsVariant;
  661. gljRec.BudgetPrice := BudgetPrice.AsCurrency;
  662. gljRec.Quantity := Quantity.AsFloat;
  663. gljRec.LibID := LibID.AsInteger;
  664. gljRec.GLJType := Types.AsInteger;
  665. gljRec.TenderPrice := TenderPrice.AsCurrency;
  666. gljRec.RationItemQuantity := RationItemQuantity.AsFloat;
  667. gljRec.RCode := RCode.AsString;
  668. gljRec.RName := RName.AsString;
  669. gljRec.RSpecs := RSpecs.AsString;
  670. gljRec.RUnit := RUnit.AsString;
  671. gljRec.Code := Code.AsString;
  672. gljRec.Name := Name.AsString;
  673. gljRec.Specs := Specs.AsString;
  674. gljRec.Units := Units.AsString;
  675. end;
  676. FGLJList.Add(gljRec);
  677. end;
  678. procedure TPersistentData.AppendMMgRec(ARecord: TsdDataRecord);
  679. const
  680. scsRationID = 'RationID';
  681. scsMinorIndex = 'MinorIndex';
  682. scsGLJID = 'GLJID';
  683. scsGLJCode = 'GLJCode';
  684. scsMRQ1 = 'MRQ1';
  685. scsMRQ2 = 'MRQ2';
  686. scsMRQ3 = 'MRQ3';
  687. var
  688. mmgRec: TMMgRec;
  689. begin
  690. mmgRec := TMMgRec.Create(nil);
  691. with ARecord do
  692. begin
  693. mmgRec.RationID := ValueByName(scsRationID).AsInteger;
  694. mmgRec.MinorIndex := ValueByName(scsMinorIndex).AsInteger;
  695. mmgRec.GLJID := ValueByName(scsGLJID).AsInteger;
  696. mmgRec.GLJCode := ValueByName(scsGLJCode).AsString;
  697. mmgRec.MRQ1 := ValueByName(scsMRQ1).AsFloat;
  698. mmgRec.MRQ2 := ValueByName(scsMRQ2).AsFloat;
  699. mmgRec.MRQ3 := ValueByName(scsMRQ3).AsFloat;
  700. end;
  701. FMMgList.Add(mmgRec);
  702. end;
  703. procedure TPersistentData.AppendMMrRec(ARecord: TsdDataRecord);
  704. const
  705. scsRationID = 'RationID';
  706. scsMinorIndex = 'MinorIndex';
  707. scsParamIndex = 'ParamIndex';
  708. scsMinorParam = 'MinorParam';
  709. scsParamName = 'ParamName';
  710. scsMinorName = 'MinorName';
  711. scsBaseValue = 'BaseValue';
  712. scsRoundDigit = 'RoundDigit';
  713. scsRoundMode = 'RoundMode';
  714. scsIncStep = 'IncStep';
  715. scsRationCode = 'RationCode';
  716. scsIDCode = 'IDCode';
  717. var
  718. mmrRec: TMMrRec;
  719. begin
  720. mmrRec := TMMrRec.Create(nil);
  721. with ARecord do
  722. begin
  723. mmrRec.RationID := ValueByName(scsRationID).AsInteger;
  724. mmrRec.MinorIndex := ValueByName(scsMinorIndex).AsInteger;
  725. mmrRec.ParamIndex := ValueByName(scsParamIndex).AsInteger;
  726. mmrRec.MinorParam := ValueByName(scsMinorParam).AsFloat;
  727. mmrRec.ParamName := ValueByName(scsParamName).AsString;
  728. mmrRec.MinorName := ValueByName(scsMinorName).AsString;
  729. mmrRec.BaseValue := ValueByName(scsBaseValue).AsFloat;
  730. mmrRec.RoundDigit := ValueByName(scsRoundDigit).AsInteger;
  731. mmrRec.RoundMode := ValueByName(scsRoundMode).AsInteger;
  732. mmrRec.IncStep := ValueByName(scsIncStep).AsInteger;
  733. mmrRec.RationCode := ValueByName(scsRationCode).AsString;
  734. mmrRec.RationIDCode := ValueByName(scsIDCode).AsInteger;
  735. end;
  736. FMMrList.Add(mmrRec);
  737. end;
  738. procedure TPersistentData.AppendPBRec(ARecord: TsdDataRecord);
  739. const
  740. scsRationID = 'RationID';
  741. scsGLJID = 'GLJID';
  742. scsGLJCode = 'GLJCode';
  743. scsRProportion = 'RProportion';
  744. scsProportion = 'Proportion';
  745. var
  746. pbRec: TPBRec;
  747. begin
  748. pbRec := TPBRec.Create(nil);
  749. with ARecord do
  750. begin
  751. pbRec.RationID := ValueByName(scsRationID).AsInteger;
  752. pbRec.Code := ValueByName(scsGLJCode).AsString;
  753. pbRec.GLJID := ValueByName(scsGLJID).AsInteger;
  754. pbRec.RProportion := ValueByName(scsRProportion).AsFloat;
  755. pbRec.Proportion := ValueByName(scsProportion).AsFloat;
  756. end;
  757. FPBList.Add(pbRec);
  758. end;
  759. procedure TPersistentData.AppendRationsRec(sdRation: TObject);
  760. var
  761. rationRec: TRationsRec;
  762. begin
  763. rationRec := TRationsRec.Create(nil);
  764. with TScRationRecord(sdRation) do
  765. begin
  766. rationRec.ID := ID.AsInteger;
  767. rationRec.Code := Code.AsString;
  768. rationRec.Name := Name.AsString;
  769. rationRec.Units := Units.AsString;
  770. rationRec.Quanity := Quantity.AsFloat;
  771. rationRec.QuantityXS := QuantityXS.AsFloat;
  772. rationRec.GetFeeKind := GetFeeKind.AsInteger;
  773. rationRec.AdjustState := AdjustState.AsString;
  774. rationRec.BillsID := BillsItemID.AsInteger;
  775. rationRec.SerialNo := SerialNo.AsInteger;
  776. rationRec.MaskName := MaskName.AsString;
  777. rationRec.UnitDirectFee := UnitDirectFee.AsCurrency;
  778. rationRec.CountPriceType := CountPriceType.AsInteger;
  779. rationRec.BuildingFee := BuildingFee.AsCurrency;
  780. rationRec.RationProjName := RationProjName.AsString;
  781. rationRec.IsCalcProfit := IsCalcProfit.AsBoolean;
  782. rationRec.IsCalcTax := IsCalcTax.AsBoolean;
  783. rationRec.CodeForReport := CodeForReport.AsString;
  784. rationRec.Content := Content.AsString;
  785. rationRec.LibType := LibType.AsInteger;
  786. rationRec.LibID := LibID.AsInteger;
  787. rationRec.CodeLength := CodeLength.AsInteger;
  788. rationRec.RationProjName2 := RationProjName2.AsString;
  789. rationRec.Name2 := Name2.AsString;
  790. rationRec.Unit2 := Unit2.AsString;
  791. rationRec.CodeForReport2 := CodeForReport2.AsString;
  792. rationRec.IsCalcEquipmentFee := IsCalcEquipmentFee.AsBoolean;
  793. rationRec.RType := RationType.AsInteger;
  794. rationRec.Specs := Specs.AsString;
  795. rationRec.IsMECalc := IsMECalc.AsBoolean;
  796. rationRec.RationUnitDirectFee := RationUnitDirectFee.AsCurrency;
  797. rationRec.UnitPrice := UnitPrice.AsCurrency;
  798. rationRec.GLJID := GLJID.AsInteger;
  799. FRationsList.Add(rationRec);
  800. end;
  801. end;
  802. procedure TPersistentData.AppendXSRec(ARecord: TsdDataRecord);
  803. const
  804. scsRationID = 'RationID';
  805. scsCoeID = 'CoeID';
  806. scsSelected = 'Selected';
  807. scsCalcOrder = 'CalcOrder';
  808. scsFlag = 'Flag';
  809. scsData = 'Data';
  810. scsGroupIdx = 'GroupIdx';
  811. scsParam = 'Param';
  812. var
  813. xsRec: TXSRec;
  814. begin
  815. xsRec := TXSRec.Create(nil);
  816. with ARecord do
  817. begin
  818. xsRec.RationID := ValueByName(scsRationID).AsInteger;
  819. xsRec.CoeID := ValueByName(scsCoeID).AsInteger;
  820. xsRec.Selected := ValueByName(scsSelected).AsBoolean;
  821. xsRec.CalcOrder := ValueByName(scsCalcOrder).AsInteger;
  822. xsRec.Flag := ValueByName(scsFlag).AsInteger;
  823. xsRec.Data := ValueByName(scsData).AsString;
  824. xsRec.GroupIdx := ValueByName(scsGroupIdx).AsInteger;
  825. xsRec.Param := ValueByName(scsParam).AsInteger;
  826. end;
  827. FXSList.Add(xsRec);
  828. end;
  829. procedure TPersistentData.AppendYSRec(ARecord: TsdDataRecord);
  830. const
  831. scsRationID = 'RationID';
  832. scsRYSRate = 'RYSRate';
  833. scsYSRate = 'YSRate';
  834. var
  835. ysRateRec: TYSRateRec;
  836. begin
  837. ysRateRec := TYSRateRec.Create(nil);
  838. with ARecord do
  839. begin
  840. ysRateRec.RationID := ValueByName(scsRationID).AsInteger;
  841. ysRateRec.RYSRate := ValueByName(scsRYSRate).AsFloat;
  842. ysRateRec.YSRate := ValueByName(scsYSRate).AsFloat;
  843. end;
  844. FYSRateList.Add(ysRateRec);
  845. end;
  846. procedure TPersistentData.CheckClassExists;
  847. begin
  848. if GetClass('TFileInfo') = nil then
  849. Classes.RegisterClass(TFileInfo);
  850. if GetClass('TBillsRec') = nil then
  851. Classes.RegisterClass(TBillsRec);
  852. if GetClass('TRationsRec') = nil then
  853. Classes.RegisterClass(TRationsRec);
  854. if GetClass('TGLJRec') = nil then
  855. Classes.RegisterClass(TGLJRec);
  856. if GetClass('TFZRec') = nil then
  857. Classes.RegisterClass(TFZRec);
  858. if GetClass('TPBRec') = nil then
  859. Classes.RegisterClass(TPBRec);
  860. if GetClass('TXSRec') = nil then
  861. Classes.RegisterClass(TXSRec);
  862. if GetClass('TDJRec') = nil then
  863. Classes.RegisterClass(TDJRec);
  864. if GetClass('TYSRateRec') = nil then
  865. Classes.RegisterClass(TYSRateRec);
  866. if GetClass('TMMrRec') = nil then
  867. Classes.RegisterClass(TMMrRec);
  868. if GetClass('TMMgRec') = nil then
  869. Classes.RegisterClass(TMMgRec);
  870. if GetClass('TExprsRec') = nil then
  871. Classes.RegisterClass(TExprsRec);
  872. if GetClass('TDrawingQuantity') = nil then
  873. Classes.RegisterClass(TDrawingQuantity);
  874. end;
  875. procedure TPersistentData.ClearAllList;
  876. var
  877. I: Integer;
  878. begin
  879. if Assigned(FFileInfo) then
  880. FreeAndNil(FFileInfo);
  881. for I := 0 to FBillsList.Count - 1 do
  882. begin
  883. TBillsRec(FBillsList.List^[I]).Free;
  884. end;
  885. FBillsList.Clear;
  886. for I := 0 to FRationsList.Count - 1 do
  887. begin
  888. TRationsRec(FRationsList.List^[I]).Free;
  889. end;
  890. FRationsList.Clear;
  891. for I := 0 to FGLJList.Count - 1 do
  892. begin
  893. TGLJRec(FGLJList.List^[I]).Free;
  894. end;
  895. FGLJList.Clear;
  896. for I := 0 to FFZList.Count - 1 do
  897. begin
  898. TFZRec(FFZList.List^[I]).Free;
  899. end;
  900. FFZList.Clear;
  901. for I := 0 to FPBList.Count - 1 do
  902. begin
  903. TPBRec(FPBList.List^[I]).Free;
  904. end;
  905. FPBList.Clear;
  906. for I := 0 to FDJList.Count - 1 do
  907. begin
  908. TDJRec(FDJList.List^[I]).Free;
  909. end;
  910. FDJList.Clear;
  911. for I := 0 to FXSList.Count - 1 do
  912. begin
  913. TXSRec(FXSList.List^[I]).Free;
  914. end;
  915. FXSList.Clear;
  916. for I := 0 to FYSRateList.Count - 1 do
  917. begin
  918. TYSRateRec(FYSRateList.List^[I]).Free;
  919. end;
  920. FYSRateList.Clear;
  921. for I := 0 to FMMrList.Count - 1 do
  922. begin
  923. TMMrRec(FMMrList.List^[I]).Free;
  924. end;
  925. FMMrList.Clear;
  926. for I := 0 to FMMgList.Count - 1 do
  927. begin
  928. TMMgRec(FMMgList.List^[I]).Free;
  929. end;
  930. FMMgList.Clear;
  931. for I := 0 to FExprsList.Count - 1 do
  932. begin
  933. TExprsRec(FExprsList.List^[I]).Free;
  934. end;
  935. FExprsList.Clear;
  936. for I := 0 to FDQList.Count - 1 do
  937. begin
  938. TDrawingQuantity(FDQList.List^[I]).Free;
  939. end;
  940. FDQList.Clear;
  941. end;
  942. procedure TPersistentData.ClearNameList;
  943. begin
  944. FNameList.Clear;
  945. end;
  946. constructor TPersistentData.Create;
  947. begin
  948. FNameList := TStringList.Create;
  949. FDeleteNameList := TStringList.Create;
  950. FBillsList := TList.Create;
  951. FRationsList := TList.Create;
  952. FGLJList := TList.Create;
  953. FFZList := TList.Create;
  954. FPBList := TList.Create;
  955. FDJList := TList.Create;
  956. FYSRateList := TList.Create;
  957. FXSList := TList.Create;
  958. FMMrList := TList.Create;
  959. FMMgList := TList.Create;
  960. FExprsList := TList.Create;
  961. FDQList := TList.Create;
  962. FFileOpManager := TFileOpManager.Create;
  963. end;
  964. procedure TPersistentData.CreateFileInfo(ARecord: TScBillsRecord);
  965. var
  966. strName, sBCode: string;
  967. begin
  968. if FFileInfo = nil then
  969. begin
  970. sBCode := '';
  971. if TScProject(FProject).IsGuangDong then
  972. sBCode := ARecord.B_Code.AsString;
  973. strName := FFileOpManager.GetSaveFileName(ARecord.Code.AsString, sBCode,
  974. ARecord.Name.AsString);
  975. FFileInfo := TFileInfo.Create(nil);
  976. FFileInfo.Name := strName;
  977. FFileInfo.DeleteTime := Now;
  978. end;
  979. end;
  980. function TPersistentData.CurProjectDir: string;
  981. begin
  982. Result := FFileOpManager.GetCurProjectDir;
  983. end;
  984. procedure TPersistentData.DeleteListFiles;
  985. var
  986. I: Integer;
  987. strName: string;
  988. begin
  989. for I := 0 to FNameList.Count - 1 do
  990. begin
  991. strName := FNameList.Strings[I];
  992. DeleteFile(PChar(strName));
  993. end;
  994. FNameList.Clear;
  995. end;
  996. destructor TPersistentData.Destroy;
  997. begin
  998. DeleteNameListFiles;
  999. FDeleteNameList.Free;
  1000. DeleteListFiles;
  1001. FNameList.Free;
  1002. FBillsList.Free;
  1003. FRationsList.Free;
  1004. FGLJList.Free;
  1005. FFZList.Free;
  1006. FPBList.Free;
  1007. FDJList.Free;
  1008. FYSRateList.Free;
  1009. FXSList.Free;
  1010. FMMrList.Free;
  1011. FMMgList.Free;
  1012. FExprsList.Free;
  1013. FDQList.Free;
  1014. FFileOpManager.Free;
  1015. inherited;
  1016. end;
  1017. procedure TPersistentData.ExtractParticularFileName(
  1018. const aProjName, aFullBPName, aAlias, aGUID: string);
  1019. begin
  1020. FFileOpManager.ExtractParticularName(aProjName, aFullBPName, aAlias, aGUID);
  1021. end;
  1022. function TPersistentData.GetFileDir: string;
  1023. begin
  1024. Result := FFileOpManager.FileDir;
  1025. end;
  1026. procedure TPersistentData.InternalPersistent;
  1027. var
  1028. I: Integer;
  1029. strName: string;
  1030. MemoryStream: TMemoryStream;
  1031. begin
  1032. MemoryStream := TMemoryStream.Create;
  1033. try
  1034. CheckClassExists;
  1035. MemoryStream.WriteComponent(FFileInfo);
  1036. I := FBillsList.Count;
  1037. MemoryStream.Write(I, SizeOf(I));
  1038. for I := 0 to FBillsList.Count - 1 do
  1039. MemoryStream.WriteComponent(TBillsRec(FBillsList.List^[I]));
  1040. I := FRationsList.Count;
  1041. MemoryStream.Write(I, SizeOf(I));
  1042. for I := 0 to FRationsList.Count - 1 do
  1043. MemoryStream.WriteComponent(TRationsRec(FRationsList.List^[I]));
  1044. I := FGLJList.Count;
  1045. MemoryStream.Write(I, SizeOf(I));
  1046. for I := 0 to FGLJList.Count - 1 do
  1047. MemoryStream.WriteComponent(TGLJRec(FGLJList.List^[I]));
  1048. I := FFZList.Count;
  1049. MemoryStream.Write(I, SizeOf(I));
  1050. for I := 0 to FFZList.Count - 1 do
  1051. MemoryStream.WriteComponent(TFZRec(FFZList.List^[I]));
  1052. I := FPBList.Count;
  1053. MemoryStream.Write(I, SizeOf(I));
  1054. for I := 0 to FPBList.Count - 1 do
  1055. MemoryStream.WriteComponent(TPBRec(FPBList.List^[I]));
  1056. I := FDJList.Count;
  1057. MemoryStream.Write(I, SizeOf(I));
  1058. for I := 0 to FDJList.Count - 1 do
  1059. MemoryStream.WriteComponent(TDJRec(FDJList.List^[I]));
  1060. I := FXSList.Count;
  1061. MemoryStream.Write(I, SizeOf(I));
  1062. for I := 0 to FXSList.Count - 1 do
  1063. MemoryStream.WriteComponent(TXSRec(FXSList.List^[I]));
  1064. I := FYSRateList.Count;
  1065. MemoryStream.Write(I, SizeOf(I));
  1066. for I := 0 to FYSRateList.Count - 1 do
  1067. MemoryStream.WriteComponent(TYSRateRec(FYSRateList.List^[I]));
  1068. I := FMMrList.Count;
  1069. MemoryStream.Write(I, SizeOf(I));
  1070. for I := 0 to FMMrList.Count - 1 do
  1071. MemoryStream.WriteComponent(TMMrRec(FMMrList.List^[I]));
  1072. I := FMMgList.Count;
  1073. MemoryStream.Write(I, SizeOf(I));
  1074. for I := 0 to FMMgList.Count - 1 do
  1075. MemoryStream.WriteComponent(TMMgRec(FMMgList.List^[I]));
  1076. I := FExprsList.Count;
  1077. MemoryStream.Write(I, SizeOf(I));
  1078. for I := 0 to FExprsList.Count - 1 do
  1079. MemoryStream.WriteComponent(TExprsRec(FExprsList.List^[I]));
  1080. I := FDQList.Count;
  1081. MemoryStream.Write(I, SizeOf(I));
  1082. for I := 0 to FDQList.Count - 1 do
  1083. MemoryStream.WriteComponent(TDrawingQuantity(FDQList.List^[I]));
  1084. MemoryStream.SaveToFile(FFileInfo.Name);
  1085. AddNameToList(FFileInfo.Name);
  1086. finally
  1087. MemoryStream.Free;
  1088. end;
  1089. end;
  1090. procedure TPersistentData.InternalReadPersistent(const AFileName: string; IsReadAll: Boolean);
  1091. var
  1092. I, ObjCount: Integer;
  1093. billsRec: TBillsRec;
  1094. rationRec: TRationsRec;
  1095. gljRec: TGLJRec;
  1096. fzRec: TFZRec;
  1097. pbRec: TPBRec;
  1098. djRec: TDJRec;
  1099. xsRec: TXSRec;
  1100. ysRateRec: TYSRateRec;
  1101. mmrRec: TMMrRec;
  1102. mmgRec: TMMgRec;
  1103. exprsRec: TExprsRec;
  1104. FileStream: TFileStream;
  1105. begin
  1106. FileStream := TFileStream.Create(AFileName, fmOpenRead);
  1107. try
  1108. // FileStream.LoadFromFile(AFileName);
  1109. CheckClassExists;
  1110. FFileInfo := TFileInfo(FileStream.ReadComponent(nil));
  1111. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1112. for I := 0 to ObjCount - 1 do
  1113. begin
  1114. billsRec := TBillsRec(FileStream.ReadComponent(nil));
  1115. FBillsList.Add(billsRec);
  1116. end;
  1117. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1118. for I := 0 to ObjCount - 1 do
  1119. begin
  1120. rationRec := TRationsRec(FileStream.ReadComponent(nil));
  1121. FRationsList.Add(rationRec);
  1122. end;
  1123. if IsReadAll then
  1124. begin
  1125. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1126. for I := 0 to ObjCount - 1 do
  1127. begin
  1128. gljRec := TGLJRec(FileStream.ReadComponent(nil));
  1129. FGLJList.Add(gljRec);
  1130. end;
  1131. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1132. for I := 0 to ObjCount - 1 do
  1133. begin
  1134. fzRec := TFZRec(FileStream.ReadComponent(nil));
  1135. FFZList.Add(fzRec);
  1136. end;
  1137. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1138. for I := 0 to ObjCount - 1 do
  1139. begin
  1140. pbRec := TPBRec(FileStream.ReadComponent(nil));
  1141. FPBList.Add(pbRec);
  1142. end;
  1143. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1144. for I := 0 to ObjCount - 1 do
  1145. begin
  1146. djRec := TDJRec(FileStream.ReadComponent(nil));
  1147. FDJList.Add(djRec);
  1148. end;
  1149. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1150. for I := 0 to ObjCount - 1 do
  1151. begin
  1152. xsRec := TXSRec(FileStream.ReadComponent(nil));
  1153. FXSList.Add(xsRec);
  1154. end;
  1155. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1156. for I := 0 to ObjCount - 1 do
  1157. begin
  1158. ysRateRec := TYSRateRec(FileStream.ReadComponent(nil));
  1159. FYSRateList.Add(ysRateRec);
  1160. end;
  1161. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1162. for I := 0 to ObjCount - 1 do
  1163. begin
  1164. mmrRec := TMMrRec(FileStream.ReadComponent(nil));
  1165. FMMrList.Add(mmrRec);
  1166. end;
  1167. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1168. for I := 0 to ObjCount - 1 do
  1169. begin
  1170. mmgRec := TMMgRec(FileStream.ReadComponent(nil));
  1171. FMMgList.Add(mmgRec);
  1172. end;
  1173. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1174. for I := 0 to ObjCount - 1 do
  1175. begin
  1176. exprsRec := TExprsRec(FileStream.ReadComponent(nil));
  1177. FExprsList.Add(exprsRec);
  1178. end;
  1179. FileStream.Read(ObjCount, SizeOf(ObjCount));
  1180. for I := 0 to ObjCount - 1 do
  1181. FDQList.Add(TDrawingQuantity(FileStream.ReadComponent(nil)));
  1182. end;
  1183. finally
  1184. FileStream.Free;
  1185. end;
  1186. end;
  1187. procedure TPersistentData.InternalWriteDB(ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
  1188. var
  1189. I: Integer;
  1190. billsRec: TBillsRec;
  1191. rationRec: TRationsRec;
  1192. begin
  1193. with ANodeBinDM do
  1194. begin
  1195. cdsFileInfo.Append;
  1196. cdsFileInfoID.Value := ID;
  1197. cdsFileInfoName.Value := ExtractFileName(FFileInfo.Name);
  1198. cdsFileInfoDeleteTime.Value := FFileInfo.DeleteTime;
  1199. cdsFileInfoFullName.Value := FFileInfo.Name;
  1200. cdsFileInfo.Post;
  1201. for I := 0 to FBillsList.Count - 1 do
  1202. begin
  1203. billsRec := TBillsRec(FBillsList.List^[I]);
  1204. cdsBills.Append;
  1205. cdsBillsFileID.Value := ID;
  1206. cdsBillsID.Value := billsRec.ID;
  1207. cdsBillsParentID.Value := billsRec.ParentID;
  1208. cdsBillsNextSiblingID.Value := billsRec.NextSiblingID;
  1209. cdsBillsCode.Value := billsRec.Code;
  1210. cdsBillsName.Value := FFileOpManager.RevertSpecialChar(billsRec.Name);
  1211. cdsBillsUnits.Value := billsRec.Units;
  1212. cdsBillsQuantity.Value := billsRec.Quantity;
  1213. cdsBillsQuantity2.Value := billsRec.Quantity2;
  1214. cdsBillsUnitPrice.Value := billsRec.UnitPrice;
  1215. cdsBillsTotalPrice.Value := billsRec.TotalPrice;
  1216. cdsBillsCalcKinds.Value := billsRec.CalcKinds;
  1217. cdsBillsIsPreDefine.Value := billsRec.IsPreDefine;
  1218. cdsBillsFlag.Value := billsRec.Flag;
  1219. cdsBillsMemoStr.Value := billsRec.MemoString;
  1220. cdsBillsIsLeaf.Value := billsRec.IsLeaf;
  1221. cdsBillsGLJPriceLib.Value := billsRec.BillsGLJPriceLib;
  1222. {$IFDEF _ScGuangDong}
  1223. cdsBillsB_Code.Value := billsRec.BCode;
  1224. cdsBillsDesignQuantity.Value := billsRec.DQuantity;
  1225. cdsBillsDesignQuantity2.Value := billsRec.DQuantity2;
  1226. cdsBillsDesignPrice.Value := billsRec.DPrice;
  1227. {$ENDIF}
  1228. cdsBills.Post;
  1229. end;
  1230. for I := 0 to FRationsList.Count - 1 do
  1231. begin
  1232. rationRec := TRationsRec(FRationsList.List^[I]);
  1233. if rationRec.RType = 0 then
  1234. begin
  1235. cdsRations.Append;
  1236. cdsRationsFileID.Value := ID;
  1237. cdsRationsSerialNo.Value := rationRec.SerialNo;
  1238. cdsRationsID.Value := rationRec.ID;
  1239. cdsRationsLibID.Value := rationRec.LibID;
  1240. cdsRationsCode.Value := rationRec.Code;
  1241. cdsRationsBillsItemID.Value := rationRec.BillsID;
  1242. cdsRationsName.Value := rationRec.Name;
  1243. cdsRationsMaskName.Value := rationRec.MaskName;
  1244. cdsRationsUnit.Value := rationRec.Units;
  1245. cdsRationsQuantity.Value := rationRec.Quanity;
  1246. if rationRec.GetFeeKind <> NULL then
  1247. cdsRationsGetFeeKind.Value := rationRec.GetFeeKind;
  1248. cdsRationsAdjustState.Value := rationRec.AdjustState;
  1249. cdsRationsUnitDirectFee.Value := rationRec.UnitDirectFee;
  1250. cdsRationsBuildingFee.Value := rationRec.BuildingFee;
  1251. cdsRationsType.Value := rationRec.RType;
  1252. cdsRationsRationProjName.Value := rationRec.RationProjName;
  1253. cdsRationsIsCalcEquipmentFee.Value := rationRec.IsCalcEquipmentFee;
  1254. cdsRationsIsCalcProfit.Value := rationRec.IsCalcProfit;
  1255. cdsRationsIsCalcTax.Value := rationRec.IsCalcTax;
  1256. cdsRationsCodeForReport.Value := rationRec.CodeForReport;
  1257. cdsRationsContent.Value := rationRec.Content;
  1258. cdsRationsLibType.Value := rationRec.LibType;
  1259. cdsRationsCodeLength.Value := rationRec.CodeLength;
  1260. cdsRationsRationProjName2.Value := rationRec.RationProjName2;
  1261. cdsRationsName2.Value := rationRec.Name2;
  1262. cdsRationsUnit2.Value := rationRec.Unit2;
  1263. cdsRationsQuantityXS.Value := rationRec.QuantityXS;
  1264. cdsRationsCodeForReport2.Value := rationRec.CodeForReport2;
  1265. cdsRations.Post;
  1266. end
  1267. else
  1268. begin
  1269. cdsCountPrice.Append;
  1270. cdsCountPriceFileID.Value := ID;
  1271. cdsCountPriceID.Value := rationRec.ID;
  1272. cdsCountPriceBillsItemID.Value := rationRec.BillsID;
  1273. cdsCountPriceName.Value := rationRec.Name;
  1274. cdsCountPriceUnit.Value := rationRec.Units;
  1275. cdsCountPriceQuantity.Value := rationRec.Quanity;
  1276. if rationRec.GetFeeKind <> NULL then
  1277. cdsCountPriceGetFeeKind.Value := rationRec.GetFeeKind;
  1278. cdsCountPriceType.Value := rationRec.RType;
  1279. cdsCountPriceIsCalcEquipmentFee.Value := rationRec.IsCalcEquipmentFee;
  1280. cdsCountPriceIsCalcProfit.Value := rationRec.IsCalcProfit;
  1281. cdsCountPriceIsCalcTax.Value := rationRec.IsCalcTax;
  1282. if rationRec.CountPriceType <> NULL then
  1283. cdsCountPriceCountPriceType.Value := rationRec.CountPriceType;
  1284. cdsCountPriceBuildingFee.Value := rationRec.BuildingFee;
  1285. cdsCountPriceUnitDirectFee.Value := rationRec.UnitDirectFee;
  1286. cdsCountPriceQuantityXS.Value := rationRec.QuantityXS;
  1287. cdsCountPrice.Post;
  1288. end;
  1289. end;
  1290. end;
  1291. end;
  1292. procedure TPersistentData.PersistentObjects;
  1293. begin
  1294. InternalPersistent;
  1295. ClearAllList;
  1296. end;
  1297. procedure TPersistentData.ReadPersistentObjects(const AFileName: string;
  1298. ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
  1299. begin
  1300. InternalReadPersistent(AFileName, False);
  1301. InternalWriteDB(ANodeBinDM, ID);
  1302. ClearAllList;
  1303. end;
  1304. procedure TPersistentData.ReturnBills(AItem: TScBillsItem;
  1305. AIsClearQ, AIsNew: Boolean);
  1306. var
  1307. I, lastNextID, firstID: Integer;
  1308. OldNextID, lpos, CurID: Integer;
  1309. Rec: TsdDataRecord;
  1310. begin
  1311. ConformStructuralLevel(firstID, lastNextID, AItem.ParentID);
  1312. if FBillsList.Count = 0 then Exit;
  1313. with TScProject(FProject).Bills do
  1314. begin
  1315. try
  1316. CurID := AItem.ID;
  1317. OldNextID := AItem.NextSiblingID;
  1318. // BeginHandler; 张博士说这个方法被多个地方引用,维持原状不要动它,调用下面这个。
  1319. // 节点回收站是直接将结点加到DataSet,不是加到树,所以需要断开树再连接树以刷新显示。
  1320. Rec := AItem.Rec;
  1321. DisConnectBillsTree;
  1322. lpos := ReturnBillsInside(TScBillsRecord(Rec), FBillsList, AIsClearQ, AIsNew, firstID, lastNextID);
  1323. if not AIsNew then
  1324. begin
  1325. Rec := BillsDM.sdsBills.Locate(SID, CurID);
  1326. if Rec <> nil then
  1327. TScBillsRecord(Rec).NextSiblingID.AsInteger := firstID;
  1328. end;
  1329. Rec := BillsDM.sdsBills.Locate(SID, lastNextID);
  1330. if Rec <> nil then
  1331. TScBillsRecord(Rec).NextSiblingID.AsInteger := OldNextID;
  1332. finally
  1333. // EndHandler; 张博士说这个方法被多个地方引用,维持原状不要动它,调用下面这个。
  1334. ConnectBillsTree;
  1335. LoadBillsExprs;
  1336. AItem := TScBillsItem(BillsTree.FindNode(lPos));
  1337. if Assigned(AItem) then
  1338. AItem.LocateInControl;
  1339. end;
  1340. end;
  1341. end;
  1342. function TPersistentData.ReturnData(const AFileName: string; AItem: TScBillsItem;
  1343. AIsClearQ, AIsNew: Boolean): Boolean;
  1344. begin
  1345. Result := False;
  1346. if not FileExists(AFileName) then Exit;
  1347. InternalReadPersistent(AFileName, True);
  1348. try
  1349. FMaxBillsID := TScProject(FProject).Bills.GetMaxBillID + 1;
  1350. FMaxRationID := TScProject(FProject).Rations.GetNewID;
  1351. FMaxDqID := TScProject(FProject).Bills.DrawingQuantityDM.GetMaxDQID;
  1352. ReturnBills(AItem, AIsClearQ, AIsNew);
  1353. finally
  1354. ClearAllList;
  1355. end;
  1356. Result := True;
  1357. end;
  1358. procedure TPersistentData.ReturnDJ(AOldID, ANewID, AType: Integer);
  1359. (*var
  1360. I: Integer;
  1361. djRec: TDJRec;
  1362. GLJPriceRec: TScGLJPriceAdjustRecord;*)
  1363. begin
  1364. (* for I := 0 to FDJList.Count - 1 do
  1365. begin
  1366. djRec := TDJRec(FDJList.List^[I]);
  1367. with TScProject(FProject).GLJ do
  1368. begin
  1369. if (djRec.OwnerID = AOldID) and (djRec.Flag = AType) then
  1370. begin
  1371. GLJPriceRec := TScGLJPriceAdjustRecord(sdsGLJPriceAdjust.Add(True));
  1372. try
  1373. GLJPriceRec.OwnerID.Value := ANewID;
  1374. GLJPriceRec.GLJID.Value := djRec.GLJID;
  1375. GLJPriceRec.GLJCode.Value := djRec.GLJCode;
  1376. GLJPriceRec.Price.Value := djRec.UnitPrice;
  1377. GLJPriceRec.LibID.Value := djRec.LibID;
  1378. GLJPriceRec.Flag.Value := AType;
  1379. finally
  1380. GLJPriceRec.EndUpdate;
  1381. end;
  1382. end;
  1383. end;
  1384. end; *)
  1385. end;
  1386. procedure TPersistentData.ReturnExprs(AOldID, ANewID, AType: Integer);
  1387. var
  1388. I: Integer;
  1389. exprsRec: TExprsRec;
  1390. ExprRecord: TScExprsRecord;
  1391. begin
  1392. for I := 0 to FExprsList.Count - 1 do
  1393. begin
  1394. exprsRec := TExprsRec(FExprsList.List^[I]);
  1395. with TScProject(FProject).Exprs do
  1396. begin
  1397. if (exprsRec.RecdID = AOldID) and (exprsRec.Flag = AType) then
  1398. begin
  1399. ExprRecord := TScExprsRecord(sdsExprs.Add(True));
  1400. try
  1401. ExprRecord.MajorID.AsInteger := exprsRec.MajorID;
  1402. ExprRecord.MinorID.AsInteger := exprsRec.MinorID;
  1403. ExprRecord.Exprs.AsString := exprsRec.Exprs;
  1404. ExprRecord.Flag.AsInteger := AType;
  1405. ExprRecord.RecdID.AsInteger := ANewID;
  1406. ExprRecord.ExprsValue.AsFloat := exprsRec.ExprsValue;
  1407. ExprRecord.Exprs1.AsString := exprsRec.Exprs1;
  1408. ExprRecord.Exprs2.AsString := exprsRec.Exprs2;
  1409. ExprRecord.Exprs3.AsString := exprsRec.Exprs3;
  1410. ExprRecord.Exprs4.AsString := exprsRec.Exprs4;
  1411. finally
  1412. ExprRecord.EndUpdate;
  1413. end;
  1414. end;
  1415. end;
  1416. end;
  1417. end;
  1418. procedure TPersistentData.ReturnFZ(AOldRationID, ANewRationID: Integer);
  1419. var
  1420. I: Integer;
  1421. fzRec: TFZRec;
  1422. FZRecord: TScFZAdjustRecord;
  1423. begin
  1424. with TScProject(FProject).Rations.RAdjusts do
  1425. begin
  1426. for I := 0 to FFZList.Count - 1 do
  1427. begin
  1428. fzRec := TFZRec(FFZList.List^[I]);
  1429. if fzRec.RationID = AOldRationID then
  1430. begin
  1431. FZRecord := TScFZAdjustRecord(sdsFZAdjust.Add(True));
  1432. try
  1433. FZRecord.ParamName.AsString := fzRec.ParamName;
  1434. FZRecord.ParamIndex.AsInteger := fzRec.ParamIndex;
  1435. FZRecord.RationID.AsInteger := ANewRationID;
  1436. FZRecord.NewValue.AsFloat := fzRec.NewValue;
  1437. FZRecord.MinorIndex.AsInteger := fzRec.MinorIndex;
  1438. FZRecord.BaseValue.AsFloat := fzRec.BaseValue;
  1439. FZRecord.IncStep.AsFloat := fzRec.IncStep;
  1440. FZRecord.RationCode.AsString := fzRec.RationCode;
  1441. FZRecord.RationCode1.AsInteger := fzRec.RationCode1;
  1442. FZRecord.RoundDigit.AsInteger := fzRec.RoundDigit;
  1443. FZRecord.RoundMode.AsInteger := fzRec.RoundMode;
  1444. finally
  1445. FZRecord.EndUpdate;
  1446. end;
  1447. end;
  1448. end;
  1449. end;
  1450. end;
  1451. procedure TPersistentData.ReturnGLJs(AOldBillsID, ANewBillsID, AOldRationID, ANewRationID: Integer);
  1452. var
  1453. I: Integer;
  1454. gljRec: TGLJRec;
  1455. sdGLJ: TScGLJRecord;
  1456. ProjectGLJRec: TScProjectGLJRecord;
  1457. begin
  1458. with TScProject(FProject).Bills.Rations.GLJ do
  1459. begin
  1460. for I := 0 to FGLJList.Count - 1 do
  1461. begin
  1462. gljRec := TGLJRec(FGLJList.List^[I]);
  1463. if (gljRec.BillsID = AOldBillsID) and (gljRec.RationsID = AOldRationID) then
  1464. begin
  1465. if FindRGLJ(ANewRationID, gljRec.RGLJID) <> nil then
  1466. Continue;
  1467. ProjectGLJRec := TScProject(FProject).ProjectGLJ.LocateGLJ(gljRec.GLJID);
  1468. sdGLJ := TScGLJRecord(sdsGLJ.Add(True));
  1469. try
  1470. sdGLJ.RationID.AsInteger := ANewRationID;
  1471. sdGLJ.BillsItemID.AsInteger := ANewBillsID;
  1472. sdGLJ.RGLJID.AsInteger := gljRec.RGLJID;
  1473. sdGLJ.RQuantity.AsFloat := gljRec.RQuantity;
  1474. sdGLJ.OrgRQuantity.AsFloat := gljRec.OrgRQuantity;
  1475. if ProjectGLJRec <> nil then
  1476. begin
  1477. sdGLJ.RationPrice.AsCurrency := ProjectGLJRec.BasePrice.AsCurrency;
  1478. sdGLJ.BudgetPrice.AsCurrency := ProjectGLJRec.BudgetPrice.AsCurrency;
  1479. // 2026-07-06 zhangyin 缓存GLJ对应ProjectGLJ记录
  1480. sdGLJ.Data := ProjectGLJRec;
  1481. end
  1482. else
  1483. begin
  1484. sdGLJ.RationPrice.AsCurrency := gljRec.RationPrice;
  1485. sdGLJ.BudgetPrice.AsCurrency := gljRec.BudgetPrice;
  1486. end;
  1487. sdGLJ.Flag.AsInteger := gljRec.Flag;
  1488. sdGLJ.MinorRQ1.AsFloat := gljRec.MinorRQ1;
  1489. sdGLJ.MinorRQ2.AsFloat := gljRec.MinorRQ2;
  1490. sdGLJ.MinorRQ3.AsFloat := gljRec.MinorRQ3;
  1491. sdGLJ.GLJID.AsInteger := gljRec.GLJID;
  1492. sdGLJ.SortParam.AsInteger := gljRec.SortParam;
  1493. sdGLJ.CalculateType.AsInteger := gljRec.CalculateType;
  1494. sdGLJ.CustomQuantity.AsVariant := gljRec.CustomQuantity;
  1495. sdGLJ.Quantity.AsFloat := gljRec.Quantity;
  1496. sdGLJ.LibID.AsInteger := gljRec.LibID;
  1497. sdGLJ.Types.AsInteger := gljRec.GLJType;
  1498. sdGLJ.TenderPrice.AsCurrency := gljRec.TenderPrice;
  1499. sdGLJ.RationItemQuantity.AsFloat := gljRec.RationItemQuantity;
  1500. sdGLJ.RCode.AsString := gljRec.RCode;
  1501. sdGLJ.RName.AsString := gljRec.RName;
  1502. sdGLJ.RSpecs.AsString := gljRec.RSpecs;
  1503. sdGLJ.RUnit.AsString := gljRec.RUnit;
  1504. sdGLJ.Code.AsString := gljRec.Code;
  1505. sdGLJ.Name.AsString := gljRec.Name;
  1506. sdGLJ.Specs.AsString := gljRec.Specs;
  1507. sdGLJ.Units.AsString := gljRec.Units;
  1508. finally
  1509. sdGLJ.EndUpdate;
  1510. end;
  1511. end;
  1512. end;
  1513. end;
  1514. end;
  1515. procedure TPersistentData.ReturnMMg(AOldRationID, ANewRation: Integer);
  1516. var
  1517. I: Integer;
  1518. mmgRec: TMMgRec;
  1519. MMGRecord: TScMultiMinorGLJRecord;
  1520. begin
  1521. with TScProject(FProject).Rations.RAdjusts do
  1522. begin
  1523. for I := 0 to FMMgList.Count - 1 do
  1524. begin
  1525. mmgRec := TMMgRec(FMMgList.List^[I]);
  1526. if mmgRec.RationID = AOldRationID then
  1527. begin
  1528. MMGRecord := TScMultiMinorGLJRecord(sdsMultiMinorGLJ.Add(True));
  1529. try
  1530. MMGRecord.RationID.AsInteger := ANewRation;
  1531. MMGRecord.MinorIndex.AsInteger := mmgRec.MinorIndex;
  1532. MMGRecord.GLJID.AsInteger := mmgRec.GLJID;
  1533. MMGRecord.GLJCode.AsString := mmgRec.GLJCode;
  1534. MMGRecord.MRQ1.AsFloat := mmgRec.MRQ1;
  1535. MMGRecord.MRQ2.AsFloat := mmgRec.MRQ2;
  1536. MMGRecord.MRQ3.AsFloat := mmgRec.MRQ3;
  1537. finally
  1538. MMGRecord.EndUpdate;
  1539. end;
  1540. end;
  1541. end;
  1542. end;
  1543. end;
  1544. procedure TPersistentData.ReturnMMr(AOldRationID, ANewRationID: Integer);
  1545. var
  1546. I: Integer;
  1547. mmrRec: TMMrRec;
  1548. MMRationRecord: TScMultiMinorRationRecord;
  1549. begin
  1550. with TScProject(FProject).Rations.RAdjusts do
  1551. begin
  1552. for I := 0 to FMMrList.Count - 1 do
  1553. begin
  1554. mmrRec := TMMrRec(FMMrList.List^[I]);
  1555. if mmrRec.RationID = AOldRationID then
  1556. begin
  1557. MMRationRecord := TScMultiMinorRationRecord(sdsMultiMinorRation.Add(True));
  1558. try
  1559. MMRationRecord.RationID.AsInteger := ANewRationID;
  1560. MMRationRecord.MinorIndex.AsInteger := mmrRec.MinorIndex;
  1561. MMRationRecord.ParamIndex.AsInteger := mmrRec.ParamIndex;
  1562. MMRationRecord.MinorParam.AsFloat := mmrRec.MinorParam;
  1563. MMRationRecord.ParamName.AsString := mmrRec.ParamName;
  1564. MMRationRecord.MinorName.AsString := mmrRec.MinorName;
  1565. MMRationRecord.BaseValue.AsFloat := mmrRec.BaseValue;
  1566. MMRationRecord.RoundDigit.AsInteger := mmrRec.RoundDigit;
  1567. MMRationRecord.RoundMode.AsInteger := mmrRec.RoundMode;
  1568. MMRationRecord.IncStep.AsFloat := mmrRec.IncStep;
  1569. MMRationRecord.RationCode.AsString := mmrRec.RationCode;
  1570. MMRationRecord.IDCode.AsInteger := mmrRec.RationIDCode;
  1571. finally
  1572. MMRationRecord.EndUpdate;
  1573. end;
  1574. end;
  1575. end;
  1576. end;
  1577. end;
  1578. procedure TPersistentData.ReturnPB(AOldRationID, ANewRationID: Integer);
  1579. var
  1580. I: Integer;
  1581. pbRec: TPBRec;
  1582. PBRecord: TScPBAdjustRecord;
  1583. begin
  1584. with TScProject(FProject).Rations.RAdjusts do
  1585. begin
  1586. for I := 0 to FPBList.Count - 1 do
  1587. begin
  1588. pbRec := TPBRec(FPBList.List^[I]);
  1589. if pbRec.RationID = AOldRationID then
  1590. begin
  1591. PBRecord := TScPBAdjustRecord(sdsPBAdjust.Add(True));
  1592. try
  1593. PBRecord.RationID.AsInteger := ANewRationID;
  1594. PBRecord.GLJCode.AsString := pbRec.Code;
  1595. PBRecord.GLJID.AsInteger := pbRec.GLJID;
  1596. PBRecord.RProportion.AsFloat := pbRec.RProportion;
  1597. PBRecord.Proportion.AsFloat := pbRec.Proportion;
  1598. finally
  1599. PBRecord.EndUpdate;
  1600. end;
  1601. end;
  1602. end;
  1603. end;
  1604. end;
  1605. procedure TPersistentData.ReturnRAdjust(AOldRationID, ANewRationID: Integer);
  1606. begin
  1607. ReturnFZ(AOldRationID, ANewRationID);
  1608. ReturnPB(AOldRationID, ANewRationID);
  1609. ReturnXS(AOldRationID, ANewRationID);
  1610. ReturnDJ(AOldRationID, ANewRationID, 1);
  1611. ReturnYSRate(AOldRationID, ANewRationID);
  1612. ReturnMMr(AOldRationID, ANewRationID);
  1613. ReturnMMg(AOldRationID, ANewRationID);
  1614. end;
  1615. procedure TPersistentData.ReturnRations(AOldBillsID, ANewBillsID: Integer; AIsClearQ: Boolean);
  1616. var
  1617. I: Integer;
  1618. rationRec: TRationsRec;
  1619. sdRation: TScRationRecord;
  1620. ProjectGLJRec: TScProjectGLJRecord;
  1621. begin
  1622. for I := 0 to FRationsList.Count - 1 do
  1623. begin
  1624. rationRec := TRationsRec(FRationsList.List^[I]);
  1625. if rationRec.BillsID = AOldBillsID then
  1626. begin
  1627. with TScProject(FProject).Bills.Rations do
  1628. begin
  1629. sdRation := TScRationRecord(sdsRations.Add(True));
  1630. try
  1631. sdRation.ID.AsInteger := FMaxRationID;
  1632. sdRation.Code.AsString := rationRec.Code;
  1633. sdRation.Name.AsString := rationRec.Name;
  1634. sdRation.Units.AsString := rationRec.Units;
  1635. if AIsClearQ then
  1636. begin
  1637. sdRation.Quantity.AsFloat := 0;
  1638. sdRation.QuantityXS.AsFloat := 0;
  1639. end
  1640. else
  1641. begin
  1642. sdRation.Quantity.AsFloat := rationRec.Quanity;
  1643. sdRation.QuantityXS.AsFloat := rationRec.QuantityXS;
  1644. end;
  1645. sdRation.GetFeeKind.AsVariant := rationRec.GetFeeKind;
  1646. sdRation.AdjustState.AsString := rationRec.AdjustState;
  1647. sdRation.BillsItemID.AsInteger := ANewBillsID;
  1648. sdRation.SerialNo.AsInteger := rationRec.SerialNo;
  1649. sdRation.MaskName.AsString := rationRec.MaskName;
  1650. sdRation.UnitDirectFee.AsCurrency := rationRec.UnitDirectFee;
  1651. sdRation.CountPriceType.AsInteger := rationRec.CountPriceType;
  1652. sdRation.BuildingFee.AsCurrency := rationRec.BuildingFee;
  1653. sdRation.RationProjName.AsString := rationRec.RationProjName;
  1654. sdRation.IsCalcProfit.AsBoolean := rationRec.IsCalcProfit;
  1655. sdRation.IsCalcTax.AsBoolean := rationRec.IsCalcTax;
  1656. sdRation.CodeForReport.AsString := rationRec.CodeForReport;
  1657. sdRation.Content.AsString := rationRec.Content;
  1658. sdRation.LibType.AsInteger := rationRec.LibType;
  1659. sdRation.LibID.AsInteger := rationRec.LibID;
  1660. sdRation.CodeLength.AsInteger := rationRec.CodeLength;
  1661. sdRation.RationProjName2.AsString := rationRec.RationProjName2;
  1662. sdRation.Name2.AsString := rationRec.Name2;
  1663. sdRation.Unit2.AsString := rationRec.Unit2;
  1664. sdRation.CodeForReport2.AsString := rationRec.CodeForReport2;
  1665. sdRation.IsCalcEquipmentFee.AsBoolean := rationRec.IsCalcEquipmentFee;
  1666. sdRation.RationType.AsInteger := rationRec.RType;
  1667. sdRation.Specs.AsString := rationRec.Specs;
  1668. sdRation.IsMECalc.AsBoolean := rationRec.IsMECalc;
  1669. if sdRation.RationType.AsInteger = SR_CountPrice then
  1670. begin
  1671. ProjectGLJRec := TScProject(Project).ProjectGLJ.LocateGLJ(CombineGLJKeys(sdRation));
  1672. if sdRation.IsMECalc.AsBoolean then
  1673. begin
  1674. if rationRec.UnitPrice <> 0 then
  1675. begin
  1676. if ProjectGLJRec <> nil then
  1677. sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
  1678. sdRation.UnitPrice.AsCurrency := rationRec.UnitPrice;
  1679. end
  1680. else
  1681. begin
  1682. if ProjectGLJRec <> nil then
  1683. begin
  1684. sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
  1685. sdRation.UnitPrice.AsCurrency := ProjectGLJRec.BasePrice.AsCurrency;
  1686. end
  1687. else
  1688. sdRation.UnitPrice.AsCurrency := rationRec.UnitDirectFee;
  1689. end;
  1690. end
  1691. else
  1692. begin
  1693. if rationRec.UnitPrice <> 0 then
  1694. begin
  1695. if ProjectGLJRec <> nil then
  1696. sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
  1697. sdRation.RationUnitDirectFee.AsCurrency := rationRec.RationUnitDirectFee;
  1698. end
  1699. else
  1700. begin
  1701. if ProjectGLJRec <> nil then
  1702. begin
  1703. sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
  1704. sdRation.RationUnitDirectFee.AsCurrency := ProjectGLJRec.BasePrice.AsCurrency;
  1705. end
  1706. else
  1707. sdRation.RationUnitDirectFee.AsCurrency := rationRec.UnitDirectFee;
  1708. end;
  1709. end
  1710. end;
  1711. finally
  1712. sdRation.EndUpdate;
  1713. end;
  1714. ReturnGLJs(AOldBillsID, ANewBillsID, rationRec.ID, sdRation.ID.AsInteger);
  1715. ReturnRAdjust(rationRec.ID, sdRation.ID.AsInteger);
  1716. if sdRation.RationType.AsInteger = 0 then
  1717. ReturnExprs(rationRec.ID, sdRation.ID.AsInteger, 2)
  1718. else
  1719. ReturnExprs(rationRec.ID, sdRation.ID.AsInteger, 3);
  1720. Inc(FMaxRationID);
  1721. end;
  1722. end;
  1723. end;
  1724. end;
  1725. procedure TPersistentData.ReturnXS(AOldRationID, ANewRationID: Integer);
  1726. var
  1727. I: Integer;
  1728. xsRec: TXSRec;
  1729. XSRecord: TScXSAdjustRecord;
  1730. begin
  1731. with TScProject(FProject).Rations.RAdjusts do
  1732. begin
  1733. for I := 0 to FXSList.Count - 1 do
  1734. begin
  1735. xsRec := TXSRec(FXSList.List^[I]);
  1736. if xsRec.RationID = AOldRationID then
  1737. begin
  1738. XSRecord := TScXSAdjustRecord(sdsXSAdjust.Add(True));
  1739. try
  1740. XSRecord.RationID.AsInteger := ANewRationID;
  1741. XSRecord.CoeID.AsInteger := xsRec.CoeID;
  1742. XSRecord.Selected.AsBoolean := xsRec.Selected;
  1743. XSRecord.CalcOrder.AsInteger := xsRec.CalcOrder;
  1744. XSRecord.Flag.AsInteger := xsRec.Flag;
  1745. XSRecord.Data.AsString := xsRec.Data;
  1746. XSRecord.GroupIdx.AsInteger := xsRec.GroupIdx;
  1747. XSRecord.Param.AsInteger := xsRec.Param;
  1748. finally
  1749. XSRecord.EndUpdate;
  1750. end;
  1751. end;
  1752. end;
  1753. end;
  1754. end;
  1755. procedure TPersistentData.ReturnYSRate(AOldRationID, ANewRationID: Integer);
  1756. var
  1757. I: Integer;
  1758. ysRateRec: TYSRateRec;
  1759. YSRecord: TScYSRateRecord;
  1760. begin
  1761. with TScProject(FProject).Rations.RAdjusts do
  1762. begin
  1763. for I := 0 to FYSRateList.Count - 1 do
  1764. begin
  1765. ysRateRec := TYSRateRec(FYSRateList.List^[I]);
  1766. if ysRateRec.RationID = AOldRationID then
  1767. begin
  1768. YSRecord := TScYSRateRecord(sdsYSRate.Add(True));
  1769. try
  1770. YSRecord.RationID.AsInteger := ANewRationID;
  1771. YSRecord.RYSRate.AsFloat := ysRateRec.RYSRate;
  1772. YSRecord.YSRate.AsFloat := ysRateRec.YSRate;
  1773. finally
  1774. YSRecord.EndUpdate;
  1775. end;
  1776. end;
  1777. end;
  1778. end;
  1779. end;
  1780. procedure TPersistentData.Save;
  1781. begin
  1782. ClearNameList;
  1783. DeleteNameListFiles;
  1784. end;
  1785. procedure TPersistentData.SetFileDir(const Value: string);
  1786. begin
  1787. FFileOpManager.FileDir := Value;
  1788. end;
  1789. function TPersistentData.CheckParentNodeExists(
  1790. AID: Integer; Flag: Integer): Boolean;
  1791. const
  1792. strParentError = '父节点不存在,无法还原节点!';
  1793. strPreError = '前兄弟节点不存在,无法还原节点!';
  1794. begin
  1795. if (AID = -1) or
  1796. (TScProject(FProject).Bills.BillsDM.sdsBills.Locate(SID, AID) <> nil) then
  1797. Result := True
  1798. else Result := False;
  1799. if not Result then
  1800. begin
  1801. case Flag of
  1802. cflParent: ShowErrorMessage(strParentError);
  1803. cflPrev: ShowErrorMessage(strPreError);
  1804. end;
  1805. end;
  1806. end;
  1807. procedure TPersistentData.ShowErrorMessage(const Text: string);
  1808. begin
  1809. MessageBox(0, PChar(Text), PChar('错误'), MB_OK or MB_ICONERROR);
  1810. end;
  1811. function TPersistentData.ReturnBillsInside(ARec: TScBillsRecord; AList: TList;
  1812. AIsClearQ, AIsNew: Boolean; var AFirstID, ALastNextID: Integer): Integer;
  1813. var
  1814. blfirstIDChanged, blLastNextIDChanged: Boolean;
  1815. procedure ModifyNodeRelation(AOldID, ANewID: Integer);
  1816. var
  1817. I: Integer;
  1818. bRec: TBillsRec;
  1819. begin
  1820. for I := 0 to AList.Count - 1 do
  1821. begin
  1822. bRec := TBillsRec(AList.List^[I]);
  1823. if (bRec.ParentID = AOldID) and not bRec.ParentIDChanged then
  1824. begin
  1825. bRec.ParentID := ANewID;
  1826. bRec.ParentIDChanged := True;
  1827. end
  1828. else if (bRec.NextSiblingID = AOldID) and not bRec.NextSiblingIDChanged then
  1829. begin
  1830. bRec.NextSiblingID := ANewID;
  1831. bRec.NextSiblingIDChanged := True;
  1832. end;
  1833. end;
  1834. end;
  1835. procedure ModifyAllRelations(AClearQ: Boolean);
  1836. var
  1837. I: Integer;
  1838. BillsRec: TBillsRec;
  1839. begin
  1840. for I := 0 to AList.Count - 1 do
  1841. begin
  1842. BillsRec := TBillsRec(AList.List^[I]);
  1843. if (BillsRec.ID = AFirstID) and not blfirstIDChanged then
  1844. begin
  1845. AFirstID := FMaxBillsID;
  1846. blfirstIDChanged := True;
  1847. end;
  1848. if (BillsRec.ID = ALastNextID) and not blLastNextIDChanged then
  1849. begin
  1850. ALastNextID := FMaxBillsID;
  1851. blLastNextIDChanged := True;
  1852. end;
  1853. ModifyNodeRelation(BillsRec.ID, FMaxBillsID);
  1854. BillsRec.ID := FMaxBillsID;
  1855. Inc(FMaxBillsID);
  1856. end;
  1857. end;
  1858. procedure AssignBillsSubItems(ABillsRec: TBillsRec; AClearQ: Boolean);
  1859. begin
  1860. ReturnDraqQty(ABillsRec.FOldID, ABillsRec.ID, AClearQ);
  1861. ReturnRations(ABillsRec.FOldID, ABillsRec.ID, AClearQ);
  1862. ReturnDJ(ABillsRec.FOldID, ABillsRec.ID, 0);
  1863. ReturnExprs(ABillsRec.FOldID, ABillsRec.ID, 1);
  1864. end;
  1865. function AssignDBValues(ARec: TScBillsRecord; ABillsRec: TBillsRec; AClearQ: Boolean): Integer;
  1866. begin
  1867. ARec.BeginUpdate;
  1868. try
  1869. ARec.ID.AsInteger := ABillsRec.ID;
  1870. ARec.ParentID.AsInteger := ABillsRec.ParentID;
  1871. ARec.NextSiblingID.AsInteger := ABillsRec.NextSiblingID;
  1872. ARec.Code.AsString := ABillsRec.Code;
  1873. ARec.Name.AsString := ABillsRec.Name;
  1874. ARec.Units.AsString := ABillsRec.Units;
  1875. ARec.B_Code.AsString := ABillsRec.BCode;
  1876. ARec.DesignQuantity.AsFloat := ABillsRec.DQuantity;
  1877. ARec.DesignQuantity2.AsFloat := ABillsRec.DQuantity2;
  1878. ARec.DesignPrice.AsFloat := ABillsRec.DPrice;
  1879. if AClearQ then
  1880. begin
  1881. ARec.Quantity.AsFloat := 1;
  1882. ARec.Quantity2.AsFloat := 1;
  1883. end
  1884. else
  1885. begin
  1886. ARec.Quantity.AsFloat := ABillsRec.Quantity;
  1887. ARec.Quantity2.AsFloat := ABillsRec.Quantity2;
  1888. end;
  1889. ARec.UnitPrice.AsCurrency := ABillsRec.UnitPrice;
  1890. ARec.Flag.AsInteger := ABillsRec.Flag;
  1891. ARec.IsPreDefine.AsBoolean := ABillsRec.IsPreDefine;
  1892. ARec.IsLeaf.AsBoolean := ABillsRec.IsLeaf;
  1893. ARec.CalcKinds.AsInteger := ABillsRec.CalcKinds;
  1894. ARec.TotalPrice.AsCurrency := ABillsRec.TotalPrice;
  1895. ARec.MemoStr.AsString := ABillsRec.MemoString;
  1896. ARec.IsCreatePriceAnalysis.AsBoolean := True;
  1897. ARec.GLJPriceLib.AsString := ABillsRec.BillsGLJPriceLib;
  1898. finally
  1899. ARec.EndUpdate;
  1900. end;
  1901. AssignBillsSubItems(ABillsRec, AClearQ);
  1902. Result := ABillsRec.ID;
  1903. end;
  1904. var
  1905. I, J: Integer;
  1906. billsRec: TBillsRec;
  1907. Rec: TScBillsRecord;
  1908. begin
  1909. J := 0;
  1910. Result := -1;
  1911. blfirstIDChanged := False;
  1912. blLastNextIDChanged := False;
  1913. with TScProject(FProject).Bills do
  1914. begin
  1915. ModifyAllRelations(AIsClearQ);
  1916. if AIsNew then
  1917. begin
  1918. billsRec := TBillsRec(AList.List^[J]);
  1919. Result := AssignDBValues(ARec, billsRec, AIsClearQ);
  1920. Inc(J);
  1921. end;
  1922. for I := J to AList.Count - 1 do
  1923. begin
  1924. billsRec := TBillsRec(AList.List^[I]);
  1925. Rec := TScBillsRecord(BillsDM.sdsBills.Add);
  1926. Result := AssignDBValues(Rec, billsRec, AIsClearQ);
  1927. end;
  1928. end;
  1929. end;
  1930. procedure TPersistentData.ConformStructuralLevel(var AFirstID, ALastNextID: Integer; AParentID: Integer);
  1931. procedure SortListBasisNextSiblingID(AList1, AList2: TList);
  1932. procedure AddRec(ARec: TBillsRec);
  1933. var
  1934. J: Integer;
  1935. blRec: TBillsRec;
  1936. begin
  1937. for J := 0 to AList1.Count - 1 do
  1938. begin
  1939. blRec := TBillsRec(AList1.List^[J]);
  1940. if blRec.NextSiblingID = ARec.ID then
  1941. begin
  1942. AddRec(blRec);
  1943. Break;
  1944. end;
  1945. end;
  1946. AList2.Add(ARec);
  1947. end;
  1948. var
  1949. I, J: Integer;
  1950. blFlag: Boolean;
  1951. bRecI, bRecJ: TBillsRec;
  1952. begin
  1953. for I := 0 to AList1.Count - 1 do
  1954. begin
  1955. blFlag := False;
  1956. bRecI := TBillsRec(AList1.List^[I]);
  1957. for J := 0 to AList1.Count - 1 do
  1958. begin
  1959. bRecJ := TBillsRec(AList1.List^[J]);
  1960. if bRecI.NextSiblingID = bRecJ.ID then
  1961. begin
  1962. blFlag := True;
  1963. Break;
  1964. end;
  1965. end;
  1966. if not blFlag then
  1967. begin
  1968. Break;
  1969. end;
  1970. end;
  1971. AddRec(bRecI);
  1972. end;
  1973. procedure RecursionDeleteRec(ABillsRec: TBillsRec);
  1974. var
  1975. I: Integer;
  1976. bRec: TBillsRec;
  1977. begin
  1978. for I := 0 to FBillsList.Count - 1 do
  1979. begin
  1980. bRec := TBillsRec(FBillsList.List^[I]);
  1981. if bRec.ParentID = ABillsRec.ID then
  1982. begin
  1983. RecursionDeleteRec(bRec);
  1984. end;
  1985. end;
  1986. FBillsList.Remove(ABillsRec);
  1987. DeleteRecordsBasisBillsID(ABillsRec.ID);
  1988. ABillsRec.Free;
  1989. end;
  1990. var
  1991. I, J: Integer;
  1992. IsExist: Boolean;
  1993. nList, temList: TList;
  1994. billsRecI, billsRecJ: TBillsRec;
  1995. begin
  1996. nList := TList.Create;
  1997. temList := TList.Create;
  1998. try
  1999. for I := 0 to FBillsList.Count - 1 do
  2000. begin
  2001. IsExist := False;
  2002. billsRecI := TBillsRec(FBillsList.List^[I]);
  2003. billsRecI.FOldID := billsRecI.ID;
  2004. for J := 0 to FBillsList.Count - 1 do
  2005. begin
  2006. billsRecJ := TBillsRec(FBillsList.List^[J]);
  2007. if billsRecI.ParentID = billsRecJ.ID then
  2008. begin
  2009. IsExist := True;
  2010. Break;
  2011. end;
  2012. end;
  2013. if not IsExist then
  2014. begin
  2015. nList.Add(billsRecI);
  2016. end;
  2017. end;
  2018. billsRecJ := TBillsRec(nList[0]);
  2019. for I := nList.Count - 1 downto 1 do
  2020. begin
  2021. billsRecI := TBillsRec(nList.List^[I]);
  2022. if billsRecI.ParentID <> billsRecJ.ParentID then
  2023. begin
  2024. RecursionDeleteRec(billsRecI);
  2025. nList.Delete(I);
  2026. end;
  2027. end;
  2028. SortListBasisNextSiblingID(nList, temList);
  2029. for I := 0 to temList.Count - 1 do
  2030. begin
  2031. billsRecI := TBillsRec(temList.List^[I]);
  2032. if I = 0 then AFirstID := billsRecI.ID;
  2033. if I = temList.Count - 1 then ALastNextID := billsRecI.ID;
  2034. billsRecI.ParentID := AParentID;
  2035. end;
  2036. finally
  2037. nList.Free;
  2038. temList.Free;
  2039. end;
  2040. end;
  2041. procedure TPersistentData.DeleteCurFile(const AFileName: string);
  2042. begin
  2043. AddDeleteNameToList(AFileName);
  2044. end;
  2045. procedure TPersistentData.DeleteNameListFiles;
  2046. var
  2047. I: Integer;
  2048. strName: string;
  2049. begin
  2050. for I := 0 to FDeleteNameList.Count - 1 do
  2051. begin
  2052. strName := FDeleteNameList.Strings[I];
  2053. DeleteFile(PChar(strName));
  2054. end;
  2055. FDeleteNameList.Clear;
  2056. end;
  2057. procedure TPersistentData.AddDeleteNameToList(const AFileName: string);
  2058. begin
  2059. FDeleteNameList.Add(AFileName);
  2060. end;
  2061. function TPersistentData.CheckFilePathInDelete(const AFileName: string): Boolean;
  2062. var
  2063. I: Integer;
  2064. strName: string;
  2065. begin
  2066. Result := False;
  2067. for I := 0 to FDeleteNameList.Count - 1 do
  2068. begin
  2069. strName := FDeleteNameList.Strings[I];
  2070. if SameText(AFileName, strName) then
  2071. begin
  2072. Result := True;
  2073. Break;
  2074. end;
  2075. end;
  2076. end;
  2077. procedure TPersistentData.DeleteRecordsBasisBillsID(ABillsID: Integer);
  2078. begin
  2079. DeleteDQ(ABillsID);
  2080. DeleteRations(ABillsID);
  2081. DeleteDJ(ABillsID, 0);
  2082. DeleteExprs(ABillsID, 1);
  2083. end;
  2084. procedure TPersistentData.DeleteDJ(AID, AType: Integer);
  2085. var
  2086. I: Integer;
  2087. djRec: TDJRec;
  2088. begin
  2089. for I := FDJList.Count - 1 downto 0 do
  2090. begin
  2091. djRec := TDJRec(FDJList.List^[I]);
  2092. if (AType = djRec.Flag) and (djRec.OwnerID = AID) then
  2093. begin
  2094. FDJList.Delete(I);
  2095. djRec.Free;
  2096. end;
  2097. end;
  2098. end;
  2099. procedure TPersistentData.DeleteExprs(AID, AType: Integer);
  2100. var
  2101. I: Integer;
  2102. exprsRec: TExprsRec;
  2103. begin
  2104. for I := FExprsList.Count - 1 downto 0 do
  2105. begin
  2106. exprsRec := TExprsRec(FExprsList.List^[I]);
  2107. if (AType = exprsRec.FFlag) and (exprsRec.RecdID = AID) then
  2108. begin
  2109. FExprsList.Delete(I);
  2110. exprsRec.Free;
  2111. end;
  2112. end;
  2113. end;
  2114. procedure TPersistentData.DeleteFZ(ARationID: Integer);
  2115. var
  2116. I: Integer;
  2117. fzRec: TFZRec;
  2118. begin
  2119. for I := FFZList.Count - 1 downto 0 do
  2120. begin
  2121. fzRec := TFZRec(FFZList.List^[I]);
  2122. if fzRec.RationID = ARationID then
  2123. begin
  2124. FFZList.Delete(I);
  2125. fzRec.Free;
  2126. end;
  2127. end;
  2128. end;
  2129. procedure TPersistentData.DeleteGLJs(ARationID: Integer);
  2130. var
  2131. I: Integer;
  2132. gljRec: TGLJRec;
  2133. begin
  2134. for I := FGLJList.Count - 1 downto 0 do
  2135. begin
  2136. gljRec := TGLJRec(FGLJList.List^[I]);
  2137. if gljRec.RationsID = ARationID then
  2138. begin
  2139. FGLJList.Delete(I);
  2140. gljRec.Free;
  2141. end;
  2142. end;
  2143. end;
  2144. procedure TPersistentData.DeleteMMg(ARationID: Integer);
  2145. var
  2146. I: Integer;
  2147. mmgRec: TMMgRec;
  2148. begin
  2149. for I := FMMgList.Count - 1 downto 0 do
  2150. begin
  2151. mmgRec := TMMgRec(FMMgList.List^[I]);
  2152. if mmgRec.RationID = ARationID then
  2153. begin
  2154. FMMgList.Delete(I);
  2155. mmgRec.Free;
  2156. end;
  2157. end;
  2158. end;
  2159. procedure TPersistentData.DeleteMMr(ARationID: Integer);
  2160. var
  2161. I: Integer;
  2162. mmrRec: TMMrRec;
  2163. begin
  2164. for I := FMMrList.Count - 1 downto 0 do
  2165. begin
  2166. mmrRec := TMMrRec(FMMrList.List^[I]);
  2167. if mmrRec.RationID = ARationID then
  2168. begin
  2169. FMMrList.Delete(I);
  2170. mmrRec.Free;
  2171. end;
  2172. end;
  2173. end;
  2174. procedure TPersistentData.DeletePB(ARationID: Integer);
  2175. var
  2176. I: Integer;
  2177. pbRec: TPBRec;
  2178. begin
  2179. for I := FPBList.Count - 1 downto 0 do
  2180. begin
  2181. pbRec := TPBRec(FPBList.List^[I]);
  2182. if pbRec.RationID = ARationID then
  2183. begin
  2184. FPBList.Delete(I);
  2185. pbRec.Free;
  2186. end;
  2187. end;
  2188. end;
  2189. procedure TPersistentData.DeleteRations(ABillsID: Integer);
  2190. var
  2191. I: Integer;
  2192. rationRec: TRationsRec;
  2193. begin
  2194. for I := FRationsList.Count - 1 downto 0 do
  2195. begin
  2196. rationRec := TRationsRec(FRationsList.List^[I]);
  2197. if rationRec.BillsID = ABillsID then
  2198. begin
  2199. DeleteGLJs(rationRec.ID);
  2200. DeleteFZ(rationRec.ID);
  2201. DeletePB(rationRec.ID);
  2202. DeleteXS(rationRec.ID);
  2203. DeleteYSRate(rationRec.ID);
  2204. DeleteDJ(rationRec.ID, 1);
  2205. DeleteMMr(rationRec.ID);
  2206. DeleteMMg(rationRec.ID);
  2207. if rationRec.RType = 0 then
  2208. DeleteExprs(rationRec.ID, 2)
  2209. else DeleteExprs(rationRec.ID, 3);
  2210. FRationsList.Delete(I);
  2211. rationRec.Free;
  2212. end;
  2213. end;
  2214. end;
  2215. procedure TPersistentData.DeleteXS(ARationID: Integer);
  2216. var
  2217. I: Integer;
  2218. xsRec: TXSRec;
  2219. begin
  2220. for I := FXSList.Count - 1 downto 0 do
  2221. begin
  2222. xsRec := TXSRec(FXSList.List^[I]);
  2223. if xsRec.RationID = ARationID then
  2224. begin
  2225. FXSList.Delete(I);
  2226. xsRec.Free;
  2227. end;
  2228. end;
  2229. end;
  2230. procedure TPersistentData.DeleteYSRate(ARationID: Integer);
  2231. var
  2232. I: Integer;
  2233. ysRateRec: TYSRateRec;
  2234. begin
  2235. for I := FYSRateList.Count - 1 downto 0 do
  2236. begin
  2237. ysRateRec := TYSRateRec(FYSRateList.List^[I]);
  2238. if ysRateRec.RationID = ARationID then
  2239. begin
  2240. FYSRateList.Delete(I);
  2241. ysRateRec.Free;
  2242. end;
  2243. end;
  2244. end;
  2245. procedure TPersistentData.DeleteDQ(ABillsID: Integer);
  2246. var
  2247. I: Integer;
  2248. DqItem: TDrawingQuantity;
  2249. begin
  2250. for I := FDQList.Count - 1 downto 0 do
  2251. begin
  2252. DqItem := TDrawingQuantity(FGLJList.List^[I]);
  2253. if DqItem.BillsID = ABillsID then
  2254. begin
  2255. FDQList.Delete(I);
  2256. DqItem.Free;
  2257. end;
  2258. end;
  2259. end;
  2260. procedure TPersistentData.ReturnDraqQty(aOldBillsID, aNewBillsID: Integer;
  2261. aIsClearQ: Boolean);
  2262. var
  2263. I: Integer;
  2264. dqItem: TDrawingQuantity;
  2265. Rec: TScDrawingQuantityRecord;
  2266. begin
  2267. with TScProject(FProject).Bills.DrawingQuantityDM do
  2268. begin
  2269. for I := 0 to FDQList.Count - 1 do
  2270. begin
  2271. dqItem := TDrawingQuantity(FDQList.List^[I]);
  2272. if dqItem.BillsID = aOldBillsID then
  2273. begin
  2274. Rec := TScDrawingQuantityRecord(sdsDrawingQuantity.Add(True));
  2275. try
  2276. Rec.ID.AsInteger := FMaxDqID;
  2277. Rec.BillsID.AsInteger := aNewBillsID;
  2278. if aIsClearQ then
  2279. Rec.DQuantity1.AsFloat := 0
  2280. else
  2281. Rec.DQuantity1.AsFloat := dqItem.DQuantity1;
  2282. Rec.Name.AsString := dqItem.Name;
  2283. Rec.Units.AsString := dqItem.Units;
  2284. Rec.MemoContext.AsString := dqItem.MemoContext;
  2285. Rec.SerinalNo.AsInteger := dqItem.SerinalNo;
  2286. Inc(FMaxDqID);
  2287. finally
  2288. Rec.EndUpdate;
  2289. end;
  2290. end;
  2291. end;
  2292. end;
  2293. end;
  2294. procedure TPersistentData.AppendDQRec(ARecord: TsdDataRecord);
  2295. var
  2296. dqRec: TDrawingQuantity;
  2297. begin
  2298. dqRec := TDrawingQuantity.Create(nil);
  2299. with ARecord do
  2300. begin
  2301. dqRec.BillsID := ValueByName('BillsID').AsInteger;
  2302. dqRec.SerinalNo := ValueByName('SerinalNo').AsInteger;
  2303. dqRec.Name := ValueByName('Name').AsString;
  2304. dqRec.Units := ValueByName('Units').AsString;
  2305. dqRec.FDQuantity1 := ValueByName('DQuantity1').AsFloat;
  2306. dqRec.MemoContext := ValueByName('MemoContext').AsString;
  2307. end;
  2308. FDQList.Add(dqRec);
  2309. end;
  2310. { TFileOpManager }
  2311. procedure TFileOpManager.ExtractParticularName(const aProjName, aFullBPName, aAlias, aGUID: string);
  2312. {var
  2313. strName, strExt: string; }
  2314. begin
  2315. FExtractFileName := aAlias;
  2316. FBuildProjectFolder := aProjName;
  2317. FFullBuildProjectPath := aFullBPName;
  2318. FGUID := aGUID;
  2319. { strName := ExtractFileName(AFileName);
  2320. strExt := ExtractFileExt(AFileName);
  2321. FExtractFileName := Trim(Copy(strName, 1, Length(strName) - Length(strExt)));
  2322. strName := Format('%s%s', [FFileDir, MyProject]);
  2323. FBuildProjectFolder := AFileName;
  2324. Delete(FBuildProjectFolder, 1, Length(strName) + 1);
  2325. FBuildProjectFolder := Trim(Copy(FBuildProjectFolder, 1, Pos('\', FBuildProjectFolder))); }
  2326. end;
  2327. function TFileOpManager.GetCurProjectDir: string;
  2328. begin
  2329. Result := Format('%s%s%s%s\', [FFileDir, RestoreBat, NodeBinFolder, FGUID]);
  2330. end;
  2331. function TFileOpManager.GetSaveFileName(const ACode, ABCode, AName: string): string;
  2332. const
  2333. unDefineName = '未命名';
  2334. {去掉换行符}
  2335. procedure DeleteRowBack(var str: string);
  2336. var
  2337. I: Integer;
  2338. begin
  2339. for I := Length(str) downto 1 do
  2340. begin
  2341. if (str[I] = #10) or (str[I] = #13) then
  2342. Delete(str, I, 1);
  2343. end;
  2344. end;
  2345. function GetUniqueName(const AFileName: string): string;
  2346. procedure SaveFolderCaption(const ADir: string);
  2347. var
  2348. sgs: TStringList;
  2349. begin
  2350. sgs := TStringList.Create;
  2351. try
  2352. sgs.Add(Format('建设项目:%s', [FFullBuildProjectPath]));
  2353. sgs.Add(Format('标段:%s', [FExtractFileName]));
  2354. finally
  2355. sgs.SaveToFile(ADir+'\说明.txt');
  2356. sgs.Free;
  2357. end;
  2358. end;
  2359. var
  2360. I: Integer;
  2361. strDir, strName, strFilePath: string;
  2362. begin
  2363. I := 1;
  2364. strName := Trim(AFileName);
  2365. HandlerSpecialChar(strName);
  2366. strDir := Format('%s%s%s%s', [FFileDir, RestoreBat, NodeBinFolder, FGUID]);
  2367. strFilePath := Format('%s\%s%s', [strDir, strName, cExt]);
  2368. DeleteRowBack(strFilePath);
  2369. while FileExists(strFilePath) do
  2370. begin
  2371. strFilePath := Format('%s\%s_%d%s', [strDir, strName, I, cExt]);
  2372. DeleteRowBack(strFilePath);
  2373. Inc(I);
  2374. end;
  2375. Result := strFilePath;
  2376. if not DirectoryExists(strDir) then
  2377. begin
  2378. ForceDirectories(strDir);
  2379. SaveFolderCaption(strDir);
  2380. end;
  2381. end;
  2382. begin
  2383. if ACode <> '' then
  2384. Result := GetUniqueName(ACode)
  2385. else if ABCode <> '' then
  2386. Result := GetUniqueName(ABCode)
  2387. else if AName <> '' then
  2388. Result := GetUniqueName(AName)
  2389. else
  2390. Result := GetUniqueName(unDefineName);
  2391. end;
  2392. procedure TFileOpManager.HandlerSpecialChar(var AText: string);
  2393. const
  2394. speChar: array [0..8] of Char = ('*', '<', '>', '/', '\', '?', ':', '|', '"');
  2395. viChar: array [0..8] of string = ('×', '<', '>', '/', '\', '?', ':', '|', '"');
  2396. var
  2397. I: Integer;
  2398. begin
  2399. for I := low(speChar) to High(speChar) do
  2400. begin
  2401. if Pos(speChar[I], AText) <> 0 then
  2402. AText := StringReplace(AText, speChar[I], viChar[I], [rfReplaceAll]);
  2403. end;
  2404. end;
  2405. function TFileOpManager.RevertSpecialChar(const AText: string): string;
  2406. const
  2407. speChar: array [0..8] of Char = ('*', '<', '>', '/', '\', '?', ':', '|', '"');
  2408. viChar: array [0..8] of string = ('×', '<', '>', '/', '\', '?', ':', '|', '"');
  2409. var
  2410. I: Integer;
  2411. begin
  2412. Result := AText;
  2413. for I := low(viChar) to High(viChar) do
  2414. begin
  2415. if Pos(viChar[I], AText) <> 0 then
  2416. Result := StringReplace(AText, viChar[I], speChar[I], [rfReplaceAll]);
  2417. end;
  2418. end;
  2419. end.