| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999 |
- {*******************************************************************************
- 单元名称: ScSearchAndReplaceView.pas
- 单元说明: 查找与替换。
- 作者时间: Chenshilong, 2010-5-18 22:32:50
- *******************************************************************************}
- unit ScSearchAndReplaceView;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, DB, ADODB, DBClient, ZjGridDBA, ExtCtrls, StdCtrls, ZJGrid,
- ScProject, ScBills, JimPages, ScUtils, ScRationAssistantDM, ScMessage, IniFiles,
- DBCtrls, Menus, Buttons, ScBillsDM, sdDB, sdGridDBA, ScConsts,
- sdGridTreeDBA, sdProvider;
- type
- TSearchKind = (skCode, skB_Code, skName);
- type
- TfrmSearchAndReplace = class(TFrame)
- pcSAndR: TJimPageControl;
- PageBill: TJimPage;
- zgBills: TZJGrid;
- PageRation: TJimPage;
- zgRations: TZJGrid;
- PageGLJ: TJimPage;
- Splitter1: TSplitter;
- zgGLJ: TZJGrid;
- zgRations2: TZJGrid;
- cdsBills: TClientDataSet;
- cdsBillsSerialNo: TIntegerField;
- cdsBillsID: TIntegerField;
- cdsBillsB_Code: TWideStringField;
- cdsBillsCode: TWideStringField;
- cdsBillsName: TWideStringField;
- zdBills: TZjGridDBA;
- zdRations: TZjGridDBA;
- cdsRations: TClientDataSet;
- cdsRationsID: TIntegerField;
- cdsRationsLibID: TIntegerField;
- cdsRationsCode: TWideStringField;
- cdsRationsBillsItemID: TIntegerField;
- cdsRationsMaskName: TWideStringField;
- cdsRationsName: TWideStringField;
- cdsRationsUnit: TWideStringField;
- cdsRationsQuantity: TFloatField;
- cdsRationsType: TSmallintField;
- cdsRationsSerialNo: TIntegerField;
- cdsRationsCodeForReport: TWideStringField;
- zdGLJ: TZjGridDBA;
- cdsGLJ: TClientDataSet;
- cdsGLJID: TIntegerField;
- cdsGLJLibID: TIntegerField;
- cdsGLJName: TWideStringField;
- cdsGLJSpecs: TWideStringField;
- cdsGLJUnit: TWideStringField;
- Panel1: TPanel;
- edtSearch: TEdit;
- btnSearch: TButton;
- rbBillB_Code: TRadioButton;
- rbBillName: TRadioButton;
- rbRationCode: TRadioButton;
- rbRationName: TRadioButton;
- rbGLJCode: TRadioButton;
- rbGLJName: TRadioButton;
- Bevel1: TBevel;
- pnReplace: TPanel;
- edtReplace: TEdit;
- btnReplace: TButton;
- lblReplace: TLabel;
- Label1: TLabel;
- cdsGLJBudgetPrice: TFloatField;
- cdsBillsQuantity: TFloatField;
- cdsBillsUnitPrice: TFloatField;
- cdsBillsTotalPrice: TFloatField;
- chkLocateFirstAppear: TCheckBox;
- chkAboveAverage: TCheckBox;
- edtAboveAverage: TEdit;
- lblAboveAverage: TLabel;
- Image2: TImage;
- rbBookmark: TRadioButton;
- PageBookmark: TJimPage;
- Splitter2: TSplitter;
- pmBM: TPopupMenu;
- mnClearAllBM: TMenuItem;
- mnClearCurBM: TMenuItem;
- cdsBillsIsME: TBooleanField;
- btnSearchAll: TButton;
- chkOnlyME: TCheckBox;
- cdsBillsUnits: TWideStringField;
- rbBillCode: TRadioButton;
- cdsBillsDesignQuantity: TCurrencyField;
- cdsBillsDesignPrice: TCurrencyField;
- Panel2: TPanel;
- zgBookmark: TZJGrid;
- zaColor: TZjGridDBA;
- pnlBM: TPanel;
- pnlColorSet: TPanel;
- zgColor: TZJGrid;
- Panel5: TPanel;
- pnlDefaultColor: TPanel;
- btnColorView: TSpeedButton;
- aqBookMarkColor: TADOQuery;
- aqBookMarkColorBMColor: TIntegerField;
- aqBookMarkColorBMMemo: TWideStringField;
- aqBookMarkColorCurColor: TIntegerField;
- aqSQL: TADOQuery;
- Panel3: TPanel;
- rbAll: TRadioButton;
- rbOnlyCur: TRadioButton;
- sdvBookMark: TsdDataView;
- sdvSearch: TsdDataView;
- sgdBookmark: TsdGridDBA;
- mmBM: TMemo;
- cdsGLJCode: TWideStringField;
- rbCountPrice: TRadioButton;
- rbDevices: TRadioButton;
- cdsRationsFTItemFlag: TBooleanField;
- cdsRationsIsMeCalc: TBooleanField;
- pnlSumBill: TPanel;
- cdsRationsBasePrice: TFloatField;
- PageCompareXML: TJimPage;
- zgCompareXML: TZJGrid;
- zaCompareXML: TZjGridDBA;
- cdsCompareXML: TClientDataSet;
- cdsCompareXMLBillID: TIntegerField;
- cdsCompareXMLRationID: TIntegerField;
- cdsCompareXMLDrawQtyID: TIntegerField;
- cdsCompareXMLOperate: TStringField;
- cdsCompareXMLKind: TStringField;
- cdsCompareXMLCode: TStringField;
- cdsCompareXMLB_Code: TStringField;
- cdsCompareXMLName: TStringField;
- cdsCompareXMLQuantity: TStringField;
- cdsCompareXMLDgnQuantity1: TStringField;
- cdsCompareXMLDgnQuantity2: TStringField;
- rbCompareXML: TRadioButton;
- pnlSelectXMLFile: TPanel;
- btnSelectFile: TSpeedButton;
- edtFile: TEdit;
- smpRations2: TsdMemoryProvider;
- stdRations2: TsdGridTreeDBA;
- sdsRations2: TsdDataSet;
- sdvRations2: TsdDataView;
- pnlSumRation: TPanel;
- cdsRationsUnitFee: TWideStringField;
- cdsRationsTotalFee: TFloatField;
- cdsRationsAdjustState: TWideStringField;
- cdsRationsUnitPrice: TFloatField;
- procedure cdsRationsTypeGetText(Sender: TField; var Text: String;
- DisplayText: Boolean);
- procedure zgRationsMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure zgBillsMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure btnReplaceClick(Sender: TObject);
- procedure zgRationsShowHint(var HintStr: String; var CanShow: Boolean;
- var HintInfo: THintInfo; const ACoord: TPoint);
- procedure zgRations2ShowHint(var HintStr: String; var CanShow: Boolean;
- var HintInfo: THintInfo; const ACoord: TPoint);
- procedure DoOnBillsScroll(DataSet: TDataSet);
- procedure btnSearchRationClick(Sender: TObject);
- procedure edtSearchKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure btnSearchClick(Sender: TObject);
- procedure zgBillsShowHint(var HintStr: String; var CanShow: Boolean;
- var HintInfo: THintInfo; const ACoord: TPoint);
- procedure cdsGLJAfterScroll(DataSet: TDataSet);
- procedure rbBillB_CodeClick(Sender: TObject);
- procedure rbBillNameClick(Sender: TObject);
- procedure rbRationCodeClick(Sender: TObject);
- procedure rbRationNameClick(Sender: TObject);
- procedure rbGLJCodeClick(Sender: TObject);
- procedure rbGLJNameClick(Sender: TObject);
- procedure edtAboveAverageKeyPress(Sender: TObject; var Key: Char);
- procedure zgBillsCellGetColor(Sender: TObject; ACoord: TPoint;
- var AColor: TColor);
- procedure edtAboveAverageExit(Sender: TObject);
- procedure rbBookmarkClick(Sender: TObject);
- procedure zgBookmarkMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure mmBMExit(Sender: TObject);
- procedure mnClearAllBMClick(Sender: TObject);
- procedure mnClearCurBMClick(Sender: TObject);
- procedure btnSearchAllClick(Sender: TObject);
- procedure chkOnlyMEClick(Sender: TObject);
- procedure chkAboveAverageClick(Sender: TObject);
- procedure cdsBillsDesignQuantityGetText(Sender: TField;
- var Text: String; DisplayText: Boolean);
- procedure mmBMEnter(Sender: TObject);
- procedure zgColorCellGetColor(Sender: TObject; ACoord: TPoint;
- var AColor: TColor);
- procedure btnColorViewClick(Sender: TObject);
- procedure zgBookmarkCellGetColor(Sender: TObject; ACoord: TPoint;
- var AColor: TColor);
- procedure zgColorMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure zgColorShowHint(var HintStr: String; var CanShow: Boolean;
- var HintInfo: THintInfo; const ACoord: TPoint);
- procedure rbAllClick(Sender: TObject);
- procedure rbOnlyCurClick(Sender: TObject);
- procedure aqBookMarkColorAfterScroll(DataSet: TDataSet);
- procedure sdvBookMarkFilterRecord(ARecord: TsdDataRecord;
- var Allow: Boolean);
- procedure sdvBookMarkCurrentChanged(ARecord: TsdDataRecord);
- procedure mmBMChange(Sender: TObject);
- procedure zgCompareXMLMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure zgCompareXMLCellGetFont(Sender: TObject; ACoord: TPoint;
- AFont: TFont);
- procedure rbCompareXMLClick(Sender: TObject);
- procedure zgRations2CellGetColor(Sender: TObject; ACoord: TPoint;
- var AColor: TColor);
- private
- { Private declarations }
- FBillsTree: TScBillsTree;
- FProject: TScProject;
- FRADM: TRationAssistantDM;
- FAggUnitPrice: TAggregate;
- procedure LocateCurBills;
- procedure SetProject(const Value: TScProject);
- procedure RadioButtonCheck;
- procedure ReplaceEnable(AEnable: Boolean);
- procedure AboveAverageEnable(AEnable: Boolean);
- procedure FilterME(AOnlyME: Boolean);
- procedure DeleteBookMark(ARec: TScBillsRecord);
- procedure SetDefaultColor;
- procedure FilterColor;
- procedure RefreshBookmarkStr(ARecord: TsdDataRecord);
- public
- { Public declarations }
- procedure Init(AProject: TScProject; AShowBookmark: Boolean = False);
- property RADM: TRationAssistantDM read FRADM;
- property Project: TScProject read FProject write SetProject;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure SearchRations(AValue: String; ASearchKind: TSearchKind);
- procedure SearchBills(AValue: String; ASearchKind: TSearchKind;
- OnlyFirstParts: Boolean = False);
- procedure SearchGLJs(AValue: String; ASearchKind: TSearchKind);
- procedure SearchBillsByB_Code(AValue: String);
- procedure SearchRationsByGLJ(AGLJID: Integer);
- procedure SearchRecords(SearchText: string);
- procedure SearchBookmarks;
- procedure CompareFromXML;
- procedure Search(SearchText: string; AType: TSearchType);
- property AggUnitPrice: TAggregate read FAggUnitPrice write FAggUnitPrice;
- end;
- implementation
- uses
- ZjCells, ScRations, ScProjectGLJ, ScGLJ, ScProjFrm, Math, ScConfig,
- ScProjBaseDM, sdIDTree, ScXMLPort, ScMainFrm,
- ScBillsSubItemViews;
- Const sDefStr = '请在此位置输入批注';
- {$R *.dfm}
- procedure TfrmSearchAndReplace.Init(AProject: TScProject; AShowBookmark: Boolean);
- var ini: TIniFile;
- begin
- FBillsTree := AProject.Bills.BillsTree;
- sdsRations2.Open;
- sdvRations2.Open;
- sdsRations2.DeleteAll;
- // Aggregate
- cdsBills.AggregatesActive := True;
- AggUnitPrice := cdsBills.Aggregates.Add;
- if Project.IsGuangDong then
- begin
- AggUnitPrice.IndexName := 'IdxBCodeCode';
- // chkOnlyME.Visible := True;
- end
- else
- begin
- // AggUnitPrice.IndexName := 'IdxName'; 这个索引导致计算的平均值为0,换成Code
- AggUnitPrice.IndexName := 'IdxCode';
- // chkOnlyME.Visible := False;
- end;
- AggUnitPrice.GroupingLevel := 1;
- if Project.IsBudget then
- AggUnitPrice.Expression := 'Avg(DesignPrice)' // 概预算计算的平均值是0,暂未找到原因
- else
- AggUnitPrice.Expression := 'Avg(UnitPrice)';
- AggUnitPrice.Active := True;
- ini:= TIniFile.Create(ConfigInfo.SystemIniFileName);
- try
- edtAboveAverage.Text:=ini.ReadString('Options','AboveAveragePercent','10');
- finally
- ini.Free;
- end;
- pcSAndR.ShowTabs := False;
- pcSAndR.ActivePage := PageBill;
- // zgRations.CellClass.Cols[3] := TZjCheckBoxCell;
- cdsBills.IndexDefs.Clear;
- cdsBills.IndexDefs.Add('IdxBCodeCode', 'B_Code;Code', []);
- cdsBills.IndexDefs.Add('IdxCode', 'Code', []);
- cdsBills.IndexDefs.Add('IdxNameBCode', 'Name;B_Code', []);
- cdsBills.IndexDefs.Add('IdxName', 'Name', []);
- // 估概算项目、预算项目只有Code,没有B_Code。有设计数量和经济指标,没有数量单价
- if Project.IsBudget then
- begin
- zdBills.Columns[0].Width := 58;
- zdBills.Columns[1].Width := 0;
- zdBills.Columns[4].Width := 0;
- zdBills.Columns[5].Width := 0;
- zdBills.Columns[6].Width := 50;
- zdBills.Columns[7].Width := 50;
- zdBills.Columns[0].Title.Caption := '预算项目节';
- zdBills.Columns[2].title.caption:= '分项名称';
- cdsBills.IndexName := 'IdxCode';
- rbBillCode.Caption := '预算项目节';
- rbBillCode.Visible := True;
- rbBillB_Code.Visible := False;
- if AShowBookmark then
- rbBookmark.Checked := True
- else
- rbBillCode.Checked := True;
- end
- else if Project.IsGD3J then
- begin
- zdBills.Columns[0].Width := 0;
- zdBills.Columns[1].Width := 58;
- zdBills.Columns[4].Width := 50;
- zdBills.Columns[5].Width := 50;
- zdBills.Columns[6].Width := 0;
- zdBills.Columns[7].Width := 0;
- zdBills.Columns[0].Title.Caption := '预算项目节';
- zdBills.Columns[2].Title.Caption := '清单名称';
- cdsBills.IndexName := 'IdxBCodeCode';
- rbBillB_Code.Visible := True;
- rbBillCode.Visible := False;
- if AShowBookmark then
- rbBookmark.Checked := True
- else
- rbBillB_Code.Checked := True;
- // 广东版要点击清单反向定位到按清单子目号查找定位的窗口中。
- // 新控件这个地方不好实现,先不管。chenshilongWaiting
- // FProject.Bills.BillsDM.OnBillsAfterScrollForSearch := DoOnBillsScroll;
- // chkLocateFirstAppear.Visible := True;
- end
- else
- begin
- rbBillB_Code.Visible := False;
- rbBillCode.Visible := True;
- if AShowBookmark then
- rbBookmark.Checked := True
- else
- rbGLJCode.Checked := True;
- cdsBills.IndexName := 'IdxName';
- zdBills.Columns[0].Width := 58;
- zdBills.Columns[1].Width := 0;
- zdBills.Columns[4].Width := 50;
- zdBills.Columns[5].Width := 50;
- zdBills.Columns[6].Width := 0;
- zdBills.Columns[7].Width := 0;
- zdBills.Columns[0].Title.Caption := '清单编号'
- end;
- zgBills.CurCol := 3;
- cdsRations.EmptyDataSet;
- cdsRations.IndexFieldNames := 'Code;BillsItemID;SerialNo';
- cdsBills.EmptyDataSet;
- // cdsSearch.IndexDefs.Add('idxB_Code', 'B_Code', []);
- // to do(s): cdsSearch.CloneCursor(AProject.Bills.cdsOrgBills, True);
- // cdsSearch.IndexName := 'idxB_Code';
- sdvSearch.DataSet := AProject.Bills.BillsDM.sdsBills;
- sdvSearch.IndexName := 'idxB_Code';
- cdsGLJ.IndexDefs.Clear;
- cdsGLJ.AddIndex('idxCode', 'Code', []);
- cdsGLJ.IndexName := 'idxCode';
- sdvBookMark.DataSet := AProject.Bills.BillsDM.sdsBills;
- sdvBookMark.Active := True;
- SearchRecords(Trim(edtSearch.Text));
- zgBookmark.Height := zgBookmark.Parent.Height - Splitter2.Height - 250;
- if AProject.ProjType in [ptBudget, ptBudgetEstimate, ptProposalEstimate,
- ptFeasibilityEstimate] then
- begin
- rbBillCode.Caption := '分项编号';
- rbBillName.Caption := '分项名称';
- end
- else
- begin
- rbBillCode.Caption := '清单编号';
- rbBillName.Caption := '清单名称';
- end;
- if AProject.IsGD3J then
- begin
- sgdBookmark.Columns[1].Visible := True;
- sgdBookmark.Columns[1].Title.Caption := '清单子目号';
- end
- else
- begin
- //sgdBookmark.Columns[1].Title.Caption := '分项编号';
- sgdBookmark.Columns[1].Visible := False;
- end;
- aqBookMarkColor.Connection := AProject.DM.acnProject;
- aqBookMarkColor.Open;
- pnlDefaultColor.Color := AProject.BookMarkColor;
- // lblDefaultColor.Color := AProject.BookMarkColor;
- aqSQL.Connection := AProject.DM.acnProject;
- end;
- procedure TfrmSearchAndReplace.cdsRationsTypeGetText(
- Sender: TField; var Text: String; DisplayText: Boolean);
- begin
- if DisplayText then
- begin
- if Sender.AsInteger = 0 then
- Text := 'False'
- else if Sender.AsInteger = 1 then
- Text := 'True';
- end;
- end;
- procedure TfrmSearchAndReplace.LocateCurBills;
- var
- ProjForm: TScProjForm;
- vNode, RNode: TsdIDTreeNode;
- begin
- ProjForm := TScProjForm(Application.MainForm.ActiveMDIChild);
- // 清单
- if pcSAndR.ActivePageIndex = 0 then
- begin
- if cdsBills.Active and (cdsBills.RecordCount > 0) then
- begin
- vNode := FBillsTree[cdsBillsID.Value];
- if vNode <> nil then
- begin
- if not vNode.Expanded then
- vNode.Expanded := True;
- vNode.LocateInControl;
- end
- else
- begin
- if FProject.IsBills then
- MessageHint(0, '无法定位,清单可能已被删除。')
- else
- MessageHint(0, '无法定位,分项可能已被删除。');
- end;
- end;
- end
- // 定额
- else if pcSAndR.ActivePageIndex = 1 then
- begin
- // 定位清单
- if cdsRations.Active and (cdsRations.RecordCount > 0) then
- begin
- vNode := FBillsTree.FindNode(cdsRationsBillsItemID.Value);
- if vNode <> nil then
- begin
- if not vNode.Expanded then
- vNode.Expanded := True;
- vNode.LocateInControl;
- end
- else
- begin
- if FProject.IsBills then
- MessageHint(0, '无法定位,该定额所在的清单可能已被删除。')
- else
- MessageHint(0, '无法定位,该定额所在的分项可能已被删除。');
- Exit;
- end;
- end;
- // 定位定额
- if cdsRationsType.AsInteger = 0 then
- begin
- ProjForm.tbtnAll.Click;
- ProjForm.tbtnAll.Down := True;
- FProject.Rations.LocateRation(cdsRationsID.AsInteger);
- end
- // 定位数量单价
- else if cdsRationsType.AsInteger = 1 then
- begin
- // ProjForm.BillsSubItemView.PageControl.ActivePageIndex := 1;
- if not cdsRationsIsMeCalc.AsBoolean then
- begin
- ProjForm.tbtnAll.Click;
- ProjForm.tbtnAll.Down := True;
- FProject.Rations.LocateRation(cdsRationsID.AsInteger);
- (* if ConfigInfo.RationDisplayMode = 0 then
- begin
- ProjForm.btnRation.Click;
- ProjForm.btnRation.Down := True;
- FProject.Rations.LocateRation(cdsRationsID.AsInteger);
- end
- else
- begin
- ProjForm.btnCountPrice.Click;
- ProjForm.btnCountPrice.Down := True;
- FProject.Rations.LocateCountPrice(cdsRationsID.AsInteger);
- end; *)
- end
- else
- begin
- ProjForm.btnME.Click;
- ProjForm.btnME.Down := True;
- FProject.Rations.LocateDevices(cdsRationsID.AsInteger);
- end
- end;
- end
- // 工料机
- else if pcSAndR.ActivePageIndex = 2 then
- begin
- if sdvRations2.Active and (sdvRations2.RecordCount > 0) then
- begin
- RNode := stdRations2.IDTree.Selected;
- if RNode <> nil then
- begin
- // 定额通过SBillsItemID定位,清单直接通过ID定位
- if RNode.Rec.ValueByName('IsRation').AsBoolean then
- vNode := FBillsTree.FindNode(RNode.Rec.ValueByName(SBillsItemID).AsInteger)
- else
- vNode := FBillsTree.FindNode(RNode.ID);
- if vNode <> nil then
- begin
- if not vNode.Expanded then
- vNode.Expanded := True;
- vNode.LocateInControl;
- end
- else
- begin
- if FProject.IsBills then
- MessageHint(0, '无法定位,该工料机所在的清单可能已被删除。')
- else
- MessageHint(0, '无法定位,该工料机所在的分项可能已被删除。');
- Exit;
- end;
- // 是定额则定位定额
- if RNode.Rec.ValueByName('IsRation').AsBoolean then
- begin
- ProjForm.BillsSubItemView.PageControl.ActivePageIndex := 0;
- ProjForm.btnRation.Down := True;
- FProject.Rations.LocateRation(RNode.Rec.ValueByName(SRationID).AsInteger);
- end;
- end;
- end;
- end
- // 书签
- else if pcSAndR.ActivePageIndex = 3 then
- begin
- // 定位清单
- if sdvBookMark.Active and (sdvBookMark.RecordCount > 0) then
- begin
- vNode := FBillsTree.FindNode(TScBillsRecord(sdvBookMark.Current).ID.AsInteger);
- if vNode <> nil then
- begin
- if not vNode.Expanded then
- vNode.Expanded := True;
- vNode.LocateInControl;
- end
- else
- begin
- if FProject.IsBills then
- MessageHint(0, '无法定位,该书签对应的清单可能已被删除。')
- else
- MessageHint(0, '无法定位,该书签对应的分项可能已被删除。');
- Exit;
- end;
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.zgRationsMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if ssDouble in Shift then
- LocateCurBills;
- end;
- procedure TfrmSearchAndReplace.SearchRations(AValue: String; ASearchKind: TSearchKind);
- var
- I: Integer;
- sdRation: TScRationRecord;
- sFiledValue: String;
- vGLJ: TScGLJRecord;
- fSumT, fSumQ: Double;
- begin
- try
- Screen.Cursor := crHourGlass;
- cdsRations.DisableControls;
- fSumT := 0;
- fSumQ := 0;
- for I := 0 to FProject.Rations.sdsRations.RecordCount - 1 do
- begin
- sdRation := TScRationRecord(FProject.Rations.sdsRations[I]);
- // 分摊的定额过滤掉
- if sdRation.FTItemFlag.AsInteger = 1 then Continue;
- if (rbRationCode.Checked or rbRationName.Checked) and (sdRation.RationType.AsInteger <> 0) then
- Continue;
- if rbCountPrice.Checked and ((sdRation.RationType.AsInteger <> 1) or sdRation.IsMECalc.AsBoolean) then
- Continue;
- if rbDevices.Checked and ((sdRation.RationType.AsInteger <> 1) or (not sdRation.IsMECalc.AsBoolean)) then
- Continue;
- case ASearchKind of
- skCode: sFiledValue := sdRation.Code.AsString;
- skName: sFiledValue := sdRation.Name.AsString;
- end;
- if ((AValue = '') or (Pos(AValue, sFiledValue) > 0)) and (sdRation.Quantity.AsFloat <> 0) then
- begin
- cdsRations.Append;
- cdsRationsID.AsInteger := sdRation.ID.AsInteger;
- cdsRationsLibID.AsInteger := sdRation.LibID.AsInteger;
- cdsRationsCode.AsString := sdRation.Code.AsString;
- cdsRationsBillsItemID.AsInteger := sdRation.BillsItemID.AsInteger;
- cdsRationsName.AsString := sdRation.Name.AsString;
- cdsRationsMaskName.AsString := sdRation.MaskName.AsString;
- cdsRationsUnit.AsString := ConvertUnitStr(sdRation.Units.AsString);
- cdsRationsQuantity.AsFloat := sdRation.Quantity.AsFloat;
- if rbCountPrice.Checked or rbDevices.Checked then
- cdsRationsUnitPrice.AsFloat := sdRation.UnitDirectFee.AsFloat
- else
- cdsRationsUnitPrice.AsFloat := sdRation.BuildingUnitPrice.AsFloat;
- cdsRationsType.AsInteger := sdRation.RationType.AsInteger;
- cdsRationsCodeForReport.AsString := sdRation.CodeForReport.AsString;
- cdsRationsSerialNo.AsInteger := sdRation.SerialNo.AsInteger;
- cdsRationsIsMeCalc.AsBoolean := sdRation.IsMECalc.AsBoolean;
- cdsRationsUnitFee.AsFloat := sdRation.UnitDirectFee.AsFloat;
- cdsRationsTotalFee.AsFloat := sdRation.BuildingFee.AsFloat;
- cdsRationsAdjustState.AsString := sdRation.AdjustState.AsString;
- if (sdRation.RationType.AsInteger = 0) then // 定额
- begin
- vGLJ := FProject.GLJ.FindGLJByRationIDAndGLJCode(sdRation.ID.AsInteger, SJiJiaCode);
- if vGLJ <> nil then
- cdsRationsBasePrice.AsFloat := vGLJ.Quantity.AsFloat;
- end
- else
- begin
- if sdRation.IsMECalc.AsBoolean then
- cdsRationsBasePrice.AsFloat := sdRation.UnitDirectFee.AsFloat;
- end;
- fSumT := fSumT + sdRation.BuildingFee.AsFloat;
- fSumQ := fSumQ + sdRation.Quantity.AsFloat;
- end;
- end;
- cdsRations.First;
- // if (rbCountPrice.Checked or rbDevices.Checked) then
- // begin
- // pnlSumRation.Visible := True;
- // pnlSumRation.Caption := Format('【金额合计】%g', [fSumT]);
- // end
- // else
- // begin
- // pnlSumRation.Visible := False;
- // end;
- pnlSumRation.Caption := Format('【金额合计】%g 【数量合计】%g', [fSumT, fSumQ]);
- finally
- cdsRations.EnableControls;
- Screen.Cursor := crDefault;
- end;
- end;
- procedure TfrmSearchAndReplace.SearchBills(AValue: String; ASearchKind:
- TSearchKind; OnlyFirstParts: Boolean);
- var
- ACDS, cdsFind: TClientDataSet;
- sFiledValue: String;
- vTree: TScBillsTree;
- Item2Idx, Item3Idx, TreeMaxIdx, i, curIdx: Integer;
- bIsME: Boolean;
- fSumT, fSumQ: Double;
- begin
- try
- Screen.Cursor := crHourGlass;
- cdsBills.DisableControls;
- vTree := FProject.Bills.BillsTree;
- Item2Idx := vTree[2].MajorIndex;
- Item3Idx := vTree[3].MajorIndex;
-
- if not Assigned(vTree[6]) then
- TreeMaxIdx := vTree[10].MajorIndex
- else
- TreeMaxIdx := vTree[6].MajorIndex;
- fSumT := 0;
- fSumQ := 0;
- for i := 0 to TreeMaxIdx do
- begin
- case ASearchKind of
- skCode: sFiledValue := vTree.Items[i].Code;
- {$IFDEF _ScGuangDong}
- skB_Code: sFiledValue := vTree.Items[i].B_Code;
- {$ENDIF}
- skName: sFiledValue := vTree.Items[i].Name;
- end;
- if (AValue = '') or (Pos(AValue, sFiledValue) > 0) then
- begin
- if FProject.IsGuangDong then
- if (ASearchKind = skB_Code) then
- begin
- if vTree.Items[i].B_Code = '' then
- Continue;
- end;
- // 只显示机电:用Filter后重新指定索引会提示“operation not permitted”
- // 所以不用Filter,直接在这里处理
- curIdx := vTree.Items[i].MajorIndex;
- bIsME := (curIdx > Item2Idx) and (curIdx < Item3Idx);
- if (not bIsME) and chkOnlyME.Checked then
- Continue;
- cdsBills.Append;
- cdsBillsIsME.AsBoolean := bIsME;
- cdsBillsSerialNo.AsInteger := curIdx;
- cdsBillsID.AsInteger:= vTree.Items[i].ID;
- cdsBillsCode.AsString := vTree.Items[i].Code;
- if FProject.IsGuangDong then
- cdsBillsB_Code.AsString := vTree.Items[i].Rec.B_Code.AsString;
- cdsBillsName.AsString := vTree.Items[i].Rec.Name.AsString;
- cdsBillsUnits.AsString := vTree.Items[i].Rec.Units.AsString;
- cdsBillsQuantity.AsFloat := vTree.Items[i].Rec.Quantity.AsFloat;
- cdsBillsUnitPrice.AsFloat := vTree.Items[i].Rec.UnitPrice.AsFloat;
- cdsBillsDesignQuantity.AsFloat := vTree.Items[i].Rec.DesignQuantity.AsFloat;
- cdsBillsDesignPrice.AsFloat := vTree.Items[i].Rec.DesignPrice.AsFloat;
- cdsBillsTotalPrice.AsFloat := vTree.Items[i].Rec.TotalPrice.AsFloat;
- cdsBills.Post;
- fSumT := fSumT + vTree.Items[i].Rec.TotalPrice.AsFloat;
- fSumQ := fSumQ + vTree.Items[i].Rec.Quantity.AsFloat;
- end;
- end;
- finally
- cdsBills.EnableControls;
- pnlSumBill.Caption := Format('【金额合计】%g 【数量合计】%g', [fSumT, fSumQ]);
- Screen.Cursor := crDefault;
- end;
- end;
- procedure TfrmSearchAndReplace.zgBillsMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if ssDouble in Shift then
- LocateCurBills;
- end;
- procedure TfrmSearchAndReplace.btnReplaceClick(Sender: TObject);
- var s1,s2, newName: string;
- sdRation: TScRationRecord;
- begin
- if not (rbBillName.Checked or rbRationName.Checked) then Exit;
- s1 := trim(edtSearch.Text);
- s2 := trim(edtReplace.Text);
- if (s1 = '') or (s2 = '') then exit;
- if ((not cdsBills.Active) or (cdsBills.RecordCount < 1)) and
- ((not cdsRations.Active) or (cdsRations.RecordCount < 1)) then exit;
- if not MessageQuest('确定要将查询结果中所有包含的 “'+ s1 + '” 替换成 “' + s2 + '” 吗?') then Exit;
- Screen.Cursor := crHourGlass;
- try
- if rbBillName.Checked then
- begin
- FProject.Bills.BillsDM.sdsBills.BeginUpdate;
- try
- cdsBills.First;
- while not cdsBills.Eof do
- begin
- newName := StringReplace(cdsBillsName.AsString, s1, s2, [rfReplaceAll,rfIgnoreCase]);
- FProject.Bills.BillsTree[cdsBillsID.AsInteger].Rec.Name.AsString := newName;
- cdsBills.Next;
- end;
- finally
- FProject.Bills.BillsDM.sdsBills.EndUpdate;
- end;
- cdsBills.EmptyDataSet;
- SearchBills(s2, skName, True);
- end
- else if rbRationName.Checked then
- begin
- cdsRations.First;
- while not cdsRations.Eof do
- begin
- newName := StringReplace(cdsRationsName.AsString, s1, s2, [rfReplaceAll,rfIgnoreCase]);
- sdRation := FProject.Rations.FindRation(cdsRationsID.AsInteger);
- sdRation.Name.AsString := newName;
- cdsRations.Next;
- end;
- cdsRations.EmptyDataSet;
- SearchRations(s2, skName);
- end;
- finally
- Screen.Cursor := crDefault;
- end;
- end;
- procedure QuickSortChildren(AParent: TsdIDTreeNode);
- function CompareNode(ANode1, ANode2: TsdIDTreeNode): Integer;
- var
- iSN1, iSN2: Integer;
- begin
- iSN1 := ANode1.Rec.ValueByName(SSerialNo).AsInteger;
- iSN2 := ANode2.Rec.ValueByName(SSerialNo).AsInteger;
- if iSN1 > iSN2 then
- Result := 1
- else if iSN1 < iSN2 then
- Result := -1
- else
- Result := 0;
- end;
- procedure QuickSort(iLo, iHi: Integer);
- var
- Lo, Hi: Integer;
- Mid: TsdIDTreeNode;
- begin
- Lo := iLo;
- Hi := iHi;
- Mid := AParent.ChildNodes[(iLo + iHi) div 2];
- repeat
- while CompareNode(AParent.ChildNodes[Lo], Mid) < 0 do Lo := Lo + 1;
- while CompareNode(AParent.ChildNodes[Hi], Mid) > 0 do Hi := Hi - 1;
- if Lo <= Hi then
- begin
- if Lo < Hi then begin
- AParent.Owner.Exchange(AParent.ChildNodes[Lo], AParent.ChildNodes[Hi]);
- end;
- Lo := Lo + 1;
- Hi := Hi - 1;
- end;
- until Lo > Hi;
- if Hi > iLo then QuickSort(iLo, Hi);
- if Lo < iHi then QuickSort(Lo, iHi);
- end;
- begin
- if AParent.ChildCount > 1 then QuickSort(0, AParent.ChildCount - 1);
- end;
- procedure TfrmSearchAndReplace.SearchRationsByGLJ(AGLJID: Integer);
- var
- Tree: TsdIDTree;
- lstBillsID: TList;
- function AddNode(ABillsItem: TScBillsItem): TsdIDTreeNode;
- var
- Node, ParentNode: TsdIDTreeNode;
- BillsNode, ParentBills, NextBills: TScBillsItem;
- I, iParentID, iNextID: Integer;
- strCode: string;
- begin
- Result := nil;
- // 先找节点是否存在
- Node := Tree.FindNode(ABillsItem.ID);
- if Node <> nil then
- begin
- Result := Node;
- Exit;
- end;
- // 递归
- if (ABillsItem <> nil) and (ABillsItem.Parent <> nil) then
- ParentNode := AddNode(TScBillsItem(ABillsItem.Parent));
- // 确定后兄弟
- ParentBills := TScBillsItem(ABillsItem.Parent);
- NextBills := nil;
- BillsNode := TScBillsItem(ABillsItem.NextSibling);
- while BillsNode <> nil do
- begin
- if ((not BillsNode.IsLeaf) or (lstBillsID.IndexOf(Pointer(BillsNode.ID)) >= 0)) and (Tree.FindNode(BillsNode.ID) <> nil) then
- begin
- NextBills := BillsNode;
- Break;
- end;
- BillsNode := TScBillsItem(BillsNode.NextSibling);
- end;
- // 添加
- if ParentBills <> nil then
- iParentID := ParentBills.ID
- else
- iParentID := -1;
- if NextBills <> nil then
- iNextID := NextBills.ID
- else
- iNextID := -1;
- Result := Tree.Add(ABillsItem.ID, iParentID, iNextID, True);
- try
- if ABillsItem.Rec.B_Code.AsString <> '' then
- strCode := ABillsItem.Rec.B_Code.AsString
- else
- strCode := ABillsItem.Rec.Code.AsString;
- Result.Rec.ValueByName(SCode).AsString := strCode;
- Result.Rec.ValueByName(SName).AsString := ABillsItem.Rec.Name.AsString;
- Result.Rec.ValueByName(SUnitPrice).AsCurrency := ABillsItem.Rec.UnitPrice.AsCurrency;
- Result.Rec.ValueByName('IsRation').AsBoolean := False;
- finally
- Result.Rec.EndUpdate;
- end;
- end;
- function AddParents(ABillsItemID: Integer): TsdIDTreeNode;
- var
- BillsItem: TScBillsItem;
- begin
- Result := Tree.FindNode(ABillsItemID);
- if Result <> nil then Exit;
- BillsItem := FBillsTree.BillsItem[ABillsItemID];
- Result := AddNode(BillsItem);
- end;
- procedure ResortRations(ANode: TsdIDTreeNode);
- begin
- if ANode = nil then Exit;
- if ANode.ChildCount > 0 then
- begin
- if ANode.FirstChild.Rec.ValueByName('IsRation').AsBoolean then
- QuickSortChildren(ANode)
- else
- ResortRations(ANode.FirstChild);
- end;
- ResortRations(ANode.NextSibling);
- end;
- var
- I, iLength: Integer;
- Node, ParentNode: TsdIDTreeNode;
- Rec: TsdDataRecord;
- sdRation: TScRationRecord;
- BillsRec: TScBillsRecord;
- RationIDsArray: TRationIDsArray;
- RCountPriceIDsArray: TRationIDsArray;
- lstRations: TList;
- begin
- Screen.Cursor := crHourGlass;
- try
- lstBillsID := TList.Create;
- lstRations := TList.Create;
- Tree := stdRations2.IDTree;
- Tree.AutoCreateKeyID := False;
- Tree.DeleteAll;
- // 通过工料机ID获取定额的ID数组
- RationIDsArray := FProject.GLJ.GetRationIDsByGLJID(AGLJID);
- // 通过工料机ID获取数量单价的ID数组
- RCountPriceIDsArray := FProject.Rations.GetCountPriceIDsByGLJID(AGLJID);
- // 合并为一个数组
- iLength := Length(RationIDsArray);
- SetLength(RationIDsArray, iLength + Length(RCountPriceIDsArray));
- CopyMemory(@RationIDsArray[iLength], @RCountPriceIDsArray[0], Length(RCountPriceIDsArray));
- // 缓存清单ID
- for I := Low(RationIDsArray) to High(RationIDsArray) do
- begin
- sdRation := FProject.Rations.FindRation(RationIDsArray[I]);
- lstRations.Add(sdRation);
- lstBillsID.Add(Pointer(sdRation.BillsItemID.AsInteger));
- end;
- // 遍历定额
- for I := 0 to lstRations.Count - 1 do
- begin
- sdRation := TScRationRecord(lstRations[I]);
- if sdRation.FTItemFlag.AsInteger = 1 then Continue;
- // 添加所有清单父项
- ParentNode := AddParents(sdRation.BillsItemID.AsInteger);
- Node := Tree.Add(10000000 + sdRation.ID.AsInteger, ParentNode.ID, -1, True);
- Rec := Node.Rec;
- try
- Rec.ValueByName(SCode).AsString := sdRation.Code.AsString;
- Rec.ValueByName(SName).AsString := sdRation.Name.AsString;
- Rec.ValueByName(SBillsItemID).AsInteger := sdRation.BillsItemID.AsInteger;
- Rec.ValueByName(SUnitPrice).AsCurrency := sdRation.BuildingUnitPrice.AsCurrency;
- Rec.ValueByName('IsRation').AsBoolean := True;
- Rec.ValueByName(SRationID).AsInteger := sdRation.ID.AsInteger;
- Rec.ValueByName(SSerialNo).AsInteger := sdRation.SerialNo.AsInteger;
- finally
- Rec.EndUpdate;
- end;
- end;
- ResortRations(Tree.FirstNode);
- finally
- Screen.Cursor := crDefault;
- lstBillsID.Free;
- lstRations.Free;
- end;
- end;
- procedure TfrmSearchAndReplace.zgRationsShowHint(var HintStr: String;
- var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
- var
- iActiveRec: Integer;
- sHint: string;
- begin
- iActiveRec := ACoord.Y - zgRations.FixedRowCount;
- begin
- if ACoord.X = 1 then
- sHint := '双击定位';
- CanShow := True;
- HintInfo.HintMaxWidth := 300;
- HintStr := sHint;
- end;
- if RADM = nil then
- Exit;
- if zdRations.ChangeActiveRecord(iActiveRec, iActiveRec) then
- try
- if ACoord.X = 2 then
- begin
- if zdRations.DataSet.FieldByName('Type').AsInteger = 0 then
- sHint := FRADM.LookupRationGLJ(zdRations.DataSet.FieldByName('Code').AsString)
- // 数量单价类
- else
- sHint := '数量单价类';
- HintInfo.HideTimeout := 30000;
- if sHint <> '' then
- begin
- CanShow := True;
- HintInfo.HintMaxWidth := 300;
- HintStr := sHint;
- end;
- end;
- finally
- zdRations.ChangeActiveRecord(iActiveRec, iActiveRec);
- end;
- end;
- procedure TfrmSearchAndReplace.zgRations2ShowHint(var HintStr: String;
- var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
- var
- iActiveRec: Integer;
- sHint: string;
- Node: TsdIDTreeNode;
- begin
- iActiveRec := ACoord.Y - zgRations2.FixedRowCount;
- begin
- if ACoord.X = 1 then
- sHint := '双击定位';
- CanShow := True;
- HintInfo.HintMaxWidth := 300;
- HintStr := sHint;
- end;
- if RADM = nil then
- Exit;
- Node := stdRations2.IDTree.Items[iActiveRec];
- if Node <> nil then
- if ACoord.X = 2 then
- begin
- // Modified by GiLi 2012-3-15 19:14:48
- // 犹豫数量单价的定额号不是标准的定额编号,而是等于工料机的编号
- // 所以,Hint不能用原来的,不然会弹出提示框“定额号需大于或等于8位数字。请重新输入”
- if Node.Rec.ValueByName('IsRation').AsBoolean then
- begin
- if 0 <> CompareText(cdsGLJCode.AsString, Node.Rec.ValueByName(SCode).AsString) then
- begin
- sHint := FRADM.LookupRationGLJ(Node.Rec.ValueByName(SCode).AsString);
- HintInfo.HideTimeout := 30000;
- if sHint <> '' then
- begin
- CanShow := True;
- HintInfo.HintMaxWidth := 300;
- HintStr := sHint;
- end;
- end
- else
- begin
- // Modified by GiLi 2012-3-15 19:41:29
- HintStr := '编号: ' + cdsGLJCode.AsString + #13#10 + '名称: ' + cdsGLJName.AsString + #13#10
- + '规格: ' + cdsGLJSpecs.AsString + #13#10 + '单位: ' + cdsGLJUnit.AsString + #13#10
- + '单价: ' + FloatToStr(ScRoundTo(cdsGLJBudgetPrice.AsFloat, -2));
- end;
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.SearchBillsByB_Code(AValue: String);
- var
- vItem: TScBillsItem;
- SNo2, i: Integer;
- procedure addBill;
- begin
- cdsBills.Append;
- if vItem.Rec.SerialNo.AsInteger > SNo2 then
- cdsBillsIsME.AsBoolean := True
- else
- cdsBillsIsME.AsBoolean := False;
- with vItem.Rec do
- begin
- cdsBillsSerialNo.AsVariant := SerialNo.AsVariant;
- cdsBillsID.AsInteger := ID.AsInteger;
- cdsBillsB_Code.AsVariant := B_Code.AsVariant;
- cdsBillsName.AsVariant := Name.AsVariant;
- cdsBillsQuantity.AsVariant := Quantity.AsVariant;
- cdsBillsUnitPrice.AsVariant := UnitPrice.AsVariant;
- cdsBillsTotalPrice.AsVariant := TotalPrice.AsVariant;
- end;
- {// Chenshilong, 2010-3-28 12:31:25
- 以下这段严重影响效率,先屏蔽。
- while (vBillItem <> nil) and (vBillItem.Code = '') do
- vBillItem := TScBillsItem(vBillItem.Parent);
- if vBillItem <> nil then
- cdsBills2Code.AsString := vBillItem.Code; }
- cdsBills.Post;
- end;
- begin
- SNo2 := TScBillsItem(FProject.Bills.BillsTree[2]).Rec.SerialNo.AsInteger;
- for i := 0 to FProject.Bills.BillsTree.Count - 1 do
- begin
- vItem := FProject.Bills.BillsTree.Items[i];
- if vItem.B_Code <> '' then
- begin
- if ((AValue = '') or (Pos(AValue, vItem.B_Code) = 1))
- and (vItem.Rec.IsLeaf.AsBoolean = True) then
- addBill;
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.DoOnBillsScroll(DataSet: TDataSet);
- begin
- if FProject.IsGuangDong then
- begin
- if not chkLocateFirstAppear.Checked then Exit;
- if FBillsTree.Selected = nil then Exit;
- if TScBillsItem(FBillsTree.Selected).B_Code <> '' then
- cdsBills.Locate('B_Code', TScBillsItem(FBillsTree.Selected).B_Code, []);
- end;
- end;
- procedure TfrmSearchAndReplace.btnSearchRationClick(Sender: TObject);
- begin
- cdsRations.EmptyDataSet;
- if rbRationName.Checked then
- SearchRations(Trim(edtSearch.Text), skName)
- else if rbRationCode.Checked then
- SearchRations(Trim(edtSearch.Text), skCode);
- end;
- procedure TfrmSearchAndReplace.edtSearchKeyDown(Sender: TObject;
- var Key: Word; Shift: TShiftState);
- begin
- if key = VK_Return then
- btnSearch.Click;
- end;
- procedure TfrmSearchAndReplace.btnSearchClick(Sender: TObject);
- begin
- SearchRecords(Trim(edtSearch.Text));
- end;
- procedure TfrmSearchAndReplace.SearchGLJs(AValue: String;
- ASearchKind: TSearchKind);
- var
- I: Integer;
- Rec: TScProjectGLJRecord;
- sFiledValue: string;
- evt: TDataSetNotifyEvent;
- begin
- evt := cdsGLJ.AfterScroll;
- cdsGLJ.AfterScroll := nil;
- cdsGLJ.DisableControls;
- Screen.Cursor := crHourGlass;
- try
- for I := 0 to FProject.ProjectGLJ.sdsProjectGLJ.RecordCount - 1 do
- begin
- Rec := FProject.ProjectGLJ.GLJ[I];
- case ASearchKind of
- skCode: sFiledValue := Rec.Code.AsString;
- skName: sFiledValue := Rec.Name.AsString;
- end;
- if (AValue = '') or (Pos(AValue, sFiledValue) > 0) then
- begin
- cdsGLJ.Append;
- cdsGLJCode.AsString := Rec.Code.AsString;
- cdsGLJName.AsString := Rec.Name.AsString;
- cdsGLJID.AsInteger := Rec.ID.AsInteger;
- cdsGLJLibID.AsInteger := Rec.LibID.AsInteger;
- cdsGLJUnit.AsString := ConvertUnitStr(Rec.Units.AsString);
- cdsGLJSpecs.AsString := Rec.Specs.AsString;
- cdsGLJBudgetPrice.AsFloat:= Rec.BudgetPrice.AsFloat;
- cdsGLJ.Post;
- end;
- end;
- cdsGLJ.First;
- if (not cdsGLJ.Active) or (cdsGLJ.RecordCount < 1) then
- begin
- stdRations2.IDTree.DeleteAll;
- Exit;
- end;
- SearchRationsByGLJ(cdsGLJID.AsInteger);
- finally
- cdsGLJ.AfterScroll := evt;
- cdsGLJ.EnableControls;
- Screen.Cursor := crDefault;
- end;
- end;
- procedure TfrmSearchAndReplace.zgBillsShowHint(var HintStr: String;
- var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
- var i: Integer;
- begin
- if FProject.IsGuangDong then
- i := 2
- else
- i := 1;
-
- if ACoord.x = i then
- begin
- CanShow := True;
- HintInfo.HintMaxWidth := 300;
- HintStr := '双击定位';
- end;
- end;
- procedure TfrmSearchAndReplace.cdsGLJAfterScroll(DataSet: TDataSet);
- begin
- if not cdsGLJ.Active then Exit;
- if cdsGLJ.RecordCount < 1 then Exit;
- sdsRations2.DeleteAll;
- SearchRationsByGLJ(cdsGLJID.AsInteger);
- end;
- procedure TfrmSearchAndReplace.SetProject(const Value: TScProject);
- begin
- FProject := Value;
- FRADM.InitData(FProject.RationLibs);
- Init(Value);
- end;
- procedure TfrmSearchAndReplace.RadioButtonCheck;
- begin
- if rbBillB_Code.Checked then
- begin
- pcSAndR.ActivePage := PageBill;
- ReplaceEnable(False);
- AboveAverageEnable(True);
- end
- else if rbBillCode.Checked then
- begin
- pcSAndR.ActivePage := PageBill;
- ReplaceEnable(False);
- AboveAverageEnable(True);
- end
- else if rbBillName.Checked then
- begin
- pcSAndR.ActivePage := PageBill;
- // ReplaceEnable(True);
- if FProject.IsGuangDong then
- // AboveAverageEnable(False)
- AboveAverageEnable(True)
- else
- if FProject.ProjType = ptBudget then
- AboveAverageEnable(True);
- end
- else if rbRationCode.Checked then
- begin
- pcSAndR.ActivePage := PageRation;
- ReplaceEnable(False);
- AboveAverageEnable(False);
- end
- else if rbRationName.Checked or rbCountPrice.Checked or rbDevices.Checked then
- begin
- pcSAndR.ActivePage := PageRation;
- // ReplaceEnable(True);
- AboveAverageEnable(False);
- end
- else if rbGLJCode.Checked then
- begin
- pcSAndR.ActivePage := PageGLJ;
- ReplaceEnable(False);
- AboveAverageEnable(False);
- end
- else if rbGLJName.Checked then
- begin
- pcSAndR.ActivePage := PageGLJ;
- ReplaceEnable(False);
- AboveAverageEnable(False);
- end
- else if rbBookmark.Checked then
- begin
- pcSAndR.ActivePage := PageBookmark;
- ReplaceEnable(False);
- AboveAverageEnable(False);
- RefreshBookmarkStr(sdvBookMark.Current);
- end;
- SearchRecords(edtSearch.Text);
- if edtSearch.CanFocus then
- edtSearch.SetFocus;
- end;
- procedure TfrmSearchAndReplace.rbBillB_CodeClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.rbBillNameClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.rbRationCodeClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.rbRationNameClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.rbGLJCodeClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.rbGLJNameClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- constructor TfrmSearchAndReplace.Create(AOwner: TComponent);
- begin
- inherited;
- FRADM := TRationAssistantDM.Create(nil);
- pnlColorSet.Visible := btnColorView.Down;
- end;
- destructor TfrmSearchAndReplace.Destroy;
- begin
- FRADM.Free;
- AggUnitPrice.Free;
- inherited;
- end;
- procedure TfrmSearchAndReplace.ReplaceEnable(AEnable: Boolean);
- begin
- pnReplace.Visible := AEnable;
- end;
- procedure TfrmSearchAndReplace.SearchRecords(SearchText: string);
- begin
- if rbBillName.Checked then
- begin
- cdsBills.EmptyDataSet;
- if Project.IsGuangDong then
- cdsBills.IndexName := 'IdxNameBCode'
- else
- cdsBills.IndexName := 'IdxName';
- SearchBills(SearchText, skName, True);
- end
- else if rbBillB_Code.Checked then
- begin
- cdsBills.EmptyDataSet;
- cdsBills.IndexName := 'IdxBCodeCode';
- SearchBills(SearchText, skB_Code);
- end
- else if rbBillCode.Checked then
- begin
- cdsBills.EmptyDataSet;
- cdsBills.IndexName := 'IdxCode';
- SearchBills(SearchText, skCode);
- end
- else if rbRationName.Checked or rbCountPrice.Checked or rbDevices.Checked then
- begin
- cdsRations.EmptyDataSet;
- SearchRations(SearchText, skName);
- end
- else if rbRationCode.Checked then
- begin
- cdsRations.EmptyDataSet;
- SearchRations(SearchText, skCode);
- end
- else if rbGLJName.Checked then
- begin
- cdsGLJ.EmptyDataSet;
- sdsRations2.DeleteAll;
- SearchGLJs(SearchText, skName);
- end
- else if rbGLJCode.Checked then
- begin
- cdsGLJ.EmptyDataSet;
- sdsRations2.DeleteAll;
- SearchGLJs(SearchText, skCode);
- end
- else if rbBookmark.Checked then
- begin
- { if SearchText = '' then
- begin
- Exit;
- end
- else }
- SearchBookmarks;
- end;
- end;
- procedure TfrmSearchAndReplace.edtAboveAverageKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not (Key in ['0'..'9', #8, #13]) then
- Key := #0;
- end;
- procedure TfrmSearchAndReplace.zgBillsCellGetColor(Sender: TObject;
- ACoord: TPoint; var AColor: TColor);
- var
- OldActiveRecd: Integer;
- dPrice, dAggValue, dPer, dPerValue: Double;
- begin
- if chkAboveAverage.Enabled and chkAboveAverage.Checked then
- begin
- if edtAboveAverage.Text = '' then Exit;
- if zdBills.ChangeActiveRecord(ACoord.Y - zgBills.FixedRowCount, OldActiveRecd)then
- begin
- { 突出显示业务:
- 当前单价Pn:P1、P2、P3....
- 平均单价P:Pn取平均价。
- 平均值V:P * x% (x是用户输入的值)
- 如果当前记录的 |(Pn - P)| > V,则标黄。
- }
- dPer := StrToFloat(edtAboveAverage.Text);
- if AggUnitPrice.Value = null then
- dAggValue := 0
- else
- dAggValue := AggUnitPrice.Value;
- dPerValue := dAggValue * (dPer / 100);
- if Project.IsBudget then
- dPrice := zdBills.DataSet.FieldByName('DesignPrice').AsFloat // 概预算
- else
- dPrice := zdBills.DataSet.FieldByName('UnitPrice').AsFloat;
- try
- if Abs(dPrice - dAggValue) > dPerValue then
- AColor := $008EFFFF;
- finally
- zdBills.ChangeActiveRecord(OldActiveRecd, OldActiveRecd);
- end;
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.edtAboveAverageExit(Sender: TObject);
- var ini: TIniFile;
- begin
- if edtAboveAverage.Modified then
- begin
- if Trim(edtAboveAverage.Text) = '' then
- begin
- ShowMessage('百分比值必须指定,不能为空!');
- edtAboveAverage.SetFocus;
- edtAboveAverage.SelectAll;
- Exit;
- end;
- try
- StrToFloat(edtAboveAverage.Text);
- except
- ShowMessage('百分比值错误,请修正!');
- edtAboveAverage.SetFocus;
- edtAboveAverage.SelectAll;
- Exit;
- end;
- ini:= TIniFile.Create(ConfigInfo.SystemIniFileName);
- try
- ini.WriteString('Options','AboveAveragePercent', edtAboveAverage.Text);
- finally
- ini.Free;
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.AboveAverageEnable(AEnable: Boolean);
- begin
- lblAboveAverage.Enabled := AEnable;
- edtAboveAverage.Enabled := AEnable;
- chkAboveAverage.Enabled := AEnable;
- end;
- procedure TfrmSearchAndReplace.rbBookmarkClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.SearchBookmarks;
- begin
- sdvBookMark.Filtered := False;
- sdvBookmark.Filtered := True;
- sdvBookmark.IndexName := 'idxSerialNo';
- //if mmBM.Visible and mmBM.CanFocus then
- // mmBM.SetFocus;
- end;
- procedure TfrmSearchAndReplace.zgBookmarkMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if ssDouble in Shift then
- LocateCurBills;
- end;
- procedure TfrmSearchAndReplace.mmBMExit(Sender: TObject);
- begin
- if mmBM.Text = sDefStr then
- begin
- Exit;
- end
- else
- begin
- if sdvBookmark.RecordCount = 0 then
- begin
- if FProject.ProjType = ptBudget then
- MessageHint(0, '无法定位,您未设置分项书签,不能设置批注!')
- else
- MessageHint(0, '无法定位,您未设置清单书签,不能设置批注!');
- mmBM.Clear;
- Exit;
- end;
- TScBillsRecord(sdvBookMark.Current).BookmarkStr.AsString := mmBM.Text;
- end;
- // if sdvBookMark.State in [dsInsert, dsEdit] then
- // cdsBookmark.Post;
- end;
- procedure TfrmSearchAndReplace.mnClearAllBMClick(Sender: TObject);
- var i: Integer;
- begin
- if Application.MessageBox('确定要删除所有书签批注吗?', '询问', MB_YESNO + MB_ICONQUESTION) = ID_No then
- Exit;
- while sdvBookMark.RecordCount > 0 do
- DeleteBookMark(TScBillsRecord(sdvBookMark.Records[0]));
- end;
- procedure TfrmSearchAndReplace.mnClearCurBMClick(Sender: TObject);
- begin
- if sdvBookMark.RecordCount = 0 then Exit;
- DeleteBookMark(TScBillsRecord(sdvBookMark.Current));
- end;
- procedure TfrmSearchAndReplace.btnSearchAllClick(Sender: TObject);
- begin
- SearchRecords('');
- end;
- procedure TfrmSearchAndReplace.FilterME(AOnlyME: Boolean);
- begin
- end;
- procedure TfrmSearchAndReplace.chkOnlyMEClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.chkAboveAverageClick(Sender: TObject);
- begin
- RadioButtonCheck;
- end;
- procedure TfrmSearchAndReplace.cdsBillsDesignQuantityGetText(
- Sender: TField; var Text: String; DisplayText: Boolean);
- begin
- if Sender.Value = 0 then
- Text := ''
- else
- Text := VarToStr(Sender.Value);
- end;
- procedure TfrmSearchAndReplace.mmBMEnter(Sender: TObject);
- begin
- if mmBM.Text = sDefStr then
- //mmBM.SelectAll;
- mmBM.Text := '';
- end;
- procedure TfrmSearchAndReplace.DeleteBookMark(ARec: TScBillsRecord);
- begin
- ARec.BeginUpdate;
- ARec.BookmarkStr.AsString := '';
- ARec.HaveBookmark.AsBoolean := False;
- ARec.BookmarkColor.AsInteger := 0;
- ARec.EndUpdate;
- end;
- procedure TfrmSearchAndReplace.zgColorCellGetColor(Sender: TObject;
- ACoord: TPoint; var AColor: TColor);
- var
- OldActiveRecd: Integer;
- vColor: TColor;
- begin
- if ACoord.X = 0 then
- begin
- if zaColor.ChangeActiveRecord(ACoord.Y - zgColor.FixedRowCount, OldActiveRecd)then
- begin
- vColor := TColor(zaColor.DataSet.FieldByName('BMColor').AsInteger);
- try
- AColor := vColor;
- finally
- zaColor.ChangeActiveRecord(OldActiveRecd, OldActiveRecd);
- end;
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.btnColorViewClick(Sender: TObject);
- begin
- pnlColorSet.Visible := btnColorView.Down;
- end;
- procedure TfrmSearchAndReplace.zgBookmarkCellGetColor(Sender: TObject;
- ACoord: TPoint; var AColor: TColor);
- var
- vRec: TsdDataRecord;
- vColor: TColor;
- begin
- // vColor := sgdBookmark.DataView.Current.ValueByName('BookMarkColor').AsInteger;
- vRec := sgdBookmark.DataView.Records[ACoord.Y - zgBookmark.FixedRowCount];
- if vRec <> nil then
- begin
- vColor := vRec.ValueByName('BookMarkColor').AsInteger;
- if vColor = 0 then // 兼容旧书签颜色
- vColor := $00CEE7FF;
- AColor := vColor;
- end;
- end;
- procedure TfrmSearchAndReplace.zgColorMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if (zgColor.CurCol = 0) and (Button = mbLeft) and (ssDouble in Shift) then
- begin
- SetDefaultColor;
- end;
- end;
- procedure TfrmSearchAndReplace.SetDefaultColor;
- var vColor: TColor;
- procedure ExecMySQL(ASQL: string);
- begin
- aqSQL.Close;
- aqSQL.SQL.Clear;
- aqSQL.SQL.Add(ASQL);
- aqSQL.ExecSQL;
- end;
- begin
- vColor := TColor(zaColor.DataSet.FieldByName('BMColor').AsInteger);
- pnlDefaultColor.Color := vColor;
- // lblDefaultColor.Font.Color := vColor;
- ExecMySQL('Update BookMarkColor set CurColor = Null');
- ExecMySQL(Format('Update BookMarkColor set CurColor = 1 where BMColor = %d', [Integer(vColor)]));
- aqBookMarkColor.Refresh;
- FProject.BookMarkColor := vColor;
- end;
- procedure TfrmSearchAndReplace.zgColorShowHint(var HintStr: String;
- var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint);
- begin
- if ACoord.X = 0 then
- begin
- HintInfo.HintStr := '双击设为默认书签颜色';
- CanShow := True;
- HintInfo.HintMaxWidth := 250;
- HintInfo.HideTimeout := 30000;
- end;
- end;
- procedure TfrmSearchAndReplace.rbAllClick(Sender: TObject);
- begin
- FilterColor;
- end;
- procedure TfrmSearchAndReplace.FilterColor;
- var vColor: Integer;
- begin
- // if rbAll.Checked then
- // begin
- // cdsBookMark.Filter := 'HaveBookmark';
- // cdsBookMark.Filtered := True;
- // end
- // else
- // begin
- // vColor := aqBookMarkColorBMColor.AsInteger;
- // cdsBookMark.Filter := Format('HaveBookmark and (BookMarkColor=%d)', [vColor]);
- // cdsBookMark.Filtered := True;
- // end;
- end;
- procedure TfrmSearchAndReplace.rbOnlyCurClick(Sender: TObject);
- begin
- FilterColor;
- end;
- procedure TfrmSearchAndReplace.aqBookMarkColorAfterScroll(
- DataSet: TDataSet);
- begin
- FilterColor;
- end;
- procedure TfrmSearchAndReplace.sdvBookMarkFilterRecord(
- ARecord: TsdDataRecord; var Allow: Boolean);
- begin
- if TScBillsRecord(ARecord).HaveBookmark.AsBoolean = True then
- Allow := True
- else
- Allow := False;
- end;
- procedure TfrmSearchAndReplace.sdvBookMarkCurrentChanged(
- ARecord: TsdDataRecord);
- begin
- RefreshBookmarkStr(ARecord);
- end;
- procedure TfrmSearchAndReplace.RefreshBookmarkStr(ARecord: TsdDataRecord);
- begin
- if ARecord = nil then
- begin
- mmBM.Text := '';
- Exit;
- end;
- mmBM.Text := TScBillsRecord(ARecord).BookmarkStr.AsString;
- if mmBM.Text = '' then
- mmBM.Text := sDefStr;
- if SameText(mmBM.Text, sDefStr) then
- mmBM.Font.Color := clGrayText
- else
- mmBM.Font.Color := clWindowText;
- end;
- procedure TfrmSearchAndReplace.mmBMChange(Sender: TObject);
- begin
- if not SameText(mmBM.Text, sDefStr) then
- mmBM.Font.Color := clWindowText;
- end;
- procedure TfrmSearchAndReplace.zgCompareXMLMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- // vGridBill.CurCol := ScMainForm.ActiveChild.BillsView.stdBills.ColumnIndex('DesignQuantity')
- // 上面这种方式不行,当有字段隐藏时,定位会错位。所以这里写个方法定死。
- function GetFocusCol(AFieldName: string): Integer;
- begin
- if Project.ProjType = ptBillsBudget then
- begin
- if AFieldName = 'Quantity' then
- Result := 5
- else if AFieldName = 'DesignQuantity' then
- Result := 6
- else if AFieldName = 'DesignQuantity2' then
- Result := 7
- end
- else if Project.ProjType = ptBills then
- begin
- if AFieldName = 'Quantity' then
- Result := 4
- else
- Result := 1
- end
- else if Project.ProjType in [ptBudget, ptBudgetEstimate, ptFeasibilityEstimate, ptProposalEstimate] then
- begin
- if AFieldName = 'DesignQuantity' then
- Result := 4
- else if AFieldName = 'DesignQuantity2' then
- Result := 5
- else
- Result := 1;
- end;
- end;
- var vNode: TScBillsItem;
- vGridBill, vGridRation: TZJGrid;
- sValue: string;
- begin
- if ssDouble in Shift then
- begin
- if cdsCompareXML.RecordCount = 0 then Exit;
- vNode := FProject.Bills.BillsTree[cdsCompareXMLBillID.AsInteger];
- if vNode <> nil then
- begin
- // 先定位到清单级别
- if not vNode.Expanded then
- vNode.Expanded := True;
- vNode.LocateInControl;
- vGridBill := ScMainForm.ActiveChild.BillsView.zgBills;
- if SameText(cdsCompareXMLKind.AsString, '分项') or SameText(cdsCompareXMLKind.AsString, '清单') then
- begin
- sValue := cdsCompareXMLQuantity.AsString;
- if Pos('设一', sValue) > 0 then
- vGridBill.CurCol := GetFocusCol('DesignQuantity')
- else if Pos('设二', sValue) > 0 then
- vGridBill.CurCol := GetFocusCol('DesignQuantity2')
- else if Pos('数量', sValue) > 0 then
- vGridBill.CurCol := GetFocusCol('Quantity')
- else
- vGridBill.CurCol := 1;
- vGridBill.SetFocus;
- end
- else if SameText(cdsCompareXMLKind.AsString, '定额') then
- begin
- if cdsCompareXMLRationID.IsNull then
- MessageHint(0, '定额已被删除,无法定位。当前定位到删除前所在的清单。')
- else
- begin
- FProject.Rations.LocateRation(cdsCompareXMLRationID.AsInteger);
- vGridBill.CurCol := 1;
- vGridRation := ScMainForm.ActiveChild.BillsSubItemView.zgRations;
- vGridRation.CurCol := 6;
- ScMainForm.ActiveChild.BillsSubItemView.PageControl.ActivePageIndex := 0;
- vGridRation.SetFocus;
- end;
- end
- else if SameText(cdsCompareXMLKind.AsString, '图纸') then
- begin
- FProject.Bills.DrawingQuantityDM.LocateDrawQty(cdsCompareXMLBillID.AsInteger, cdsCompareXMLDrawQtyID.AsInteger);
- end;
- end
- else
- begin
- MessageHint(0, '清单已被删除,无法定位。');
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.zgCompareXMLCellGetFont(Sender: TObject;
- ACoord: TPoint; AFont: TFont);
- var
- OldActiveRecd: Integer;
- sValue: string;
- begin
- if zaCompareXML.ChangeActiveRecord(ACoord.Y - zgCompareXML.FixedRowCount, OldActiveRecd)then
- begin
- sValue := zaCompareXML.DataSet.FieldByName('Operate').AsString;
- try
- if (sValue = '增加') then
- AFont.Color := clBlue
- else if (sValue = '删除') then
- AFont.Color := $006060FF;
- finally
- zaCompareXML.ChangeActiveRecord(OldActiveRecd, OldActiveRecd);
- end;
- end;
- end;
- procedure TfrmSearchAndReplace.rbCompareXMLClick(Sender: TObject);
- begin
- pcSAndR.ActivePage := PageCompareXML;
- end;
- procedure TfrmSearchAndReplace.CompareFromXML;
- var
- vPort: TtzslXMLPort;
- vODlg: TOpenDialog;
- sPath, sFile: string;
- begin
- rbCompareXML.Checked := True;
- vODlg := TOpenDialog.Create(nil);
- vODlg.Title := '算量对比';
- vODlg.Filter := '算量对比XML文件(*.XML)|*.XML';
- try
- if vODlg.Execute then
- begin
- vPort := TtzslXMLPort.Create;
- try
- vPort.Project := FProject;
- vPort.XMLFile := vODlg.FileName;
- edtFile.Text := vODlg.FileName;
- vPort.CompareFromXML(cdsCompareXML);
- finally
- vPort.Free;
- end;
- end
- else
- Exit;
- finally
- vODlg.Free;
- end;
- end;
- procedure TfrmSearchAndReplace.Search(SearchText: string;
- AType: TSearchType);
- begin
- edtSearch.Text := SearchText;
- case AType of
- stBilsCode:
- rbBillCode.Checked := True;
- stBillsName:
- rbBillName.Checked := True;
- stRationCode:
- rbRationCode.Checked := True;
- stRationName:
- rbRationName.Checked := True;
- stCountPrice:
- rbCountPrice.Checked := True;
- stDevice:
- rbDevices.Checked := True;
- stGLJCode:
- rbGLJCode.Checked := True;
- stGLJName:
- rbGLJName.Checked := True;
- stBookmark:
- rbBookmark.Checked := True;
- stCompareXML:
- begin
- rbCompareXML.Checked := True;
- pcSAndR.ActivePage := PageCompareXML;
- Exit;
- end;
- end;
- RadioButtonCheck;
- LocateCurBills;
- zgRations2.SetFocus;
- end;
- procedure TfrmSearchAndReplace.zgRations2CellGetColor(Sender: TObject;
- ACoord: TPoint; var AColor: TColor);
- var
- Node: TsdIDTreeNode;
- begin
- Node := stdRations2.IDTree.Items[ACoord.Y - zgRations2.FixedRowCount];
- if Node <> nil then
- begin
- if Node.Rec.ValueByName('IsRation').AsBoolean then
- AColor := clWhite
- else
- AColor := $00F0F0F0;
- end;
- end;
- end.
|