| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652 |
- {}
- {李涛 日期: 2010.5.6}
- {节点回收站: 保存已删除的项目节点}
- {}
- unit ScPersistentData;
- interface
- uses Classes, DBClient, ScNodeRecycleBinDM, ScBills, Variants, ScBillsDM, sdDB;
- type
- {****************************************************************************}
- {***************************** 数据结构 *************************************}
- {****************************************************************************}
-
- {文件信息}
- TFileInfo = class(TComponent)
- private
- FName: string;
- FDeleteTime: TDateTime;
- published
- property Name: string read FName write FName;
- property DeleteTime: TDateTime read FDeleteTime write FDeleteTime;
- end;
- {清单记录}
- TBillsRec = class(TComponent)
- private
- FID: Integer;
- FParentID: Integer;
- FNextSiblingID: Integer;
- FCode: string;
- FName: string;
- FUnits: string;
- FBCode: string;
- FDQuantity: Double;
- FDQuantity2: Double;
- FDPrice: Double;
- FFlag: Integer;
- FIsPreDefine: Boolean;
- FIsLeaf: Boolean;
- FCalcKinds: Integer;
- FQuantity: Double;
- FQuantity2: Double;
- FUnitPrice: Double;
- FTotalPrice: Double;
- FBillsGLJPriceLib: string;
- FMemoString: string;
- FParentIDChanged: Boolean;
- FNextSiblingIDChanged: Boolean;
- FOldID: Integer;
- published
- property ID: Integer read FID write FID;
- property ParentID: Integer read FParentID write FParentID;
- property NextSiblingID: Integer read FNextSiblingID write FNextSiblingID;
- property Code: string read FCode write FCode;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property BCode: string read FBCode write FBCode;
- property DQuantity: Double read FDQuantity write FDQuantity;
- property DQuantity2: Double read FDQuantity2 write FDQuantity2;
- property DPrice: Double read FDPrice write FDPrice;
- property IsPreDefine: Boolean read FIsPreDefine write FIsPreDefine;
- property Flag: Integer read FFlag write FFlag;
- property IsLeaf: Boolean read FIsLeaf write FIsLeaf;
- property CalcKinds: Integer read FCalcKinds write FCalcKinds;
- property Quantity: Double read FQuantity write FQuantity;
- property Quantity2: Double read FQuantity2 write FQuantity2;
- property UnitPrice: Double read FUnitPrice write FUnitPrice;
- property TotalPrice: Double read FTotalPrice write FTotalPrice;
- property BillsGLJPriceLib: string read FBillsGLJPriceLib write FBillsGLJPriceLib;
- property MemoString: string read FMemoString write FMemoString;
- property ParentIDChanged: Boolean read FParentIDChanged write FParentIDChanged;
- property NextSiblingIDChanged: Boolean read FNextSiblingIDChanged write FNextSiblingIDChanged;
- end;
- TDrawingQuantity = class(TComponent)
- private
- FBillsID: Integer;
- FSerinalNo: Integer;
- FName: string;
- FUnits: string;
- FDQuantity1: Double;
- FMemoContext: string;
- published
- property BillsID: Integer read FBillsID write FBillsID;
- property SerinalNo: Integer read FSerinalNo write FSerinalNo;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property DQuantity1: Double read FDQuantity1 write FDQuantity1;
- property MemoContext: string read FMemoContext write FMemoContext;
- end;
- {定额、数量单价}
- TRationsRec = class(TComponent)
- private
- FID: Integer;
- FCode: string;
- FName: string;
- FUnits: string;
- FQuantity: Double;
- FQuantityXS: Double;
- FGetFeeKind: Variant;
- FAdjustState: string;
- FBillsID: Integer;
- FSerialNo: Integer;
- FMaskName: string;
- FUnitDirectFee: Double;
- FCountPriceType: Variant;
- FBuildingFee: Double;
- FRationProjName: string;
- FIsCalcProfit: Boolean;
- FCodeForReport: string;
- FContent: string;
- FLibType: Integer;
- FCodeLength: Integer;
- FRationProjName2: string;
- FName2: string;
- FUnit2: string;
- FCodeForReport2: string;
- FIsCalcEquipmentFee: Boolean;
- FIsCalcTax: Boolean;
- FRType: Integer;
- FLibID: Integer;
- FIsMECalc: Boolean;
- FUnitPrice: Double;
- FRationUnitDirectFee: Double;
- FSpecs: string;
- FGLJID: Integer;
- published
- property ID: Integer read FID write FID;
- property Code: string read FCode write FCode;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property Quanity: Double read FQuantity write FQuantity;
- property QuantityXS: Double read FQuantityXS write FQuantityXS;
- property GetFeeKind: Variant read FGetFeeKind write FGetFeeKind;
- property AdjustState: string read FAdjustState write FAdjustState;
- property BillsID: Integer read FBillsID write FBillsID;
- property SerialNo: Integer read FSerialNo write FSerialNo;
- property MaskName: string read FMaskName write FMaskName;
- property CountPriceType: Variant read FCountPriceType write FCountPriceType;
- property UnitDirectFee: Double read FUnitDirectFee write FUnitDirectFee;
- property BuildingFee: Double read FBuildingFee write FBuildingFee;
- property RationProjName: string read FRationProjName write FRationProjName;
- property IsCalcProfit: Boolean read FIsCalcProfit write FIsCalcProfit;
- property CodeForReport: string read FCodeForReport write FCodeForReport;
- property Content: string read FContent write FContent;
- property LibType: Integer read FLibType write FLibType;
- property CodeLength: Integer read FCodeLength write FCodeLength;
- property RationProjName2: string read FRationProjName2 write FRationProjName2;
- property Name2: string read FName2 write FName2;
- property Unit2: string read FUnit2 write FUnit2;
- property CodeForReport2: string read FCodeForReport2 write FCodeForReport2;
- property IsCalcEquipmentFee: Boolean read FIsCalcEquipmentFee write FIsCalcEquipmentFee;
- property IsCalcTax: Boolean read FIsCalcTax write FIsCalcTax;
- property RType: Integer read FRType write FRType;
- property LibID: Integer read FLibID write FLibID;
- property Specs: string read FSpecs write FSpecs;
- property IsMECalc: Boolean read FIsMECalc write FIsMECalc;
- property RationUnitDirectFee: Double read FRationUnitDirectFee write FRationUnitDirectFee;
- property UnitPrice: Double read FUnitPrice write FUnitPrice;
- property GLJID: Integer read FGLJID write FGLJID;
- end;
- {工料机}
- TGLJRec = class(TComponent)
- private
- FRGLJID: Integer;
- FRQuantity: Double;
- FOrgRQuantity: Variant;
- FRationPrice: Double;
- FFlag: Integer;
- FMinorRQ1: Double;
- FMinorRQ2: Double;
- FMinorRQ3: Double;
- FGLJID: Integer;
- FRUID: Integer;
- FSortParam: Integer;
- FCalculateType: Variant;
- FUID: Integer;
- FCustomQuantity: Variant;
- FBudgetPrice: Double;
- FQuantity: Double;
- FLibID: Integer;
- FBillsID: Integer;
- FRationsID: Integer;
- FGLJType: Variant;
- FTenderPrice: Double;
- FRationItemQuantity: Double;
- FRName: string;
- FUnit: string;
- FSpecs: string;
- FRCode: string;
- FCode: string;
- FName: string;
- FRUnit: string;
- FRSpecs: string;
- published
- property RGLJID: Integer read FRGLJID write FRGLJID;
- property RQuantity: Double read FRQuantity write FRQuantity;
- property OrgRQuantity: Variant read FOrgRQuantity write FOrgRQuantity;
- property RationPrice: Double read FRationPrice write FRationPrice;
- property Flag: Integer read FFlag write FFlag;
- property MinorRQ1: Double read FMinorRQ1 write FMinorRQ1;
- property MinorRQ2: Double read FMinorRQ2 write FMinorRQ2;
- property MinorRQ3: Double read FMinorRQ3 write FMinorRQ3;
- property GLJID: Integer read FGLJID write FGLJID;
- property SortParam: Integer read FSortParam write FSortParam;
- property CalculateType: Variant read FCalculateType write FCalculateType;
- property CustomQuantity: Variant read FCustomQuantity write FCustomQuantity;
- property BudgetPrice: Double read FBudgetPrice write FBudgetPrice;
- property Quantity: Double read FQuantity write FQuantity;
- property LibID: Integer read FLibID write FLibID;
- property BillsID: Integer read FBillsID write FBillsID;
- property RationsID: Integer read FRationsID write FRationsID;
- property GLJType: Variant read FGLJType write FGLJType;
- property TenderPrice: Double read FTenderPrice write FTenderPrice;
- property RationItemQuantity: Double read FRationItemQuantity write FRationItemQuantity;
- property RCode: string read FRCode write FRCode;
- property RName: string read FRName write FRName;
- property RSpecs: string read FRSpecs write FRSpecs;
- property RUnit: string read FRUnit write FRUnit;
- property Code: string read FCode write FCode;
- property Name: string read FName write FName;
- property Specs: string read FSpecs write FSpecs;
- property Units: string read FUnit write FUnit;
- end;
- {辅助调整}
- TFZRec = class(TComponent)
- private
- FRationID: Integer;
- FParamName: string;
- FParamIndex: Integer;
- FNewValue: Double;
- FMinorIndex: Integer;
- FBaseValue: Double;
- FIncStep: Double;
- FRationCode: string;
- FRationCode1: Integer;
- FRoundDigit: Integer;
- FRoundMode: Integer;
- published
- property RationID: Integer read FRationID write FRationID;
- property ParamName: string read FParamName write FParamName;
- property ParamIndex: Integer read FParamIndex write FParamIndex;
- property NewValue: Double read FNewValue write FNewValue;
- property MinorIndex: Integer read FMinorIndex write FMinorIndex;
- property BaseValue: Double read FBaseValue write FBaseValue;
- property IncStep: Double read FIncStep write FIncStep;
- property RationCode: string read FRationCode write FRationCode;
- property RationCode1: Integer read FRationCode1 write FRationCode1;
- property RoundDigit: Integer read FRoundDigit write FRoundDigit;
- property RoundMode: Integer read FRoundMode write FRoundMode;
- end;
- {配比调整}
- TPBRec = class(TComponent)
- private
- FRationID: Integer;
- FCode: string;
- FGLJID: Integer;
- FProportion: Double;
- FRProportion: Double;
- published
- property RationID: Integer read FRationID write FRationID;
- property Code: string read FCode write FCode;
- property GLJID: Integer read FGLJID write FGLJID;
- property Proportion: Double read FProportion write FProportion;
- property RProportion: Double read FRProportion write FRProportion;
- end;
- {单价调整}
- TDJRec = class(TComponent)
- private
- FOwnerID: Integer;
- FGLJID: Integer;
- FUnitPrice: Double;
- FFlag: Integer;
- FGLJCode: Integer;
- FLibID: Integer;
- published
- property OwnerID: Integer read FOwnerID write FOwnerID;
- property GLJID: Integer read FGLJID write FGLJID;
- property UnitPrice: Double read FUnitPrice write FUnitPrice;
- property Flag: Integer read FFlag write FFlag;
- property GLJCode: Integer read FGLJCode write FGLJCode;
- property LibID: Integer read FLibID write FLibID;
- end;
- {油石率调整}
- TYSRateRec = class(TComponent)
- private
- FRationID: Integer;
- FRYSRate: Double;
- FYSRate: Variant;
- published
- property RationID: Integer read FRationID write FRationID;
- property RYSRate: Double read FRYSRate write FRYSRate;
- property YSRate: Variant read FYSRate write FYSRate;
- end;
- {系数调整}
- TXSRec = class(TComponent)
- private
- FRationID: Integer;
- FCoeID: Integer;
- FSelected: Boolean;
- FFlag: Integer;
- FData: string;
- FCalcOrder: Integer;
- FGroupIdx: Integer;
- FParam: Integer;
- published
- property RationID: Integer read FRationID write FRationID;
- property CoeID: Integer read FCoeID write FCoeID;
- property Selected: Boolean read FSelected write FSelected;
- property Flag: Integer read FFlag write FFlag;
- property Data: string read FData write FData;
- property CalcOrder: Integer read FCalcOrder write FCalcOrder;
- property GroupIdx: Integer read FGroupIdx write FGroupIdx;
- property Param: Integer read FParam write FParam;
- end;
- {辅助定额}
- TMMrRec = class(TComponent)
- private
- FRationID: Integer;
- FMinorIndex: Integer;
- FParamIndex: Integer;
- FMinorParam: Double;
- FParamName: string;
- FMinorName: string;
- FBaseValue: Double;
- FRoundDigit: Integer;
- FRoundMode: Integer;
- FIncStep: Double;
- FRationCode: string;
- FRationIDCode: Integer;
- published
- property RationID: Integer read FRationID write FRationID;
- property MinorIndex: Integer read FMinorIndex write FMinorIndex;
- property ParamIndex: Integer read FParamIndex write FParamIndex;
- property MinorParam: Double read FMinorParam write FMinorParam;
- property ParamName: string read FParamName write FParamName;
- property MinorName: string read FMinorName write FMinorName;
- property BaseValue: Double read FBaseValue write FBaseValue;
- property RoundDigit: Integer read FRoundDigit write FRoundDigit;
- property RoundMode: Integer read FRoundMode write FRoundMode;
- property IncStep: Double read FIncStep write FIncStep;
- property RationCode: string read FRationCode write FRationCode;
- property RationIDCode: Integer read FRationIDCode write FRationIDCode;
- end;
- {辅助工料机}
- TMMgRec = class(TComponent)
- private
- FRationID: Integer;
- FMinorIndex: Integer;
- FGLJID: Integer;
- FGLJCode: string;
- FMRQ1: Double;
- FMRQ2: Double;
- FMRQ3: Double;
- published
- property RationID: Integer read FRationID write FRationID;
- property MinorIndex: Integer read FMinorIndex write FMinorIndex;
- property GLJID: Integer read FGLJID write FGLJID;
- property GLJCode: string read FGLJCode write FGLJCode;
- property MRQ1: Double read FMRQ1 write FMRQ1;
- property MRQ2: Double read FMRQ2 write FMRQ2;
- property MRQ3: Double read FMRQ3 write FMRQ3;
- end;
- {公式}
- TExprsRec = class(TComponent)
- private
- FMajorID: Integer;
- FMinorID: Integer;
- FExprs: String;
- FFlag: Integer;
- FRecdID: Integer;
- FExprsValue: Double;
- FExprs1: string;
- FExprs2: string;
- FExprs3: string;
- FExprs4: string;
- published
- property MajorID: Integer read FMajorID write FMinorID;
- property MinorID: Integer read FMinorID write FMinorID;
- property Exprs: string read FExprs write FExprs;
- property Flag: Integer read FFlag write FFlag;
- property RecdID: Integer read FRecdID write FRecdID;
- property ExprsValue: Double read FExprsValue write FExprsValue;
- property Exprs1: string read FExprs1 write FExprs1;
- property Exprs2: string read FExprs2 write FExprs2;
- property Exprs3: string read FExprs3 write FExprs3;
- property Exprs4: string read FExprs4 write FExprs4;
- end;
- {文件操作管理}
- TFileOpManager = class
- private
- FFileDir: string;
- FBuildProjectFolder: string;
- FFullBuildProjectPath: string;
- FExtractFileName: string;
- FGUID: string;
- procedure HandlerSpecialChar(var AText: string);
- function RevertSpecialChar(const AText: string): string;
- public
- procedure ExtractParticularName(const aProjName, aFullBPName, aAlias, aGUID: string);
- function GetCurProjectDir: string;
- function GetSaveFileName(const ACode, ABCode, AName: string): string;
- property FileDir: string read FFileDir write FFileDir;
- property ExtractNameWithOutExt: string read FExtractFileName write FExtractFileName;
- end;
- {****************************************************************************}
- {*********************************** 结束 ***********************************}
- {****************************************************************************}
-
- TPersistentData = class
- private
- FMaxBillsID: Integer;
- FMaxRationID: Integer;
- FMaxDqID: Integer;
- FProject: TObject;
- FFileInfo: TFileInfo;
- FBillsList: TList;
- FDQList: TList;
- FRationsList: TList;
- FGLJList: TList;
- FFZList: TList;
- FPBList: TList;
- FDJList: TList;
- FYSRateList: TList;
- FXSList: TList;
- FMMrList: TList;
- FMMgList: TList;
- FExprsList: TList;
- FNameList: TStringList;
- FDeleteNameList: TStringList;
- FFileOpManager: TFileOpManager;
- procedure ClearAllList;
- procedure ClearNameList;
- procedure DeleteListFiles;
- procedure DeleteNameListFiles;
- procedure ShowErrorMessage(const Text: string);
- procedure AddNameToList(const AFileName: string);
- procedure AddDeleteNameToList(const AFileName: string);
- procedure DeleteDQ(ABillsID: Integer);
- procedure DeleteRations(ABillsID: Integer);
- procedure DeleteGLJs(ARationID: Integer);
- procedure DeleteFZ(ARationID: Integer);
- procedure DeletePB(ARationID: Integer);
- procedure DeleteXS(ARationID: Integer);
- procedure DeleteDJ(AID, AType: Integer);
- procedure DeleteYSRate(ARationID: Integer);
- procedure DeleteMMr(ARationID: Integer);
- procedure DeleteMMg(ARationID: Integer);
- procedure DeleteExprs(AID, AType: Integer);
- procedure DeleteRecordsBasisBillsID(ABillsID: Integer);
- procedure CheckClassExists;
- function CheckParentNodeExists(AID: Integer; Flag: Integer): Boolean;
- procedure ConformStructuralLevel(var AFirstID, ALastNextID: Integer; AParentID: Integer);
- function ReturnBillsInside(ARec: TScBillsRecord; AList: TList;
- AIsClearQ, AIsNew: Boolean; var AFirstID, ALastNextID: Integer): Integer;
- procedure InternalPersistent;
- procedure InternalReadPersistent(const AFileName: string; IsReadAll: Boolean);
- procedure InternalWriteDB(ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
- procedure ReturnBills(AItem: TScBillsItem; AIsClearQ, AIsNew: Boolean);
- procedure ReturnDraqQty(aOldBillsID, aNewBillsID: Integer; aIsClearQ: Boolean);
- procedure ReturnRations(AOldBillsID, ANewBillsID: Integer; AIsClearQ: Boolean);
- procedure ReturnGLJs(AOldBillsID, ANewBillsID, AOldRationID, ANewRationID: Integer);
- procedure ReturnFZ(AOldRationID, ANewRationID: Integer);
- procedure ReturnPB(AOldRationID, ANewRationID: Integer);
- procedure ReturnXS(AOldRationID, ANewRationID: Integer);
- procedure ReturnDJ(AOldID, ANewID, AType: Integer);
- procedure ReturnYSRate(AOldRationID, ANewRationID: Integer);
- procedure ReturnMMr(AOldRationID, ANewRationID: Integer);
- procedure ReturnMMg(AOldRationID, ANewRation: Integer);
- procedure ReturnRAdjust(AOldRationID, ANewRationID: Integer);
- procedure ReturnExprs(AOldID, ANewID, AType: Integer);
- function GetFileDir: string;
- procedure SetFileDir(const Value: string);
- public
- constructor Create;
- destructor Destroy; override;
- procedure Save;
- procedure DeleteCurFile(const AFileName: string);
- procedure CreateFileInfo(ARecord: TScBillsRecord);
- procedure AppendBillsRec(ARecord: TScBillsRecord);
- procedure AppendRationsRec(sdRation: TObject);
- procedure AppendGLJRec(sdGLJ: TObject);
- procedure AppendExprsRec(ARecord: TsdDataRecord);
- procedure AppendFZRec(ARecord: TsdDataRecord);
- procedure AppendPBRec(ARecord: TsdDataRecord);
- procedure AppendXSRec(ARecord: TsdDataRecord);
- procedure AppendYSRec(ARecord: TsdDataRecord);
- procedure AppendMMrRec(ARecord: TsdDataRecord);
- procedure AppendMMgRec(ARecord: TsdDataRecord);
- procedure AppendDJRec(ARecord: TsdDataRecord);
- procedure AppendDQRec(ARecord: TsdDataRecord);
- procedure PersistentObjects;
- procedure ReadPersistentObjects(const AFileName: string;
- ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
- procedure ExtractParticularFileName(const aProjName, aFullBPName, aAlias, aGUID: string);
- function CurProjectDir: string;
- function CheckFilePathInDelete(const AFileName: string): Boolean;
- function ReturnData(const AFileName: string; AItem: TScBillsItem;
- AIsClearQ, AIsNew: Boolean): Boolean;
- property FileDir: string read GetFileDir write SetFileDir;
- property Project: TObject read FProject write FProject;
- end;
- implementation
- uses ScRations, ScGLJ, ScConsts, SysUtils, DB, ScProject, ScExprs,
- ScRAdjusts, Windows, ZjIDTree, ScDrawingQuantityDM, ScProjectGLJ, ScUtils;
- const
- cflParent = 0;
- cflPrev = 1;
- cflNone = -1;
- RestoreBat = 'Pro_BackUp\';
- NodeBinFolder = 'NodeRecycleBin\';
- MyProject = '我的项目';
- cExt = '.pdn';
- { TPersistentData }
- procedure TPersistentData.AddNameToList(const AFileName: string);
- begin
- FNameList.Add(AFileName);
- end;
- procedure TPersistentData.AppendBillsRec(ARecord: TScBillsRecord);
- const
- sDQuantity = 'DesignQuantity';
- sDQuantity2 = 'DesignQuantity2';
- sDPrice = 'DesignPrice';
- sFlag = 'Flag';
- sIsPreDefine = 'IsPreDefine';
- sCalcKinds = 'CalcKinds';
- sMemoStr = 'MemoStr';
- sBillsGLJPriceLib = 'GLJPriceLib';
- var
- billsRec: TBillsRec;
- begin
- billsRec := TBillsRec.Create(nil);
- billsRec.ID := ARecord.ID.AsInteger;
- billsRec.ParentID := ARecord.ParentID.AsInteger;
- billsRec.NextSiblingID := ARecord.NextSiblingID.AsInteger;
- billsRec.Code := ARecord.Code.AsString;
- billsRec.Name := ARecord.Name.AsString;
- billsRec.Units := ARecord.Units.AsString;
- if TScProject(FProject).IsGuangDong then
- begin
- billsRec.BCode := ARecord.B_Code.AsString;
- end;
- billsRec.DQuantity := ARecord.DesignQuantity.AsFloat;
- billsRec.DQuantity2 := ARecord.DesignQuantity2.AsFloat;
- billsRec.DPrice := ARecord.DesignPrice.AsFloat;
- billsRec.Quantity := ARecord.Quantity.AsFloat;
- billsRec.Quantity2 := ARecord.Quantity2.AsFloat;
- billsRec.UnitPrice := ARecord.UnitPrice.AsFloat;
- billsRec.Flag := ARecord.Flag.AsInteger;
- billsRec.IsPreDefine := ARecord.IsPreDefine.AsBoolean;
- billsRec.IsLeaf := ARecord.IsLeaf.AsBoolean;
- billsRec.CalcKinds := ARecord.CalcKinds.AsInteger;
- billsRec.TotalPrice := ARecord.TotalPrice.AsFloat;
- billsRec.MemoString := ARecord.MemoStr.AsString;
- billsRec.BillsGLJPriceLib := ARecord.GLJPriceLib.AsString;
- FBillsList.Add(billsRec);
- end;
- procedure TPersistentData.AppendDJRec(ARecord: TsdDataRecord);
- const
- scsOwnerID = 'OwnerID';
- scsGLJCode = 'GLJCode';
- scsPrice = 'Price';
- scsFlag = 'Flag';
- scsGLJID = 'GLJID';
- scsLibID = 'LibID';
- var
- djRec: TDJRec;
- begin
- djRec := TDJRec.Create(nil);
- with ARecord do
- begin
- djRec.OwnerID := ValueByName(scsOwnerID).AsInteger;
- djRec.GLJID := ValueByName(scsGLJID).AsInteger;
- djRec.GLJCode := ValueByName(scsGLJCode).AsInteger;
- djRec.UnitPrice := ValueByName(scsPrice).AsFloat;
- djRec.LibID := ValueByName(scsLibID).AsInteger;
- djRec.Flag := ValueByName(scsFlag).AsInteger;
- end;
- FDJList.Add(djRec);
- end;
- procedure TPersistentData.AppendExprsRec(ARecord: TsdDataRecord);
- const
- scsMajorID = 'MajorID';
- scsMinorID = 'MinorID';
- scsExprs = 'Exprs';
- scsFlag = 'Flag';
- scsRecdID = 'RecdID';
- scsExprsValue = 'ExprsValue';
- scsExprs1 = 'Exprs1';
- scsExprs2 = 'Exprs2';
- scsExprs3 = 'Exprs3';
- scsExprs4 = 'Exprs4';
- var
- exprsRec: TExprsRec;
- begin
- exprsRec := TExprsRec.Create(nil);
- with ARecord do
- begin
- exprsRec.MajorID := ValueByName(scsMajorID).AsInteger;
- exprsRec.MinorID := ValueByName(scsMinorID).AsInteger;
- exprsRec.Exprs := ValueByName(scsExprs).AsString;
- exprsRec.Flag := ValueByName(scsFlag).AsInteger;
- exprsRec.RecdID := ValueByName(scsRecdID).AsInteger;
- exprsRec.ExprsValue := ValueByName(scsExprsValue).AsFloat;
- exprsRec.Exprs1 := ValueByName(scsExprs1).AsString;
- exprsRec.Exprs2 := ValueByName(scsExprs2).AsString;
- exprsRec.Exprs3 := ValueByName(scsExprs3).AsString;
- exprsRec.Exprs4 := ValueByName(scsExprs4).AsString;
- end;
- FExprsList.Add(exprsRec);
- end;
- procedure TPersistentData.AppendFZRec(ARecord: TsdDataRecord);
- const
- scsParamName = 'ParamName';
- scsParamIndex = 'ParamIndex';
- scsRationID = 'RationID';
- scsNewValue = 'NewValue';
- scsBaseValue = 'BaseValue';
- scsIncStep = 'IncStep';
- scsRationCode = 'RationCode';
- scsRationCode1 = 'RationCode1';
- scsMinorIndex = 'MinorIndex';
- scsRoundDigit = 'RoundDigit';
- scsRoundMode = 'RoundMode';
- var
- fzRec: TFZRec;
- begin
- fzRec := TFZRec.Create(nil);
- with ARecord do
- begin
- fzRec.ParamName := ValueByName(scsParamName).AsString;
- fzRec.ParamIndex := ValueByName(scsParamIndex).AsInteger;
- fzRec.RationID := ValueByName(scsRationID).AsInteger;
- fzRec.NewValue := ValueByName(scsNewValue).AsFloat;
- fzRec.MinorIndex := ValueByName(scsMinorIndex).AsInteger;
- fzRec.BaseValue := ValueByName(scsBaseValue).AsFloat;
- fzRec.IncStep := ValueByName(scsIncStep).AsFloat;
- fzRec.RationCode := ValueByName(scsRationCode).AsString;
- fzRec.RationCode1 := ValueByName(scsRationCode1).AsInteger;
- fzRec.RoundDigit := ValueByName(scsRoundDigit).AsInteger;
- fzRec.RoundMode := ValueByName(scsRoundMode).AsInteger;
- end;
- FFZList.Add(fzRec);
- end;
- procedure TPersistentData.AppendGLJRec(sdGLJ: TObject);
- var
- gljRec: TGLJRec;
- begin
- gljRec := TGLJRec.Create(nil);
- with TScGLJRecord(sdGLJ) do
- begin
- gljRec.RationsID := RationID.AsInteger;
- gljRec.BillsID := BillsItemID.AsInteger;
- gljRec.RGLJID := RGLJID.AsInteger;
- gljRec.RQuantity := RQuantity.AsFloat;
- gljRec.OrgRQuantity := OrgRQuantity.AsFloat;
- gljRec.RationPrice := RationPrice.AsCurrency;
- gljRec.Flag := Flag.AsInteger;
- gljRec.MinorRQ1 := MinorRQ1.AsFloat;
- gljRec.MinorRQ2 := MinorRQ2.AsFloat;
- gljRec.MinorRQ3 := MinorRQ3.AsFloat;
- gljRec.GLJID := GLJID.AsInteger;
- gljRec.SortParam := SortParam.AsInteger;
- gljRec.CalculateType := CalculateType.AsInteger;
- gljRec.CustomQuantity := CustomQuantity.AsVariant;
- gljRec.BudgetPrice := BudgetPrice.AsCurrency;
- gljRec.Quantity := Quantity.AsFloat;
- gljRec.LibID := LibID.AsInteger;
- gljRec.GLJType := Types.AsInteger;
- gljRec.TenderPrice := TenderPrice.AsCurrency;
- gljRec.RationItemQuantity := RationItemQuantity.AsFloat;
- gljRec.RCode := RCode.AsString;
- gljRec.RName := RName.AsString;
- gljRec.RSpecs := RSpecs.AsString;
- gljRec.RUnit := RUnit.AsString;
- gljRec.Code := Code.AsString;
- gljRec.Name := Name.AsString;
- gljRec.Specs := Specs.AsString;
- gljRec.Units := Units.AsString;
- end;
- FGLJList.Add(gljRec);
- end;
- procedure TPersistentData.AppendMMgRec(ARecord: TsdDataRecord);
- const
- scsRationID = 'RationID';
- scsMinorIndex = 'MinorIndex';
- scsGLJID = 'GLJID';
- scsGLJCode = 'GLJCode';
- scsMRQ1 = 'MRQ1';
- scsMRQ2 = 'MRQ2';
- scsMRQ3 = 'MRQ3';
- var
- mmgRec: TMMgRec;
- begin
- mmgRec := TMMgRec.Create(nil);
- with ARecord do
- begin
- mmgRec.RationID := ValueByName(scsRationID).AsInteger;
- mmgRec.MinorIndex := ValueByName(scsMinorIndex).AsInteger;
- mmgRec.GLJID := ValueByName(scsGLJID).AsInteger;
- mmgRec.GLJCode := ValueByName(scsGLJCode).AsString;
- mmgRec.MRQ1 := ValueByName(scsMRQ1).AsFloat;
- mmgRec.MRQ2 := ValueByName(scsMRQ2).AsFloat;
- mmgRec.MRQ3 := ValueByName(scsMRQ3).AsFloat;
- end;
- FMMgList.Add(mmgRec);
- end;
- procedure TPersistentData.AppendMMrRec(ARecord: TsdDataRecord);
- const
- scsRationID = 'RationID';
- scsMinorIndex = 'MinorIndex';
- scsParamIndex = 'ParamIndex';
- scsMinorParam = 'MinorParam';
- scsParamName = 'ParamName';
- scsMinorName = 'MinorName';
- scsBaseValue = 'BaseValue';
- scsRoundDigit = 'RoundDigit';
- scsRoundMode = 'RoundMode';
- scsIncStep = 'IncStep';
- scsRationCode = 'RationCode';
- scsIDCode = 'IDCode';
- var
- mmrRec: TMMrRec;
- begin
- mmrRec := TMMrRec.Create(nil);
- with ARecord do
- begin
- mmrRec.RationID := ValueByName(scsRationID).AsInteger;
- mmrRec.MinorIndex := ValueByName(scsMinorIndex).AsInteger;
- mmrRec.ParamIndex := ValueByName(scsParamIndex).AsInteger;
- mmrRec.MinorParam := ValueByName(scsMinorParam).AsFloat;
- mmrRec.ParamName := ValueByName(scsParamName).AsString;
- mmrRec.MinorName := ValueByName(scsMinorName).AsString;
- mmrRec.BaseValue := ValueByName(scsBaseValue).AsFloat;
- mmrRec.RoundDigit := ValueByName(scsRoundDigit).AsInteger;
- mmrRec.RoundMode := ValueByName(scsRoundMode).AsInteger;
- mmrRec.IncStep := ValueByName(scsIncStep).AsInteger;
- mmrRec.RationCode := ValueByName(scsRationCode).AsString;
- mmrRec.RationIDCode := ValueByName(scsIDCode).AsInteger;
- end;
- FMMrList.Add(mmrRec);
- end;
- procedure TPersistentData.AppendPBRec(ARecord: TsdDataRecord);
- const
- scsRationID = 'RationID';
- scsGLJID = 'GLJID';
- scsGLJCode = 'GLJCode';
- scsRProportion = 'RProportion';
- scsProportion = 'Proportion';
- var
- pbRec: TPBRec;
- begin
- pbRec := TPBRec.Create(nil);
- with ARecord do
- begin
- pbRec.RationID := ValueByName(scsRationID).AsInteger;
- pbRec.Code := ValueByName(scsGLJCode).AsString;
- pbRec.GLJID := ValueByName(scsGLJID).AsInteger;
- pbRec.RProportion := ValueByName(scsRProportion).AsFloat;
- pbRec.Proportion := ValueByName(scsProportion).AsFloat;
- end;
- FPBList.Add(pbRec);
- end;
- procedure TPersistentData.AppendRationsRec(sdRation: TObject);
- var
- rationRec: TRationsRec;
- begin
- rationRec := TRationsRec.Create(nil);
- with TScRationRecord(sdRation) do
- begin
- rationRec.ID := ID.AsInteger;
- rationRec.Code := Code.AsString;
- rationRec.Name := Name.AsString;
- rationRec.Units := Units.AsString;
- rationRec.Quanity := Quantity.AsFloat;
- rationRec.QuantityXS := QuantityXS.AsFloat;
- rationRec.GetFeeKind := GetFeeKind.AsInteger;
- rationRec.AdjustState := AdjustState.AsString;
- rationRec.BillsID := BillsItemID.AsInteger;
- rationRec.SerialNo := SerialNo.AsInteger;
- rationRec.MaskName := MaskName.AsString;
- rationRec.UnitDirectFee := UnitDirectFee.AsCurrency;
- rationRec.CountPriceType := CountPriceType.AsInteger;
- rationRec.BuildingFee := BuildingFee.AsCurrency;
- rationRec.RationProjName := RationProjName.AsString;
- rationRec.IsCalcProfit := IsCalcProfit.AsBoolean;
- rationRec.IsCalcTax := IsCalcTax.AsBoolean;
- rationRec.CodeForReport := CodeForReport.AsString;
- rationRec.Content := Content.AsString;
- rationRec.LibType := LibType.AsInteger;
- rationRec.LibID := LibID.AsInteger;
- rationRec.CodeLength := CodeLength.AsInteger;
- rationRec.RationProjName2 := RationProjName2.AsString;
- rationRec.Name2 := Name2.AsString;
- rationRec.Unit2 := Unit2.AsString;
- rationRec.CodeForReport2 := CodeForReport2.AsString;
- rationRec.IsCalcEquipmentFee := IsCalcEquipmentFee.AsBoolean;
- rationRec.RType := RationType.AsInteger;
- rationRec.Specs := Specs.AsString;
- rationRec.IsMECalc := IsMECalc.AsBoolean;
- rationRec.RationUnitDirectFee := RationUnitDirectFee.AsCurrency;
- rationRec.UnitPrice := UnitPrice.AsCurrency;
- rationRec.GLJID := GLJID.AsInteger;
-
- FRationsList.Add(rationRec);
- end;
- end;
- procedure TPersistentData.AppendXSRec(ARecord: TsdDataRecord);
- const
- scsRationID = 'RationID';
- scsCoeID = 'CoeID';
- scsSelected = 'Selected';
- scsCalcOrder = 'CalcOrder';
- scsFlag = 'Flag';
- scsData = 'Data';
- scsGroupIdx = 'GroupIdx';
- scsParam = 'Param';
- var
- xsRec: TXSRec;
- begin
- xsRec := TXSRec.Create(nil);
- with ARecord do
- begin
- xsRec.RationID := ValueByName(scsRationID).AsInteger;
- xsRec.CoeID := ValueByName(scsCoeID).AsInteger;
- xsRec.Selected := ValueByName(scsSelected).AsBoolean;
- xsRec.CalcOrder := ValueByName(scsCalcOrder).AsInteger;
- xsRec.Flag := ValueByName(scsFlag).AsInteger;
- xsRec.Data := ValueByName(scsData).AsString;
- xsRec.GroupIdx := ValueByName(scsGroupIdx).AsInteger;
- xsRec.Param := ValueByName(scsParam).AsInteger;
- end;
- FXSList.Add(xsRec);
- end;
- procedure TPersistentData.AppendYSRec(ARecord: TsdDataRecord);
- const
- scsRationID = 'RationID';
- scsRYSRate = 'RYSRate';
- scsYSRate = 'YSRate';
- var
- ysRateRec: TYSRateRec;
- begin
- ysRateRec := TYSRateRec.Create(nil);
- with ARecord do
- begin
- ysRateRec.RationID := ValueByName(scsRationID).AsInteger;
- ysRateRec.RYSRate := ValueByName(scsRYSRate).AsFloat;
- ysRateRec.YSRate := ValueByName(scsYSRate).AsFloat;
- end;
- FYSRateList.Add(ysRateRec);
- end;
- procedure TPersistentData.CheckClassExists;
- begin
- if GetClass('TFileInfo') = nil then
- Classes.RegisterClass(TFileInfo);
- if GetClass('TBillsRec') = nil then
- Classes.RegisterClass(TBillsRec);
- if GetClass('TRationsRec') = nil then
- Classes.RegisterClass(TRationsRec);
- if GetClass('TGLJRec') = nil then
- Classes.RegisterClass(TGLJRec);
- if GetClass('TFZRec') = nil then
- Classes.RegisterClass(TFZRec);
- if GetClass('TPBRec') = nil then
- Classes.RegisterClass(TPBRec);
- if GetClass('TXSRec') = nil then
- Classes.RegisterClass(TXSRec);
- if GetClass('TDJRec') = nil then
- Classes.RegisterClass(TDJRec);
- if GetClass('TYSRateRec') = nil then
- Classes.RegisterClass(TYSRateRec);
- if GetClass('TMMrRec') = nil then
- Classes.RegisterClass(TMMrRec);
- if GetClass('TMMgRec') = nil then
- Classes.RegisterClass(TMMgRec);
- if GetClass('TExprsRec') = nil then
- Classes.RegisterClass(TExprsRec);
- if GetClass('TDrawingQuantity') = nil then
- Classes.RegisterClass(TDrawingQuantity);
- end;
- procedure TPersistentData.ClearAllList;
- var
- I: Integer;
- begin
- if Assigned(FFileInfo) then
- FreeAndNil(FFileInfo);
- for I := 0 to FBillsList.Count - 1 do
- begin
- TBillsRec(FBillsList.List^[I]).Free;
- end;
- FBillsList.Clear;
- for I := 0 to FRationsList.Count - 1 do
- begin
- TRationsRec(FRationsList.List^[I]).Free;
- end;
- FRationsList.Clear;
- for I := 0 to FGLJList.Count - 1 do
- begin
- TGLJRec(FGLJList.List^[I]).Free;
- end;
- FGLJList.Clear;
- for I := 0 to FFZList.Count - 1 do
- begin
- TFZRec(FFZList.List^[I]).Free;
- end;
- FFZList.Clear;
- for I := 0 to FPBList.Count - 1 do
- begin
- TPBRec(FPBList.List^[I]).Free;
- end;
- FPBList.Clear;
- for I := 0 to FDJList.Count - 1 do
- begin
- TDJRec(FDJList.List^[I]).Free;
- end;
- FDJList.Clear;
- for I := 0 to FXSList.Count - 1 do
- begin
- TXSRec(FXSList.List^[I]).Free;
- end;
- FXSList.Clear;
- for I := 0 to FYSRateList.Count - 1 do
- begin
- TYSRateRec(FYSRateList.List^[I]).Free;
- end;
- FYSRateList.Clear;
- for I := 0 to FMMrList.Count - 1 do
- begin
- TMMrRec(FMMrList.List^[I]).Free;
- end;
- FMMrList.Clear;
- for I := 0 to FMMgList.Count - 1 do
- begin
- TMMgRec(FMMgList.List^[I]).Free;
- end;
- FMMgList.Clear;
- for I := 0 to FExprsList.Count - 1 do
- begin
- TExprsRec(FExprsList.List^[I]).Free;
- end;
- FExprsList.Clear;
- for I := 0 to FDQList.Count - 1 do
- begin
- TDrawingQuantity(FDQList.List^[I]).Free;
- end;
- FDQList.Clear;
- end;
- procedure TPersistentData.ClearNameList;
- begin
- FNameList.Clear;
- end;
- constructor TPersistentData.Create;
- begin
- FNameList := TStringList.Create;
- FDeleteNameList := TStringList.Create;
- FBillsList := TList.Create;
- FRationsList := TList.Create;
- FGLJList := TList.Create;
- FFZList := TList.Create;
- FPBList := TList.Create;
- FDJList := TList.Create;
- FYSRateList := TList.Create;
- FXSList := TList.Create;
- FMMrList := TList.Create;
- FMMgList := TList.Create;
- FExprsList := TList.Create;
- FDQList := TList.Create;
- FFileOpManager := TFileOpManager.Create;
- end;
- procedure TPersistentData.CreateFileInfo(ARecord: TScBillsRecord);
- var
- strName, sBCode: string;
- begin
- if FFileInfo = nil then
- begin
- sBCode := '';
- if TScProject(FProject).IsGuangDong then
- sBCode := ARecord.B_Code.AsString;
- strName := FFileOpManager.GetSaveFileName(ARecord.Code.AsString, sBCode,
- ARecord.Name.AsString);
- FFileInfo := TFileInfo.Create(nil);
- FFileInfo.Name := strName;
- FFileInfo.DeleteTime := Now;
- end;
- end;
- function TPersistentData.CurProjectDir: string;
- begin
- Result := FFileOpManager.GetCurProjectDir;
- end;
- procedure TPersistentData.DeleteListFiles;
- var
- I: Integer;
- strName: string;
- begin
- for I := 0 to FNameList.Count - 1 do
- begin
- strName := FNameList.Strings[I];
- DeleteFile(PChar(strName));
- end;
- FNameList.Clear;
- end;
- destructor TPersistentData.Destroy;
- begin
- DeleteNameListFiles;
- FDeleteNameList.Free;
- DeleteListFiles;
- FNameList.Free;
- FBillsList.Free;
- FRationsList.Free;
- FGLJList.Free;
- FFZList.Free;
- FPBList.Free;
- FDJList.Free;
- FYSRateList.Free;
- FXSList.Free;
- FMMrList.Free;
- FMMgList.Free;
- FExprsList.Free;
- FDQList.Free;
- FFileOpManager.Free;
- inherited;
- end;
- procedure TPersistentData.ExtractParticularFileName(
- const aProjName, aFullBPName, aAlias, aGUID: string);
- begin
- FFileOpManager.ExtractParticularName(aProjName, aFullBPName, aAlias, aGUID);
- end;
- function TPersistentData.GetFileDir: string;
- begin
- Result := FFileOpManager.FileDir;
- end;
- procedure TPersistentData.InternalPersistent;
- var
- I: Integer;
- strName: string;
- MemoryStream: TMemoryStream;
- begin
- MemoryStream := TMemoryStream.Create;
- try
- CheckClassExists;
- MemoryStream.WriteComponent(FFileInfo);
- I := FBillsList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FBillsList.Count - 1 do
- MemoryStream.WriteComponent(TBillsRec(FBillsList.List^[I]));
- I := FRationsList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FRationsList.Count - 1 do
- MemoryStream.WriteComponent(TRationsRec(FRationsList.List^[I]));
- I := FGLJList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FGLJList.Count - 1 do
- MemoryStream.WriteComponent(TGLJRec(FGLJList.List^[I]));
- I := FFZList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FFZList.Count - 1 do
- MemoryStream.WriteComponent(TFZRec(FFZList.List^[I]));
- I := FPBList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FPBList.Count - 1 do
- MemoryStream.WriteComponent(TPBRec(FPBList.List^[I]));
- I := FDJList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FDJList.Count - 1 do
- MemoryStream.WriteComponent(TDJRec(FDJList.List^[I]));
- I := FXSList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FXSList.Count - 1 do
- MemoryStream.WriteComponent(TXSRec(FXSList.List^[I]));
- I := FYSRateList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FYSRateList.Count - 1 do
- MemoryStream.WriteComponent(TYSRateRec(FYSRateList.List^[I]));
- I := FMMrList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FMMrList.Count - 1 do
- MemoryStream.WriteComponent(TMMrRec(FMMrList.List^[I]));
- I := FMMgList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FMMgList.Count - 1 do
- MemoryStream.WriteComponent(TMMgRec(FMMgList.List^[I]));
- I := FExprsList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FExprsList.Count - 1 do
- MemoryStream.WriteComponent(TExprsRec(FExprsList.List^[I]));
- I := FDQList.Count;
- MemoryStream.Write(I, SizeOf(I));
- for I := 0 to FDQList.Count - 1 do
- MemoryStream.WriteComponent(TDrawingQuantity(FDQList.List^[I]));
- MemoryStream.SaveToFile(FFileInfo.Name);
- AddNameToList(FFileInfo.Name);
- finally
- MemoryStream.Free;
- end;
- end;
- procedure TPersistentData.InternalReadPersistent(const AFileName: string; IsReadAll: Boolean);
- var
- I, ObjCount: Integer;
- billsRec: TBillsRec;
- rationRec: TRationsRec;
- gljRec: TGLJRec;
- fzRec: TFZRec;
- pbRec: TPBRec;
- djRec: TDJRec;
- xsRec: TXSRec;
- ysRateRec: TYSRateRec;
- mmrRec: TMMrRec;
- mmgRec: TMMgRec;
- exprsRec: TExprsRec;
- FileStream: TFileStream;
- begin
- FileStream := TFileStream.Create(AFileName, fmOpenRead);
- try
- // FileStream.LoadFromFile(AFileName);
- CheckClassExists;
-
- FFileInfo := TFileInfo(FileStream.ReadComponent(nil));
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- billsRec := TBillsRec(FileStream.ReadComponent(nil));
- FBillsList.Add(billsRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- rationRec := TRationsRec(FileStream.ReadComponent(nil));
- FRationsList.Add(rationRec);
- end;
- if IsReadAll then
- begin
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- gljRec := TGLJRec(FileStream.ReadComponent(nil));
- FGLJList.Add(gljRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- fzRec := TFZRec(FileStream.ReadComponent(nil));
- FFZList.Add(fzRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- pbRec := TPBRec(FileStream.ReadComponent(nil));
- FPBList.Add(pbRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- djRec := TDJRec(FileStream.ReadComponent(nil));
- FDJList.Add(djRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- xsRec := TXSRec(FileStream.ReadComponent(nil));
- FXSList.Add(xsRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- ysRateRec := TYSRateRec(FileStream.ReadComponent(nil));
- FYSRateList.Add(ysRateRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- mmrRec := TMMrRec(FileStream.ReadComponent(nil));
- FMMrList.Add(mmrRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- mmgRec := TMMgRec(FileStream.ReadComponent(nil));
- FMMgList.Add(mmgRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- begin
- exprsRec := TExprsRec(FileStream.ReadComponent(nil));
- FExprsList.Add(exprsRec);
- end;
- FileStream.Read(ObjCount, SizeOf(ObjCount));
- for I := 0 to ObjCount - 1 do
- FDQList.Add(TDrawingQuantity(FileStream.ReadComponent(nil)));
- end;
-
- finally
- FileStream.Free;
- end;
- end;
- procedure TPersistentData.InternalWriteDB(ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
- var
- I: Integer;
- billsRec: TBillsRec;
- rationRec: TRationsRec;
- begin
- with ANodeBinDM do
- begin
- cdsFileInfo.Append;
- cdsFileInfoID.Value := ID;
- cdsFileInfoName.Value := ExtractFileName(FFileInfo.Name);
- cdsFileInfoDeleteTime.Value := FFileInfo.DeleteTime;
- cdsFileInfoFullName.Value := FFileInfo.Name;
- cdsFileInfo.Post;
- for I := 0 to FBillsList.Count - 1 do
- begin
- billsRec := TBillsRec(FBillsList.List^[I]);
-
- cdsBills.Append;
- cdsBillsFileID.Value := ID;
- cdsBillsID.Value := billsRec.ID;
- cdsBillsParentID.Value := billsRec.ParentID;
- cdsBillsNextSiblingID.Value := billsRec.NextSiblingID;
- cdsBillsCode.Value := billsRec.Code;
- cdsBillsName.Value := FFileOpManager.RevertSpecialChar(billsRec.Name);
- cdsBillsUnits.Value := billsRec.Units;
- cdsBillsQuantity.Value := billsRec.Quantity;
- cdsBillsQuantity2.Value := billsRec.Quantity2;
- cdsBillsUnitPrice.Value := billsRec.UnitPrice;
- cdsBillsTotalPrice.Value := billsRec.TotalPrice;
- cdsBillsCalcKinds.Value := billsRec.CalcKinds;
- cdsBillsIsPreDefine.Value := billsRec.IsPreDefine;
- cdsBillsFlag.Value := billsRec.Flag;
- cdsBillsMemoStr.Value := billsRec.MemoString;
- cdsBillsIsLeaf.Value := billsRec.IsLeaf;
- cdsBillsGLJPriceLib.Value := billsRec.BillsGLJPriceLib;
- {$IFDEF _ScGuangDong}
- cdsBillsB_Code.Value := billsRec.BCode;
- cdsBillsDesignQuantity.Value := billsRec.DQuantity;
- cdsBillsDesignQuantity2.Value := billsRec.DQuantity2;
- cdsBillsDesignPrice.Value := billsRec.DPrice;
- {$ENDIF}
-
- cdsBills.Post;
- end;
- for I := 0 to FRationsList.Count - 1 do
- begin
- rationRec := TRationsRec(FRationsList.List^[I]);
- if rationRec.RType = 0 then
- begin
- cdsRations.Append;
- cdsRationsFileID.Value := ID;
- cdsRationsSerialNo.Value := rationRec.SerialNo;
- cdsRationsID.Value := rationRec.ID;
- cdsRationsLibID.Value := rationRec.LibID;
- cdsRationsCode.Value := rationRec.Code;
- cdsRationsBillsItemID.Value := rationRec.BillsID;
- cdsRationsName.Value := rationRec.Name;
- cdsRationsMaskName.Value := rationRec.MaskName;
- cdsRationsUnit.Value := rationRec.Units;
- cdsRationsQuantity.Value := rationRec.Quanity;
- if rationRec.GetFeeKind <> NULL then
- cdsRationsGetFeeKind.Value := rationRec.GetFeeKind;
- cdsRationsAdjustState.Value := rationRec.AdjustState;
- cdsRationsUnitDirectFee.Value := rationRec.UnitDirectFee;
- cdsRationsBuildingFee.Value := rationRec.BuildingFee;
- cdsRationsType.Value := rationRec.RType;
- cdsRationsRationProjName.Value := rationRec.RationProjName;
- cdsRationsIsCalcEquipmentFee.Value := rationRec.IsCalcEquipmentFee;
- cdsRationsIsCalcProfit.Value := rationRec.IsCalcProfit;
- cdsRationsIsCalcTax.Value := rationRec.IsCalcTax;
- cdsRationsCodeForReport.Value := rationRec.CodeForReport;
- cdsRationsContent.Value := rationRec.Content;
- cdsRationsLibType.Value := rationRec.LibType;
- cdsRationsCodeLength.Value := rationRec.CodeLength;
- cdsRationsRationProjName2.Value := rationRec.RationProjName2;
- cdsRationsName2.Value := rationRec.Name2;
- cdsRationsUnit2.Value := rationRec.Unit2;
- cdsRationsQuantityXS.Value := rationRec.QuantityXS;
- cdsRationsCodeForReport2.Value := rationRec.CodeForReport2;
- cdsRations.Post;
- end
- else
- begin
- cdsCountPrice.Append;
- cdsCountPriceFileID.Value := ID;
- cdsCountPriceID.Value := rationRec.ID;
- cdsCountPriceBillsItemID.Value := rationRec.BillsID;
- cdsCountPriceName.Value := rationRec.Name;
- cdsCountPriceUnit.Value := rationRec.Units;
- cdsCountPriceQuantity.Value := rationRec.Quanity;
- if rationRec.GetFeeKind <> NULL then
- cdsCountPriceGetFeeKind.Value := rationRec.GetFeeKind;
- cdsCountPriceType.Value := rationRec.RType;
- cdsCountPriceIsCalcEquipmentFee.Value := rationRec.IsCalcEquipmentFee;
- cdsCountPriceIsCalcProfit.Value := rationRec.IsCalcProfit;
- cdsCountPriceIsCalcTax.Value := rationRec.IsCalcTax;
- if rationRec.CountPriceType <> NULL then
- cdsCountPriceCountPriceType.Value := rationRec.CountPriceType;
- cdsCountPriceBuildingFee.Value := rationRec.BuildingFee;
- cdsCountPriceUnitDirectFee.Value := rationRec.UnitDirectFee;
- cdsCountPriceQuantityXS.Value := rationRec.QuantityXS;
- cdsCountPrice.Post;
- end;
- end;
- end;
- end;
- procedure TPersistentData.PersistentObjects;
- begin
- InternalPersistent;
- ClearAllList;
- end;
- procedure TPersistentData.ReadPersistentObjects(const AFileName: string;
- ANodeBinDM: TNodeRecycleBinDM; ID: Integer);
- begin
- InternalReadPersistent(AFileName, False);
- InternalWriteDB(ANodeBinDM, ID);
- ClearAllList;
- end;
- procedure TPersistentData.ReturnBills(AItem: TScBillsItem;
- AIsClearQ, AIsNew: Boolean);
- var
- I, lastNextID, firstID: Integer;
- OldNextID, lpos, CurID: Integer;
- Rec: TsdDataRecord;
- begin
- ConformStructuralLevel(firstID, lastNextID, AItem.ParentID);
- if FBillsList.Count = 0 then Exit;
- with TScProject(FProject).Bills do
- begin
- try
- CurID := AItem.ID;
- OldNextID := AItem.NextSiblingID;
- // BeginHandler; 张博士说这个方法被多个地方引用,维持原状不要动它,调用下面这个。
- // 节点回收站是直接将结点加到DataSet,不是加到树,所以需要断开树再连接树以刷新显示。
- Rec := AItem.Rec;
- DisConnectBillsTree;
- lpos := ReturnBillsInside(TScBillsRecord(Rec), FBillsList, AIsClearQ, AIsNew, firstID, lastNextID);
- if not AIsNew then
- begin
- Rec := BillsDM.sdsBills.Locate(SID, CurID);
- if Rec <> nil then
- TScBillsRecord(Rec).NextSiblingID.AsInteger := firstID;
- end;
- Rec := BillsDM.sdsBills.Locate(SID, lastNextID);
- if Rec <> nil then
- TScBillsRecord(Rec).NextSiblingID.AsInteger := OldNextID;
- finally
- // EndHandler; 张博士说这个方法被多个地方引用,维持原状不要动它,调用下面这个。
- ConnectBillsTree;
- LoadBillsExprs;
- AItem := TScBillsItem(BillsTree.FindNode(lPos));
- if Assigned(AItem) then
- AItem.LocateInControl;
- end;
- end;
- end;
- function TPersistentData.ReturnData(const AFileName: string; AItem: TScBillsItem;
- AIsClearQ, AIsNew: Boolean): Boolean;
- begin
- Result := False;
- if not FileExists(AFileName) then Exit;
- InternalReadPersistent(AFileName, True);
- try
- FMaxBillsID := TScProject(FProject).Bills.GetMaxBillID + 1;
- FMaxRationID := TScProject(FProject).Rations.GetNewID;
- FMaxDqID := TScProject(FProject).Bills.DrawingQuantityDM.GetMaxDQID;
- ReturnBills(AItem, AIsClearQ, AIsNew);
-
- finally
- ClearAllList;
- end;
- Result := True;
- end;
- procedure TPersistentData.ReturnDJ(AOldID, ANewID, AType: Integer);
- (*var
- I: Integer;
- djRec: TDJRec;
- GLJPriceRec: TScGLJPriceAdjustRecord;*)
- begin
- (* for I := 0 to FDJList.Count - 1 do
- begin
- djRec := TDJRec(FDJList.List^[I]);
- with TScProject(FProject).GLJ do
- begin
- if (djRec.OwnerID = AOldID) and (djRec.Flag = AType) then
- begin
- GLJPriceRec := TScGLJPriceAdjustRecord(sdsGLJPriceAdjust.Add(True));
- try
- GLJPriceRec.OwnerID.Value := ANewID;
- GLJPriceRec.GLJID.Value := djRec.GLJID;
- GLJPriceRec.GLJCode.Value := djRec.GLJCode;
- GLJPriceRec.Price.Value := djRec.UnitPrice;
- GLJPriceRec.LibID.Value := djRec.LibID;
- GLJPriceRec.Flag.Value := AType;
- finally
- GLJPriceRec.EndUpdate;
- end;
- end;
- end;
- end; *)
- end;
- procedure TPersistentData.ReturnExprs(AOldID, ANewID, AType: Integer);
- var
- I: Integer;
- exprsRec: TExprsRec;
- ExprRecord: TScExprsRecord;
- begin
- for I := 0 to FExprsList.Count - 1 do
- begin
- exprsRec := TExprsRec(FExprsList.List^[I]);
- with TScProject(FProject).Exprs do
- begin
- if (exprsRec.RecdID = AOldID) and (exprsRec.Flag = AType) then
- begin
- ExprRecord := TScExprsRecord(sdsExprs.Add(True));
- try
- ExprRecord.MajorID.AsInteger := exprsRec.MajorID;
- ExprRecord.MinorID.AsInteger := exprsRec.MinorID;
- ExprRecord.Exprs.AsString := exprsRec.Exprs;
- ExprRecord.Flag.AsInteger := AType;
- ExprRecord.RecdID.AsInteger := ANewID;
- ExprRecord.ExprsValue.AsFloat := exprsRec.ExprsValue;
- ExprRecord.Exprs1.AsString := exprsRec.Exprs1;
- ExprRecord.Exprs2.AsString := exprsRec.Exprs2;
- ExprRecord.Exprs3.AsString := exprsRec.Exprs3;
- ExprRecord.Exprs4.AsString := exprsRec.Exprs4;
- finally
- ExprRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnFZ(AOldRationID, ANewRationID: Integer);
- var
- I: Integer;
- fzRec: TFZRec;
- FZRecord: TScFZAdjustRecord;
- begin
- with TScProject(FProject).Rations.RAdjusts do
- begin
- for I := 0 to FFZList.Count - 1 do
- begin
- fzRec := TFZRec(FFZList.List^[I]);
- if fzRec.RationID = AOldRationID then
- begin
- FZRecord := TScFZAdjustRecord(sdsFZAdjust.Add(True));
- try
- FZRecord.ParamName.AsString := fzRec.ParamName;
- FZRecord.ParamIndex.AsInteger := fzRec.ParamIndex;
- FZRecord.RationID.AsInteger := ANewRationID;
- FZRecord.NewValue.AsFloat := fzRec.NewValue;
- FZRecord.MinorIndex.AsInteger := fzRec.MinorIndex;
- FZRecord.BaseValue.AsFloat := fzRec.BaseValue;
- FZRecord.IncStep.AsFloat := fzRec.IncStep;
- FZRecord.RationCode.AsString := fzRec.RationCode;
- FZRecord.RationCode1.AsInteger := fzRec.RationCode1;
- FZRecord.RoundDigit.AsInteger := fzRec.RoundDigit;
- FZRecord.RoundMode.AsInteger := fzRec.RoundMode;
- finally
- FZRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnGLJs(AOldBillsID, ANewBillsID, AOldRationID, ANewRationID: Integer);
- var
- I: Integer;
- gljRec: TGLJRec;
- sdGLJ: TScGLJRecord;
- ProjectGLJRec: TScProjectGLJRecord;
- begin
- with TScProject(FProject).Bills.Rations.GLJ do
- begin
- for I := 0 to FGLJList.Count - 1 do
- begin
- gljRec := TGLJRec(FGLJList.List^[I]);
- if (gljRec.BillsID = AOldBillsID) and (gljRec.RationsID = AOldRationID) then
- begin
- if FindRGLJ(ANewRationID, gljRec.RGLJID) <> nil then
- Continue;
- ProjectGLJRec := TScProject(FProject).ProjectGLJ.LocateGLJ(gljRec.GLJID);
- sdGLJ := TScGLJRecord(sdsGLJ.Add(True));
- try
- sdGLJ.RationID.AsInteger := ANewRationID;
- sdGLJ.BillsItemID.AsInteger := ANewBillsID;
- sdGLJ.RGLJID.AsInteger := gljRec.RGLJID;
- sdGLJ.RQuantity.AsFloat := gljRec.RQuantity;
- sdGLJ.OrgRQuantity.AsFloat := gljRec.OrgRQuantity;
- if ProjectGLJRec <> nil then
- begin
- sdGLJ.RationPrice.AsCurrency := ProjectGLJRec.BasePrice.AsCurrency;
- sdGLJ.BudgetPrice.AsCurrency := ProjectGLJRec.BudgetPrice.AsCurrency;
- // 2026-07-06 zhangyin 缓存GLJ对应ProjectGLJ记录
- sdGLJ.Data := ProjectGLJRec;
- end
- else
- begin
- sdGLJ.RationPrice.AsCurrency := gljRec.RationPrice;
- sdGLJ.BudgetPrice.AsCurrency := gljRec.BudgetPrice;
- end;
- sdGLJ.Flag.AsInteger := gljRec.Flag;
- sdGLJ.MinorRQ1.AsFloat := gljRec.MinorRQ1;
- sdGLJ.MinorRQ2.AsFloat := gljRec.MinorRQ2;
- sdGLJ.MinorRQ3.AsFloat := gljRec.MinorRQ3;
- sdGLJ.GLJID.AsInteger := gljRec.GLJID;
- sdGLJ.SortParam.AsInteger := gljRec.SortParam;
- sdGLJ.CalculateType.AsInteger := gljRec.CalculateType;
- sdGLJ.CustomQuantity.AsVariant := gljRec.CustomQuantity;
- sdGLJ.Quantity.AsFloat := gljRec.Quantity;
- sdGLJ.LibID.AsInteger := gljRec.LibID;
- sdGLJ.Types.AsInteger := gljRec.GLJType;
- sdGLJ.TenderPrice.AsCurrency := gljRec.TenderPrice;
- sdGLJ.RationItemQuantity.AsFloat := gljRec.RationItemQuantity;
- sdGLJ.RCode.AsString := gljRec.RCode;
- sdGLJ.RName.AsString := gljRec.RName;
- sdGLJ.RSpecs.AsString := gljRec.RSpecs;
- sdGLJ.RUnit.AsString := gljRec.RUnit;
- sdGLJ.Code.AsString := gljRec.Code;
- sdGLJ.Name.AsString := gljRec.Name;
- sdGLJ.Specs.AsString := gljRec.Specs;
- sdGLJ.Units.AsString := gljRec.Units;
- finally
- sdGLJ.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnMMg(AOldRationID, ANewRation: Integer);
- var
- I: Integer;
- mmgRec: TMMgRec;
- MMGRecord: TScMultiMinorGLJRecord;
- begin
- with TScProject(FProject).Rations.RAdjusts do
- begin
- for I := 0 to FMMgList.Count - 1 do
- begin
- mmgRec := TMMgRec(FMMgList.List^[I]);
- if mmgRec.RationID = AOldRationID then
- begin
- MMGRecord := TScMultiMinorGLJRecord(sdsMultiMinorGLJ.Add(True));
- try
- MMGRecord.RationID.AsInteger := ANewRation;
- MMGRecord.MinorIndex.AsInteger := mmgRec.MinorIndex;
- MMGRecord.GLJID.AsInteger := mmgRec.GLJID;
- MMGRecord.GLJCode.AsString := mmgRec.GLJCode;
- MMGRecord.MRQ1.AsFloat := mmgRec.MRQ1;
- MMGRecord.MRQ2.AsFloat := mmgRec.MRQ2;
- MMGRecord.MRQ3.AsFloat := mmgRec.MRQ3;
- finally
- MMGRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnMMr(AOldRationID, ANewRationID: Integer);
- var
- I: Integer;
- mmrRec: TMMrRec;
- MMRationRecord: TScMultiMinorRationRecord;
- begin
- with TScProject(FProject).Rations.RAdjusts do
- begin
- for I := 0 to FMMrList.Count - 1 do
- begin
- mmrRec := TMMrRec(FMMrList.List^[I]);
- if mmrRec.RationID = AOldRationID then
- begin
- MMRationRecord := TScMultiMinorRationRecord(sdsMultiMinorRation.Add(True));
- try
- MMRationRecord.RationID.AsInteger := ANewRationID;
- MMRationRecord.MinorIndex.AsInteger := mmrRec.MinorIndex;
- MMRationRecord.ParamIndex.AsInteger := mmrRec.ParamIndex;
- MMRationRecord.MinorParam.AsFloat := mmrRec.MinorParam;
- MMRationRecord.ParamName.AsString := mmrRec.ParamName;
- MMRationRecord.MinorName.AsString := mmrRec.MinorName;
- MMRationRecord.BaseValue.AsFloat := mmrRec.BaseValue;
- MMRationRecord.RoundDigit.AsInteger := mmrRec.RoundDigit;
- MMRationRecord.RoundMode.AsInteger := mmrRec.RoundMode;
- MMRationRecord.IncStep.AsFloat := mmrRec.IncStep;
- MMRationRecord.RationCode.AsString := mmrRec.RationCode;
- MMRationRecord.IDCode.AsInteger := mmrRec.RationIDCode;
- finally
- MMRationRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnPB(AOldRationID, ANewRationID: Integer);
- var
- I: Integer;
- pbRec: TPBRec;
- PBRecord: TScPBAdjustRecord;
- begin
- with TScProject(FProject).Rations.RAdjusts do
- begin
- for I := 0 to FPBList.Count - 1 do
- begin
- pbRec := TPBRec(FPBList.List^[I]);
- if pbRec.RationID = AOldRationID then
- begin
- PBRecord := TScPBAdjustRecord(sdsPBAdjust.Add(True));
- try
- PBRecord.RationID.AsInteger := ANewRationID;
- PBRecord.GLJCode.AsString := pbRec.Code;
- PBRecord.GLJID.AsInteger := pbRec.GLJID;
- PBRecord.RProportion.AsFloat := pbRec.RProportion;
- PBRecord.Proportion.AsFloat := pbRec.Proportion;
- finally
- PBRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnRAdjust(AOldRationID, ANewRationID: Integer);
- begin
- ReturnFZ(AOldRationID, ANewRationID);
- ReturnPB(AOldRationID, ANewRationID);
- ReturnXS(AOldRationID, ANewRationID);
- ReturnDJ(AOldRationID, ANewRationID, 1);
- ReturnYSRate(AOldRationID, ANewRationID);
- ReturnMMr(AOldRationID, ANewRationID);
- ReturnMMg(AOldRationID, ANewRationID);
- end;
- procedure TPersistentData.ReturnRations(AOldBillsID, ANewBillsID: Integer; AIsClearQ: Boolean);
- var
- I: Integer;
- rationRec: TRationsRec;
- sdRation: TScRationRecord;
- ProjectGLJRec: TScProjectGLJRecord;
- begin
- for I := 0 to FRationsList.Count - 1 do
- begin
- rationRec := TRationsRec(FRationsList.List^[I]);
- if rationRec.BillsID = AOldBillsID then
- begin
- with TScProject(FProject).Bills.Rations do
- begin
- sdRation := TScRationRecord(sdsRations.Add(True));
- try
- sdRation.ID.AsInteger := FMaxRationID;
- sdRation.Code.AsString := rationRec.Code;
- sdRation.Name.AsString := rationRec.Name;
- sdRation.Units.AsString := rationRec.Units;
- if AIsClearQ then
- begin
- sdRation.Quantity.AsFloat := 0;
- sdRation.QuantityXS.AsFloat := 0;
- end
- else
- begin
- sdRation.Quantity.AsFloat := rationRec.Quanity;
- sdRation.QuantityXS.AsFloat := rationRec.QuantityXS;
- end;
- sdRation.GetFeeKind.AsVariant := rationRec.GetFeeKind;
- sdRation.AdjustState.AsString := rationRec.AdjustState;
- sdRation.BillsItemID.AsInteger := ANewBillsID;
- sdRation.SerialNo.AsInteger := rationRec.SerialNo;
- sdRation.MaskName.AsString := rationRec.MaskName;
- sdRation.UnitDirectFee.AsCurrency := rationRec.UnitDirectFee;
- sdRation.CountPriceType.AsInteger := rationRec.CountPriceType;
- sdRation.BuildingFee.AsCurrency := rationRec.BuildingFee;
- sdRation.RationProjName.AsString := rationRec.RationProjName;
- sdRation.IsCalcProfit.AsBoolean := rationRec.IsCalcProfit;
- sdRation.IsCalcTax.AsBoolean := rationRec.IsCalcTax;
- sdRation.CodeForReport.AsString := rationRec.CodeForReport;
- sdRation.Content.AsString := rationRec.Content;
- sdRation.LibType.AsInteger := rationRec.LibType;
- sdRation.LibID.AsInteger := rationRec.LibID;
- sdRation.CodeLength.AsInteger := rationRec.CodeLength;
- sdRation.RationProjName2.AsString := rationRec.RationProjName2;
- sdRation.Name2.AsString := rationRec.Name2;
- sdRation.Unit2.AsString := rationRec.Unit2;
- sdRation.CodeForReport2.AsString := rationRec.CodeForReport2;
- sdRation.IsCalcEquipmentFee.AsBoolean := rationRec.IsCalcEquipmentFee;
- sdRation.RationType.AsInteger := rationRec.RType;
- sdRation.Specs.AsString := rationRec.Specs;
- sdRation.IsMECalc.AsBoolean := rationRec.IsMECalc;
- if sdRation.RationType.AsInteger = SR_CountPrice then
- begin
- ProjectGLJRec := TScProject(Project).ProjectGLJ.LocateGLJ(CombineGLJKeys(sdRation));
- if sdRation.IsMECalc.AsBoolean then
- begin
- if rationRec.UnitPrice <> 0 then
- begin
- if ProjectGLJRec <> nil then
- sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
- sdRation.UnitPrice.AsCurrency := rationRec.UnitPrice;
- end
- else
- begin
- if ProjectGLJRec <> nil then
- begin
- sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
- sdRation.UnitPrice.AsCurrency := ProjectGLJRec.BasePrice.AsCurrency;
- end
- else
- sdRation.UnitPrice.AsCurrency := rationRec.UnitDirectFee;
- end;
- end
- else
- begin
- if rationRec.UnitPrice <> 0 then
- begin
- if ProjectGLJRec <> nil then
- sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
- sdRation.RationUnitDirectFee.AsCurrency := rationRec.RationUnitDirectFee;
- end
- else
- begin
- if ProjectGLJRec <> nil then
- begin
- sdRation.GLJID.AsInteger := ProjectGLJRec.ID.AsInteger;
- sdRation.RationUnitDirectFee.AsCurrency := ProjectGLJRec.BasePrice.AsCurrency;
- end
- else
- sdRation.RationUnitDirectFee.AsCurrency := rationRec.UnitDirectFee;
- end;
- end
- end;
- finally
- sdRation.EndUpdate;
- end;
- ReturnGLJs(AOldBillsID, ANewBillsID, rationRec.ID, sdRation.ID.AsInteger);
- ReturnRAdjust(rationRec.ID, sdRation.ID.AsInteger);
- if sdRation.RationType.AsInteger = 0 then
- ReturnExprs(rationRec.ID, sdRation.ID.AsInteger, 2)
- else
- ReturnExprs(rationRec.ID, sdRation.ID.AsInteger, 3);
- Inc(FMaxRationID);
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnXS(AOldRationID, ANewRationID: Integer);
- var
- I: Integer;
- xsRec: TXSRec;
- XSRecord: TScXSAdjustRecord;
- begin
- with TScProject(FProject).Rations.RAdjusts do
- begin
- for I := 0 to FXSList.Count - 1 do
- begin
- xsRec := TXSRec(FXSList.List^[I]);
- if xsRec.RationID = AOldRationID then
- begin
- XSRecord := TScXSAdjustRecord(sdsXSAdjust.Add(True));
- try
- XSRecord.RationID.AsInteger := ANewRationID;
- XSRecord.CoeID.AsInteger := xsRec.CoeID;
- XSRecord.Selected.AsBoolean := xsRec.Selected;
- XSRecord.CalcOrder.AsInteger := xsRec.CalcOrder;
- XSRecord.Flag.AsInteger := xsRec.Flag;
- XSRecord.Data.AsString := xsRec.Data;
- XSRecord.GroupIdx.AsInteger := xsRec.GroupIdx;
- XSRecord.Param.AsInteger := xsRec.Param;
- finally
- XSRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.ReturnYSRate(AOldRationID, ANewRationID: Integer);
- var
- I: Integer;
- ysRateRec: TYSRateRec;
- YSRecord: TScYSRateRecord;
- begin
- with TScProject(FProject).Rations.RAdjusts do
- begin
- for I := 0 to FYSRateList.Count - 1 do
- begin
- ysRateRec := TYSRateRec(FYSRateList.List^[I]);
- if ysRateRec.RationID = AOldRationID then
- begin
- YSRecord := TScYSRateRecord(sdsYSRate.Add(True));
- try
- YSRecord.RationID.AsInteger := ANewRationID;
- YSRecord.RYSRate.AsFloat := ysRateRec.RYSRate;
- YSRecord.YSRate.AsFloat := ysRateRec.YSRate;
- finally
- YSRecord.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.Save;
- begin
- ClearNameList;
- DeleteNameListFiles;
- end;
- procedure TPersistentData.SetFileDir(const Value: string);
- begin
- FFileOpManager.FileDir := Value;
- end;
- function TPersistentData.CheckParentNodeExists(
- AID: Integer; Flag: Integer): Boolean;
- const
- strParentError = '父节点不存在,无法还原节点!';
- strPreError = '前兄弟节点不存在,无法还原节点!';
- begin
- if (AID = -1) or
- (TScProject(FProject).Bills.BillsDM.sdsBills.Locate(SID, AID) <> nil) then
- Result := True
- else Result := False;
- if not Result then
- begin
- case Flag of
- cflParent: ShowErrorMessage(strParentError);
- cflPrev: ShowErrorMessage(strPreError);
- end;
- end;
- end;
- procedure TPersistentData.ShowErrorMessage(const Text: string);
- begin
- MessageBox(0, PChar(Text), PChar('错误'), MB_OK or MB_ICONERROR);
- end;
- function TPersistentData.ReturnBillsInside(ARec: TScBillsRecord; AList: TList;
- AIsClearQ, AIsNew: Boolean; var AFirstID, ALastNextID: Integer): Integer;
- var
- blfirstIDChanged, blLastNextIDChanged: Boolean;
- procedure ModifyNodeRelation(AOldID, ANewID: Integer);
- var
- I: Integer;
- bRec: TBillsRec;
- begin
- for I := 0 to AList.Count - 1 do
- begin
- bRec := TBillsRec(AList.List^[I]);
- if (bRec.ParentID = AOldID) and not bRec.ParentIDChanged then
- begin
- bRec.ParentID := ANewID;
- bRec.ParentIDChanged := True;
- end
- else if (bRec.NextSiblingID = AOldID) and not bRec.NextSiblingIDChanged then
- begin
- bRec.NextSiblingID := ANewID;
- bRec.NextSiblingIDChanged := True;
- end;
- end;
- end;
- procedure ModifyAllRelations(AClearQ: Boolean);
- var
- I: Integer;
- BillsRec: TBillsRec;
- begin
- for I := 0 to AList.Count - 1 do
- begin
- BillsRec := TBillsRec(AList.List^[I]);
- if (BillsRec.ID = AFirstID) and not blfirstIDChanged then
- begin
- AFirstID := FMaxBillsID;
- blfirstIDChanged := True;
- end;
- if (BillsRec.ID = ALastNextID) and not blLastNextIDChanged then
- begin
- ALastNextID := FMaxBillsID;
- blLastNextIDChanged := True;
- end;
- ModifyNodeRelation(BillsRec.ID, FMaxBillsID);
- BillsRec.ID := FMaxBillsID;
- Inc(FMaxBillsID);
- end;
- end;
- procedure AssignBillsSubItems(ABillsRec: TBillsRec; AClearQ: Boolean);
- begin
- ReturnDraqQty(ABillsRec.FOldID, ABillsRec.ID, AClearQ);
- ReturnRations(ABillsRec.FOldID, ABillsRec.ID, AClearQ);
- ReturnDJ(ABillsRec.FOldID, ABillsRec.ID, 0);
- ReturnExprs(ABillsRec.FOldID, ABillsRec.ID, 1);
- end;
- function AssignDBValues(ARec: TScBillsRecord; ABillsRec: TBillsRec; AClearQ: Boolean): Integer;
- begin
- ARec.BeginUpdate;
- try
- ARec.ID.AsInteger := ABillsRec.ID;
- ARec.ParentID.AsInteger := ABillsRec.ParentID;
- ARec.NextSiblingID.AsInteger := ABillsRec.NextSiblingID;
- ARec.Code.AsString := ABillsRec.Code;
- ARec.Name.AsString := ABillsRec.Name;
- ARec.Units.AsString := ABillsRec.Units;
- ARec.B_Code.AsString := ABillsRec.BCode;
- ARec.DesignQuantity.AsFloat := ABillsRec.DQuantity;
- ARec.DesignQuantity2.AsFloat := ABillsRec.DQuantity2;
- ARec.DesignPrice.AsFloat := ABillsRec.DPrice;
- if AClearQ then
- begin
- ARec.Quantity.AsFloat := 1;
- ARec.Quantity2.AsFloat := 1;
- end
- else
- begin
- ARec.Quantity.AsFloat := ABillsRec.Quantity;
- ARec.Quantity2.AsFloat := ABillsRec.Quantity2;
- end;
- ARec.UnitPrice.AsCurrency := ABillsRec.UnitPrice;
- ARec.Flag.AsInteger := ABillsRec.Flag;
- ARec.IsPreDefine.AsBoolean := ABillsRec.IsPreDefine;
- ARec.IsLeaf.AsBoolean := ABillsRec.IsLeaf;
- ARec.CalcKinds.AsInteger := ABillsRec.CalcKinds;
- ARec.TotalPrice.AsCurrency := ABillsRec.TotalPrice;
- ARec.MemoStr.AsString := ABillsRec.MemoString;
- ARec.IsCreatePriceAnalysis.AsBoolean := True;
- ARec.GLJPriceLib.AsString := ABillsRec.BillsGLJPriceLib;
- finally
- ARec.EndUpdate;
- end;
- AssignBillsSubItems(ABillsRec, AClearQ);
- Result := ABillsRec.ID;
- end;
- var
- I, J: Integer;
- billsRec: TBillsRec;
- Rec: TScBillsRecord;
- begin
- J := 0;
- Result := -1;
- blfirstIDChanged := False;
- blLastNextIDChanged := False;
- with TScProject(FProject).Bills do
- begin
- ModifyAllRelations(AIsClearQ);
- if AIsNew then
- begin
- billsRec := TBillsRec(AList.List^[J]);
- Result := AssignDBValues(ARec, billsRec, AIsClearQ);
- Inc(J);
- end;
- for I := J to AList.Count - 1 do
- begin
- billsRec := TBillsRec(AList.List^[I]);
- Rec := TScBillsRecord(BillsDM.sdsBills.Add);
- Result := AssignDBValues(Rec, billsRec, AIsClearQ);
- end;
- end;
- end;
- procedure TPersistentData.ConformStructuralLevel(var AFirstID, ALastNextID: Integer; AParentID: Integer);
- procedure SortListBasisNextSiblingID(AList1, AList2: TList);
- procedure AddRec(ARec: TBillsRec);
- var
- J: Integer;
- blRec: TBillsRec;
- begin
- for J := 0 to AList1.Count - 1 do
- begin
- blRec := TBillsRec(AList1.List^[J]);
- if blRec.NextSiblingID = ARec.ID then
- begin
- AddRec(blRec);
- Break;
- end;
- end;
- AList2.Add(ARec);
- end;
- var
- I, J: Integer;
- blFlag: Boolean;
- bRecI, bRecJ: TBillsRec;
- begin
- for I := 0 to AList1.Count - 1 do
- begin
- blFlag := False;
- bRecI := TBillsRec(AList1.List^[I]);
- for J := 0 to AList1.Count - 1 do
- begin
- bRecJ := TBillsRec(AList1.List^[J]);
- if bRecI.NextSiblingID = bRecJ.ID then
- begin
- blFlag := True;
- Break;
- end;
- end;
- if not blFlag then
- begin
- Break;
- end;
- end;
- AddRec(bRecI);
- end;
- procedure RecursionDeleteRec(ABillsRec: TBillsRec);
- var
- I: Integer;
- bRec: TBillsRec;
- begin
- for I := 0 to FBillsList.Count - 1 do
- begin
- bRec := TBillsRec(FBillsList.List^[I]);
- if bRec.ParentID = ABillsRec.ID then
- begin
- RecursionDeleteRec(bRec);
- end;
- end;
- FBillsList.Remove(ABillsRec);
- DeleteRecordsBasisBillsID(ABillsRec.ID);
- ABillsRec.Free;
- end;
- var
- I, J: Integer;
- IsExist: Boolean;
- nList, temList: TList;
- billsRecI, billsRecJ: TBillsRec;
- begin
- nList := TList.Create;
- temList := TList.Create;
- try
- for I := 0 to FBillsList.Count - 1 do
- begin
- IsExist := False;
- billsRecI := TBillsRec(FBillsList.List^[I]);
- billsRecI.FOldID := billsRecI.ID;
- for J := 0 to FBillsList.Count - 1 do
- begin
- billsRecJ := TBillsRec(FBillsList.List^[J]);
- if billsRecI.ParentID = billsRecJ.ID then
- begin
- IsExist := True;
- Break;
- end;
- end;
- if not IsExist then
- begin
- nList.Add(billsRecI);
- end;
- end;
- billsRecJ := TBillsRec(nList[0]);
- for I := nList.Count - 1 downto 1 do
- begin
- billsRecI := TBillsRec(nList.List^[I]);
- if billsRecI.ParentID <> billsRecJ.ParentID then
- begin
- RecursionDeleteRec(billsRecI);
- nList.Delete(I);
- end;
- end;
- SortListBasisNextSiblingID(nList, temList);
- for I := 0 to temList.Count - 1 do
- begin
- billsRecI := TBillsRec(temList.List^[I]);
- if I = 0 then AFirstID := billsRecI.ID;
- if I = temList.Count - 1 then ALastNextID := billsRecI.ID;
- billsRecI.ParentID := AParentID;
- end;
- finally
- nList.Free;
- temList.Free;
- end;
- end;
- procedure TPersistentData.DeleteCurFile(const AFileName: string);
- begin
- AddDeleteNameToList(AFileName);
- end;
- procedure TPersistentData.DeleteNameListFiles;
- var
- I: Integer;
- strName: string;
- begin
- for I := 0 to FDeleteNameList.Count - 1 do
- begin
- strName := FDeleteNameList.Strings[I];
- DeleteFile(PChar(strName));
- end;
- FDeleteNameList.Clear;
- end;
- procedure TPersistentData.AddDeleteNameToList(const AFileName: string);
- begin
- FDeleteNameList.Add(AFileName);
- end;
- function TPersistentData.CheckFilePathInDelete(const AFileName: string): Boolean;
- var
- I: Integer;
- strName: string;
- begin
- Result := False;
- for I := 0 to FDeleteNameList.Count - 1 do
- begin
- strName := FDeleteNameList.Strings[I];
- if SameText(AFileName, strName) then
- begin
- Result := True;
- Break;
- end;
- end;
- end;
- procedure TPersistentData.DeleteRecordsBasisBillsID(ABillsID: Integer);
- begin
- DeleteDQ(ABillsID);
- DeleteRations(ABillsID);
- DeleteDJ(ABillsID, 0);
- DeleteExprs(ABillsID, 1);
- end;
- procedure TPersistentData.DeleteDJ(AID, AType: Integer);
- var
- I: Integer;
- djRec: TDJRec;
- begin
- for I := FDJList.Count - 1 downto 0 do
- begin
- djRec := TDJRec(FDJList.List^[I]);
- if (AType = djRec.Flag) and (djRec.OwnerID = AID) then
- begin
- FDJList.Delete(I);
- djRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteExprs(AID, AType: Integer);
- var
- I: Integer;
- exprsRec: TExprsRec;
- begin
- for I := FExprsList.Count - 1 downto 0 do
- begin
- exprsRec := TExprsRec(FExprsList.List^[I]);
- if (AType = exprsRec.FFlag) and (exprsRec.RecdID = AID) then
- begin
- FExprsList.Delete(I);
- exprsRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteFZ(ARationID: Integer);
- var
- I: Integer;
- fzRec: TFZRec;
- begin
- for I := FFZList.Count - 1 downto 0 do
- begin
- fzRec := TFZRec(FFZList.List^[I]);
- if fzRec.RationID = ARationID then
- begin
- FFZList.Delete(I);
- fzRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteGLJs(ARationID: Integer);
- var
- I: Integer;
- gljRec: TGLJRec;
- begin
- for I := FGLJList.Count - 1 downto 0 do
- begin
- gljRec := TGLJRec(FGLJList.List^[I]);
- if gljRec.RationsID = ARationID then
- begin
- FGLJList.Delete(I);
- gljRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteMMg(ARationID: Integer);
- var
- I: Integer;
- mmgRec: TMMgRec;
- begin
- for I := FMMgList.Count - 1 downto 0 do
- begin
- mmgRec := TMMgRec(FMMgList.List^[I]);
- if mmgRec.RationID = ARationID then
- begin
- FMMgList.Delete(I);
- mmgRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteMMr(ARationID: Integer);
- var
- I: Integer;
- mmrRec: TMMrRec;
- begin
- for I := FMMrList.Count - 1 downto 0 do
- begin
- mmrRec := TMMrRec(FMMrList.List^[I]);
- if mmrRec.RationID = ARationID then
- begin
- FMMrList.Delete(I);
- mmrRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeletePB(ARationID: Integer);
- var
- I: Integer;
- pbRec: TPBRec;
- begin
- for I := FPBList.Count - 1 downto 0 do
- begin
- pbRec := TPBRec(FPBList.List^[I]);
- if pbRec.RationID = ARationID then
- begin
- FPBList.Delete(I);
- pbRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteRations(ABillsID: Integer);
- var
- I: Integer;
- rationRec: TRationsRec;
- begin
- for I := FRationsList.Count - 1 downto 0 do
- begin
- rationRec := TRationsRec(FRationsList.List^[I]);
- if rationRec.BillsID = ABillsID then
- begin
- DeleteGLJs(rationRec.ID);
- DeleteFZ(rationRec.ID);
- DeletePB(rationRec.ID);
- DeleteXS(rationRec.ID);
- DeleteYSRate(rationRec.ID);
- DeleteDJ(rationRec.ID, 1);
- DeleteMMr(rationRec.ID);
- DeleteMMg(rationRec.ID);
- if rationRec.RType = 0 then
- DeleteExprs(rationRec.ID, 2)
- else DeleteExprs(rationRec.ID, 3);
- FRationsList.Delete(I);
- rationRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteXS(ARationID: Integer);
- var
- I: Integer;
- xsRec: TXSRec;
- begin
- for I := FXSList.Count - 1 downto 0 do
- begin
- xsRec := TXSRec(FXSList.List^[I]);
- if xsRec.RationID = ARationID then
- begin
- FXSList.Delete(I);
- xsRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteYSRate(ARationID: Integer);
- var
- I: Integer;
- ysRateRec: TYSRateRec;
- begin
- for I := FYSRateList.Count - 1 downto 0 do
- begin
- ysRateRec := TYSRateRec(FYSRateList.List^[I]);
- if ysRateRec.RationID = ARationID then
- begin
- FYSRateList.Delete(I);
- ysRateRec.Free;
- end;
- end;
- end;
- procedure TPersistentData.DeleteDQ(ABillsID: Integer);
- var
- I: Integer;
- DqItem: TDrawingQuantity;
- begin
- for I := FDQList.Count - 1 downto 0 do
- begin
- DqItem := TDrawingQuantity(FGLJList.List^[I]);
- if DqItem.BillsID = ABillsID then
- begin
- FDQList.Delete(I);
- DqItem.Free;
- end;
- end;
- end;
- procedure TPersistentData.ReturnDraqQty(aOldBillsID, aNewBillsID: Integer;
- aIsClearQ: Boolean);
- var
- I: Integer;
- dqItem: TDrawingQuantity;
- Rec: TScDrawingQuantityRecord;
- begin
- with TScProject(FProject).Bills.DrawingQuantityDM do
- begin
- for I := 0 to FDQList.Count - 1 do
- begin
- dqItem := TDrawingQuantity(FDQList.List^[I]);
- if dqItem.BillsID = aOldBillsID then
- begin
- Rec := TScDrawingQuantityRecord(sdsDrawingQuantity.Add(True));
- try
- Rec.ID.AsInteger := FMaxDqID;
- Rec.BillsID.AsInteger := aNewBillsID;
- if aIsClearQ then
- Rec.DQuantity1.AsFloat := 0
- else
- Rec.DQuantity1.AsFloat := dqItem.DQuantity1;
- Rec.Name.AsString := dqItem.Name;
- Rec.Units.AsString := dqItem.Units;
- Rec.MemoContext.AsString := dqItem.MemoContext;
- Rec.SerinalNo.AsInteger := dqItem.SerinalNo;
- Inc(FMaxDqID);
- finally
- Rec.EndUpdate;
- end;
- end;
- end;
- end;
- end;
- procedure TPersistentData.AppendDQRec(ARecord: TsdDataRecord);
- var
- dqRec: TDrawingQuantity;
- begin
- dqRec := TDrawingQuantity.Create(nil);
- with ARecord do
- begin
- dqRec.BillsID := ValueByName('BillsID').AsInteger;
- dqRec.SerinalNo := ValueByName('SerinalNo').AsInteger;
- dqRec.Name := ValueByName('Name').AsString;
- dqRec.Units := ValueByName('Units').AsString;
- dqRec.FDQuantity1 := ValueByName('DQuantity1').AsFloat;
- dqRec.MemoContext := ValueByName('MemoContext').AsString;
- end;
- FDQList.Add(dqRec);
- end;
- { TFileOpManager }
- procedure TFileOpManager.ExtractParticularName(const aProjName, aFullBPName, aAlias, aGUID: string);
- {var
- strName, strExt: string; }
- begin
- FExtractFileName := aAlias;
- FBuildProjectFolder := aProjName;
- FFullBuildProjectPath := aFullBPName;
- FGUID := aGUID;
- { strName := ExtractFileName(AFileName);
- strExt := ExtractFileExt(AFileName);
- FExtractFileName := Trim(Copy(strName, 1, Length(strName) - Length(strExt)));
- strName := Format('%s%s', [FFileDir, MyProject]);
- FBuildProjectFolder := AFileName;
- Delete(FBuildProjectFolder, 1, Length(strName) + 1);
- FBuildProjectFolder := Trim(Copy(FBuildProjectFolder, 1, Pos('\', FBuildProjectFolder))); }
- end;
- function TFileOpManager.GetCurProjectDir: string;
- begin
- Result := Format('%s%s%s%s\', [FFileDir, RestoreBat, NodeBinFolder, FGUID]);
- end;
- function TFileOpManager.GetSaveFileName(const ACode, ABCode, AName: string): string;
- const
- unDefineName = '未命名';
- {去掉换行符}
- procedure DeleteRowBack(var str: string);
- var
- I: Integer;
- begin
- for I := Length(str) downto 1 do
- begin
- if (str[I] = #10) or (str[I] = #13) then
- Delete(str, I, 1);
- end;
- end;
- function GetUniqueName(const AFileName: string): string;
- procedure SaveFolderCaption(const ADir: string);
- var
- sgs: TStringList;
- begin
- sgs := TStringList.Create;
- try
- sgs.Add(Format('建设项目:%s', [FFullBuildProjectPath]));
- sgs.Add(Format('标段:%s', [FExtractFileName]));
- finally
- sgs.SaveToFile(ADir+'\说明.txt');
- sgs.Free;
- end;
- end;
- var
- I: Integer;
- strDir, strName, strFilePath: string;
- begin
- I := 1;
- strName := Trim(AFileName);
- HandlerSpecialChar(strName);
- strDir := Format('%s%s%s%s', [FFileDir, RestoreBat, NodeBinFolder, FGUID]);
- strFilePath := Format('%s\%s%s', [strDir, strName, cExt]);
- DeleteRowBack(strFilePath);
- while FileExists(strFilePath) do
- begin
- strFilePath := Format('%s\%s_%d%s', [strDir, strName, I, cExt]);
- DeleteRowBack(strFilePath);
- Inc(I);
- end;
-
- Result := strFilePath;
- if not DirectoryExists(strDir) then
- begin
- ForceDirectories(strDir);
- SaveFolderCaption(strDir);
- end;
- end;
- begin
- if ACode <> '' then
- Result := GetUniqueName(ACode)
- else if ABCode <> '' then
- Result := GetUniqueName(ABCode)
- else if AName <> '' then
- Result := GetUniqueName(AName)
- else
- Result := GetUniqueName(unDefineName);
- end;
- procedure TFileOpManager.HandlerSpecialChar(var AText: string);
- const
- speChar: array [0..8] of Char = ('*', '<', '>', '/', '\', '?', ':', '|', '"');
- viChar: array [0..8] of string = ('×', '<', '>', '/', '\', '?', ':', '|', '"');
- var
- I: Integer;
- begin
- for I := low(speChar) to High(speChar) do
- begin
- if Pos(speChar[I], AText) <> 0 then
- AText := StringReplace(AText, speChar[I], viChar[I], [rfReplaceAll]);
- end;
- end;
- function TFileOpManager.RevertSpecialChar(const AText: string): string;
- const
- speChar: array [0..8] of Char = ('*', '<', '>', '/', '\', '?', ':', '|', '"');
- viChar: array [0..8] of string = ('×', '<', '>', '/', '\', '?', ':', '|', '"');
- var
- I: Integer;
- begin
- Result := AText;
- for I := low(viChar) to High(viChar) do
- begin
- if Pos(viChar[I], AText) <> 0 then
- Result := StringReplace(AText, viChar[I], speChar[I], [rfReplaceAll]);
- end;
- end;
- end.
|