补齐方法
This commit is contained in:
parent
392fc649b9
commit
7075ab03dd
|
@ -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);
|
||||
|
||||
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,11 +36,14 @@ 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');
|
||||
|
||||
procedure addAdoSelField(SADOQry: TADOQuery; mSelFieldName: string = 'Ssel');
|
||||
{四舍五入取指定位小数}
|
||||
|
||||
function RoundFloat(f: double; i: Integer): double;
|
||||
|
@ -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,9 +211,12 @@ 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); //抛出异常
|
||||
|
||||
function isCanDataDelete(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||
|
||||
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
|
||||
|
||||
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;
|
||||
|
||||
// **************** 师爷写的 *****************//
|
||||
procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string);
|
||||
procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string);
|
||||
|
||||
type
|
||||
TMyF = function(App: TApplication; // 主应用程序 (对Delphi而言)
|
||||
FormH: HWND; // 创建窗口的父窗口句柄 (对PB而言)
|
||||
|
@ -237,7 +258,151 @@ var
|
|||
implementation
|
||||
|
||||
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;
|
||||
var
|
||||
|
@ -810,18 +975,18 @@ begin
|
|||
else
|
||||
idx := -1;
|
||||
TcxComboBox(Controls[i]).ItemIndex := idx;
|
||||
end
|
||||
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
|
||||
TcxDateEdit(Controls[i]).text := '';
|
||||
end
|
||||
else if Controls[i] is Tcxmemo then
|
||||
begin
|
||||
Tcxmemo(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
|
||||
end
|
||||
end
|
||||
// else if Controls[i] is TRTComboBox then
|
||||
// begin
|
||||
// idx := TRTComboBox(Controls[i]).IndexOfItem2(Trim(fieldByName(mfield).AsString));
|
||||
|
@ -1458,7 +1623,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -1558,8 +1722,8 @@ begin
|
|||
end
|
||||
else if Controls[i] is TcxDateEdit then
|
||||
begin
|
||||
if trim(TcxDateEdit(Controls[i]).Text)='' then
|
||||
ADOQueryCmd.fieldByName(Controls[i].Name).Value :=null
|
||||
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
|
||||
|
@ -1576,7 +1740,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure SClearData(mParent: TWinControl; FTag: Integer);
|
||||
var
|
||||
i, idx: Integer;
|
||||
|
@ -1875,15 +2038,15 @@ function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer)
|
|||
var
|
||||
i, j, k: Integer;
|
||||
fsj, fsj1: string;
|
||||
control:Tcontrol;
|
||||
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
|
||||
control := Controls[i];
|
||||
if control is TLabel or (control.Tag = 99) then
|
||||
continue;
|
||||
//
|
||||
if Controls[i] is TcxTextEdit then
|
||||
|
@ -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
|
||||
/// /////////////////////////////////////////////////////////
|
||||
|
@ -2225,7 +2422,7 @@ begin
|
|||
end;
|
||||
|
||||
////////////////////////////////////
|
||||
procedure addAdoSelField(SADOQry: TADOQuery;mSelFieldName:string='Ssel');
|
||||
procedure addAdoSelField(SADOQry: TADOQuery; mSelFieldName: string = 'Ssel');
|
||||
begin
|
||||
//if SADOQry.FieldDefs.IndexOf(mSelFieldName)<0 then
|
||||
// SADOQry.Fields.Add()
|
||||
|
@ -2239,7 +2436,7 @@ begin
|
|||
if fromADO.isEmpty then
|
||||
exit;
|
||||
fromADO.first;
|
||||
k := toCDS.RecordCount+1;
|
||||
k := toCDS.RecordCount + 1;
|
||||
try
|
||||
toCDS.DisableControls;
|
||||
toCDS.Filtered := false;
|
||||
|
@ -2277,11 +2474,11 @@ 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
|
||||
|
@ -2290,10 +2487,10 @@ begin
|
|||
SQL.Clear;
|
||||
sql.Add(SqlStr);
|
||||
Open;
|
||||
end;
|
||||
end;
|
||||
|
||||
if trim(FilterStr) <> '' then
|
||||
SDofilter(ADO1, FilterStr);
|
||||
SDofilter(ADO1, FilterStr);
|
||||
|
||||
SCreateCDS(ADO1, CDS1);
|
||||
SInitCDSData(ADO1, CDS1);
|
||||
|
@ -2303,10 +2500,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;
|
||||
|
@ -2329,12 +2527,13 @@ 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
|
||||
|
@ -2409,7 +2608,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 +2644,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))
|
||||
|
@ -2665,7 +2864,7 @@ end;
|
|||
/// ////////////////////////////////////////////////
|
||||
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
Result := false;
|
||||
try
|
||||
with ADOQueryTmp do
|
||||
begin
|
||||
|
@ -2711,7 +2910,7 @@ end;
|
|||
/// ////////////////////////////////////////////////
|
||||
function GetLSNo20(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
Result := false;
|
||||
try
|
||||
with ADOQueryTmp do
|
||||
begin
|
||||
|
@ -2756,13 +2955,13 @@ var
|
|||
begin
|
||||
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
|
||||
cxGrid.RestoreFromIniFile(mFileName, false, false);
|
||||
cxGrid.RestoreFromIniFile(mFileName, false, false);
|
||||
exit;
|
||||
end ;
|
||||
end;
|
||||
|
||||
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
|
||||
|
||||
|
@ -2797,11 +2996,11 @@ begin
|
|||
while not eof do
|
||||
begin
|
||||
|
||||
mcxGridDbColumn1:= cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)) ;
|
||||
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name)=lowercase(trim(fieldByName('columnName').asstring))) then
|
||||
mcxGridDbColumn1 := cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring));
|
||||
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name) = lowercase(trim(fieldByName('columnName').asstring))) then
|
||||
begin
|
||||
if mcxGridDbColumn1.Hidden then
|
||||
mcxGridDbColumn1.Visible := false
|
||||
mcxGridDbColumn1.Visible := false
|
||||
else
|
||||
mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean;
|
||||
mcxGridDbColumn1.Width := fieldByName('width').asInteger;
|
||||
|
@ -2848,7 +3047,7 @@ begin
|
|||
cxGrid.RestoreFromIniFile(mFileName);
|
||||
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
|
||||
|
||||
try
|
||||
|
@ -2905,8 +3104,8 @@ begin
|
|||
// break;
|
||||
// end;
|
||||
// end;
|
||||
mcxGridDbColumn1:= cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring)) ;
|
||||
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name)=lowercase(trim(fieldByName('columnName').asstring)))then
|
||||
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
|
||||
|
@ -2951,14 +3150,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';
|
||||
|
@ -2976,7 +3175,7 @@ begin
|
|||
try
|
||||
mADOCmd := TADOQuery.Create(nil);
|
||||
mADOCmd.ConnectionString := DConString;
|
||||
mADOCmd.LockType:=ltBatchOptimistic;
|
||||
mADOCmd.LockType := ltBatchOptimistic;
|
||||
with mADOCmd do
|
||||
begin
|
||||
close;
|
||||
|
@ -3032,7 +3231,7 @@ begin
|
|||
post;
|
||||
end;
|
||||
end;
|
||||
mADOCmd.UpdateBatch() ;
|
||||
mADOCmd.UpdateBatch();
|
||||
finally
|
||||
mADOCmd.close;
|
||||
mADOCmd.Free;
|
||||
|
@ -3050,14 +3249,14 @@ var
|
|||
mADOCmd: TADOQuery;
|
||||
mGridName: string;
|
||||
mfromName: string;
|
||||
mDir:string;
|
||||
mDir: string;
|
||||
i: integer;
|
||||
mcurdate: Tdatetime;
|
||||
begin
|
||||
mDir:= ExtractFilePath(application.ExeName) + 'Layout\' + filePack ;
|
||||
if not DirectoryExists( mDir) then
|
||||
mDir := ExtractFilePath(application.ExeName) + 'Layout\' + filePack;
|
||||
if not DirectoryExists(mDir) then
|
||||
begin
|
||||
CreateDirectory(pwidechar(mDir), nil);
|
||||
CreateDirectory(pwidechar(mDir), nil);
|
||||
end;
|
||||
mFileName := mDir + '\' + Trim(fileName) + '.dbg';
|
||||
//mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
|
||||
|
@ -3279,6 +3478,7 @@ begin
|
|||
Result := RTValues;
|
||||
end;
|
||||
// 复制TV焦点内容
|
||||
|
||||
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView);
|
||||
var
|
||||
MVlaue: string;
|
||||
|
@ -3457,7 +3657,7 @@ begin
|
|||
end;
|
||||
|
||||
////////////////////////////
|
||||
function writeSysLog():boolean;
|
||||
function writeSysLog(): boolean;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
@ -3490,61 +3690,61 @@ begin
|
|||
end;
|
||||
|
||||
// 抛出异常
|
||||
procedure raiseException(msg:string);
|
||||
procedure raiseException(msg: string);
|
||||
begin
|
||||
raise Exception.Create(PWideChar( trim(msg)));
|
||||
raise Exception.Create(PWideChar(trim(msg)));
|
||||
end;
|
||||
//////////////////////////////
|
||||
//是否能删除数据记录
|
||||
function isCanDataDelete(mFillerId:string='';mfiller:string=''):boolean;
|
||||
|
||||
function isCanDataDelete(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||
begin
|
||||
result:=false;
|
||||
if (lowercase(mFillerId)='admin')or (mFillerId=dcode) or (mfiller=dname) or (pos(mfiller,gTeamWorker)>0) then
|
||||
result := false;
|
||||
if (lowercase(mFillerId) = 'admin') or (mFillerId = dcode) or (mfiller = dname) or (pos(mfiller, gTeamWorker) > 0) then
|
||||
begin
|
||||
result:=true;
|
||||
result := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
////////////////////////////////
|
||||
//是否能修改数据记录
|
||||
function isCanDataEdit(mFillerId:string='';mfiller:string=''):boolean;
|
||||
function isCanDataEdit(mFillerId: string = ''; mfiller: string = ''): boolean;
|
||||
begin
|
||||
result:=false;
|
||||
if (lowercase(mFillerId)='admin') or (mFillerId=dcode) or (mfiller=dname)or (pos(mfiller,gTeamWorker)>0) then
|
||||
result := false;
|
||||
if (lowercase(mFillerId) = 'admin') or (mFillerId = dcode) or (mfiller = dname) or (pos(mfiller, gTeamWorker) > 0) then
|
||||
begin
|
||||
result:=true;
|
||||
result := true;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
//////////////////////////////////
|
||||
function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery):Variant;
|
||||
function getConfigValue(DllName: string; ConfigName: string; ADOQueryTmp: TADOQuery): Variant;
|
||||
begin
|
||||
Result:=null;
|
||||
Result := null;
|
||||
with ADOQueryTmp do
|
||||
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
|
||||
if Trim(FieldByName('data_type').AsString)='数字' then
|
||||
if Trim(FieldByName('data_type').AsString) = '数字' then
|
||||
begin
|
||||
Result:=StrToFloatDef(Trim(FieldByName('item_value').AsString),0);
|
||||
Result := StrToFloatDef(Trim(FieldByName('item_value').AsString), 0);
|
||||
end
|
||||
else if Trim(FieldByName('data_type').AsString)='布尔' then
|
||||
else if Trim(FieldByName('data_type').AsString) = '布尔' then
|
||||
begin
|
||||
Result:=False;
|
||||
if lowercase(Trim(FieldByName('item_value').AsString))='true' then
|
||||
Result := False;
|
||||
if lowercase(Trim(FieldByName('item_value').AsString)) = 'true' then
|
||||
begin
|
||||
Result:=True;
|
||||
Result := True;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result:=Trim(FieldByName('item_value').AsString);
|
||||
Result := Trim(FieldByName('item_value').AsString);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -3553,57 +3753,61 @@ end;
|
|||
/////////////////////////////////////////////////////////////////
|
||||
/// 粘贴剪贴板中的数据到表格
|
||||
///
|
||||
procedure pasteDatatTocxGrid(Tv1:TcxGridDBTableView);
|
||||
|
||||
procedure pasteDatatTocxGrid(Tv1: TcxGridDBTableView);
|
||||
var
|
||||
SelectedCount: Integer;
|
||||
ClipboardText: string;
|
||||
StringList: TStringList;
|
||||
RowData: TStringDynArray;
|
||||
i, j: Integer;
|
||||
startColIndex:integer;
|
||||
startrowIndex:integer;
|
||||
startColIndex: integer;
|
||||
startrowIndex: integer;
|
||||
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));
|
||||
// 将文本按行拆分
|
||||
StringList := TStringList.Create;
|
||||
try
|
||||
StringList.Text := ClipboardText;
|
||||
StringList := TStringList.Create;
|
||||
try
|
||||
StringList.Text := ClipboardText;
|
||||
|
||||
// 遍历每一行
|
||||
for i := 0 to StringList.Count - 1 do
|
||||
begin
|
||||
if i>tv1.Controller.SelectedRowCount-1 then break;
|
||||
for i := 0 to StringList.Count - 1 do
|
||||
begin
|
||||
if i > Tv1.Controller.SelectedRowCount - 1 then
|
||||
break;
|
||||
|
||||
// 将每行按制表符(或其他分隔符)拆分为单元格数据
|
||||
RowData := Split(StringList[i], #9); // 假设使用制表符作为分隔符
|
||||
Tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[i];
|
||||
RowData := Split(StringList[i], #9); // 假设使用制表符作为分隔符
|
||||
Tv1.Controller.FocusedRow := Tv1.Controller.SelectedRows[i];
|
||||
|
||||
// 遍历每一列,并将数据填充到cxGrid
|
||||
for j := 0 to Length(RowData) - 1 do
|
||||
begin
|
||||
if j>tv1.Controller.SelectedColumnCount-1 then break;
|
||||
for j := 0 to Length(RowData) - 1 do
|
||||
begin
|
||||
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;
|
||||
end;
|
||||
Tv1.DataController.DataSet.Edit;
|
||||
Tv1.DataController.DataSet.FieldByName(Tv1.Columns[startColIndex + j].DataBinding.FieldName).AsString := RowData[j];
|
||||
|
||||
Tv1.Controller.EditingController.ShowEdit;
|
||||
end;
|
||||
finally
|
||||
|
||||
StringList.Free;
|
||||
|
||||
end;
|
||||
finally
|
||||
|
||||
StringList.Free;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
// 分割字符串函数
|
||||
|
@ -3644,5 +3848,6 @@ begin
|
|||
|
||||
Result[ItemIndex] := Copy(s, Start, len - Start + 1);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user