刷新bug
This commit is contained in:
parent
392fc649b9
commit
b066b0e4eb
|
@ -4,15 +4,16 @@ interface
|
|||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,System.Types,
|
||||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB, cxDBData,
|
||||
cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB, StrUtils, Midas,
|
||||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxTimeEdit,
|
||||
cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,dxLayoutContainer,
|
||||
cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox, cxDropDownEdit,
|
||||
cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit,
|
||||
IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit, FireDAC.Comp.Client,
|
||||
Vcl.Clipbrd, cxMemo,dxLayoutControl;
|
||||
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,
|
||||
System.Types, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB,
|
||||
cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB,
|
||||
StrUtils, Midas, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||||
cxTimeEdit, cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,
|
||||
dxLayoutContainer, cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox,
|
||||
cxDropDownEdit, cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit,
|
||||
cxButtonEdit, IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit,
|
||||
FireDAC.Comp.Client, Vcl.Clipbrd, cxMemo, dxLayoutControl, uSZHN_JSON,
|
||||
System.JSON;
|
||||
|
||||
type
|
||||
TA = class(TComponent)
|
||||
|
@ -22,9 +23,12 @@ type
|
|||
|
||||
// 调用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 pasteDatatTocxGrid(Tv1: TcxGridDBTableView);
|
||||
// 取主键
|
||||
|
||||
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);
|
||||
|
@ -32,10 +36,13 @@ procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: t
|
|||
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');
|
||||
{四舍五入取指定位小数}
|
||||
|
||||
|
@ -55,9 +62,13 @@ 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);
|
||||
|
||||
{ÖÕ¼«¹ýÂË }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 *****************//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -183,6 +194,12 @@ procedure SelOKNo(CDS_MainSel: TclientDataSet; FSel: Boolean); // ȫѡ/ȫ
|
|||
|
||||
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
|
||||
|
||||
function SelCDSKey(CDS_1: TclientDataSet; Keys: TArray<string>): TArray<string>; // 返回选择列key
|
||||
|
@ -194,8 +211,11 @@ procedure HiddenTVColumn(Tv1: TcxGridDBTableView; FieldName: string); //
|
|||
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView); // 复制TV焦点内容
|
||||
|
||||
//是否能删除数据记录
|
||||
|
||||
function isCanDataDelete(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||
|
||||
function isCanDataEdit(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||
|
||||
procedure raiseException(msg: string); //抛出异常
|
||||
|
||||
// **************** 访问网页 *****************//
|
||||
|
@ -220,6 +240,7 @@ function Split(const s: string; Separator: char): TStringDynArray;
|
|||
|
||||
// **************** 师爷写的 *****************//
|
||||
procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string);
|
||||
|
||||
type
|
||||
TMyF = function(App: TApplication; // 主应用程序 (对Delphi而言)
|
||||
FormH: HWND; // 创建窗口的父窗口句柄 (对PB而言)
|
||||
|
@ -239,6 +260,150 @@ implementation
|
|||
uses
|
||||
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;
|
||||
var
|
||||
fFileName, fpathFileName: string;
|
||||
|
@ -1458,7 +1623,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -1576,7 +1740,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure SClearData(mParent: TWinControl; FTag: Integer);
|
||||
var
|
||||
i, idx: Integer;
|
||||
|
@ -2099,6 +2262,40 @@ begin
|
|||
Result := Trim(RightStr(Result, Length(Result) - 4));
|
||||
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
|
||||
/// /////////////////////////////////////////////////////////
|
||||
|
@ -2288,6 +2485,7 @@ begin
|
|||
begin
|
||||
Close;
|
||||
SQL.Clear;
|
||||
Filtered := false;
|
||||
sql.Add(SqlStr);
|
||||
Open;
|
||||
end;
|
||||
|
@ -2303,10 +2501,11 @@ 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;
|
||||
|
@ -2335,6 +2534,7 @@ begin
|
|||
Tv1.EndUpdate();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string);
|
||||
begin
|
||||
with ADOQueryTmp do
|
||||
|
@ -2409,7 +2609,7 @@ begin
|
|||
end;
|
||||
while not Eof do
|
||||
begin
|
||||
A := TA.create(Nil);
|
||||
A := TA.create(nil);
|
||||
A.S := Trim(fieldByName('Code').AsString);
|
||||
if PState = 1 then
|
||||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(Trim(fieldByName('name').AsString), TObject(A))
|
||||
|
@ -2445,7 +2645,7 @@ begin
|
|||
end;
|
||||
while not Eof do
|
||||
begin
|
||||
A := TA.create(Nil);
|
||||
A := TA.create(nil);
|
||||
A.S := Trim(fieldByName('Code').AsString);
|
||||
if PState = 1 then
|
||||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(Trim(fieldByName('name').AsString), TObject(A))
|
||||
|
@ -3279,6 +3479,7 @@ begin
|
|||
Result := RTValues;
|
||||
end;
|
||||
// 复制TV焦点内容
|
||||
|
||||
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView);
|
||||
var
|
||||
MVlaue: string;
|
||||
|
@ -3496,6 +3697,7 @@ begin
|
|||
end;
|
||||
//////////////////////////////
|
||||
//是否能删除数据记录
|
||||
|
||||
function isCanDataDelete(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||
begin
|
||||
result := false;
|
||||
|
@ -3525,8 +3727,7 @@ begin
|
|||
begin
|
||||
Close;
|
||||
sql.Clear;
|
||||
sql.Add('select item_value,data_type from sy_module_param_set where dll_name=''' +
|
||||
Trim(DllName) + ''' and config_name=''' + Trim(ConfigName) + '''');
|
||||
sql.Add('select item_value,data_type from sy_module_param_set where dll_name=''' + Trim(DllName) + ''' and config_name=''' + Trim(ConfigName) + '''');
|
||||
Open;
|
||||
if RecordCount > 0 then
|
||||
begin
|
||||
|
@ -3553,6 +3754,7 @@ end;
|
|||
/////////////////////////////////////////////////////////////////
|
||||
/// 粘贴剪贴板中的数据到表格
|
||||
///
|
||||
|
||||
procedure pasteDatatTocxGrid(Tv1: TcxGridDBTableView);
|
||||
var
|
||||
SelectedCount: Integer;
|
||||
|
@ -3563,7 +3765,8 @@ var
|
|||
startColIndex: integer;
|
||||
startrowIndex: integer;
|
||||
begin
|
||||
if Tv1.Controller.SelectedRowCount=0 then exit;
|
||||
if Tv1.Controller.SelectedRowCount = 0 then
|
||||
exit;
|
||||
|
||||
startColIndex := Tv1.Controller.CellSelectionAnchor.Index;
|
||||
|
||||
|
@ -3578,7 +3781,8 @@ begin
|
|||
// 遍历每一行
|
||||
for i := 0 to StringList.Count - 1 do
|
||||
begin
|
||||
if i>tv1.Controller.SelectedRowCount-1 then break;
|
||||
if i > Tv1.Controller.SelectedRowCount - 1 then
|
||||
break;
|
||||
|
||||
// 将每行按制表符(或其他分隔符)拆分为单元格数据
|
||||
RowData := Split(StringList[i], #9); // 假设使用制表符作为分隔符
|
||||
|
@ -3587,15 +3791,16 @@ begin
|
|||
// 遍历每一列,并将数据填充到cxGrid
|
||||
for j := 0 to Length(RowData) - 1 do
|
||||
begin
|
||||
if j>tv1.Controller.SelectedColumnCount-1 then break;
|
||||
if j > Tv1.Controller.SelectedColumnCount - 1 then
|
||||
break;
|
||||
|
||||
// 假设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.FieldByName(Tv1.Columns[startColIndex + j].DataBinding.FieldName).AsString := RowData[j];
|
||||
|
||||
TV1.Controller.EditingController.ShowEdit;
|
||||
Tv1.Controller.EditingController.ShowEdit;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
@ -3644,5 +3849,6 @@ begin
|
|||
|
||||
Result[ItemIndex] := Copy(s, Start, len - Start + 1);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user