From fa72f2444219a69ce89e87acedcab6cfafc4be09 Mon Sep 17 00:00:00 2001 From: sgwp <63001967@qq.com> Date: Tue, 12 Nov 2024 11:05:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0InitAdoData=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9InitCDSData=20=E6=96=B9=E6=B3=95=EF=BC=8C=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E6=A1=86=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public10/ThreeFun/Fun/U_RTFun.pas | 85 +++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/public10/ThreeFun/Fun/U_RTFun.pas b/public10/ThreeFun/Fun/U_RTFun.pas index 24fc213..e50b2dd 100644 --- a/public10/ThreeFun/Fun/U_RTFun.pas +++ b/public10/ThreeFun/Fun/U_RTFun.pas @@ -218,6 +218,7 @@ procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Int procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer); function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string; +procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string); // **************** ʦүдµÄ *****************// type @@ -2178,34 +2179,66 @@ procedure InitCDSData(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTable var MarkStrValue: string; begin - if trim(MarkStr) <> '' then - begin - if not CDS1.IsEmpty then - MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString); + try + + Tv1.BeginUpdate() ; + if trim(MarkStr) <> '' then + begin + if not CDS1.IsEmpty then + MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString); + end; + + with ADO1 do + begin + Close; + SQL.Clear; + sql.Add(SqlStr); + Open; + end; + + if trim(FilterStr) <> '' then + SDofilter(ADO1, FilterStr); + + SCreateCDS(ADO1, CDS1); + SInitCDSData(ADO1, CDS1); + + Tv1.DataController.Filter.Refresh; + + if trim(MarkStr) <> '' then + CDS1.Locate(MarkStr, MarkStrValue, []); + finally + tv1.EndUpdate; + end; +end; +////////////////////////////////////// +procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string); +var + MarkStrValue: string; +begin + try + Tv1.BeginUpdate(); + if trim(MarkStr) <> '' then + begin + if not ADO1.IsEmpty then + MarkStrValue := TRIM(ADO1.FieldByName(MarkStr).AsString); + end; + with ADO1 do + begin + Close; + SQL.Clear; + Filtered := false; + sql.Add(SqlStr); + Open; + end; + if trim(FilterStr) <> '' then + SDofilter(ADO1, FilterStr); + Tv1.DataController.Filter.Refresh; + if trim(MarkStr) <> '' then + ADO1.Locate(MarkStr, MarkStrValue, []); + finally + Tv1.EndUpdate(); end; - - with ADO1 do - begin - Close; - SQL.Clear; - Filtered := false; - sql.Add(SqlStr); -// ShowMessage(sql.text); - Open; - end; - - if trim(FilterStr) <> '' then - SDofilter(ADO1, FilterStr); - - SCreateCDS(ADO1, CDS1); - SInitCDSData(ADO1, CDS1); - - Tv1.DataController.Filter.Refresh; - - if trim(MarkStr) <> '' then - CDS1.Locate(MarkStr, MarkStrValue, []); end; - procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string); begin with ADOQueryTmp do