From 30266185db44169c07d418ed80dfb732fa5cc27e Mon Sep 17 00:00:00 2001 From: sgwp <63001967@qq.com> Date: Sat, 22 Feb 2025 17:32:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dp10RepoV1/public10/ThreeFun/Fun/U_RTFun.pas | 1510 ++++++----------- 1 file changed, 566 insertions(+), 944 deletions(-) diff --git a/Delphi10/开发档案/Dp10RepoV1/public10/ThreeFun/Fun/U_RTFun.pas b/Delphi10/开发档案/Dp10RepoV1/public10/ThreeFun/Fun/U_RTFun.pas index 8bf1c45..8dde1c3 100644 --- a/Delphi10/开发档案/Dp10RepoV1/public10/ThreeFun/Fun/U_RTFun.pas +++ b/Delphi10/开发档案/Dp10RepoV1/public10/ThreeFun/Fun/U_RTFun.pas @@ -8,11 +8,11 @@ uses cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB, cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB, StrUtils, Midas, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxTimeEdit, - cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit, + cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,dxLayoutContainer, cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox, cxDropDownEdit, cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit, - IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit, FireDAC.Comp.Client, cxCheckBox, - Vcl.Clipbrd, cxMemo, dxLayoutControl,uSZHN_JSON, System.JSON; + IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit, FireDAC.Comp.Client, + Vcl.Clipbrd, cxMemo,dxLayoutControl; type TA = class(TComponent) @@ -20,20 +20,23 @@ type S: string; end; -procedure pasteDatatTocxGrid(Tv1:TcxGridDBTableView); -function Split(const s: string; Separator: char): TStringDynArray; // DLLļ procedure InitDllEvt(FromFile: string; FormID: Integer; Para: string; FormType: Integer; Title: string; Def1: string; Def2: string; Def3: string; Def4: string; Def5: string; Def6: string; Def7: string; Def8: string; Def9: string; Def10: string); // ȡ function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean; +function GetLSNo20(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean; procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime); function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime; // ȡ function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime; // ȡʱ +function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string; +procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer); +procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer); +procedure addAdoSelField(SADOQry: TADOQuery;mSelFieldName:string='Ssel'); {ȡָλС} function RoundFloat(f: double; i: Integer): double; @@ -52,6 +55,7 @@ function RoundFloat(f: double; i: Integer): double; {ִй }procedure SDofilter(ADOQry: TADOQuery; FilterStr: string); {CDS }procedure SCreateCDS(SADOQry: TADOQuery; mClientDataset: TclientDataSet); {CDSֵ }procedure SInitCDSData(fromADO: TADOQuery; toCDS: TclientDataSet); +procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string); {ռˢ }procedure InitCDSData(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string); ////////////////////////////////////////////////////////////////////////////////////////// @@ -68,15 +72,7 @@ procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFla procedure SInitComBoxBySql(ADOQueryTmp: TADOQuery; cb: TComboBox; emptyFlag: Boolean; mSql: string); // TcxGriddbColumnеTComboBoxֵ -procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string); - -// TcxGriddbColumnеTComboBoxֵ procedure SInitCxGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string); - -// TcxGriddbColumnеTComboBoxֵ V2 -procedure SInitCxGridComboBoxBySqlV2(ADOQueryTmp: TADOQuery; Tv1: TcxGridDBTableView; FieldName: string; mSql: string); - - // TcxGridDBBandedColumnеTComboBoxֵ procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string); @@ -187,17 +183,6 @@ procedure SelOKNo(CDS_MainSel: TclientDataSet; FSel: Boolean); // ȫѡ/ȫ procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean); // Tv1ȫѡ/ȫ -function isCanDataDelete(mFillerId:string='';mfiller:string=''):boolean; -function isCanDataEdit(mFillerId:string='';mfiller:string=''):boolean; - -//¹˷ -function CommonFiltersByContainer(TMControl: TControl; JsonArgs: string): string; - -function CommonFiltersByTv(Tv1: TcxGridDBTableView; JsonArgs: string): string; - -function CommonGetSingleFilter(MyControl: TControl; EquTag, LikeTag, FieldTag: Integer; MFields: TStringList): string; - - procedure SelTVToCDS(Tv1: TcxGridDBTableView; CDS1: TclientDataSet; KeyId: string); // ͨKeyIdTv1ѡӳ䵽CDS1 function SelCDSKey(CDS_1: TclientDataSet; Keys: TArray): TArray; // ѡkey @@ -208,7 +193,11 @@ procedure HiddenTVColumn(Tv1: TcxGridDBTableView; FieldName: string); // procedure CopyTVFocusValue(Tv1: TcxGridDBTableView); // TV -function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery):Variant; + //Ƿɾݼ¼ +function isCanDataDelete(mFillerId:string='';mfiller:string=''):boolean; +function isCanDataEdit(mFillerId:string='';mfiller:string=''):boolean; +procedure raiseException(msg:string); //׳쳣 + // **************** ҳ *****************// procedure GetHTTP(FUrl: string); @@ -225,18 +214,12 @@ function WriteCloseWin(AdoCmd: TADOQuery; mCaption: string; FormID: Integer; mDl procedure selectDataRow(Sender: TcxCustomGridTableView; mKeyField: string); // ʦүдTv1ӡcds -procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer); +function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery):Variant; -procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer); +function Split(const s: string; Separator: char): TStringDynArray; -function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string; - -procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string); - -{ռ }procedure CDSDataFilter(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTableView; JsonArgs: string); overload; -{ռ }procedure CDSDataFilter(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBBandedTableView; JsonArgs: string); overload // **************** ʦүд *****************// - + procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string); type TMyF = function(App: TApplication; // Ӧó (Delphi) FormH: HWND; // ڵĸھ (PB) @@ -254,146 +237,7 @@ var implementation uses - U_DataLink, U_globalVar; - - - /// ///////////////////////////////////////// -/// /************ȡ***********///// -/// ///////////////////////////////////////// -function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string; -var - i, j, k: Integer; - fsj, fsj1: string; -begin - Result := ''; - with layoutControl do - begin - for i := 0 to ControlCount - 1 do - begin - if Controls[i] is TLabel or (Controls[i].Tag = 99) then - continue; - if Controls[i] is TEdit then - begin - if Trim(TEdit(Controls[i]).Text) <> '' then - begin - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TEdit(Controls[i]).Text)) - else if Controls[i].Tag = LikeTag then - begin - j := Pos(' ', Trim(TEdit(Controls[i]).Text)); - if j > 0 then - begin - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Copy(Trim(TEdit(Controls[i]).Text), 1, j - 1) + '%'); - fsj1 := Copy(Trim(TEdit(Controls[i]).Text), j + 1, Length(Trim(TEdit(Controls[i]).Text))); - while Trim(fsj1) <> '' do - begin - j := Pos(' ', Trim(fsj1)); - if j > 0 then - begin - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Copy(Trim(fsj1), 1, j - 1) + '%'); - fsj1 := Copy(Trim(fsj1), j + 1, Length(Trim(fsj1))); - end - else - begin - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(fsj1) + '%'); - fsj1 := ''; - end; - end; - end - else - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%'); - end; - end; - end - else if Controls[i] is TcxTextEdit then - begin - if Trim(TcxTextEdit(Controls[i]).Text) <> '' then - begin - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TcxTextEdit(Controls[i]).Text)) - else if Controls[i].Tag = LikeTag then - begin - j := Pos(' ', Trim(TcxTextEdit(Controls[i]).Text)); - if j > 0 then - begin - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Copy(Trim(TcxTextEdit(Controls[i]).Text), 1, j - 1) + '%'); - fsj1 := Copy(Trim(TcxTextEdit(Controls[i]).Text), j + 1, Length(Trim(TcxTextEdit(Controls[i]).Text))); - while Trim(fsj1) <> '' do - begin - j := Pos(' ', Trim(fsj1)); - if j > 0 then - begin - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Copy(Trim(fsj1), 1, j - 1) + '%'); - fsj1 := Copy(Trim(fsj1), j + 1, Length(Trim(fsj1))); - end - else - begin - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(fsj1) + '%'); - fsj1 := ''; - end; - end; - end - else - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TcxTextEdit(Controls[i]).Text) + '%'); - end; - end; - end - else if Controls[i] is TBtnEditA then - begin - if Trim(TBtnEditA(Controls[i]).Text) <> '' then - begin - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TBtnEditA(Controls[i]).TxtCode)) - else if Controls[i].Tag = LikeTag then - Result := Result + 'and ' + Controls[i].Name + 'Name' + ' like ' + quotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%') - else if Controls[i].Tag = 99 then - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr(Trim(TBtnEditA(Controls[i]).TxtCode) + '%'); - end; - end - else if Controls[i] is TBtnEditC then - begin - if Trim(TBtnEditC(Controls[i]).TxtCode) <> '' then - begin - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TBtnEditC(Controls[i]).TxtCode)) - else if Controls[i].Tag = LikeTag then - Result := Result + 'and ' + Controls[i].Name + 'Name' + ' like ' + quotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%'); - end; - end - else if Controls[i] is TRTComboBox then - begin - if Trim(TRTComboBox(Controls[i]).Text) <> '' then - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TRTComboBox(Controls[i]).Item2)) - else if Controls[i].Tag = LikeTag then - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TRTComboBox(Controls[i]).Item2) + '%'); - end - else if Controls[i] is TComboBox then - begin - if Trim(TComboBox(Controls[i]).Text) <> '' then - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TComboBox(Controls[i]).Text)) - else if Controls[i].Tag = LikeTag then - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TComboBox(Controls[i]).Text) + '%'); - end - else if Controls[i] is TcxComboBox then - begin - if Trim(TcxComboBox(Controls[i]).Text) <> '' then - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TcxComboBox(Controls[i]).Text)) - else if Controls[i].Tag = LikeTag then - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TcxComboBox(Controls[i]).Text) + '%'); - end; - end; - end; - if Trim(Result) <> '' then - Result := Trim(RightStr(Result, Length(Result) - 4)); -end; - - -/// ///////////////////////////////////////////////////////// -// ù˺ -/// ///////////////////////////////////////////////////////// + U_DataLink,U_globalVar; function ExportToFtErp(mFileName: string; ADOQueryCmd: TADOQuery): boolean; var @@ -498,10 +342,9 @@ begin begin for i := 0 to MTV.ColumnCount - 1 do begin - if UpperCase(Trim(TEdit(TMPanel.Controls[j]).Name)) = UpperCase(Trim(MTV.Columns[i].DataBinding.FieldName)) then + if Trim(TEdit(TMPanel.Controls[j]).Name) = Trim(MTV.Columns[i].DataBinding.FieldName) then begin MTV.Columns[i].Visible := IsVisible; - MTV.Columns[i].Hidden := not IsVisible; Continue; end; end; @@ -516,54 +359,15 @@ begin begin for i := 0 to MTV.ColumnCount - 1 do begin - if UpperCase(Trim(TComboBox(TMPanel.Controls[j]).Name)) = UpperCase(Trim(MTV.Columns[i].DataBinding.FieldName)) then + if Trim(TComboBox(TMPanel.Controls[j]).Name) = Trim(MTV.Columns[i].DataBinding.FieldName) then begin MTV.Columns[i].Visible := IsVisible; - MTV.Columns[i].Hidden := not IsVisible; Continue; end; end; end; end; end; - - if TMPanel.Controls[j] is TcxTextEdit then - begin - if Trim(TcxTextEdit(TMPanel.Controls[j]).Hint) = Hintvalue then - begin - with MTV do - begin - for i := 0 to MTV.ColumnCount - 1 do - begin - if UpperCase(Trim(TcxTextEdit(TMPanel.Controls[j]).Name)) = UpperCase(Trim(MTV.Columns[i].DataBinding.FieldName)) then - begin - MTV.Columns[i].Visible := IsVisible; - MTV.Columns[i].Hidden := not IsVisible; - Continue; - end; - end; - end; - end; - end; - if TMPanel.Controls[j] is TcxComboBox then - begin - if Trim(TcxComboBox(TMPanel.Controls[j]).Hint) = Hintvalue then - begin - with MTV do - begin - for i := 0 to MTV.ColumnCount - 1 do - begin - if UpperCase(Trim(TcxComboBox(TMPanel.Controls[j]).Name)) = UpperCase(Trim(MTV.Columns[i].DataBinding.FieldName)) then - begin - MTV.Columns[i].Visible := IsVisible; - MTV.Columns[i].Hidden := not IsVisible; - Continue; - end; - end; - end; - end; - end; - end; end; end; @@ -589,27 +393,13 @@ begin TEdit(Controls[i]).Text := Trim(TMClientDataset.FieldByName(TEdit(Controls[i]).Name).AsString); end; end; - if Controls[i] is TcxTextEdit then - begin - if Trim(TcxTextEdit(Controls[i]).Hint) = Hintvalue then - begin - TcxTextEdit(Controls[i]).Text := Trim(TMClientDataset.FieldByName(TcxTextEdit(Controls[i]).Name).AsString); - end; - end; if Controls[i] is TComboBox then begin - if Trim(TComboBox(Controls[i]).Hint) = Hintvalue then + if Trim(TEdit(Controls[i]).Hint) = Hintvalue then begin TComboBox(Controls[i]).ItemIndex := TComboBox(Controls[i]).Items.IndexOf(Trim(TMClientDataset.FieldByName(TComboBox(Controls[i]).Name).AsString)); end; end; - if Controls[i] is TcxComboBox then - begin - if Trim(TcxComboBox(Controls[i]).Hint) = Hintvalue then - begin - TcxComboBox(Controls[i]).ItemIndex := TcxComboBox(Controls[i]).Properties.Items.IndexOf(Trim(TMClientDataset.FieldByName(TcxComboBox(Controls[i]).Name).AsString)); - end; - end; end; end; end; @@ -668,54 +458,6 @@ begin TEdit(Controls[i]).Text := ''; end; end; - if Controls[i] is TcxCheckBox then - begin - if TcxCheckBox(Controls[i]).Hint = HintValue then - begin - TcxCheckBox(Controls[i]).Visible := IsHide; - if IsClear then - TcxCheckBox(Controls[i]).Checked := False; - end; - end; - - if Controls[i] is TLabel then - begin - if TLabel(Controls[i]).Hint = HintValue then - begin - TLabel(Controls[i]).Visible := IsHide; - end; - end; - - if Controls[i] is TcxComboBox then - begin - if TcxComboBox(Controls[i]).Hint = HintValue then - begin - TcxComboBox(Controls[i]).Visible := IsHide; - if IsClear then - TcxComboBox(Controls[i]).ItemIndex := -1; - end; - end; - - if Controls[i] is TcxTextEdit then - begin - if Trim(TcxTextEdit(Controls[i]).Hint) = HintValue then - begin - TcxTextEdit(Controls[i]).Visible := IsHide; - if IsClear then - TcxTextEdit(Controls[i]).Text := ''; - end; - end; - - if Controls[i] is TcxButtonEdit then - begin - if Trim(TcxButtonEdit(Controls[i]).Hint) = HintValue then - begin - TcxButtonEdit(Controls[i]).Visible := IsHide; - if IsClear then - TcxButtonEdit(Controls[i]).Text := ''; - end; - end; - end; end; end; @@ -865,17 +607,19 @@ end; function WriteCloseWin(AdoCmd: TADOQuery; mCaption: string; FormID: Integer; mDllName: string): Boolean; begin - Result := false; + Result := true; + exit; try DServerDate := SGetServerDateTime(AdoCmd); with AdoCmd do begin close; sql.Clear; - sql.Add('select *'); + sql.Add('select top 1 *'); sql.Add('from SY_CloseFormInfo'); sql.Add('where UserId=' + quotedStr(DCode)); sql.Add('and formCaption=' + quotedStr(mCaption)); + sql.Add('order by filltime desc'); Open; if Recordcount > 0 then @@ -1001,7 +745,142 @@ begin else if Controls[i] is TcxDateEdit then begin if not isEmpty and not fieldByName(mfield).IsNull then - TcxDateEdit(Controls[i]).date := fieldByName(mfield).AsDateTime; + TcxDateEdit(Controls[i]).Date := fieldByName(mfield).AsDateTime; + end + else if Controls[i] is TcxTimeEdit then + begin + if not isEmpty and (fieldByName(mfield).AsString <> '') then + TcxTimeEdit(Controls[i]).Text := fieldByName(mfield).AsString; + end + else if Controls[i] is TcxCurrencyEdit then + begin + TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString; + end + else if Controls[i] is TcheckBox then + begin + TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean; + end + else if Controls[i] is TcxButtonEdit then + begin + TcxButtonEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); +// if TcxButtonEdit(Controls[i]).ParentShowHint = false then +// begin +// mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4)); +// TcxButtonEdit(Controls[i]).Hint := Trim(fieldByName(mfieldCode).AsString); +// end; + end; + end; // end for + end; // end with + end; // end for with + +end; + +procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer); +var + i, idx: Integer; + mfield, mfieldCode: string; + ma: TA; +begin + with ADOQueryTmp do + begin + if isEmpty then + exit; + with mParent do + begin + for i := 0 to ControlCount - 1 do + begin + if Controls[i] is TLabel then + continue; + if Controls[i].Tag <> FTag then + continue; + mfield := Controls[i].Name; + + //////////////////////// + if Controls[i] is TcxTextEdit then + begin + if Trim(fieldByName(mfield).AsString) <> '' then + TcxTextEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); + end + else if Controls[i] is TcxComboBox then + begin + if TcxComboBox(Controls[i]).Properties.Items.Count > 0 then + begin + idx := TcxComboBox(Controls[i]).Properties.Items.IndexOf(Trim(fieldByName(mfield).AsString)); + end + else + idx := -1; + TcxComboBox(Controls[i]).ItemIndex := idx; + end + else if Controls[i] is TcxDateEdit then + begin + if not isEmpty and not fieldByName(mfield).IsNull then + TcxDateEdit(Controls[i]).date := fieldByName(mfield).AsDateTime + else + TcxDateEdit(Controls[i]).text := ''; + end + else if Controls[i] is Tcxmemo then + begin + Tcxmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString); + end +// else if Controls[i] is TRTComboBox then +// begin +// idx := TRTComboBox(Controls[i]).IndexOfItem2(Trim(fieldByName(mfield).AsString)); +// TComboBox(Controls[i]).ItemIndex := idx; +// end + else if Controls[i] is TRichEdit then + begin + if Trim(fieldByName(mfield).AsString) <> '' then + TRichEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); + end + else if Controls[i] is TcxRichEdit then + begin + if Trim(fieldByName(mfield).AsString) <> '' then + TcxRichEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); + end + else if Controls[i] is TComboBox then + begin + if TComboBox(Controls[i]).Items.Count > 0 then + begin + idx := TComboBox(Controls[i]).Items.IndexOf(Trim(fieldByName(mfield).AsString)); + end + else + idx := -1; + TComboBox(Controls[i]).ItemIndex := idx; + end + else if Controls[i] is TEdit then + begin + if Trim(fieldByName(mfield).AsString) <> '' then + TEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); + end + else if Controls[i] is TBtnEditA then + begin + if Trim(TBtnEditA(Controls[i]).Hint) <> '' then + begin + TBtnEditA(TBtnEditA(Controls[i])).TxtCode := Trim(fieldByName(mfield).AsString); + TBtnEditA(Controls[i]).Text := Trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString); + end + else + begin + TBtnEditA(Controls[i]).Text := Trim(fieldByName(mfield).AsString); + end; + + end + else if Controls[i] is TBtnEditC then + begin + TBtnEditC(TBtnEditA(Controls[i])).Text := Trim(fieldByName(mfield).AsString); + end + else if Controls[i] is TDateTimePicker then + begin + if Trim(fieldByName(mfield).AsString) = '' then + begin + TDateTimePicker(Controls[i]).Checked := false; + end + else + TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime; + end + else if Controls[i] is Tmemo then + begin + Tmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString); end else if Controls[i] is TcxTimeEdit then begin @@ -1560,14 +1439,11 @@ begin ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; end else - ADOQueryCmd.fieldByName(Controls[i].Name).Value := FormatDateTime('yyyy-MM-dd', TDateTimePicker(Controls[i]).Date); + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime; end else if Controls[i] is TcxDateEdit then begin - if trim(TcxDateEdit(Controls[i]).Text)<>'' then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxDateEdit(Controls[i]).Text - else - ADOQueryCmd.fieldByName(Controls[i].Name).Value :=null; + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxDateEdit(Controls[i]).Text; end else if Controls[i] is TcxMemo then begin @@ -1582,6 +1458,125 @@ begin end; end; + +procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer); +var + i: Integer; +begin + with Myparent do + begin + for i := 0 to ControlCount - 1 do + begin + if Controls[i].Tag = MyTag then + begin + if Controls[i] is TBtnEditA then + begin + ADOQueryCmd.fieldByName(TBtnEditA(Controls[i]).Name).Value := Trim(TBtnEditA(Controls[i]).Text); + if Trim(TBtnEditA(Controls[i]).Hint) <> '' then + begin + if Pos('/', Trim(TBtnEditA(Controls[i]).Hint)) > 0 then + continue; + ADOQueryCmd.fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode); + end; + end + else if Controls[i] is TBtnEditC then + begin + ADOQueryCmd.fieldByName(TBtnEditC(Controls[i]).Name).Value := Trim(TBtnEditC(Controls[i]).Text); + if Trim(TBtnEditC(Controls[i]).Hint) <> '' then + begin + if Pos('/', Trim(TBtnEditC(Controls[i]).Hint)) > 0 then + continue; + ADOQueryCmd.fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode); + end; + end + else if Controls[i] is TcxButtonEdit then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxButtonEdit(Controls[i]).Text) + end + else if Controls[i] is TcxCurrencyEdit then + begin + if Trim(TcxCurrencyEdit(Controls[i]).Text) = '' then + ADOQueryCmd.fieldByName(Controls[i].Name).Value := 0 + else + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxCurrencyEdit(Controls[i]).Text); + end + else if Controls[i] is TEdit then + begin + if Trim(TEdit(Controls[i]).Text) <> '' then + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text) + else + begin + if Trim(TEdit(Controls[i]).Hint) <> '' then + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Hint) + else + ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; + end; + end + else if Controls[i] is TcxTextEdit then + begin + if Trim(TcxTextEdit(Controls[i]).Text) <> '' then + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxTextEdit(Controls[i]).Text) + else + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; + end; + end + else if Controls[i] is TRichEdit then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text; + end + else if Controls[i] is Tmemo then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Tmemo(Controls[i]).Text; + end + else if Controls[i] is TRTComboBox then + begin + if (TRTComboBox(Controls[i]).Text) <> '' then + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TRTComboBox(Controls[i]).Item2); + end + else if Controls[i] is TComboBox then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text); + end + else if Controls[i] is TcxComboBox then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxComboBox(Controls[i]).Text); + end + else if Controls[i] is TDateTimePicker then + begin + if TDateTimePicker(Controls[i]).ShowCheckbox then + begin + if TDateTimePicker(Controls[i]).Checked then + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime + else + ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; + end + else + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime; + end; + end + else if Controls[i] is TcxDateEdit then + begin + if trim(TcxDateEdit(Controls[i]).Text)='' then + ADOQueryCmd.fieldByName(Controls[i].Name).Value :=null + else + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxDateEdit(Controls[i]).Text; + end + else if Controls[i] is TcxMemo then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxMemo(Controls[i]).Text; + end + else if Controls[i] is TcxTimeEdit then + begin + ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text); + end; + end; + end; + end; +end; + + procedure SClearData(mParent: TWinControl; FTag: Integer); var i, idx: Integer; @@ -1594,7 +1589,6 @@ begin continue; if Controls[i].Tag <> FTag then continue; - if Controls[i] is TEdit then begin TEdit(Controls[i]).Text := ''; @@ -1607,6 +1601,18 @@ begin begin Tmemo(Controls[i]).Text := ''; end + else if Controls[i] is TDateTimePicker then + begin + if TDateTimePicker(Controls[i]).ShowCheckbox = true then + begin + TDateTimePicker(Controls[i]).Checked := false; + end; + + end + else if Controls[i] is TcxRichEdit then + begin + TcxRichEdit(Controls[i]).Text := ''; + end else if Controls[i] is TBtnEditC then begin TBtnEditC(Controls[i]).Text := ''; @@ -1622,35 +1628,6 @@ begin idx := -1; TComboBox(Controls[i]).ItemIndex := idx; end - else if Controls[i] is TDateTimePicker then - begin - if TDateTimePicker(Controls[i]).ShowCheckbox = true then - begin - TDateTimePicker(Controls[i]).Checked := false; - end; - end - else if Controls[i] is TcxRichEdit then - begin - TcxRichEdit(Controls[i]).Text := ''; - end - else if Controls[i] is TcxTextEdit then - begin - TcxTextEdit(Controls[i]).Text := ''; - end - else if Controls[i] is TcxComboBox then - begin - idx := -1; - TcxComboBox(Controls[i]).ItemIndex := idx; - end - else if Controls[i] is TcxMemo then - begin - TcxMemo(Controls[i]).Text := ''; - end - else if Controls[i] is TcxButtonEdit then - begin - TcxButtonEdit(Controls[i]).Text := ''; - TcxButtonEdit(Controls[i]).Properties.LookupItems.Text := ''; - end end; end; end; @@ -1884,14 +1861,6 @@ begin Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TComboBox(Controls[i]).Text)) else if Controls[i].Tag = LikeTag then Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TComboBox(Controls[i]).Text) + '%'); - end - else if Controls[i] is TcxComboBox then - begin - if Trim(TcxComboBox(Controls[i]).Text) <> '' then - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Name + '=' + quotedStr(Trim(TcxComboBox(Controls[i]).Text)) - else if Controls[i].Tag = LikeTag then - Result := Result + 'and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TcxComboBox(Controls[i]).Text) + '%'); end; end; end; @@ -1899,9 +1868,143 @@ begin Result := Trim(RightStr(Result, Length(Result) - 4)); end; -/// ///////////////////////////////////////////////////////// -// ù˺ -/// ///////////////////////////////////////////////////////// +/// ///////////////////////////////////////// +/// /************ȡ***********///// +/// ///////////////////////////////////////// +function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string; +var + i, j, k: Integer; + fsj, fsj1: string; + control:Tcontrol; +begin + Result := ''; + with layoutControl do + begin + for i := 0 to ControlCount - 1 do + begin + control:= Controls[i] ; + if control is TLabel or (control.Tag=99) then + continue; + // + if Controls[i] is TcxTextEdit then + begin + if Trim(TcxTextEdit(control).Text) <> '' then + begin + if control.Tag = EquTag then + Result := Result + ' and ' + control.Name + '=' + quotedStr(Trim(TcxTextEdit(control).Text)) + else if control.Tag = LikeTag then + begin + j := Pos(' ', Trim(TcxTextEdit(control).Text)); + if j > 0 then + begin + Result := Result + ' and ' + control.Name + ' like ' + quotedStr('%' + Copy(Trim(TcxTextEdit(control).Text), 1, j - 1) + '%'); + fsj1 := Copy(Trim(TcxTextEdit(control).Text), j + 1, Length(Trim(TcxTextEdit(control).Text))); + while Trim(fsj1) <> '' do + begin + j := Pos(' ', Trim(fsj1)); + if j > 0 then + begin + Result := Result + ' and ' + control.Name + ' like ' + quotedStr('%' + Copy(Trim(fsj1), 1, j - 1) + '%'); + fsj1 := Copy(Trim(fsj1), j + 1, Length(Trim(fsj1))); + end + else + begin + Result := Result + ' and ' + control.Name + ' like ' + quotedStr('%' + Trim(fsj1) + '%'); + fsj1 := ''; + end; + end; + end + else + Result := Result + ' and ' + control.Name + ' like ' + quotedStr('%' + Trim(TcxTextEdit(control).Text) + '%'); + end; + end; + end + else if Controls[i] is TcxComboBox then + begin + if Trim(TcxComboBox(control).Text) <> '' then + if control.Tag = EquTag then + Result := Result + ' and ' + control.Name + '=' + quotedStr(Trim(TcxComboBox(control).Text)) + else if control.Tag = LikeTag then + Result := Result + ' and ' + control.Name + ' like ' + quotedStr('%' + Trim(TcxComboBox(control).Text) + '%'); + end + else if control is TEdit then + begin + if Trim(TEdit(control).Text) <> '' then + begin + if control.Tag = EquTag then + Result := Result + ' and ' + Controls[i].Name + '=' + quotedStr(Trim(TEdit(Controls[i]).Text)) + else if Controls[i].Tag = LikeTag then + begin + j := Pos(' ', Trim(TEdit(Controls[i]).Text)); + if j > 0 then + begin + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr('%' + Copy(Trim(TEdit(Controls[i]).Text), 1, j - 1) + '%'); + fsj1 := Copy(Trim(TEdit(Controls[i]).Text), j + 1, Length(Trim(TEdit(Controls[i]).Text))); + while Trim(fsj1) <> '' do + begin + j := Pos(' ', Trim(fsj1)); + if j > 0 then + begin + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr('%' + Copy(Trim(fsj1), 1, j - 1) + '%'); + fsj1 := Copy(Trim(fsj1), j + 1, Length(Trim(fsj1))); + end + else + begin + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(fsj1) + '%'); + fsj1 := ''; + end; + end; + end + else + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%'); + end; + end; + end + else if Controls[i] is TBtnEditA then + begin + if Trim(TBtnEditA(Controls[i]).Text) <> '' then + begin + if Controls[i].Tag = EquTag then + Result := Result + ' and ' + Controls[i].Name + '=' + quotedStr(Trim(TBtnEditA(Controls[i]).TxtCode)) + else if Controls[i].Tag = LikeTag then + Result := Result + ' and ' + Controls[i].Name + 'Name' + ' like ' + quotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%') + else if Controls[i].Tag = 99 then + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr(Trim(TBtnEditA(Controls[i]).TxtCode) + '%'); + end; + end + else if Controls[i] is TBtnEditC then + begin + if Trim(TBtnEditC(Controls[i]).TxtCode) <> '' then + begin + if Controls[i].Tag = EquTag then + Result := Result + ' and ' + Controls[i].Name + '=' + quotedStr(Trim(TBtnEditC(Controls[i]).TxtCode)) + else if Controls[i].Tag = LikeTag then + Result := Result + ' and ' + Controls[i].Name + 'Name' + ' like ' + quotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%'); + end; + end + else if Controls[i] is TRTComboBox then + begin + if Trim(TRTComboBox(Controls[i]).Text) <> '' then + if Controls[i].Tag = EquTag then + Result := Result + ' and ' + Controls[i].Name + '=' + quotedStr(Trim(TRTComboBox(Controls[i]).Item2)) + else if Controls[i].Tag = LikeTag then + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TRTComboBox(Controls[i]).Item2) + '%'); + end + else if Controls[i] is TComboBox then + begin + if Trim(TComboBox(Controls[i]).Text) <> '' then + if Controls[i].Tag = EquTag then + Result := Result + ' and ' + Controls[i].Name + '=' + quotedStr(Trim(TComboBox(Controls[i]).Text)) + else if Controls[i].Tag = LikeTag then + Result := Result + ' and ' + Controls[i].Name + ' like ' + quotedStr('%' + Trim(TComboBox(Controls[i]).Text) + '%'); + end; + end; + end; + if Trim(Result) <> '' then + Result := Trim(RightStr(Result, Length(Result) - 4)); +end; + + /// ///////////////////////////////////////// @@ -1952,39 +2055,6 @@ begin end; end; end - else if Controls[i] is TcxTextEdit then - begin - if Trim(TcxTextEdit(Controls[i]).Text) <> '' then - begin - if Controls[i].Tag = EquTag then - Result := Result + 'and ' + Controls[i].Hint + '=' + quotedStr(Trim(TcxTextEdit(Controls[i]).Text)) - else if Controls[i].Tag = LikeTag then - begin - j := Pos(' ', Trim(TcxTextEdit(Controls[i]).Text)); - if j > 0 then - begin - Result := Result + 'and ' + Controls[i].Hint + ' like ' + quotedStr('%' + Copy(Trim(TcxTextEdit(Controls[i]).Text), 1, j - 1) + '%'); - fsj1 := Copy(Trim(TcxTextEdit(Controls[i]).Text), j + 1, Length(Trim(TcxTextEdit(Controls[i]).Text))); - while Trim(fsj1) <> '' do - begin - j := Pos(' ', Trim(fsj1)); - if j > 0 then - begin - Result := Result + 'and ' + Controls[i].Hint + ' like ' + quotedStr('%' + Copy(Trim(fsj1), 1, j - 1) + '%'); - fsj1 := Copy(Trim(fsj1), j + 1, Length(Trim(fsj1))); - end - else - begin - Result := Result + 'and ' + Controls[i].Hint + ' like ' + quotedStr('%' + Trim(fsj1) + '%'); - fsj1 := ''; - end; - end; - end - else - Result := Result + 'and ' + Controls[i].Hint + ' like ' + quotedStr('%' + Trim(TcxTextEdit(Controls[i]).Text) + '%'); - end; - end; - end else if Controls[i] is TBtnEditA then begin if Trim(TBtnEditA(Controls[i]).Text) <> '' then @@ -2148,12 +2218,19 @@ begin mClientDataset.FieldDefs.Add('Sflag', ftString, 1); mClientDataset.FieldDefs.Add('Sindex', ftInteger, 0); mClientDataset.FieldDefs.Add('Ssel', ftBoolean, 0); - mClientDataset.FieldDefs.Add('SDefNote', ftString, 10); + mClientDataset.FieldDefs.Add('SDefNote', ftString, 100); mClientDataset.FieldDefs.Add('XHNoTemp', ftFloat, 0); mClientDataset.close; mClientDataset.CreateDataSet; end; +//////////////////////////////////// +procedure addAdoSelField(SADOQry: TADOQuery;mSelFieldName:string='Ssel'); +begin + //if SADOQry.FieldDefs.IndexOf(mSelFieldName)<0 then + // SADOQry.Fields.Add() +end; + procedure SInitCDSData(fromADO: TADOQuery; toCDS: TclientDataSet); var i: Integer; @@ -2162,7 +2239,7 @@ begin if fromADO.isEmpty then exit; fromADO.first; - k := 1; + k := toCDS.RecordCount+1; try toCDS.DisableControls; toCDS.Filtered := false; @@ -2200,24 +2277,23 @@ var begin try - Tv1.BeginUpdate(); + Tv1.BeginUpdate() ; if trim(MarkStr) <> '' then begin if not CDS1.IsEmpty then - MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString); + MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString); end; with ADO1 do begin Close; SQL.Clear; - Filtered := false; sql.Add(SqlStr); Open; - end; + end; if trim(FilterStr) <> '' then - SDofilter(ADO1, FilterStr); + SDofilter(ADO1, FilterStr); SCreateCDS(ADO1, CDS1); SInitCDSData(ADO1, CDS1); @@ -2227,11 +2303,10 @@ begin if trim(MarkStr) <> '' then CDS1.Locate(MarkStr, MarkStrValue, []); finally - Tv1.EndUpdate; + tv1.EndUpdate; end; end; ////////////////////////////////////// - procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string); var MarkStrValue: string; @@ -2254,13 +2329,12 @@ begin if trim(FilterStr) <> '' then SDofilter(ADO1, FilterStr); Tv1.DataController.Filter.Refresh; - if trim(MarkStr) <> '' then - ADO1.Locate(MarkStr, MarkStrValue, []); + if trim(MarkStr) <> '' then + ADO1.Locate(MarkStr, MarkStrValue, []); finally Tv1.EndUpdate(); end; end; - procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string); begin with ADOQueryTmp do @@ -2316,34 +2390,6 @@ begin end; end; -procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string); -begin - with ADOQueryTmp do - begin - close; - sql.Clear; - sql.Add(mSql); - Open; - if isEmpty then - begin - // plication.MessageBox(PWideChar(showMsg),'',0); - exit; - end; - cb.Properties.Items.Clear; - while not Eof do - begin - cb.Properties.Items.Add(Trim(fieldByName('Name').AsString)); - Next; - end; - - if not emptyFlag then - cb.Properties.Items.Add(''); - - if emptyFlag and (cb.Properties.Items.Count > 0) then - cb.ItemIndex := 0; - end; -end; - procedure SInitCxGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string); var A: TA; @@ -2381,37 +2427,6 @@ begin end; -procedure SInitCxGridComboBoxBySqlV2(ADOQueryTmp: TADOQuery; Tv1: TcxGridDBTableView; FieldName: string; mSql: string); -begin - with ADOQueryTmp do - begin - close; - sql.Clear; - sql.Add(mSql); - Open; - - if isEmpty then - begin - exit; - end - else - begin - // ͨĿеֶȡҪݵ ComboBox - with TcxComboBoxProperties(Tv1.GetColumnByFieldName(FieldName).Properties) do - begin - Items.Clear; - // ѭӲѯ ComboBox - ADOQueryTmp.First; - while not ADOQueryTmp.Eof do - begin - Items.Add(ADOQueryTmp.FieldByName('Name').AsString); - ADOQueryTmp.Next; - end; - end; - end; - end; -end; - procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string); var A: TA; @@ -2650,6 +2665,7 @@ end; /// //////////////////////////////////////////////// function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean; begin + Result := false; try with ADOQueryTmp do begin @@ -2678,11 +2694,53 @@ begin end; if not Result then - application.MessageBox(PWideChar('޷ˮ(' + mFlag + ')'), 'ʾϢ', MB_ICONINFORMATION); + raise Exception.Create(PWideChar('޷ˮ(' + mFlag + ')')); except + + raise Exception.Create(PWideChar('޷ˮ(' + mFlag + ')')); + + end; +end; + + +/// //////////////////////////////////////////////// +// ܣȡˮ +// mFlag:ǰ׺mTable: +// mlen:ˮų; mtype:Ƿ 1 0 +/// //////////////////////////////////////////////// +function GetLSNo20(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean; +begin Result := false; - application.MessageBox(PWideChar('޷ˮ(' + mFlag + ')'), 'ʾϢ', MB_ICONINFORMATION); + try + with ADOQueryTmp do + begin + close; + sql.Clear; + sql.Add('exec Get_SY_MaxBH_new '); + sql.Add(' ' + quotedStr(mFlag)); + sql.Add(',' + quotedStr(mTable)); + sql.Add(',' + intTostr(mlen)); + sql.Add(',' + intTostr(mtype)); + // ShowMessage(SQL.Text); + Open; + + if Recordcount > 0 then + begin + mMaxNo := Trim(fieldByName('MaxBH').AsString); + if mMaxNo <> '' then + Result := true + else + Result := false; + end; + + end; + if not Result then + raise Exception.Create(PWideChar('ˮ(' + mFlag + ')ʧ,!')); + + except + + raise Exception.Create(PWideChar('޷ˮ(' + mFlag + ')')); end; end; @@ -2692,23 +2750,19 @@ var mFileName: string; mADOTmp: TADOQuery; mGridName: string; - mfromName: string; - mcxGridDbColumn1: TcxGridDbColumn; mDir: string; + mcxGridDbColumn1: TcxGridDbColumn; i: integer; begin - if gGridNativeSet then + if gGridNativeSet or gIsYsUse then begin - mDir := ExtractFilePath(application.ExeName) + 'Layout\' + filePack; - mFileName := mDir + '\' + Trim(fileName) + '.dbg'; - + mDir:= ExtractFilePath(application.ExeName) + 'Layout\' + filePack ; + mFileName := mDir + '\' + Trim(fileName) + '.dbg'; //Ӳļлָ if FileExists(mFileName) then - begin - cxGrid.RestoreFromIniFile(mFileName, false, false); - end; + cxGrid.RestoreFromIniFile(mFileName, false, false); exit; - end; + end ; mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name; @@ -2720,12 +2774,11 @@ begin begin close; sql.clear; - sql.Add('select * from sd_cxgrid_dbg_set'); + sql.Add('select fieldName,columnName,Visible,width,ColIndexNo,GroupIndex,SortOrder from sd_cxgrid_dbg_set'); sql.Add('where userId=' + quotedstr(DCode)); sql.Add('and dllfileName=' + quotedstr(fDllFileName)); sql.Add('and fileName=' + quotedstr(fileName)); sql.Add('and cxGridName = ' + quotedstr(mGridName)); - sql.Add('order by ColIndexNo'); open; if mADOTmp.IsEmpty then @@ -2737,19 +2790,20 @@ begin sql.Add('and dllfileName=' + quotedstr(fDllFileName)); sql.Add('and fileName=' + quotedstr(fileName)); sql.Add('and cxGridName = ' + quotedstr(mGridName)); - sql.Add('order by ColIndexNo'); open; end; first; while not eof do begin - //cxgrid.find - mcxGridDbColumn1 := cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)); - if (mcxGridDbColumn1 <> nil) then //and (lowercase(mcxGridDbColumn1.Name) = lowercase(trim(fieldByName('columnName').asstring))) + mcxGridDbColumn1:= cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)) ; + if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name)=lowercase(trim(fieldByName('columnName').asstring))) then begin - mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean; + if mcxGridDbColumn1.Hidden then + mcxGridDbColumn1.Visible := false + else + mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean; mcxGridDbColumn1.Width := fieldByName('width').asInteger; mcxGridDbColumn1.index := fieldByName('ColIndexNo').asInteger; // if cxgrid.OptionsView.GroupByBox then @@ -2794,8 +2848,7 @@ begin cxGrid.RestoreFromIniFile(mFileName); exit; - end; - + end; mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name; try @@ -2844,15 +2897,16 @@ begin first; while not eof do begin - for i := 0 to cxGrid.ColumnCount - 1 do - begin - if lowercase(cxGrid.Columns[i].Name) = lowercase(trim(fieldByName('columnName').asstring)) then - begin - mcxGridDbColumn1 := cxGrid.Columns[i]; - break; - end; - end; - if mcxGridDbColumn1 <> nil then +// for i := 0 to cxGrid.ColumnCount - 1 do +// begin +// if lowercase(cxGrid.Columns[i].Name) = lowercase(trim(fieldByName('columnName').asstring)) then +// begin +// mcxGridDbColumn1 := cxGrid.Columns[i]; +// break; +// end; +// end; + mcxGridDbColumn1:= cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)) ; + if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name)=lowercase(trim(fieldByName('columnName').asstring)))then begin mcxGridDbColumn1.Position.BandIndex := fieldByName('BandIndexNo').asInteger; if fieldByName('BandWidth').AsInteger > 0 then @@ -2882,7 +2936,7 @@ begin finally mADOTmp.close; mADOTmp.Free; - cxGrid.EndUpdate; + cxGrid.EndUpdate(); end; end; @@ -2897,14 +2951,14 @@ var mADOCmd: TADOQuery; mGridName: string; mfromName: string; - mDir: string; + mDir:string; i: integer; mcurdate: Tdatetime; begin - mDir := ExtractFilePath(application.ExeName) + 'Layout\'; - if not DirectoryExists(mDir) then + mDir:= ExtractFilePath(application.ExeName) + 'Layout\' ; + if not DirectoryExists( mDir) then begin - CreateDir(pwidechar(mDir)); + CreateDir(pwidechar(mDir)); end; // mFileName := mDir + '\' + Trim(fileName) + '.dbg'; mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg'; @@ -2916,7 +2970,7 @@ begin mfromName := GetParentForm(TControl(cxGrid.GetParentComponent), true).Name; mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name; - + // showmessage(mGridName); //////////////////////////////// // try @@ -2978,9 +3032,8 @@ begin post; end; end; - mADOCmd.UpdateBatch(); + mADOCmd.UpdateBatch() ; finally - // showMessage('3'); mADOCmd.close; mADOCmd.Free; end; @@ -2997,10 +3050,17 @@ var mADOCmd: TADOQuery; mGridName: string; mfromName: string; + mDir:string; i: integer; mcurdate: Tdatetime; begin - mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg'; + mDir:= ExtractFilePath(application.ExeName) + 'Layout\' + filePack ; + if not DirectoryExists( mDir) then + begin + CreateDirectory(pwidechar(mDir), nil); + end; + mFileName := mDir + '\' + Trim(fileName) + '.dbg'; + //mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg'; if not DirectoryExists(ExtractFileDir(mFileName)) then CreateDir(ExtractFileDir(mFileName)); // Ϊļ @@ -3145,6 +3205,7 @@ begin end; Screen.Cursor := crDefault; Tv1.EndUpdate; + end; procedure ClearCDSColumn(CDS_1: TclientDataSet; Keys: TArray); @@ -3218,7 +3279,6 @@ begin Result := RTValues; end; // TV - procedure CopyTVFocusValue(Tv1: TcxGridDBTableView); var MVlaue: string; @@ -3272,60 +3332,6 @@ begin end; -function SelTVKey(Tv1: TcxGridDBTableView; Keys: TArray): TArray; // ѡkey -var - RTValues: TArray; - i, j, k, CurRow: Integer; - mvalue: string; -begin - SetLength(RTValues, Length(Keys)); - try -// CurRow := Tv1.Controller.FocusedRowIndex; -// Tv1.DataController.DataSet.DisableControls; -// Tv1.DataController.DataSet.First; - j := 0; - -// for k := 0 to Tv1.Controller.SelectedRowCount - 1 do -// begin -// tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[k]; -// -// RTValues := RTValues + Tv1.DataController.DataSet.FieldByName('spid').AsString + ','; -// end; - - for k := 0 to Tv1.Controller.SelectedRowCount - 1 do - begin - Tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[k]; - if j = 0 then - begin - for i := 0 to Length(RTValues) - 1 do - begin - RTValues[i] := Tv1.DataController.DataSet.FieldByName(Keys[i]).AsString + ','; -// RTValues[i] := Tv1.DataController.GetValue(Tv1.DataController.GetSelectedRowIndex(k), Tv1.GetColumnByFieldName(Keys[i]).Index) + ','; - end; - end - else - begin - for i := 0 to Length(RTValues) - 1 do - begin - RTValues[i] := RTValues[i] + Tv1.DataController.DataSet.FieldByName(Keys[i]).AsString + ','; -// RTValues[i] := RTValues[i] + Tv1.DataController.GetValue(Tv1.DataController.GetSelectedRowIndex(k), Tv1.GetColumnByFieldName(Keys[i]).Index) + ','; - end; - end; - j := j + 1; - end; - finally -// Tv1.Controller.FocusedRowIndex := CurRow; -// Tv1.DataController.DataSet.EnableControls; - end; - - for i := 0 to Length(RTValues) - 1 do - begin - RTValues[i] := copy(RTValues[i], 1, Length(RTValues[i]) - 1); - end; - Tv1.DataController.ClearSelection; - Result := RTValues; -end; - { function SelTVKey(Tv1: TcxGridDBTableView; Keys: TArray): TArray; // ѡkey var RTValues: TArray; @@ -3368,7 +3374,7 @@ begin end; // Tv1.DataController.ClearSelection; Result := RTValues; -end; } +end; procedure HiddenTVColumn(Tv1: TcxGridDBTableView; FieldName: string); begin @@ -3450,435 +3456,50 @@ begin end; end; -procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer); -var - i, idx: Integer; - mfield, mfieldCode: string; - ma: TA; +//////////////////////////// +function writeSysLog():boolean; +begin + +end; + +// +procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string); begin with ADOQueryTmp do begin + close; + sql.Clear; + sql.Add(mSql); + Open; if isEmpty then + begin + // plication.MessageBox(PWideChar(showMsg),'',0); exit; - with mParent do + end; + cb.Properties.Items.Clear; + while not Eof do begin - for i := 0 to ControlCount - 1 do - begin - if Controls[i] is TLabel then - continue; - if Controls[i].Tag <> FTag then - continue; - mfield := Controls[i].Name; - - if Controls[i] is TEdit then - begin - if Trim(fieldByName(mfield).AsString) <> '' then - TEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is TcxTextEdit then - begin - if Trim(fieldByName(mfield).AsString) <> '' then - TcxTextEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is TRTComboBox then - begin - idx := TRTComboBox(Controls[i]).IndexOfItem2(Trim(fieldByName(mfield).AsString)); - TComboBox(Controls[i]).ItemIndex := idx; - end - else if Controls[i] is TRichEdit then - begin - if Trim(fieldByName(mfield).AsString) <> '' then - TRichEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is TcxRichEdit then - begin - if Trim(fieldByName(mfield).AsString) <> '' then - TcxRichEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is TComboBox then - begin - if TComboBox(Controls[i]).Items.Count > 0 then - begin - idx := TComboBox(Controls[i]).Items.IndexOf(Trim(fieldByName(mfield).AsString)); - end - else - idx := -1; - TComboBox(Controls[i]).ItemIndex := idx; - end - else if Controls[i] is TcxComboBox then - begin - if TcxComboBox(Controls[i]).Properties.Items.Count > 0 then - begin - idx := TcxComboBox(Controls[i]).Properties.Items.IndexOf(Trim(fieldByName(mfield).AsString)); - end - else - idx := -1; - TcxComboBox(Controls[i]).ItemIndex := idx; - end - else if Controls[i] is TBtnEditA then - begin - if Trim(TBtnEditA(Controls[i]).Hint) <> '' then - begin - TBtnEditA(TBtnEditA(Controls[i])).TxtCode := Trim(fieldByName(mfield).AsString); - TBtnEditA(Controls[i]).Text := Trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString); - end - else - begin - TBtnEditA(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end; - - end - else if Controls[i] is TBtnEditC then - begin - TBtnEditC(TBtnEditA(Controls[i])).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is TDateTimePicker then - begin - if Trim(fieldByName(mfield).AsString) = '' then - begin - TDateTimePicker(Controls[i]).Checked := false; - end - else - TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime; - end - else if Controls[i] is Tmemo then - begin - Tmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is Tcxmemo then - begin - Tcxmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString); - end - else if Controls[i] is TcxDateEdit then - begin - if not isEmpty and not fieldByName(mfield).IsNull then - TcxDateEdit(Controls[i]).date := fieldByName(mfield).AsDateTime; - end - else if Controls[i] is TcxTimeEdit then - begin - if not isEmpty and (fieldByName(mfield).AsString <> '') then - TcxTimeEdit(Controls[i]).Text := fieldByName(mfield).AsString; - end - else if Controls[i] is TcxCurrencyEdit then - begin - TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString; - end - else if Controls[i] is TcheckBox then - begin - TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean; - end - else if Controls[i] is TcxButtonEdit then - begin - TcxButtonEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString); -// if TcxButtonEdit(Controls[i]).ParentShowHint = false then -// begin -// mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4)); -// TcxButtonEdit(Controls[i]).Hint := Trim(fieldByName(mfieldCode).AsString); -// end; - end; - end; // end for - end; // end with - end; // end for with - + cb.Properties.Items.Add(Trim(fieldByName('Name').AsString)); + Next; + end; + if not emptyFlag then + cb.Properties.Items.Add(''); + if emptyFlag and (cb.Properties.Items.Count > 0) then + cb.ItemIndex := 0; + end; end; -procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer); -var - i: Integer; +// ׳쳣 +procedure raiseException(msg:string); begin - with Myparent do - begin - for i := 0 to ControlCount - 1 do - begin - if Controls[i].Tag = MyTag then - begin - if Controls[i] is TBtnEditA then - begin - ADOQueryCmd.fieldByName(TBtnEditA(Controls[i]).Name).Value := Trim(TBtnEditA(Controls[i]).Text); - if Trim(TBtnEditA(Controls[i]).Hint) <> '' then - begin - if Pos('/', Trim(TBtnEditA(Controls[i]).Hint)) > 0 then - continue; - ADOQueryCmd.fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode); - end; - end - else if Controls[i] is TBtnEditC then - begin - ADOQueryCmd.fieldByName(TBtnEditC(Controls[i]).Name).Value := Trim(TBtnEditC(Controls[i]).Text); - if Trim(TBtnEditC(Controls[i]).Hint) <> '' then - begin - if Pos('/', Trim(TBtnEditC(Controls[i]).Hint)) > 0 then - continue; - ADOQueryCmd.fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode); - end; - end - else if Controls[i] is TcxButtonEdit then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxButtonEdit(Controls[i]).Text) - end - else if Controls[i] is TcxCurrencyEdit then - begin - if Trim(TcxCurrencyEdit(Controls[i]).Text) = '' then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := 0 - else - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxCurrencyEdit(Controls[i]).Text); - end - else if Controls[i] is TEdit then - begin - if Trim(TEdit(Controls[i]).Text) <> '' then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text) - else - begin - if Trim(TEdit(Controls[i]).Hint) <> '' then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Hint) - else - ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; - end; - end - else if Controls[i] is TcxTextEdit then - begin - if Trim(TcxTextEdit(Controls[i]).Text) <> '' then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxTextEdit(Controls[i]).Text) - else - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; - end; - end - else if Controls[i] is TRichEdit then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text; - end - else if Controls[i] is Tmemo then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Tmemo(Controls[i]).Text; - end - else if Controls[i] is TRTComboBox then - begin - if (TRTComboBox(Controls[i]).Text) <> '' then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TRTComboBox(Controls[i]).Item2); - end - else if Controls[i] is TComboBox then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text); - end - else if Controls[i] is TcxComboBox then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxComboBox(Controls[i]).Text); - end - else if Controls[i] is TDateTimePicker then - begin - if TDateTimePicker(Controls[i]).ShowCheckbox then - begin - if TDateTimePicker(Controls[i]).Checked then - ADOQueryCmd.fieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime - else - ADOQueryCmd.fieldByName(Controls[i].Name).Value := null; - end - else - ADOQueryCmd.fieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime; - end - else if Controls[i] is TcxDateEdit then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxDateEdit(Controls[i]).Text; - end - else if Controls[i] is TcxMemo then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxMemo(Controls[i]).Text; - end - else if Controls[i] is TcxTimeEdit then - begin - ADOQueryCmd.fieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text); - end; - end; - end; - end; + raise Exception.Create(PWideChar( trim(msg))); end; - -function CommonFiltersByTv(Tv1: TcxGridDBTableView; JsonArgs: string): string; -var - i: integer; - JSONObject: TJSONObject; - MFields: TStringList; -begin - Result := ''; - JSONObject := TJSONObject.ParseJSONValue(JsonArgs) as TJSONObject; - MFields := TStringList.Create(); - ExtractStrings(['|'], [' '], PChar(JSONObject.S['Fields']), MFields); - for i := 0 to Tv1.ColumnCount - 1 do - begin - if MFields.IndexOf(Tv1.Columns[i].DataBinding.FieldName) >= 0 then - begin - Result := Result + 'and isnull(' + Tv1.Columns[i].DataBinding.FieldName + ','''')=' + quotedStr(Trim(Tv1.DataController.DataSet.FieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString)) + ' '; - end; - end; - MFields.Free; - if Trim(Result) <> '' then - Result := Trim(RightStr(Result, Length(Result) - 4)); -end; - -function CommonFiltersByContainer(TMControl: TControl; JsonArgs: string): string; -var - i, EquTag, LikeTag, FieldTag: Integer; - JSONObject: TJSONObject; - MFields: TStringList; -begin - Result := ''; - JSONObject := TJSONObject.ParseJSONValue(JsonArgs) as TJSONObject; - MFields := TStringList.Create(); - ExtractStrings(['|'], [' '], PChar(JSONObject.S['Fields']), MFields); - EquTag := JSONObject.I['EquTag']; - LikeTag := JSONObject.I['LikeTag']; - FieldTag := JSONObject.I['FieldTag']; - if TMControl is TPanel then - begin - with TPanel(TMControl) do - begin - for i := 0 to ControlCount - 1 do - begin - if Controls[i] is TLabel then - continue; - Result := Result + CommonGetSingleFilter(Controls[i], EquTag, LikeTag, FieldTag, MFields); - end; - end; - end - else if TMControl is TdxLayoutControl then - begin - with TdxLayoutControl(TMControl) do - begin - for i := 0 to ControlCount - 1 do - begin - if Controls[i] is TLabel then - continue; - Result := Result + CommonGetSingleFilter(Controls[i], EquTag, LikeTag, FieldTag, MFields); - end; - end; - end; - - MFields.Free; - if Trim(Result) <> '' then - Result := Trim(RightStr(Result, Length(Result) - 4)); -end; - -function CommonGetSingleFilter(MyControl: TControl; EquTag, LikeTag, FieldTag: Integer; MFields: TStringList): string; -var - MValue, MField, MResult: string; - MTag: Integer; -begin - MResult := ''; - if MyControl is TEdit then - begin - if Trim(TEdit(MyControl).Text) <> '' then - begin - if FieldTag = 1 then - MField := MyControl.Hint - else - MField := MyControl.Name; - MValue := Trim(TEdit(MyControl).Text); - MTag := MyControl.Tag; - end; - end - else if MyControl is TcxTextEdit then - begin - if Trim(TcxTextEdit(MyControl).Text) <> '' then - begin - if FieldTag = 1 then - MField := MyControl.Hint - else - MField := MyControl.Name; - MValue := Trim(TcxTextEdit(MyControl).Text); - MTag := MyControl.Tag; - end; - end - else if MyControl is TComboBox then - begin - if Trim(TComboBox(MyControl).Text) <> '' then - begin - if FieldTag = 1 then - MField := MyControl.Hint - else - MField := MyControl.Name; - MValue := Trim(TComboBox(MyControl).Text); - MTag := MyControl.Tag; - end; - end - else if MyControl is TcxComboBox then - begin - if Trim(TcxComboBox(MyControl).Text) <> '' then - begin - if FieldTag = 1 then - MField := MyControl.Hint - else - MField := MyControl.Name; - MValue := Trim(TcxComboBox(MyControl).Text); - MTag := MyControl.Tag; - end; - end; - - if MValue <> '' then - begin - if MFields.Count = 0 then - begin - if MTag = EquTag then - MResult := MResult + 'and ' + MField + '=' + quotedStr(MValue) - else if MTag = LikeTag then - MResult := MResult + 'and ' + MField + ' like ' + quotedStr('%' + MValue + '%'); - end - else - begin - if MFields.IndexOf(MField) >= 0 then - begin - if MTag = EquTag then - MResult := MResult + 'and ' + MField + '=' + quotedStr(MValue) - else if MTag = LikeTag then - MResult := MResult + 'and ' + MField + ' like ' + quotedStr('%' + MValue + '%'); - end; - end; - end; - - Result := MResult; -end; - -/////////////////////////////// -procedure CDSDataFilter(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTableView; JsonArgs: string); -var - JSONObject: TJSONObject; -begin - JSONObject := TJSONObject.ParseJSONValue(JsonArgs) as TJSONObject; - - if ADO1.Active then - begin - Tv1.BeginUpdate(); - SDofilter(ADO1, JSONObject.S['FilterStr']); - SCreateCDS(ADO1, CDS1); - SInitCDSData(ADO1, CDS1); - Tv1.EndUpdate; - end; - -end; - -procedure CDSDataFilter(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBBandedTableView; JsonArgs: string); -var - JSONObject: TJSONObject; -begin - JSONObject := TJSONObject.ParseJSONValue(JsonArgs) as TJSONObject; - - if ADO1.Active then - begin - Tv1.BeginUpdate(); - SDofilter(ADO1, JSONObject.S['FilterStr']); - SCreateCDS(ADO1, CDS1); - SInitCDSData(ADO1, CDS1); - Tv1.EndUpdate; - end; - -end; - ////////////////////////////// //Ƿɾݼ¼ function isCanDataDelete(mFillerId:string='';mfiller:string=''):boolean; begin result:=false; - if (mFillerId=dcode) or (mfiller=dname) or (pos(mfiller,gTeamWorker)>0) then + if (lowercase(mFillerId)='admin')or (mFillerId=dcode) or (mfiller=dname) or (pos(mfiller,gTeamWorker)>0) then begin result:=true; end; @@ -3889,12 +3510,13 @@ end; function isCanDataEdit(mFillerId:string='';mfiller:string=''):boolean; begin result:=false; - if (mFillerId=dcode) or (mfiller=dname)or (pos(mfiller,gTeamWorker)>0) then + if (lowercase(mFillerId)='admin') or (mFillerId=dcode) or (mfiller=dname)or (pos(mfiller,gTeamWorker)>0) then begin result:=true; end; end; + ////////////////////////////////// function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery):Variant; begin @@ -3928,8 +3550,6 @@ begin end; end; - -///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// /// ճеݵ /// @@ -3943,6 +3563,8 @@ var startColIndex:integer; startrowIndex:integer; begin + if Tv1.Controller.SelectedRowCount=0 then exit; + startColIndex:= Tv1.Controller.CellSelectionAnchor.Index; // ȡеı