补齐方法
This commit is contained in:
parent
392fc649b9
commit
7075ab03dd
|
@ -4,15 +4,16 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,System.Types,
|
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,
|
||||||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB, cxDBData,
|
System.Types, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB,
|
||||||
cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB, StrUtils, Midas,
|
cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB,
|
||||||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxTimeEdit,
|
StrUtils, Midas, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||||||
cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,dxLayoutContainer,
|
cxTimeEdit, cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,
|
||||||
cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox, cxDropDownEdit,
|
dxLayoutContainer, cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox,
|
||||||
cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit,
|
cxDropDownEdit, cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit,
|
||||||
IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit, FireDAC.Comp.Client,
|
cxButtonEdit, IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit,
|
||||||
Vcl.Clipbrd, cxMemo,dxLayoutControl;
|
FireDAC.Comp.Client, Vcl.Clipbrd, cxMemo, dxLayoutControl, uSZHN_JSON,
|
||||||
|
System.JSON;
|
||||||
|
|
||||||
type
|
type
|
||||||
TA = class(TComponent)
|
TA = class(TComponent)
|
||||||
|
@ -22,9 +23,12 @@ type
|
||||||
|
|
||||||
// 调用DLL文件
|
// 调用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);
|
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);
|
||||||
procedure pasteDatatTocxGrid(Tv1:TcxGridDBTableView);
|
|
||||||
|
procedure pasteDatatTocxGrid(Tv1: TcxGridDBTableView);
|
||||||
// 取主键
|
// 取主键
|
||||||
|
|
||||||
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean;
|
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;
|
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);
|
procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime);
|
||||||
|
@ -32,11 +36,14 @@ procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: t
|
||||||
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime; // 取服务器日期
|
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime; // 取服务器日期
|
||||||
|
|
||||||
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime; // 取服务器日期时间
|
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime; // 取服务器日期时间
|
||||||
|
|
||||||
function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string;
|
function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string;
|
||||||
|
|
||||||
procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer);
|
procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer);
|
||||||
|
|
||||||
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
|
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
|
||||||
procedure addAdoSelField(SADOQry: TADOQuery;mSelFieldName:string='Ssel');
|
|
||||||
|
procedure addAdoSelField(SADOQry: TADOQuery; mSelFieldName: string = 'Ssel');
|
||||||
{四舍五入取指定位小数}
|
{四舍五入取指定位小数}
|
||||||
|
|
||||||
function RoundFloat(f: double; i: Integer): double;
|
function RoundFloat(f: double; i: Integer): double;
|
||||||
|
@ -55,9 +62,13 @@ function RoundFloat(f: double; i: Integer): double;
|
||||||
{执行过滤 }procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
|
{执行过滤 }procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
|
||||||
{创建CDS列名 }procedure SCreateCDS(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
|
{创建CDS列名 }procedure SCreateCDS(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
|
||||||
{CDS赋值 }procedure SInitCDSData(fromADO: TADOQuery; toCDS: TclientDataSet);
|
{CDS赋值 }procedure SInitCDSData(fromADO: TADOQuery; toCDS: TclientDataSet);
|
||||||
|
|
||||||
procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
|
procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
|
||||||
{终极刷新 }procedure InitCDSData(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
|
{终极刷新 }procedure InitCDSData(ADO1: TADOQuery; CDS1: TclientDataSet; 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;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// **************** 刷新 ADO CDS TV *****************//
|
// **************** 刷新 ADO CDS TV *****************//
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -183,6 +194,12 @@ procedure SelOKNo(CDS_MainSel: TclientDataSet; FSel: Boolean); // ȫѡ/ȫ
|
||||||
|
|
||||||
procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean); // Tv1全选/全弃
|
procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean); // Tv1全选/全弃
|
||||||
|
|
||||||
|
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); // 通过KeyId将Tv1选择映射到CDS1
|
procedure SelTVToCDS(Tv1: TcxGridDBTableView; CDS1: TclientDataSet; KeyId: string); // 通过KeyId将Tv1选择映射到CDS1
|
||||||
|
|
||||||
function SelCDSKey(CDS_1: TclientDataSet; Keys: TArray<string>): TArray<string>; // 返回选择列key
|
function SelCDSKey(CDS_1: TclientDataSet; Keys: TArray<string>): TArray<string>; // 返回选择列key
|
||||||
|
@ -194,9 +211,12 @@ procedure HiddenTVColumn(Tv1: TcxGridDBTableView; FieldName: string); //
|
||||||
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView); // 复制TV焦点内容
|
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView); // 复制TV焦点内容
|
||||||
|
|
||||||
//是否能删除数据记录
|
//是否能删除数据记录
|
||||||
function isCanDataDelete(mFillerId:string='';mfiller:string=''):boolean;
|
|
||||||
function isCanDataEdit(mFillerId:string='';mfiller:string=''):boolean;
|
function isCanDataDelete(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||||
procedure raiseException(msg:string); //抛出异常
|
|
||||||
|
function isCanDataEdit(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||||
|
|
||||||
|
procedure raiseException(msg: string); //抛出异常
|
||||||
|
|
||||||
// **************** 访问网页 *****************//
|
// **************** 访问网页 *****************//
|
||||||
|
|
||||||
|
@ -214,12 +234,13 @@ function WriteCloseWin(AdoCmd: TADOQuery; mCaption: string; FormID: Integer; mDl
|
||||||
|
|
||||||
procedure selectDataRow(Sender: TcxCustomGridTableView; mKeyField: string); // 师爷写的Tv1印设cds
|
procedure selectDataRow(Sender: TcxCustomGridTableView; mKeyField: string); // 师爷写的Tv1印设cds
|
||||||
|
|
||||||
function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery):Variant;
|
function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery): Variant;
|
||||||
|
|
||||||
function Split(const s: string; Separator: char): TStringDynArray;
|
function Split(const s: string; Separator: char): TStringDynArray;
|
||||||
|
|
||||||
// **************** 师爷写的 *****************//
|
// **************** 师爷写的 *****************//
|
||||||
procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string);
|
procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string);
|
||||||
|
|
||||||
type
|
type
|
||||||
TMyF = function(App: TApplication; // 主应用程序 (对Delphi而言)
|
TMyF = function(App: TApplication; // 主应用程序 (对Delphi而言)
|
||||||
FormH: HWND; // 创建窗口的父窗口句柄 (对PB而言)
|
FormH: HWND; // 创建窗口的父窗口句柄 (对PB而言)
|
||||||
|
@ -237,7 +258,151 @@ var
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
U_DataLink,U_globalVar;
|
U_DataLink, U_globalVar;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
function ExportToFtErp(mFileName: string; ADOQueryCmd: TADOQuery): boolean;
|
function ExportToFtErp(mFileName: string; ADOQueryCmd: TADOQuery): boolean;
|
||||||
var
|
var
|
||||||
|
@ -810,18 +975,18 @@ begin
|
||||||
else
|
else
|
||||||
idx := -1;
|
idx := -1;
|
||||||
TcxComboBox(Controls[i]).ItemIndex := idx;
|
TcxComboBox(Controls[i]).ItemIndex := idx;
|
||||||
end
|
end
|
||||||
else if Controls[i] is TcxDateEdit then
|
else if Controls[i] is TcxDateEdit then
|
||||||
begin
|
begin
|
||||||
if not isEmpty and not fieldByName(mfield).IsNull then
|
if not isEmpty and not fieldByName(mfield).IsNull then
|
||||||
TcxDateEdit(Controls[i]).date := fieldByName(mfield).AsDateTime
|
TcxDateEdit(Controls[i]).date := fieldByName(mfield).AsDateTime
|
||||||
else
|
else
|
||||||
TcxDateEdit(Controls[i]).text := '';
|
TcxDateEdit(Controls[i]).text := '';
|
||||||
end
|
end
|
||||||
else if Controls[i] is Tcxmemo then
|
else if Controls[i] is Tcxmemo then
|
||||||
begin
|
begin
|
||||||
Tcxmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
|
Tcxmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
|
||||||
end
|
end
|
||||||
// else if Controls[i] is TRTComboBox then
|
// else if Controls[i] is TRTComboBox then
|
||||||
// begin
|
// begin
|
||||||
// idx := TRTComboBox(Controls[i]).IndexOfItem2(Trim(fieldByName(mfield).AsString));
|
// idx := TRTComboBox(Controls[i]).IndexOfItem2(Trim(fieldByName(mfield).AsString));
|
||||||
|
@ -1458,7 +1623,6 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
|
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
@ -1558,8 +1722,8 @@ begin
|
||||||
end
|
end
|
||||||
else if Controls[i] is TcxDateEdit then
|
else if Controls[i] is TcxDateEdit then
|
||||||
begin
|
begin
|
||||||
if trim(TcxDateEdit(Controls[i]).Text)='' then
|
if trim(TcxDateEdit(Controls[i]).Text) = '' then
|
||||||
ADOQueryCmd.fieldByName(Controls[i].Name).Value :=null
|
ADOQueryCmd.fieldByName(Controls[i].Name).Value := null
|
||||||
else
|
else
|
||||||
ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxDateEdit(Controls[i]).Text;
|
ADOQueryCmd.fieldByName(Controls[i].Name).Value := TcxDateEdit(Controls[i]).Text;
|
||||||
end
|
end
|
||||||
|
@ -1576,7 +1740,6 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure SClearData(mParent: TWinControl; FTag: Integer);
|
procedure SClearData(mParent: TWinControl; FTag: Integer);
|
||||||
var
|
var
|
||||||
i, idx: Integer;
|
i, idx: Integer;
|
||||||
|
@ -1875,15 +2038,15 @@ function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer)
|
||||||
var
|
var
|
||||||
i, j, k: Integer;
|
i, j, k: Integer;
|
||||||
fsj, fsj1: string;
|
fsj, fsj1: string;
|
||||||
control:Tcontrol;
|
control: Tcontrol;
|
||||||
begin
|
begin
|
||||||
Result := '';
|
Result := '';
|
||||||
with layoutControl do
|
with layoutControl do
|
||||||
begin
|
begin
|
||||||
for i := 0 to ControlCount - 1 do
|
for i := 0 to ControlCount - 1 do
|
||||||
begin
|
begin
|
||||||
control:= Controls[i] ;
|
control := Controls[i];
|
||||||
if control is TLabel or (control.Tag=99) then
|
if control is TLabel or (control.Tag = 99) then
|
||||||
continue;
|
continue;
|
||||||
//
|
//
|
||||||
if Controls[i] is TcxTextEdit then
|
if Controls[i] is TcxTextEdit then
|
||||||
|
@ -2099,6 +2262,40 @@ begin
|
||||||
Result := Trim(RightStr(Result, Length(Result) - 4));
|
Result := Trim(RightStr(Result, Length(Result) - 4));
|
||||||
end;
|
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;
|
||||||
|
|
||||||
/// /////////////////////////////////////////////////////////
|
/// /////////////////////////////////////////////////////////
|
||||||
// 公用过滤函数Hint
|
// 公用过滤函数Hint
|
||||||
/// /////////////////////////////////////////////////////////
|
/// /////////////////////////////////////////////////////////
|
||||||
|
@ -2225,7 +2422,7 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
procedure addAdoSelField(SADOQry: TADOQuery;mSelFieldName:string='Ssel');
|
procedure addAdoSelField(SADOQry: TADOQuery; mSelFieldName: string = 'Ssel');
|
||||||
begin
|
begin
|
||||||
//if SADOQry.FieldDefs.IndexOf(mSelFieldName)<0 then
|
//if SADOQry.FieldDefs.IndexOf(mSelFieldName)<0 then
|
||||||
// SADOQry.Fields.Add()
|
// SADOQry.Fields.Add()
|
||||||
|
@ -2239,7 +2436,7 @@ begin
|
||||||
if fromADO.isEmpty then
|
if fromADO.isEmpty then
|
||||||
exit;
|
exit;
|
||||||
fromADO.first;
|
fromADO.first;
|
||||||
k := toCDS.RecordCount+1;
|
k := toCDS.RecordCount + 1;
|
||||||
try
|
try
|
||||||
toCDS.DisableControls;
|
toCDS.DisableControls;
|
||||||
toCDS.Filtered := false;
|
toCDS.Filtered := false;
|
||||||
|
@ -2277,11 +2474,11 @@ var
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
|
|
||||||
Tv1.BeginUpdate() ;
|
Tv1.BeginUpdate();
|
||||||
if trim(MarkStr) <> '' then
|
if trim(MarkStr) <> '' then
|
||||||
begin
|
begin
|
||||||
if not CDS1.IsEmpty then
|
if not CDS1.IsEmpty then
|
||||||
MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString);
|
MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
with ADO1 do
|
with ADO1 do
|
||||||
|
@ -2290,10 +2487,10 @@ begin
|
||||||
SQL.Clear;
|
SQL.Clear;
|
||||||
sql.Add(SqlStr);
|
sql.Add(SqlStr);
|
||||||
Open;
|
Open;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if trim(FilterStr) <> '' then
|
if trim(FilterStr) <> '' then
|
||||||
SDofilter(ADO1, FilterStr);
|
SDofilter(ADO1, FilterStr);
|
||||||
|
|
||||||
SCreateCDS(ADO1, CDS1);
|
SCreateCDS(ADO1, CDS1);
|
||||||
SInitCDSData(ADO1, CDS1);
|
SInitCDSData(ADO1, CDS1);
|
||||||
|
@ -2303,10 +2500,11 @@ begin
|
||||||
if trim(MarkStr) <> '' then
|
if trim(MarkStr) <> '' then
|
||||||
CDS1.Locate(MarkStr, MarkStrValue, []);
|
CDS1.Locate(MarkStr, MarkStrValue, []);
|
||||||
finally
|
finally
|
||||||
tv1.EndUpdate;
|
Tv1.EndUpdate;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
|
procedure InitAdoData(ADO1: TADOQuery; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
|
||||||
var
|
var
|
||||||
MarkStrValue: string;
|
MarkStrValue: string;
|
||||||
|
@ -2329,12 +2527,13 @@ begin
|
||||||
if trim(FilterStr) <> '' then
|
if trim(FilterStr) <> '' then
|
||||||
SDofilter(ADO1, FilterStr);
|
SDofilter(ADO1, FilterStr);
|
||||||
Tv1.DataController.Filter.Refresh;
|
Tv1.DataController.Filter.Refresh;
|
||||||
if trim(MarkStr) <> '' then
|
if trim(MarkStr) <> '' then
|
||||||
ADO1.Locate(MarkStr, MarkStrValue, []);
|
ADO1.Locate(MarkStr, MarkStrValue, []);
|
||||||
finally
|
finally
|
||||||
Tv1.EndUpdate();
|
Tv1.EndUpdate();
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string);
|
procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string);
|
||||||
begin
|
begin
|
||||||
with ADOQueryTmp do
|
with ADOQueryTmp do
|
||||||
|
@ -2409,7 +2608,7 @@ begin
|
||||||
end;
|
end;
|
||||||
while not Eof do
|
while not Eof do
|
||||||
begin
|
begin
|
||||||
A := TA.create(Nil);
|
A := TA.create(nil);
|
||||||
A.S := Trim(fieldByName('Code').AsString);
|
A.S := Trim(fieldByName('Code').AsString);
|
||||||
if PState = 1 then
|
if PState = 1 then
|
||||||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(Trim(fieldByName('name').AsString), TObject(A))
|
(c3.Properties as TcxComboBoxProperties).Items.AddObject(Trim(fieldByName('name').AsString), TObject(A))
|
||||||
|
@ -2445,7 +2644,7 @@ begin
|
||||||
end;
|
end;
|
||||||
while not Eof do
|
while not Eof do
|
||||||
begin
|
begin
|
||||||
A := TA.create(Nil);
|
A := TA.create(nil);
|
||||||
A.S := Trim(fieldByName('Code').AsString);
|
A.S := Trim(fieldByName('Code').AsString);
|
||||||
if PState = 1 then
|
if PState = 1 then
|
||||||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(Trim(fieldByName('name').AsString), TObject(A))
|
(c3.Properties as TcxComboBoxProperties).Items.AddObject(Trim(fieldByName('name').AsString), TObject(A))
|
||||||
|
@ -2665,7 +2864,7 @@ end;
|
||||||
/// ////////////////////////////////////////////////
|
/// ////////////////////////////////////////////////
|
||||||
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean;
|
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := false;
|
Result := false;
|
||||||
try
|
try
|
||||||
with ADOQueryTmp do
|
with ADOQueryTmp do
|
||||||
begin
|
begin
|
||||||
|
@ -2711,7 +2910,7 @@ end;
|
||||||
/// ////////////////////////////////////////////////
|
/// ////////////////////////////////////////////////
|
||||||
function GetLSNo20(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;
|
||||||
begin
|
begin
|
||||||
Result := false;
|
Result := false;
|
||||||
try
|
try
|
||||||
with ADOQueryTmp do
|
with ADOQueryTmp do
|
||||||
begin
|
begin
|
||||||
|
@ -2756,13 +2955,13 @@ var
|
||||||
begin
|
begin
|
||||||
if gGridNativeSet or gIsYsUse then
|
if gGridNativeSet or gIsYsUse then
|
||||||
begin
|
begin
|
||||||
mDir:= ExtractFilePath(application.ExeName) + 'Layout\' + filePack ;
|
mDir := ExtractFilePath(application.ExeName) + 'Layout\' + filePack;
|
||||||
mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
||||||
//从布局文件中恢复
|
//从布局文件中恢复
|
||||||
if FileExists(mFileName) then
|
if FileExists(mFileName) then
|
||||||
cxGrid.RestoreFromIniFile(mFileName, false, false);
|
cxGrid.RestoreFromIniFile(mFileName, false, false);
|
||||||
exit;
|
exit;
|
||||||
end ;
|
end;
|
||||||
|
|
||||||
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
|
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
|
||||||
|
|
||||||
|
@ -2797,11 +2996,11 @@ begin
|
||||||
while not eof do
|
while not eof do
|
||||||
begin
|
begin
|
||||||
|
|
||||||
mcxGridDbColumn1:= cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)) ;
|
mcxGridDbColumn1 := cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring));
|
||||||
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name)=lowercase(trim(fieldByName('columnName').asstring))) then
|
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name) = lowercase(trim(fieldByName('columnName').asstring))) then
|
||||||
begin
|
begin
|
||||||
if mcxGridDbColumn1.Hidden then
|
if mcxGridDbColumn1.Hidden then
|
||||||
mcxGridDbColumn1.Visible := false
|
mcxGridDbColumn1.Visible := false
|
||||||
else
|
else
|
||||||
mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean;
|
mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean;
|
||||||
mcxGridDbColumn1.Width := fieldByName('width').asInteger;
|
mcxGridDbColumn1.Width := fieldByName('width').asInteger;
|
||||||
|
@ -2848,7 +3047,7 @@ begin
|
||||||
cxGrid.RestoreFromIniFile(mFileName);
|
cxGrid.RestoreFromIniFile(mFileName);
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
|
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -2905,8 +3104,8 @@ begin
|
||||||
// break;
|
// break;
|
||||||
// end;
|
// end;
|
||||||
// end;
|
// end;
|
||||||
mcxGridDbColumn1:= cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)) ;
|
mcxGridDbColumn1 := cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring));
|
||||||
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name)=lowercase(trim(fieldByName('columnName').asstring)))then
|
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name) = lowercase(trim(fieldByName('columnName').asstring))) then
|
||||||
begin
|
begin
|
||||||
mcxGridDbColumn1.Position.BandIndex := fieldByName('BandIndexNo').asInteger;
|
mcxGridDbColumn1.Position.BandIndex := fieldByName('BandIndexNo').asInteger;
|
||||||
if fieldByName('BandWidth').AsInteger > 0 then
|
if fieldByName('BandWidth').AsInteger > 0 then
|
||||||
|
@ -2951,14 +3150,14 @@ var
|
||||||
mADOCmd: TADOQuery;
|
mADOCmd: TADOQuery;
|
||||||
mGridName: string;
|
mGridName: string;
|
||||||
mfromName: string;
|
mfromName: string;
|
||||||
mDir:string;
|
mDir: string;
|
||||||
i: integer;
|
i: integer;
|
||||||
mcurdate: Tdatetime;
|
mcurdate: Tdatetime;
|
||||||
begin
|
begin
|
||||||
mDir:= ExtractFilePath(application.ExeName) + 'Layout\' ;
|
mDir := ExtractFilePath(application.ExeName) + 'Layout\';
|
||||||
if not DirectoryExists( mDir) then
|
if not DirectoryExists(mDir) then
|
||||||
begin
|
begin
|
||||||
CreateDir(pwidechar(mDir));
|
CreateDir(pwidechar(mDir));
|
||||||
end;
|
end;
|
||||||
// mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
// mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
||||||
mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
|
mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
|
||||||
|
@ -2976,7 +3175,7 @@ begin
|
||||||
try
|
try
|
||||||
mADOCmd := TADOQuery.Create(nil);
|
mADOCmd := TADOQuery.Create(nil);
|
||||||
mADOCmd.ConnectionString := DConString;
|
mADOCmd.ConnectionString := DConString;
|
||||||
mADOCmd.LockType:=ltBatchOptimistic;
|
mADOCmd.LockType := ltBatchOptimistic;
|
||||||
with mADOCmd do
|
with mADOCmd do
|
||||||
begin
|
begin
|
||||||
close;
|
close;
|
||||||
|
@ -3032,7 +3231,7 @@ begin
|
||||||
post;
|
post;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
mADOCmd.UpdateBatch() ;
|
mADOCmd.UpdateBatch();
|
||||||
finally
|
finally
|
||||||
mADOCmd.close;
|
mADOCmd.close;
|
||||||
mADOCmd.Free;
|
mADOCmd.Free;
|
||||||
|
@ -3050,14 +3249,14 @@ var
|
||||||
mADOCmd: TADOQuery;
|
mADOCmd: TADOQuery;
|
||||||
mGridName: string;
|
mGridName: string;
|
||||||
mfromName: string;
|
mfromName: string;
|
||||||
mDir:string;
|
mDir: string;
|
||||||
i: integer;
|
i: integer;
|
||||||
mcurdate: Tdatetime;
|
mcurdate: Tdatetime;
|
||||||
begin
|
begin
|
||||||
mDir:= ExtractFilePath(application.ExeName) + 'Layout\' + filePack ;
|
mDir := ExtractFilePath(application.ExeName) + 'Layout\' + filePack;
|
||||||
if not DirectoryExists( mDir) then
|
if not DirectoryExists(mDir) then
|
||||||
begin
|
begin
|
||||||
CreateDirectory(pwidechar(mDir), nil);
|
CreateDirectory(pwidechar(mDir), nil);
|
||||||
end;
|
end;
|
||||||
mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
||||||
//mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
|
//mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
|
||||||
|
@ -3279,6 +3478,7 @@ begin
|
||||||
Result := RTValues;
|
Result := RTValues;
|
||||||
end;
|
end;
|
||||||
// 复制TV焦点内容
|
// 复制TV焦点内容
|
||||||
|
|
||||||
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView);
|
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView);
|
||||||
var
|
var
|
||||||
MVlaue: string;
|
MVlaue: string;
|
||||||
|
@ -3457,7 +3657,7 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
function writeSysLog():boolean;
|
function writeSysLog(): boolean;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -3490,61 +3690,61 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// 抛出异常
|
// 抛出异常
|
||||||
procedure raiseException(msg:string);
|
procedure raiseException(msg: string);
|
||||||
begin
|
begin
|
||||||
raise Exception.Create(PWideChar( trim(msg)));
|
raise Exception.Create(PWideChar(trim(msg)));
|
||||||
end;
|
end;
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//是否能删除数据记录
|
//是否能删除数据记录
|
||||||
function isCanDataDelete(mFillerId:string='';mfiller:string=''):boolean;
|
|
||||||
|
function isCanDataDelete(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||||
begin
|
begin
|
||||||
result:=false;
|
result := false;
|
||||||
if (lowercase(mFillerId)='admin')or (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
|
begin
|
||||||
result:=true;
|
result := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//是否能修改数据记录
|
//是否能修改数据记录
|
||||||
function isCanDataEdit(mFillerId:string='';mfiller:string=''):boolean;
|
function isCanDataEdit(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||||
begin
|
begin
|
||||||
result:=false;
|
result := false;
|
||||||
if (lowercase(mFillerId)='admin') or (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
|
begin
|
||||||
result:=true;
|
result := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery):Variant;
|
function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery): Variant;
|
||||||
begin
|
begin
|
||||||
Result:=null;
|
Result := null;
|
||||||
with ADOQueryTmp do
|
with ADOQueryTmp do
|
||||||
begin
|
begin
|
||||||
Close;
|
Close;
|
||||||
sql.Clear;
|
sql.Clear;
|
||||||
sql.Add('select item_value,data_type from sy_module_param_set where dll_name=''' +
|
sql.Add('select item_value,data_type from sy_module_param_set where dll_name=''' + Trim(DllName) + ''' and config_name=''' + Trim(ConfigName) + '''');
|
||||||
Trim(DllName) + ''' and config_name=''' + Trim(ConfigName) + '''');
|
|
||||||
Open;
|
Open;
|
||||||
if RecordCount > 0 then
|
if RecordCount > 0 then
|
||||||
begin
|
begin
|
||||||
if Trim(FieldByName('data_type').AsString)='数字' then
|
if Trim(FieldByName('data_type').AsString) = '数字' then
|
||||||
begin
|
begin
|
||||||
Result:=StrToFloatDef(Trim(FieldByName('item_value').AsString),0);
|
Result := StrToFloatDef(Trim(FieldByName('item_value').AsString), 0);
|
||||||
end
|
end
|
||||||
else if Trim(FieldByName('data_type').AsString)='布尔' then
|
else if Trim(FieldByName('data_type').AsString) = '布尔' then
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result := False;
|
||||||
if lowercase(Trim(FieldByName('item_value').AsString))='true' then
|
if lowercase(Trim(FieldByName('item_value').AsString)) = 'true' then
|
||||||
begin
|
begin
|
||||||
Result:=True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Result:=Trim(FieldByName('item_value').AsString);
|
Result := Trim(FieldByName('item_value').AsString);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -3553,57 +3753,61 @@ end;
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
/// 粘贴剪贴板中的数据到表格
|
/// 粘贴剪贴板中的数据到表格
|
||||||
///
|
///
|
||||||
procedure pasteDatatTocxGrid(Tv1:TcxGridDBTableView);
|
|
||||||
|
procedure pasteDatatTocxGrid(Tv1: TcxGridDBTableView);
|
||||||
var
|
var
|
||||||
SelectedCount: Integer;
|
SelectedCount: Integer;
|
||||||
ClipboardText: string;
|
ClipboardText: string;
|
||||||
StringList: TStringList;
|
StringList: TStringList;
|
||||||
RowData: TStringDynArray;
|
RowData: TStringDynArray;
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
startColIndex:integer;
|
startColIndex: integer;
|
||||||
startrowIndex:integer;
|
startrowIndex: integer;
|
||||||
begin
|
begin
|
||||||
if Tv1.Controller.SelectedRowCount=0 then exit;
|
if Tv1.Controller.SelectedRowCount = 0 then
|
||||||
|
exit;
|
||||||
|
|
||||||
startColIndex:= Tv1.Controller.CellSelectionAnchor.Index;
|
startColIndex := Tv1.Controller.CellSelectionAnchor.Index;
|
||||||
|
|
||||||
// 获取剪贴板中的文本
|
// 获取剪贴板中的文本
|
||||||
ClipboardText := Clipboard.AsText;
|
ClipboardText := Clipboard.AsText;
|
||||||
// showMessage(inttostr(startColIndex));
|
// showMessage(inttostr(startColIndex));
|
||||||
// 将文本按行拆分
|
// 将文本按行拆分
|
||||||
StringList := TStringList.Create;
|
StringList := TStringList.Create;
|
||||||
try
|
try
|
||||||
StringList.Text := ClipboardText;
|
StringList.Text := ClipboardText;
|
||||||
|
|
||||||
// 遍历每一行
|
// 遍历每一行
|
||||||
for i := 0 to StringList.Count - 1 do
|
for i := 0 to StringList.Count - 1 do
|
||||||
begin
|
begin
|
||||||
if i>tv1.Controller.SelectedRowCount-1 then break;
|
if i > Tv1.Controller.SelectedRowCount - 1 then
|
||||||
|
break;
|
||||||
|
|
||||||
// 将每行按制表符(或其他分隔符)拆分为单元格数据
|
// 将每行按制表符(或其他分隔符)拆分为单元格数据
|
||||||
RowData := Split(StringList[i], #9); // 假设使用制表符作为分隔符
|
RowData := Split(StringList[i], #9); // 假设使用制表符作为分隔符
|
||||||
Tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[i];
|
Tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[i];
|
||||||
|
|
||||||
// 遍历每一列,并将数据填充到cxGrid
|
// 遍历每一列,并将数据填充到cxGrid
|
||||||
for j := 0 to Length(RowData) - 1 do
|
for j := 0 to Length(RowData) - 1 do
|
||||||
begin
|
begin
|
||||||
if j>tv1.Controller.SelectedColumnCount-1 then break;
|
if j > Tv1.Controller.SelectedColumnCount - 1 then
|
||||||
|
break;
|
||||||
|
|
||||||
// 假设cxGrid已经初始化,且有足够的行和列
|
// 假设cxGrid已经初始化,且有足够的行和列
|
||||||
TV1.DataController.Values[Tv1.Controller.FocusedRecordIndex, startColIndex+j] := RowData[j];
|
Tv1.DataController.Values[Tv1.Controller.FocusedRecordIndex, startColIndex + j] := RowData[j];
|
||||||
|
|
||||||
Tv1.DataController.DataSet.Edit;
|
Tv1.DataController.DataSet.Edit;
|
||||||
Tv1.DataController.DataSet.FieldByName(Tv1.Columns[startColIndex+j].DataBinding.FieldName).AsString := RowData[j];
|
Tv1.DataController.DataSet.FieldByName(Tv1.Columns[startColIndex + j].DataBinding.FieldName).AsString := RowData[j];
|
||||||
|
|
||||||
TV1.Controller.EditingController.ShowEdit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
Tv1.Controller.EditingController.ShowEdit;
|
||||||
end;
|
end;
|
||||||
finally
|
|
||||||
|
|
||||||
StringList.Free;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
|
||||||
|
StringList.Free;
|
||||||
|
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// 分割字符串函数
|
// 分割字符串函数
|
||||||
|
@ -3644,5 +3848,6 @@ begin
|
||||||
|
|
||||||
Result[ItemIndex] := Copy(s, Start, len - Start + 1);
|
Result[ItemIndex] := Copy(s, Start, len - Start + 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user