RTFormwork/public10/ThreeFun/Fun/U_RTFun.pas

3618 lines
118 KiB
ObjectPascal
Raw Normal View History

2024-07-07 09:35:27 +08:00
unit U_RTFun;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB, cxDBData,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB, StrUtils, Midas,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxTimeEdit,
cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,
cxGridExportLink, ExtCtrls, Buttons, DBClient, RTComboBox, cxDropDownEdit,
cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit,
2024-08-27 15:48:31 +08:00
IniFiles, WinSock, IdHTTP, dxcore, cxTextEdit, FireDAC.Comp.Client, cxCheckBox,
2024-07-07 09:35:27 +08:00
Vcl.Clipbrd, cxMemo, dxLayoutControl;
type
TA = class(TComponent)
public
S: string;
end;
// <20><><EFBFBD><EFBFBD>DLL<4C>ļ<EFBFBD>
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);
// ȡ<><C8A1><EFBFBD><EFBFBD>
function GetLSNo(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; // ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime; // ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡָ<C8A1><D6B8>λС<CEBB><D0A1>}
function RoundFloat(f: double; i: Integer): double;
{ <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>еİ<D0B5><C4B0><EFBFBD><EFBFBD><EFBFBD><E6BBBB>ȫ<EFBFBD><C8AB><EFBFBD>ַ<EFBFBD> }function FormatTitle(S: string): string;
// **************** ƴ<>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *****************//
//////////////////////////////////////////////////////////////////////////////////////////
<>Ӳ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>}function SGetFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
<>Ӳ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>Hint}function SGetHintFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
<>Ӳ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>TclientDataSet}function SGetCDSFilters(Tv1: TcxGridDBTableView; CDS1: TclientDataSet): string;
//////////////////////////////////////////////////////////////////////////////////////////
// **************** ƴ<>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *****************//
//////////////////////////////////////////////////////////////////////////////////////////
// **************** ˢ<><CBA2> ADO CDS TV *****************//
<>й<EFBFBD><D0B9><EFBFBD> }procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
{<7B><><EFBFBD><EFBFBD>CDS<44><53><EFBFBD><EFBFBD> }procedure SCreateCDS(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
{CDS<44><53>ֵ }procedure SInitCDSData(fromADO: TADOQuery; toCDS: TclientDataSet);
{<7B>ռ<EFBFBD>ˢ<EFBFBD><CBA2> }procedure InitCDSData(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
//////////////////////////////////////////////////////////////////////////////////////////
// **************** ˢ<><CBA2> ADO CDS TV *****************//
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// **************** <20>ؼ<EFBFBD><D8BC><EFBFBD>ֵ *****************//
//////////////////////////////////////////////////////////////////////////////////////////
// <20><>RadioGroup1<70><31>ֵ
procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string);
// <20><>TComboBox<6F><78>ֵ
procedure SInitComBoxBySql(ADOQueryTmp: TADOQuery; cb: TComboBox; emptyFlag: Boolean; mSql: string);
// <20><>TcxGriddbColumn<6D>е<EFBFBD>TComboBox<6F><78>ֵ
procedure SInitTcxComBoxBySql(ADOQueryTmp: TADOQuery; cb: TcxComboBox; emptyFlag: Boolean; mSql: string);
2024-08-27 15:48:31 +08:00
// <20><>TcxGriddbColumn<6D>е<EFBFBD>TComboBox<6F><78>ֵ
2024-07-07 09:35:27 +08:00
procedure SInitCxGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
2024-08-27 15:48:31 +08:00
// <20><>TcxGriddbColumn<6D>е<EFBFBD>TComboBox<6F><78>ֵ V2
procedure SInitCxGridComboBoxBySqlV2(ADOQueryTmp: TADOQuery; Tv1: TcxGridDBTableView; FieldName: string; mSql: string);
2024-07-07 09:35:27 +08:00
// <20><>TcxGridDBBandedColumn<6D>е<EFBFBD>TComboBox<6F><78>ֵ
procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
//////////////////////////////////////////////////////////////////////////////////////////
// **************** <20>ؼ<EFBFBD><D8BC><EFBFBD>ֵ *****************//
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// **************** CDS<44><53><EFBFBD>ݸ<EFBFBD>ֵ *****************//
//////////////////////////////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CDS
procedure CopyAddRowCDS(CDS_Sub: TclientDataSet);
// TcxGridDBTableView<65><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>groupformat<61><74><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
procedure CopyAddRow(Tv1: TcxGridDBTableView; CDS_Sub: TclientDataSet);
// TcxGridDBBandedTableView<65><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>groupformat<61><74><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
procedure CopyAddRowBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TclientDataSet);
// <20>ƶ<EFBFBD>CDS<44><53><EFBFBD><EFBFBD>
procedure MoveCDS(CDS_Left: TclientDataSet; CDS_Right: TclientDataSet);
// һ<><D2BB><EFBFBD>滻ճ<E6BBBB><D5B3> TcxGridDBTableView
procedure OneKeyPost(Tv1: TcxGridDBTableView; CDS_Sub: TclientDataSet);
// һ<><D2BB><EFBFBD>滻ճ<E6BBBB><D5B3> TcxGridDBBandedTableView
procedure OneKeyPostBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TclientDataSet);
//////////////////////////////////////////////////////////////////////////////////////////
// **************** CDS<44><53><EFBFBD>ݸ<EFBFBD>ֵ *****************//
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// **************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ *****************//
//////////////////////////////////////////////////////////////////////////////////////////
procedure ReadCxGrid(fileName: string; cxGrid: TcxGridDBTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
procedure ReadCxBandedGrid(fileName: string; cxGrid: TcxGridDBBandedTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
procedure WriteCxGrid(fileName: string; cxGrid: TcxGridDBTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
procedure WriteCxBandedGrid(fileName: string; cxGrid: TcxGridDBBandedTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
//////////////////////////////////////////////////////////////////////////////////////////
// **************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ *****************//
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
// **************** <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> *****************//
//////////////////////////////////////////////////////////////////////////////////////////
// <20><>ȡ<EFBFBD>ļ<EFBFBD>
function ReadINIFileStr(ininame, TypeName: string; ValueName, ValueMR: string): string;
// **************** <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> *****************//
function CovFileDate(Fd: _FileTime): TdateTime;
procedure UpdateFileTime(fileName: string; CreationTime, LastAccessTime, LastWriteTime: TdateTime);
procedure GetFileEditTime(mFile: string; var editTime: TdateTime);
function ExportFtErpFile(mFileName: string; ADORead: TADOQuery): Boolean;
// **************** <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> *****************//
// **************** <20>ϴ<EFBFBD><CFB4>ļ<EFBFBD> *****************//
function ExportToFtErp(mFileName: string; ADOQueryCmd: TADOQuery): boolean;
// **************** <20>ϴ<EFBFBD><CFB4>ļ<EFBFBD> *****************//
//////////////////////////////////////////////////////////////////////////////////////////
// **************** <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> *****************//
//////////////////////////////////////////////////////////////////////////////////////////
///
///
procedure TcxGridToExcel(mFileName: string; gridName: TcxGrid); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure ClearCDSColumn(CDS_1: TclientDataSet; Keys: TArray<string>); // <20><><EFBFBD><EFBFBD>CDS<44><53>
// **************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> *****************//
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> }
procedure IsVisibleTV(TMPanel: TPanel; MTV: TcxGridDBTableView; Hintvalue: string; IsVisible: Boolean);
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> }procedure ClearOrHideControls(TMPanel: TPanel; HintValue: string; IsClear: Boolean; IsHide: Boolean);
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> }procedure AssignmentControls(TMPanel: TPanel; TMClientDataset: TclientDataSet; Hintvalue: string);
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>пؼ<D0BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> }procedure SClearData(mParent: TWinControl; FTag: Integer);
procedure SCSHDataCDS(CDS_Main: TclientDataSet; mParent: TWinControl; FTag: Integer);
procedure SCSHData(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
procedure SSetWinData(ADOQueryTmp: TADOQuery; mParent: TWinControl);
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> }procedure FDCreateCDS(SADOQry: TFDConnection; mClientDataset: TclientDataSet);
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>T WinControl}procedure RTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: Integer);
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD> DBTable}function RTSetSaveDataCDS(ADOQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TclientDataSet; MyTable: string; MyTag: Integer): Boolean;
{<7B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD> BandedTable}function RTSetSaveDataCDSBand(ADOQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TclientDataSet; MyTable: string; MyTag: Integer): Boolean;
// **************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD> *****************//
procedure SelOKNo(CDS_MainSel: TclientDataSet; FSel: Boolean); // ȫѡ/ȫ<><C8AB>
procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean); // Tv1ȫѡ<><C8AB>
procedure SelTVToCDS(Tv1: TcxGridDBTableView; CDS1: TclientDataSet; KeyId: string); // ͨ<><CDA8>KeyId<49><64>Tv1ѡ<31><D1A1>ӳ<EFBFBD>䵽CDS1
function SelCDSKey(CDS_1: TclientDataSet; Keys: TArray<string>): TArray<string>; // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>key
function SelTVKey(Tv1: TcxGridDBTableView; Keys: TArray<string>): TArray<string>; // Tv1<76><31><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>key
procedure HiddenTVColumn(Tv1: TcxGridDBTableView; FieldName: string); //<2F><><EFBFBD><EFBFBD>TV<54><56>
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView); // <20><><EFBFBD><EFBFBD>TV<54><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// **************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ *****************//
procedure GetHTTP(FUrl: string);
function Utf8Encode(const WS: WideString): UTF8String;
// **************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ *****************//
// **************** ʦүд<D2AF><D0B4> *****************//
function WriteCloseWin(AdoCmd: TADOQuery; mCaption: string; FormID: Integer; mDllName: string): Boolean;
procedure selectDataRow(Sender: TcxCustomGridTableView; mKeyField: string); // ʦүд<D2AF><D0B4>Tv1ӡ<31><D3A1>cds
procedure LSCSHData(ADOQueryTmp: TADOQuery; mParent: TdxLayoutControl; FTag: Integer);
procedure LRTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TdxLayoutControl; MyTag: Integer);
function SLGetFilters(layoutControl: TdxLayoutControl; EquTag, LikeTag: Integer): string;
// **************** ʦүд<D2AF><D0B4> *****************//
type
TMyF = function(App: TApplication; // <20><>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD> (<28><>Delphi<68><69><EFBFBD><EFBFBD>)
FormH: HWND; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĸ<DAB5><C4B8><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD> (<28><>PB<50><42><EFBFBD><EFBFBD>)
FormID: Integer; // Ҫ<><D2AA><EFBFBD><EFBFBD>dll<6C>й<EFBFBD><D0B9>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD>Id<49><64>; <20><><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4>ڣ<EFBFBD>FormIDĬ<44><C4AC>Ϊ0
Language: Integer; // 0=Delphi; 1=PB
WinStyle: Integer; // 0=<3D>Ӵ<EFBFBD><D3B4><EFBFBD>; 1<><31><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD> (PB<50>ж<EFBFBD>Ϊ<EFBFBD><CEAA>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>)
UID: PWideChar; // <20>û<EFBFBD>Id
UName: PWideChar; // <20>û<EFBFBD><C3BB><EFBFBD>
Para: PWideChar; Title: PWideChar; Defstr1: PWideChar; Defstr2: PWideChar; Defstr3: PWideChar; Defstr4: PWideChar; Defstr5: PWideChar; Defstr6: PWideChar; Defstr7: PWideChar; Defstr8: PWideChar; Defstr9: PWideChar; Defstr10: PWideChar; Datalink: PWideChar): HWND; stdcall;
var
TP: FARPROC;
Tf: TMyF;
implementation
uses
U_DataLink;
/// /////////////////////////////////////////
/// /************<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********/////
/// /////////////////////////////////////////
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;
/// /////////////////////////////////////////////////////////
// <20><><EFBFBD>ù<EFBFBD><C3B9>˺<EFBFBD><CBBA><EFBFBD>
/// /////////////////////////////////////////////////////////
function ExportToFtErp(mFileName: string; ADOQueryCmd: TADOQuery): boolean;
var
fFileName, fpathFileName: string;
Stream: TMemoryStream;
mfileSize: integer;
mCreationTime: TdateTime;
mWriteTime: TdateTime;
begin
result := false;
fFileName := ExtractFileName(Trim(mFileName));
fpathFileName := trim(mFileName);
try
// ADOQueryCmd.Connection.BeginTrans ;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
Open;
//////////////////////////
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
GetFileInfo(fpathFileName, mfileSize, mCreationTime, mWriteTime);
if RecordCount <= 0 then
begin
Append;
fieldByName('FileName').AsString := fFileName;
end
else
begin
edit;
end;
fieldByName('FileEditDate').Value := mWriteTime;
fieldByName('FileCreateDate').Value := mCreationTime;
fieldByName('FileSize').Value := mfileSize;
fieldByName('Filler').Value := Dname;
fieldByName('LastEditer').Value := Dname;
fieldByName('LastEditTime').Value := DServerDate;
if pos('.rmf', fFileName) > 0 then
begin
fieldByName('FilePath').Value := 'report';
fieldByName('FileType').Value := '<27><><EFBFBD><EFBFBD>';
end
else if pos('.dll', fFileName) > 0 then
begin
fieldByName('FilePath').Value := '';
fieldByName('FileType').Value := 'һ<><D2BB>';
end
else
begin
fieldByName('FilePath').Value := '';
fieldByName('FileType').Value := '<27><><EFBFBD><EFBFBD>';
end;
// FJStream.LoadFromFile(fpathFileName);
// CompressionStream(FJStream);
//tblobfield(FieldByName('Files')).LoadFromFile(FJStream);
tblobfield(FieldByName('Files')).LoadFromFile(fpathFileName);
//<2F><>OLE<4C><45><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
// ADOQueryCmdFileContent.LoadFromFile(fpathFileName);
//ADOQueryCmdFileContent.LoadFromStream(Stream);
post;
end;
finally
// FJStream.free;
end;
result := true;
// ADOQueryCmd.Connection.CommitTrans ;
except
// ADOQueryCmd.Connection.RollbackTrans ;
application.MessageBox(pchar('<27><EFBFBD>ļ<EFBFBD>[' + trim(fFileName) + ']ʧ<><CAA7>!'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
end;
end;
procedure IsVisibleTV(TMPanel: TPanel; MTV: TcxGridDBTableView; Hintvalue: string; IsVisible: Boolean);
var
i, j: integer;
begin
with TMPanel do
begin
for j := 0 to TMPanel.ControlCount - 1 do
begin
if TMPanel.Controls[j] is TEdit then
begin
if Trim(TEdit(TMPanel.Controls[j]).Hint) = Hintvalue then
begin
with MTV do
begin
for i := 0 to MTV.ColumnCount - 1 do
begin
2024-08-27 15:48:31 +08:00
if UpperCase(Trim(TEdit(TMPanel.Controls[j]).Name)) = UpperCase(Trim(MTV.Columns[i].DataBinding.FieldName)) then
2024-07-07 09:35:27 +08:00
begin
MTV.Columns[i].Visible := IsVisible;
2024-08-27 15:48:31 +08:00
MTV.Columns[i].Hidden := not IsVisible;
2024-07-07 09:35:27 +08:00
Continue;
end;
end;
end;
end;
end;
if TMPanel.Controls[j] is TComboBox then
begin
if Trim(TComboBox(TMPanel.Controls[j]).Hint) = Hintvalue then
begin
with MTV do
begin
for i := 0 to MTV.ColumnCount - 1 do
begin
2024-08-27 15:48:31 +08:00
if UpperCase(Trim(TComboBox(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 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
2024-07-07 09:35:27 +08:00
begin
MTV.Columns[i].Visible := IsVisible;
2024-08-27 15:48:31 +08:00
MTV.Columns[i].Hidden := not IsVisible;
2024-07-07 09:35:27 +08:00
Continue;
end;
end;
end;
end;
end;
2024-08-27 15:48:31 +08:00
2024-07-07 09:35:27 +08:00
end;
end;
end;
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///////////////////////////////////////////////////////
procedure AssignmentControls(TMPanel: TPanel; TMClientDataset: TclientDataSet; Hintvalue: string);
var
i: integer;
begin
with TMPanel do
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TEdit then
begin
if Trim(TEdit(Controls[i]).Hint) = Hintvalue then
begin
TEdit(Controls[i]).Text := Trim(TMClientDataset.FieldByName(TEdit(Controls[i]).Name).AsString);
end;
end;
2024-08-27 15:48:31 +08:00
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;
2024-07-07 09:35:27 +08:00
if Controls[i] is TComboBox then
begin
2024-08-27 15:48:31 +08:00
if Trim(TComboBox(Controls[i]).Hint) = Hintvalue then
2024-07-07 09:35:27 +08:00
begin
TComboBox(Controls[i]).ItemIndex := TComboBox(Controls[i]).Items.IndexOf(Trim(TMClientDataset.FieldByName(TComboBox(Controls[i]).Name).AsString));
end;
end;
2024-08-27 15:48:31 +08:00
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;
2024-07-07 09:35:27 +08:00
end;
end;
end;
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///////////////////////////////////////////////////////
procedure ClearOrHideControls(TMPanel: TPanel; HintValue: string; IsClear: Boolean; IsHide: Boolean);
var
i: Integer;
begin
with TMPanel do
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TCheckBox then
begin
if TCheckBox(Controls[i]).Hint = HintValue then
begin
TCheckBox(Controls[i]).Visible := IsHide;
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 TComboBox then
begin
if TComboBox(Controls[i]).Hint = HintValue then
begin
TComboBox(Controls[i]).Visible := IsHide;
if IsClear then
TComboBox(Controls[i]).ItemIndex := -1;
end;
end;
if Controls[i] is TEdit then
begin
if Trim(TEdit(Controls[i]).Hint) = HintValue then
begin
TEdit(Controls[i]).Visible := IsHide;
if IsClear then
TEdit(Controls[i]).Text := '';
end;
end;
if Controls[i] is TBtnEditA then
begin
if Trim(TEdit(Controls[i]).Hint) = HintValue then
begin
TEdit(Controls[i]).Visible := IsHide;
if IsClear then
TEdit(Controls[i]).Text := '';
end;
end;
2024-08-27 15:48:31 +08:00
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;
2024-07-07 09:35:27 +08:00
end;
end;
end;
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///////////////////////////////////////////////////////
/// //////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// //////////////////////////////////////////////////
procedure SSetWinData(ADOQueryTmp: TADOQuery; mParent: TWinControl);
var
i, idx: Integer;
mfield: 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 >= 999 then
continue;
mfield := Controls[i].Name;
/// ////////////////////////
// EDIT
if Controls[i] is TEdit then
begin
{ if Trim(Controls[i].Hint)='<27><>ֵ' then
continue
else }
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
end
else if Controls[i] is TRichEdit then
begin
{ if Trim(Controls[i].Hint)='<27><>ֵ' then
continue
else }
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
end // ftcombobox
else if Controls[i] is TRTComboBox then
begin
if Controls[i].Tag = 99 then
begin
idx := TRTComboBox(Controls[i]).Items.IndexOf(Trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
end
else
begin
idx := TRTComboBox(Controls[i]).IndexOfItem2(Trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
end;
end // combobox
else if Controls[i] is TComboBox then
begin
if TComboBox(Controls[i]).Items.Count > 0 then
begin
// idx:=getCombIdx(TComboBox(Controls[i]),i,trim(fieldByName(mfield).AsString));
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 TBtnEditA then
begin
if TBtnEditA(Controls[i]).Tag = 1 then
begin
TBtnEditA(Controls[i]).TxtCode := Trim(fieldByName(mfield).AsString);
TBtnEditA(Controls[i]).Text := Trim(fieldByName(mfield + 'Name').AsString);
end
else
begin
TBtnEditA(Controls[i]).TxtCode := Trim(fieldByName(mfield).AsString);
TBtnEditA(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
end;
end
else if Controls[i] is TBtnEditC then
begin
TBtnEditC(Controls[i]).TxtCode := Trim(fieldByName(mfield).AsString);
TBtnEditC(Controls[i]).Text := Trim(fieldByName(mfield + 'Name').AsString);
end
else if Controls[i] is TDateTimePicker then
begin
if isEmpty or fieldByName(mfield).IsNull then
begin
if TDateTimePicker(Controls[i]).Checked then
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
end
else
TDateTimePicker(Controls[i]).Date := 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 TcxRichEdit then
begin
TcxRichEdit(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]).Text := fieldByName(mfield).AsString;
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;
end; // end for
end; // end with
end; // end for with
end;
function ReadINIFileStr(ininame, TypeName: string; ValueName, ValueMR: string): string;
var
programIni: Tinifile; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
fileName, ValueZS: string;
begin
fileName := ExtractFilePath(Paramstr(0)) + ininame;
programIni := Tinifile.create(fileName);
ValueZS := programIni.ReadString(TypeName, ValueName, ValueMR);
Result := ValueZS;
programIni.Free;
end;
function WriteCloseWin(AdoCmd: TADOQuery; mCaption: string; FormID: Integer; mDllName: string): Boolean;
begin
Result := false;
try
DServerDate := SGetServerDateTime(AdoCmd);
with AdoCmd do
begin
close;
sql.Clear;
sql.Add('select *');
sql.Add('from SY_CloseFormInfo');
sql.Add('where UserId=' + quotedStr(DCode));
sql.Add('and formCaption=' + quotedStr(mCaption));
Open;
if Recordcount > 0 then
begin
edit;
end
else
begin
append;
fieldByName('UserId').Value := DCode;
fieldByName('formCaption').Value := mCaption;
fieldByName('formId').Value := FormID;
fieldByName('dllfileName').Value := mDllName;
end;
fieldByName('filltime').Value := DServerDate;
post;
end;
Result := true;
except
application.MessageBox(<>ر<EFBFBD><D8B1><EFBFBD>Ϣʱ<CFA2><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure SCSHData(ADOQueryTmp: TADOQuery; mParent: TWinControl; 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 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]).Text := fieldByName(mfield).AsString;
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;
function Utf8Encode(const WS: WideString): UTF8String;
var
L: Integer;
Temp: UTF8String;
begin
Result := '';
if WS = '' then
exit;
SetLength(Temp, Length(WS) * 3);
// SetLength includes space for null terminator
L := UnicodeToUtf8(PAnsiChar(Temp), Length(Temp) + 1, PWideChar(WS), Length(WS));
if L > 0 then
SetLength(Temp, L - 1)
else
Temp := '';
Result := Temp;
end;
procedure GetFileInfo(mFile: string; var mfileSize: Integer; var CreationTime: TdateTime; var WriteTime: TdateTime);
var
vSearchRec: TSearchRec;
begin
FindFirst(mFile, faAnyFile, vSearchRec);
mfileSize := vSearchRec.Size;
CreationTime := CovFileDate(vSearchRec.FindData.ftCreationTime); // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
// vSearchRec.FindData.ftLastAccessTime//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
WriteTime := CovFileDate(vSearchRec.FindData.ftLastWriteTime); // <20>޸<EFBFBD>ʱ<EFBFBD><CAB1>
FindClose(vSearchRec);
end;
procedure GetFileEditTime(mFile: string; var editTime: TdateTime);
var
vSearchRec: TSearchRec;
begin
FindFirst(mFile, faAnyFile, vSearchRec);
// mfileSize:=vSearchRec.Size;
// CreationTime:=CovFileDate(vSearchRec.FindData.ftCreationTime);//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
// vSearchRec.FindData.ftLastAccessTime//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
editTime := CovFileDate(vSearchRec.FindData.ftLastWriteTime); // <20>޸<EFBFBD>ʱ<EFBFBD><CAB1>
FindClose(vSearchRec);
end;
function CovFileDate(Fd: _FileTime): TdateTime;
var
Tct: _SystemTime;
Temp: _FileTime;
begin
FileTimeToLocalFileTime(Fd, Temp);
FileTimeToSystemTime(Temp, Tct);
CovFileDate := SystemTimeToDateTime(Tct);
end;
procedure UpdateFileTime(fileName: string; CreationTime, LastAccessTime, LastWriteTime: TdateTime);
var
FileHnd: Integer;
SysTime: TSystemTime;
tTzi: TTimezoneInformation;
FCreationTime, FLastAccessTime, FLastWriteTime: TFileTime;
begin
GetTimezoneInformation(tTzi);
CreationTime := CreationTime + tTzi.Bias / 1440;
DateTimeToSystemTime(CreationTime, SysTime);
SystemTimeToFileTime(SysTime, FCreationTime);
// LastAccessTime := LastAccessTime + Ttzi.Bias/1440;
// DateTimeToSystemTime(LastAccessTime,SysTime);
// SystemTimeToFileTime(SysTime,FLastAccessTime);
LastWriteTime := LastWriteTime + tTzi.Bias / 1440;
DateTimeToSystemTime(LastWriteTime, SysTime);
SystemTimeToFileTime(SysTime, FLastWriteTime);
try
FileHnd := FileOpen(fileName, fmOpenWrite or fmShareDenyNone);
SetFileTime(FileHnd, @FCreationTime, nil, @FLastWriteTime);
finally
FileClose(FileHnd);
end;
end;
/// ////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
/// ////////////////////////////////////////////////////
function ExportFtErpFile(mFileName: string; ADORead: TADOQuery): Boolean;
var
Stream: TMemoryStream;
ff: TADOBlobstream;
mfileSize: Integer;
mCreationTime: TdateTime;
mWriteTime: TdateTime;
IsFileHas: Boolean;
mChildPath: string;
mFilePath: string;
begin
try
Result := false;
mChildPath := '';
/// ////////////////////////////////////////////
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>·<EFBFBD><C2B7>
with ADORead do
begin
close;
sql.Clear;
sql.Add('select FilePath ');
sql.Add('from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(mFileName));
Open;
if Recordcount > 0 then
begin
// if not fieldByName('valid').AsBoolean then exit;
if Trim(fieldByName('FilePath').AsString) <> '' then
mChildPath := Trim(fieldByName('FilePath').AsString) + '\';
end;
end;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
mFilePath := ExtractFilePath(Paramstr(0)) + mChildPath;
IsFileHas := FileExists(mFilePath + mFileName);
if IsFileHas then
begin
/// ///////////////////////
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
GetFileInfo(mFilePath + mFileName, mfileSize, mCreationTime, mWriteTime);
end;
/// ///////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
if IsFileHas then
begin
with ADORead do
begin
close;
sql.Clear;
sql.Add('select count(FileName) as cnt ');
sql.Add('from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(mFileName));
// sql.Add('and fileEditDate>'''+formatDateTime('yyyy-MM-dd hh:mm',mWriteTime)+'''');
sql.Add(' and DATEDIFF(minute,' + quotedStr(formatDateTime('yyyy-MM-dd hh:mm', mWriteTime)) + ',fileEditDate)>0');
Open;
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
if fieldByName('cnt').AsInteger > 0 then
begin
close;
sql.Clear;
sql.Add('select * ');
sql.Add('from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(mFileName));
Open;
ff := TADOBlobstream.create(fieldByName('Files') as TblobField, bmRead);
end
else
begin
exit;
end;
if Trim(fieldByName('FilePath').AsString) <> '' then
mChildPath := Trim(fieldByName('FilePath').AsString) + '\';
end;
end /// ///////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
else
begin
with ADORead do
begin
close;
sql.Clear;
sql.Add('select * ');
sql.Add('from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(mFileName));
Open;
if Recordcount > 0 then
begin
ff := TADOBlobstream.create(fieldByName('Files') as TblobField, bmRead);
end
else
begin
exit;
end;
if Trim(fieldByName('FilePath').AsString) <> '' then
mChildPath := Trim(fieldByName('FilePath').AsString) + '\';
end;
end;
if ff <> nil then
begin
try
mFileName := Trim(ADORead.fieldByName('FileName').AsString);
if not DirectoryExists(ExtractFileDir(mFilePath + mFileName)) then
ForceDirectories(ExtractFileDir(mFilePath + mFileName));
Stream := TMemoryStream.create;
// OleContainer1.SaveToStream(Stream);
// ADOQuery1FileContent.SaveToFile('tmp'); //<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD>
// OleContainer1.LoadFromFile('tmp'); //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD><C4BC>ж<EFBFBD>ȡOLE<4C><45><EFBFBD><EFBFBD>
ff.SaveToStream(Stream);
// OleContainer1.SaveToFile(ExtractFilePath(Paramstr(0))+mfielName)
Stream.SaveToFile(mFilePath + mFileName); // +'\tmpFile\'
// OleContainer1.SaveToFile('tmp');
finally
Stream.Free;
end;
end;
UpdateFileTime(mFilePath + mFileName, ADORead.fieldByName('FileCreateDate').AsDateTime, ADORead.fieldByName('FileEditDate').AsDateTime, ADORead.fieldByName('FileEditDate').AsDateTime);
Result := true;
except
application.MessageBox(PWideChar('<27><>ȡ<EFBFBD>ļ<EFBFBD>' + mFileName + <><CAA7>!'), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
/// /////////////////////////////////////////////////////
procedure GetHTTP(FUrl: string);
var
IdHTTP: TIdHTTP;
ResponseStream: TStringStream; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
ResponseStr: string;
begin
// <20><><EFBFBD><EFBFBD>IDHTTP<54>ؼ<EFBFBD>
IdHTTP := TIdHTTP.create(nil);
IdHTTP.HTTPOptions := IdHTTP.HTTPOptions + [hoKeepOrigProtocol];
// TStringStream<61><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>Ϣ
ResponseStream := TStringStream.create('');
try
try
IdHTTP.Get(FUrl, ResponseStream); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
except
on e: Exception do
begin
ShowMessage(e.Message);
end;
end;
// <20><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Ϣ
ResponseStr := ResponseStream.DataString;
// <20><>ҳ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>UTF8<46><38><EFBFBD><EFBFBD>
ResponseStr := UTF8Decode(ResponseStr);
// ShowMessage(ResponseStr);
finally
IdHTTP.Free;
ResponseStream.Free;
end;
end;
function RoundFloat(f: double; i: Integer): double;
var
S: string;
ef: Extended;
begin
if f = 0 then
begin
Result := 0;
exit;
end;
S := '#.' + StringOfChar('0', i);
if S = '#.' then
S := '#';
ef := StrToFloat(FloatToStr(f)); // <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Result := StrToFloat(FormatFloat(S, ef));
end;
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);
var
Th: HMODULE;
begin
Th := LoadLibrary(PWideChar(FromFile));
if Th > 0 then
begin
TP := GetProcAddress(Th, 'GetDllForm');
if TP <> nil then
begin
Tf := TMyF(TP);
Tf(application, 0, FormID, 0, FormType, PWideChar(DCode), PWideChar(DName), PWideChar(Para), PWideChar(Title), PWideChar(Def1), PWideChar(Def2), PWideChar(Def3), PWideChar(Def4), PWideChar(Def5), PWideChar(Def6), PWideChar(Def7), PWideChar(Def8), PWideChar(Def9), PWideChar(Def10), PWideChar(DConString));
end;
end
else
begin
application.MessageBox(PWideChar('<27>򲻿<EFBFBD><F2B2BBBF>ļ<EFBFBD>' + FromFile + '<27><>'), '<27><><EFBFBD><EFBFBD>', MB_ICONERROR);
end;
end;
function RTSetSaveDataCDS(ADOQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TclientDataSet; MyTable: string; MyTag: Integer): Boolean;
var
i: Integer;
begin
try
Result := false;
for i := 0 to Tv1.ColumnCount - 1 do
begin
if Tv1.Columns[i].Tag = MyTag then
begin
// if Tv1.Columns[i].Visible = false then
// continue;
if Trim(Tv1.Columns[i].DataBinding.FilterFieldName) = '' then
continue;
begin
if Trim(CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
begin
ADOQueryCmd.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value;
end
else
begin
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) = '0' then
begin
ADOQueryCmd.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := 0;
end
else
begin
ADOQueryCmd.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := null;
end;
end;
end;
end;
end;
Result := true;
except
Result := false;
application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
end;
end;
function RTSetSaveDataCDSBand(ADOQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TclientDataSet; MyTable: string; MyTag: Integer): Boolean;
var
i: Integer;
begin
try
Result := false;
for i := 0 to Tv1.ColumnCount - 1 do
begin
if Tv1.Columns[i].Tag = MyTag then
begin
if Tv1.Columns[i].Visible = false then
continue;
if Trim(Tv1.Columns[i].DataBinding.FilterFieldName) = '' then
continue;
begin
if Trim(CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
begin
ADOQueryCmd.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value;
end
else
begin
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '' then
ADOQueryCmd.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := 0
else
ADOQueryCmd.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := null;
end;
end;
end;
end;
Result := true;
except
Result := false;
application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
end;
end;
/// ////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////////////////
// function SGetServerDate(ADOQueryTmp:TADOQuery):TdateTime;
// begin
// try
// with ADOQueryTmp do
// begin
// close;
// sql.Clear;
// sql.Add('select getDate()as dt');
// open;
// result:=StrToDate(formatdatetime('yyyy-MM-dd',fieldByName('dt').AsDatetime));
// close;
// SQL.Clear;
// end;
// except
// application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
// end;
//
// end;
/// ////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////////////////
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime;
begin
with FormatSettings do
begin
ShortDateFormat := 'yyyy-mm-dd';
LongDateFormat := 'yyyy-mm-dd';
ShortTimeFormat := 'hh:nn:ss';
LongTimeFormat := 'hh:nn:ss';
DateSeparator := '-';
TimeSeparator := ':';
end;
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
Open;
Result := strToDate(formatDateTime('yyyy-MM-dd', fieldByName('dt').AsDateTime));
close;
sql.Clear;
end;
except
application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime;
begin
with FormatSettings do
begin
ShortDateFormat := 'yyyy-mm-dd';
LongDateFormat := 'yyyy-mm-dd';
ShortTimeFormat := 'hh:nn:ss';
LongTimeFormat := 'hh:nn:ss';
DateSeparator := '-';
TimeSeparator := ':';
end;
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
Open;
Result := fieldByName('dt').AsDateTime;
close;
sql.Clear;
end;
except
application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure RTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; 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
2024-08-27 15:48:31 +08:00
ADOQueryCmd.fieldByName(Controls[i].Name).Value := FormatDateTime('yyyy-MM-dd', TDateTimePicker(Controls[i]).Date);
2024-07-07 09:35:27 +08:00
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;
end;
procedure SClearData(mParent: TWinControl; FTag: Integer);
var
i, idx: Integer;
begin
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;
2024-08-27 15:48:31 +08:00
2024-07-07 09:35:27 +08:00
if Controls[i] is TEdit then
begin
TEdit(Controls[i]).Text := '';
end
else if Controls[i] is TRichEdit then
begin
TRichEdit(Controls[i]).Text := '';
end
else if Controls[i] is Tmemo then
begin
Tmemo(Controls[i]).Text := '';
end
2024-08-27 15:48:31 +08:00
else if Controls[i] is TBtnEditC then
begin
TBtnEditC(Controls[i]).Text := '';
TBtnEditC(Controls[i]).TxtCode := '';
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).Text := '';
TBtnEditA(Controls[i]).TxtCode := '';
end
else if Controls[i] is TComboBox then
begin
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
end
2024-07-07 09:35:27 +08:00
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
2024-08-27 15:48:31 +08:00
else if Controls[i] is TcxTextEdit then
2024-07-07 09:35:27 +08:00
begin
2024-08-27 15:48:31 +08:00
TcxTextEdit(Controls[i]).Text := '';
2024-07-07 09:35:27 +08:00
end
2024-08-27 15:48:31 +08:00
else if Controls[i] is TcxComboBox then
2024-07-07 09:35:27 +08:00
begin
2024-08-27 15:48:31 +08:00
idx := -1;
TcxComboBox(Controls[i]).ItemIndex := idx;
2024-07-07 09:35:27 +08:00
end
2024-08-27 15:48:31 +08:00
else if Controls[i] is TcxMemo then
2024-07-07 09:35:27 +08:00
begin
2024-08-27 15:48:31 +08:00
TcxMemo(Controls[i]).Text := '';
end
else if Controls[i] is TcxButtonEdit then
begin
TcxButtonEdit(Controls[i]).Text := '';
TcxButtonEdit(Controls[i]).Properties.LookupItems.Text := '';
2024-07-07 09:35:27 +08:00
end
end;
end;
end;
procedure SCSHDataCDS(CDS_Main: TclientDataSet; mParent: TWinControl; FTag: Integer);
var
i, idx: Integer;
mfield, mfieldCode: string;
ma: TA;
begin
with CDS_Main 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;
/// ////////////////////////
// EDIT
if Controls[i] is TEdit then
begin
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := Trim(fieldByName(mfield).AsString);
end // ftcombobox
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 // combobox
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 TBtnEditA then
begin
TBtnEditA(Controls[i]).TxtCode := Trim(fieldByName(mfield).AsString);
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
TBtnEditA(Controls[i]).Text := Trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
end
else if Controls[i] is TBtnEditC then
begin
TBtnEditC(Controls[i]).TxtCode := Trim(fieldByName(mfield).AsString);
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
TBtnEditC(Controls[i]).Text := Trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).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 TcxDateEdit then
begin
if not isEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).Text := fieldByName(mfield).AsString;
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;
/// /////////////////////////////////////////
/// /************<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********/////
/// /////////////////////////////////////////
function SGetFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
var
i, j, k: Integer;
fsj, fsj1: string;
begin
Result := '';
with TMPanel do
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TLabel 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) + '%');
2024-07-22 11:38:34 +08:00
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) + '%');
2024-07-07 09:35:27 +08:00
end;
end;
end;
if Trim(Result) <> '' then
Result := Trim(RightStr(Result, Length(Result) - 4));
end;
/// /////////////////////////////////////////////////////////
// <20><><EFBFBD>ù<EFBFBD><C3B9>˺<EFBFBD><CBBA><EFBFBD>
/// /////////////////////////////////////////////////////////
/// /////////////////////////////////////////
/// /************<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Hint***********/////
/// /////////////////////////////////////////
function SGetHintFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
var
i, j, k: Integer;
fsj, fsj1: string;
begin
Result := '';
with TMPanel do
begin
for i := 0 to ControlCount - 1 do
begin
if Controls[i] is TLabel 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].Hint + '=' + 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].Hint + ' 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].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(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].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
begin
if Controls[i].Tag = EquTag then
Result := Result + 'and ' + Controls[i].Hint + '=' + quotedStr(Trim(TBtnEditA(Controls[i]).TxtCode))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].Hint + 'Name' + ' like ' + quotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%')
else if Controls[i].Tag = 99 then
Result := Result + 'and ' + Controls[i].Hint + ' 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].Hint + '=' + quotedStr(Trim(TBtnEditC(Controls[i]).TxtCode))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].Hint + '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].Hint + '=' + quotedStr(Trim(TRTComboBox(Controls[i]).Item2))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].Hint + ' 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].Hint + '=' + quotedStr(Trim(TComboBox(Controls[i]).Text))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].Hint + ' like ' + quotedStr('%' + Trim(TComboBox(Controls[i]).Text) + '%');
end;
end;
end;
if Trim(Result) <> '' then
Result := Trim(RightStr(Result, Length(Result) - 4));
end;
/// /////////////////////////////////////////////////////////
// <20><><EFBFBD>ù<EFBFBD><C3B9>˺<EFBFBD><CBBA><EFBFBD>Hint
/// /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////
//<2F><><EFBFBD>ù<EFBFBD><C3B9>˺<EFBFBD><CBBA><EFBFBD>TMClientDataset
///////////////////////////////////////////////////////
function SGetCDSFilters(Tv1: TcxGridDBTableView; CDS1: TclientDataSet): string;
var
i: integer;
begin
Result := '';
if CDS1.isEmpty then
exit;
for i := 0 to Tv1.ColumnCount - 1 do
begin
if True then //if dxmx.findfield('CFWZ')<>nil
if Tv1.Columns[i].Tag = 11 then
begin
if CDS1.findfield(Tv1.Columns[i].DataBinding.FieldName) <> nil then
begin
if Trim(CDS1.fieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
begin
Result := Result + 'and ' + Tv1.Columns[i].DataBinding.FieldName + '=' + quotedStr(Trim(CDS1.fieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString)) + ' ';
end;
end;
end;
end;
if Trim(Result) <> '' then
Result := Trim(RightStr(Result, Length(Result) - 4));
end;
///////////////////////////////////////////////////////
//<2F><><EFBFBD>ù<EFBFBD><C3B9>˺<EFBFBD><CBBA><EFBFBD>TMClientDataset
///////////////////////////////////////////////////////
procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
begin
try
ADOQry.DisableControls;
with ADOQry do
begin
if Trim(FilterStr) = '' then
begin
Filtered := false;
end
else
begin
Filtered := false;
Filter := FilterStr;
Filtered := true;
end;
end;
finally
ADOQry.EnableControls;
end;
end;
procedure FDCreateCDS(SADOQry: TFDConnection; mClientDataset: TclientDataSet);
var
i: Integer;
mfieldName: string;
mSize: Integer;
begin
//
// mfieldName := '';
// mClientDataset.FieldDefs.Clear;
// with SADOQry do
// begin
// for i := 0 to fieldCount - 1 do //
// begin
// if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
// begin
// mSize := 1;
// end
// else
// mSize := Fields[i].Size;
// mfieldName := Trim(Fields[i].FieldName);
// mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
//
// end;
// end;
// 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('XHNoTemp', ftFloat, 0);
// mClientDataset.close;
// mClientDataset.CreateDataSet;
end;
procedure SCreateCDS(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
var
i: Integer;
mfieldName: string;
mSize: Integer;
begin
mfieldName := '';
mClientDataset.FieldDefs.Clear;
with SADOQry do
begin
for i := 0 to fieldCount - 1 do //
begin
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
begin
mSize := 1;
end
else
mSize := Fields[i].Size;
mfieldName := Trim(Fields[i].FieldName);
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
end;
end;
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('XHNoTemp', ftFloat, 0);
mClientDataset.close;
mClientDataset.CreateDataSet;
end;
procedure SInitCDSData(fromADO: TADOQuery; toCDS: TclientDataSet);
var
i: Integer;
k: Integer;
begin
if fromADO.isEmpty then
exit;
fromADO.first;
k := 1;
try
toCDS.DisableControls;
toCDS.Filtered := false;
while not fromADO.Eof do
begin
with toCDS do
begin
append;
for i := 0 to fromADO.fieldCount - 1 do
begin
Fields[i].Value := fromADO.Fields[i].Value;
end;
fieldByName('Sflag').AsString := '1';
fieldByName('Sindex').Value := k;
fieldByName('Ssel').Value := false;
fieldByName('SDefNote').Value := '';
inc(k);
post;
end;
fromADO.Next;
end;
if not toCDS.isEmpty then
begin
toCDS.first;
end;
finally
toCDS.EnableControls;
end;
end;
procedure InitCDSData(ADO1: TADOQuery; CDS1: TclientDataSet; Tv1: TcxGridDBTableView; SqlStr, FilterStr, MarkStr: string);
var
MarkStrValue: string;
begin
if trim(MarkStr) <> '' then
begin
if not CDS1.IsEmpty then
MarkStrValue := TRIM(CDS1.FieldByName(MarkStr).AsString);
end;
with ADO1 do
begin
Close;
SQL.Clear;
Filtered := false;
sql.Add(SqlStr);
// ShowMessage(sql.text);
Open;
end;
if trim(FilterStr) <> '' then
SDofilter(ADO1, FilterStr);
SCreateCDS(ADO1, CDS1);
SInitCDSData(ADO1, CDS1);
Tv1.DataController.Filter.Refresh;
if trim(MarkStr) <> '' then
CDS1.Locate(MarkStr, MarkStrValue, []);
end;
procedure SInitRadioGroupBySql(ADOQueryTmp: TADOQuery; rg: TRadioGroup; emptyFlag: Boolean; mSql: string);
begin
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add(mSql);
Open;
if isEmpty then
begin
exit;
end;
rg.Items.Clear;
while not Eof do
begin
rg.Items.Add(Trim(fieldByName('Name').AsString));
Next;
end;
if not emptyFlag then
rg.Items.Add('');
if emptyFlag and (rg.Items.Count > 0) then
rg.ItemIndex := 0;
end;
end;
procedure SInitComBoxBySql(ADOQueryTmp: TADOQuery; cb: TComboBox; 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.Clear;
while not Eof do
begin
cb.Items.Add(Trim(fieldByName('Name').AsString));
Next;
end;
if not emptyFlag then
cb.Items.Add('');
if emptyFlag and (cb.Items.Count > 0) then
cb.ItemIndex := 0;
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;
begin
(c3.Properties as TcxComboBoxProperties).Items.Clear;
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add(FSql);
Open;
if isEmpty then
begin
// Application.MessageBox(PWideChar('δ<>ҵ<EFBFBD>:'+shmeg),'',0);
exit;
end;
while not Eof do
begin
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))
else if PState = 0 then
begin
(c3.Properties as TcxComboBoxProperties).Items.Add(Trim(fieldByName('name').AsString));
end;
Next;
end;
if not IsNull then
begin
(c3.Properties as TcxComboBoxProperties).Items.Add('');
end;
end;
end;
2024-08-27 15:48:31 +08:00
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
// ͨ<><CDA8>Ŀ<EFBFBD><C4BF><EFBFBD>е<EFBFBD><D0B5>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD> ComboBox
with TcxComboBoxProperties(Tv1.GetColumnByFieldName(FieldName).Properties) do
begin
Items.Clear;
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ComboBox <20><>
ADOQueryTmp.First;
while not ADOQueryTmp.Eof do
begin
Items.Add(ADOQueryTmp.FieldByName('Name').AsString);
ADOQueryTmp.Next;
end;
end;
end;
end;
end;
2024-07-07 09:35:27 +08:00
procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
var
A: TA;
begin
(c3.Properties as TcxComboBoxProperties).Items.Clear;
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add(FSql);
Open;
if isEmpty then
begin
application.MessageBox(PWideChar(<>ҵ<EFBFBD>:' + Shmeg), '', 0);
exit;
end;
while not Eof do
begin
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))
else if PState = 0 then
begin
(c3.Properties as TcxComboBoxProperties).Items.Add(Trim(fieldByName('name').AsString));
end;
Next;
end;
if not IsNull then
begin
(c3.Properties as TcxComboBoxProperties).Items.Add('');
end;
end;
end;
procedure MoveCDS(CDS_Left: TclientDataSet; CDS_Right: TclientDataSet);
var
i: Integer;
begin
with CDS_Right do
begin
Append;
for i := 0 to CDS_Left.FieldCount - 1 do
begin
CDS_Right.FieldByName(CDS_Left.Fields[i].FieldName).Value := CDS_Left.fieldbyname(CDS_Left.Fields[i].FieldName).Value;
end;
Post;
end;
end;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure CopyAddRow(Tv1: TcxGridDBTableView; CDS_Sub: TclientDataSet);
var
AA: array[0..50] of string;
i, j: Integer;
begin
if CDS_Sub.isEmpty then
begin
CDS_Sub.append;
CDS_Sub.post;
exit;
end;
for i := 0 to Tv1.ColumnCount - 1 do
begin
AA[i] := Trim(CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString);
end;
with CDS_Sub do
begin
append;
for i := 0 to Tv1.ColumnCount - 1 do
begin
if AA[i] <> '' then
begin
CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := AA[i];
end;
end;
post;
end;
end;
procedure CopyAddRowBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TclientDataSet);
var
AA: array[0..300] of string;
i, j: Integer;
begin
if CDS_Sub.isEmpty then
begin
CDS_Sub.append;
CDS_Sub.post;
exit;
end;
for i := 0 to Tv1.ColumnCount - 1 do
begin
AA[i] := Trim(CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).AsString);
end;
with CDS_Sub do
begin
append;
for i := 0 to Tv1.ColumnCount - 1 do
begin
if AA[i] <> '' then
begin
CDS_Sub.fieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := AA[i];
end;
end;
post;
end;
end;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure CopyAddRowCDS(CDS_Sub: TclientDataSet);
var
AA: array[0..300] of string;
i, j: Integer;
begin
if CDS_Sub.isEmpty then
exit;
for i := 0 to CDS_Sub.fieldCount - 1 do
begin
AA[i] := Trim(CDS_Sub.fieldByName(CDS_Sub.Fields[i].FieldName).AsString);
end;
with CDS_Sub do
begin
append;
for i := 0 to CDS_Sub.fieldCount - 1 do
begin
if AA[i] <> '' then
begin
CDS_Sub.fieldByName(CDS_Sub.Fields[i].FieldName).Value := AA[i];
end;
end;
post;
end;
end;
procedure OneKeyPost(Tv1: TcxGridDBTableView; CDS_Sub: TclientDataSet);
var
FValue, FFValue, FColumn, FFColumn: string;
begin
// FColumn:=tv1.Columns[Tv1.Controller.FocusedColumnIndex].DataBinding.FieldName;
// FFColumn:=Tv1.Columns[Tv1.Controller.FocusedColumnIndex].Summary.GroupFormat;
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
FFColumn := Tv1.Controller.FocusedColumn.Summary.GroupFormat;
FValue := Trim(CDS_Sub.fieldByName(FColumn).AsString);
if Trim(FFColumn) <> '' then
begin
FFValue := Trim(CDS_Sub.fieldByName(FFColumn).AsString);
end;
with CDS_Sub do
begin
DisableControls;
first;
while not Eof do
begin
edit;
if FValue = '' then
begin
CDS_Sub.fieldByName(FColumn).Value := null;
end
else
begin
CDS_Sub.fieldByName(FColumn).Value := FValue;
end;
if Trim(FFColumn) <> '' then
begin
if FFValue = '' then
begin
CDS_Sub.fieldByName(FFColumn).Value := null;
end
else
begin
CDS_Sub.fieldByName(FFColumn).Value := FFValue;
end;
end;
post;
Next;
end;
EnableControls;
end;
end;
procedure OneKeyPostBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TclientDataSet);
var
FValue, FFValue, FColumn, FFColumn: string;
begin
// FColumn:=tv1.Columns[Tv1.Controller.FocusedColumnIndex].DataBinding.FieldName;
// FFColumn:=Tv1.Columns[Tv1.Controller.FocusedColumnIndex].Summary.GroupFormat;
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
FFColumn := Tv1.Controller.FocusedColumn.Summary.GroupFormat;
FValue := Trim(CDS_Sub.fieldByName(FColumn).AsString);
if Trim(FFColumn) <> '' then
begin
FFValue := Trim(CDS_Sub.fieldByName(FFColumn).AsString);
end;
with CDS_Sub do
begin
DisableControls;
first;
while not Eof do
begin
edit;
if FValue = '' then
begin
CDS_Sub.fieldByName(FColumn).Value := null;
end
else
begin
CDS_Sub.fieldByName(FColumn).Value := FValue;
end;
if Trim(FFColumn) <> '' then
begin
if FFValue = '' then
begin
CDS_Sub.fieldByName(FFColumn).Value := null;
end
else
begin
CDS_Sub.fieldByName(FFColumn).Value := FFValue;
end;
end;
post;
Next;
end;
EnableControls;
end;
end;
/// ////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>ȡ<EFBFBD><C8A1>ˮ<EFBFBD><CBAE>
// mFlag:ǰ׺<C7B0><D7BA>mTable:<3A><><EFBFBD><EFBFBD>
// mlen:<3A><>ˮ<EFBFBD>ų<EFBFBD><C5B3><EFBFBD>; mtype:<3A>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<><31><EFBFBD><EFBFBD> 0 <20><><EFBFBD><EFBFBD>
/// ////////////////////////////////////////////////
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: Integer; mtype: Integer = 0): Boolean;
begin
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('exec Get_SY_MaxBH ');
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
else
begin
Result := false;
end;
end;
if not Result then
application.MessageBox(PWideChar('<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>(' + mFlag + ')'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONINFORMATION);
except
Result := false;
application.MessageBox(PWideChar('<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>(' + mFlag + ')'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONINFORMATION);
end;
end;
procedure ReadCxGrid(fileName: string; cxGrid: TcxGridDBTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
var
mFileName: string;
mADOTmp: TADOQuery;
mGridName: string;
mfromName: string;
mcxGridDbColumn1: TcxGridDbColumn;
i: integer;
begin
// mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
// <20>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>лָ<D0BB>
//if FileExists(mFileName) then
// cxGrid.RestoreFromIniFile(mFileName, false, false);
//mfromName:=GetParentForm(TControl(cxGrid.GetParentComponent),true).Name;
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
try
2024-07-22 10:38:54 +08:00
cxGrid.BeginUpdate();
2024-07-07 09:35:27 +08:00
mADOTmp := TADOQuery.Create(nil);
mADOTmp.ConnectionString := DConString;
with mADOTmp do
begin
close;
sql.clear;
sql.Add('select * 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
begin
close;
sql.clear;
sql.Add('select * from sd_cxgrid_dbg_set');
sql.Add('where userId=' + quotedstr('ADMIN'));
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
2024-08-27 15:48:31 +08:00
mcxGridDbColumn1 := cxGrid.GetColumnByFieldName(trim(fieldByName('fieldName').asstring));
if (mcxGridDbColumn1 <> nil) and (lowercase(mcxGridDbColumn1.Name) = lowercase(trim(fieldByName('columnName').asstring))) then
2024-07-07 09:35:27 +08:00
begin
mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean;
mcxGridDbColumn1.Width := fieldByName('width').asInteger;
mcxGridDbColumn1.index := fieldByName('ColIndexNo').asInteger;
// if cxgrid.OptionsView.GroupByBox then
mcxGridDbColumn1.GroupIndex := fieldByName('GroupIndex').asInteger;
if (fieldByName('SortOrder').asInteger = 0) then
mcxGridDbColumn1.SortOrder := soNone
else if (fieldByName('SortOrder').asInteger = 1) then
mcxGridDbColumn1.SortOrder := soAscending
else if (fieldByName('SortOrder').asInteger = 2) then
mcxGridDbColumn1.SortOrder := soDescending;
end;
mcxGridDbColumn1 := nil;
next;
end;
end;
finally
mADOTmp.close;
mADOTmp.Free;
2024-07-22 11:38:34 +08:00
cxGrid.EndUpdate();
2024-07-07 09:35:27 +08:00
end;
end;
/// ////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ж<EFBFBD>ȡcxGridCol<6F><6C><EFBFBD><EFBFBD>
// fileName <20>Ƽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڵ<EFBFBD>caption<6F><6E><EFBFBD><EFBFBD>caption<6F><6E><EFBFBD><EFBFBD>
/// ////////////////////////////////////////////////////////////
procedure ReadCxBandedGrid(fileName: string; cxGrid: TcxGridDBBandedTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
var
mFileName: string;
mADOTmp: TADOQuery;
mGridName: string;
mfromName: string;
mcxGridDbColumn1: TcxGridDbBandedColumn;
i: integer;
begin
mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
// <20>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>лָ<D0BB>
//if FileExists(mFileName) then
// cxGrid.RestoreFromIniFile(mFileName);
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
try
2024-07-22 11:38:34 +08:00
cxGrid.BeginUpdate();
2024-07-07 09:35:27 +08:00
mADOTmp := TADOQuery.Create(nil);
mADOTmp.ConnectionString := DConString;
/////////////////////////////////////////
with mADOTmp do
begin
close;
sql.clear;
sql.Add('select bandIndexNo,bandWidth=sum(width),bandvisible from sd_cxgrid_dbg_set');
sql.Add('where userId=' + quotedstr(DCode));
sql.Add('and fileName=' + quotedstr(fileName));
sql.Add('and cxGridName=' + quotedstr(mGridName));
sql.Add('and dllfileName=' + quotedstr(fDllFileName));
sql.Add('and bandIndexNo>=0 and bandWidth>=0');
sql.Add('group by bandIndexNo,bandvisible');
// ShowMessage(sql.Text);
open;
first;
while not eof do
begin
cxGrid.Bands[fieldByName('bandIndexNo').AsInteger].Width := fieldByName('BandWidth').AsInteger;
cxGrid.Bands[fieldByName('bandIndexNo').AsInteger].Visible := fieldByName('bandVisible').AsBoolean;
next;
end;
end;
with mADOTmp do
begin
close;
sql.clear;
sql.Add('select * from sd_cxgrid_dbg_set');
sql.Add('where userId=' + quotedstr(DCode));
sql.Add('and fileName=' + quotedstr(fileName));
sql.Add('and cxGridName=' + quotedstr(mGridName));
sql.Add('and dllfileName=' + quotedstr(fDllFileName));
sql.Add('order by ColIndexNo');
// ShowMessage(sql.Text);
open;
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
begin
mcxGridDbColumn1.Position.BandIndex := fieldByName('BandIndexNo').asInteger;
if fieldByName('BandWidth').AsInteger > 0 then
begin
mcxGridDbColumn1.Position.Band.Width := fieldByName('BandWidth').AsInteger;
mcxGridDbColumn1.Position.Band.Visible := fieldByName('bandVisible').AsBoolean;
end;
mcxGridDbColumn1.Visible := fieldByName('Visible').AsBoolean;
mcxGridDbColumn1.Width := fieldByName('width').asInteger;
mcxGridDbColumn1.Position.ColIndex := fieldByName('ColIndexNo').asInteger;
//mcxGridDbColumn1.index:=fieldByName('ColIndexNo').asInteger;
mcxGridDbColumn1.index := fieldByName('IndexNo').asInteger;
if (fieldByName('SortOrder').asInteger = 0) then
mcxGridDbColumn1.SortOrder := soNone
else if (fieldByName('SortOrder').asInteger = 1) then
mcxGridDbColumn1.SortOrder := soAscending
else
mcxGridDbColumn1.SortOrder := soDescending;
end;
// mcxGridDbColumn1.ApplyBestFit();
mcxGridDbColumn1 := nil;
next;
end;
end;
finally
mADOTmp.close;
mADOTmp.Free;
2024-07-22 11:38:34 +08:00
cxGrid.EndUpdate;
2024-07-07 09:35:27 +08:00
end;
end;
/// ////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>дcxGridCol<6F><6C><EFBFBD>õ<EFBFBD>.dbg<62>ļ<EFBFBD><C4BC><EFBFBD>
// Ĭ<><C4AC><EFBFBD>Ƽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڵ<EFBFBD>caption<6F><6E><EFBFBD><EFBFBD>
/// ////////////////////////////////////////////////////////////
procedure WriteCxGrid(fileName: string; cxGrid: TcxGridDBTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
var
mFileName: string;
mADOCmd: TADOQuery;
mGridName: string;
mfromName: string;
i: integer;
mcurdate: Tdatetime;
begin
{ mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
if not DirectoryExists(ExtractFileDir(mFileName)) then
CreateDir(ExtractFileDir(mFileName));
// <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
cxGrid.StoreToIniFile(mFileName); }
mfromName := GetParentForm(TControl(cxGrid.GetParentComponent), true).Name;
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
// showmessage(mGridName);
////////////////////////////////
//
try
mADOCmd := TADOQuery.Create(nil);
mADOCmd.ConnectionString := DConString;
with mADOCmd do
begin
close;
sql.clear;
sql.Add('select getdate() as dt');
open;
mcurdate := fieldByname('dt').AsDateTime;
end;
with mADOCmd do
begin
close;
sql.clear;
sql.Add('select * from sd_cxgrid_dbg_set');
sql.Add('where userId=' + quotedstr(DCode));
sql.Add('and fileName=' + quotedstr(fileName));
sql.Add('and cxGridName=' + quotedstr(mGridName));
sql.Add('and dllfileName=' + quotedstr(fDllFileName));
open;
for i := 0 to cxGrid.ColumnCount - 1 do
begin
if locate('columnName', cxGrid.Columns[i].Name, []) then
begin
edit;
end
else
begin
append;
fieldByName('userId').value := DCode;
fieldByName('fileName').value := fileName;
fieldByName('groupname').value := filePack;
fieldByName('cxGridName').value := mGridName;
fieldByName('dllfileName').value := fDllFileName;
end;
fieldByName('indexNo').value := i;
fieldByName('Visible').value := cxGrid.Columns[i].Visible;
fieldByName('BandIndexNo').value := 0;
fieldByName('caption').value := cxGrid.Columns[i].caption;
fieldByName('fieldName').value := cxGrid.Columns[i].DataBinding.FieldName;
fieldByName('columnName').value := cxGrid.Columns[i].Name;
fieldByName('ColIndexNo').value := cxGrid.Columns[i].Index;
fieldByName('groupIndex').value := cxGrid.Columns[i].GroupIndex;
fieldByName('width').value := cxGrid.Columns[i].Width;
fieldByName('SortOrder').value := cxGrid.Columns[i].SortOrder;
fieldByName('formName').value := mfromName;
fieldByName('updatetime').value := mcurdate;
fieldByName('updateMan').value := DCode;
post;
end;
end;
finally
mADOCmd.close;
mADOCmd.Free;
end;
end;
/// ////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>дcxGridCol<6F><6C><EFBFBD>õ<EFBFBD>.dbg<62>ļ<EFBFBD><C4BC><EFBFBD>
// Ĭ<><C4AC><EFBFBD>Ƽ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڵ<EFBFBD>caption<6F><6E><EFBFBD><EFBFBD>
/// ////////////////////////////////////////////////////////////
procedure WriteCxBandedGrid(fileName: string; cxGrid: TcxGridDBBandedTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
var
mFileName: string;
mADOCmd: TADOQuery;
mGridName: string;
mfromName: string;
i: integer;
mcurdate: Tdatetime;
begin
mFileName := ExtractFilePath(application.ExeName) + 'Layout\' + filePack + '\' + Trim(fileName) + '.dbg';
if not DirectoryExists(ExtractFileDir(mFileName)) then
CreateDir(ExtractFileDir(mFileName));
// <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
cxGrid.StoreToIniFile(mFileName);
mfromName := GetParentForm(TControl(cxGrid.GetParentComponent), true).Name;
mGridName := cxGrid.GetParentComponent.Name + '.' + cxGrid.name;
// showmessage(mGridName);
////////////////////////////////
//
try
mADOCmd := TADOQuery.Create(nil);
mADOCmd.ConnectionString := DConString;
with mADOCmd do
begin
close;
sql.clear;
sql.Add('select getdate() as dt');
open;
mcurdate := fieldByname('dt').AsDateTime;
end;
with mADOCmd do
begin
close;
sql.clear;
sql.Add('select * from sd_cxgrid_dbg_set');
sql.Add('where userId=' + quotedstr(DCode));
sql.Add('and fileName=' + quotedstr(fileName));
sql.Add('and cxGridName=' + quotedstr(mGridName));
sql.Add('and dllfileName=' + quotedstr(fDllFileName));
// ShowMessage(sql.Text);
open;
for i := 0 to cxGrid.ColumnCount - 1 do
begin
if locate('columnName', cxGrid.Columns[i].Name, []) then
begin
edit;
end
else
begin
append;
fieldByName('userId').value := DCode;
fieldByName('fileName').value := fileName;
fieldByName('groupname').value := filePack;
fieldByName('cxGridName').value := mGridName;
fieldByName('dllfileName').value := fDllFileName;
end;
fieldByName('ColIndexNo').value := cxGrid.Columns[i].Position.ColIndex;
fieldByName('Visible').value := cxGrid.Columns[i].Visible;
fieldByName('BandIndexNo').value := cxGrid.Columns[i].Position.BandIndex;
if cxGrid.Columns[i].Position.BandIndex >= 0 then
begin
//if cxGrid.Bands[cxGrid.Columns[i].Position.BandIndex].Width>0 then
fieldByName('BandWidth').value := cxGrid.Bands[cxGrid.Columns[i].Position.BandIndex].Width; //cxGrid.Columns[i].Position.Band.Width;
fieldByName('bandVisible').value := cxGrid.Columns[i].Position.Band.Visible;
end;
fieldByName('caption').value := cxGrid.Columns[i].caption;
fieldByName('fieldName').value := cxGrid.Columns[i].DataBinding.FieldName;
fieldByName('columnName').value := cxGrid.Columns[i].Name;
fieldByName('indexNo').value := cxGrid.Columns[i].Index;
fieldByName('width').value := cxGrid.Columns[i].Width;
fieldByName('SortOrder').value := cxGrid.Columns[i].SortOrder;
fieldByName('updatetime').value := mcurdate;
fieldByName('updateMan').value := DCode;
fieldByName('formName').value := mfromName;
post;
end;
end;
finally
mADOCmd.close;
mADOCmd.Free;
end;
end;
procedure TcxGridToExcel(mFileName: string; gridName: TcxGrid);
var
saveDialog: TSaveDialog;
begin
try
saveDialog := TSaveDialog.create(nil);
saveDialog.Filter := 'xls(*.xls)|*.xls|ȫ<><C8AB>(*.*)|*.*';
saveDialog.Options := [ofOverwritePrompt];
saveDialog.fileName := mFileName;
if saveDialog.Execute then
if Assigned(gridName) then
begin
try
ExportGridToExcel(saveDialog.fileName, gridName);
except
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4>ڱ༭״̬!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
application.MessageBox('<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end
else
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
finally
saveDialog.Free;
end;
end;
procedure SelOKNo(CDS_MainSel: TclientDataSet; FSel: Boolean);
begin
if CDS_MainSel.isEmpty then
exit;
CDS_MainSel.DisableControls;
with CDS_MainSel do
begin
first;
while not Eof do
begin
if fieldByName('SSel').asBoolean = not FSel then
begin
edit;
fieldByName('SSel').Value := FSel;
post;
end;
Next;
end;
end;
CDS_MainSel.EnableControls;
end;
procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean);
var
i: integer;
begin
Screen.Cursor := crHourGlass;
Tv1.BeginUpdate();
Tv1.DataController.GotoFirst;
for i := 0 to Tv1.DataController.FilteredRecordCount - 1 do
begin
Tv1.DataController.GetItemByFieldName('ssel').EditValue := FSel;
Tv1.DataController.GotoNext;
end;
Screen.Cursor := crDefault;
Tv1.EndUpdate;
end;
procedure ClearCDSColumn(CDS_1: TclientDataSet; Keys: TArray<string>);
var
i, CurRow: Integer;
begin
CurRow := CDS_1.recno;
CDS_1.DisableControls;
with CDS_1 do
begin
First;
while not Eof do
begin
for i := 0 to Length(Keys) - 1 do
begin
CDS_1.Edit;
CDS_1.fieldbyname(Keys[i]).Value := null;
CDS_1.Post;
end;
CDS_1.Next;
end;
end;
CDS_1.recno := CurRow;
CDS_1.EnableControls;
end;
function SelCDSKey(CDS_1: TclientDataSet; Keys: TArray<string>): TArray<string>;
var
RTValues: TArray<string>;
i, j, CurRow: Integer;
begin
SetLength(RTValues, Length(Keys));
CurRow := CDS_1.recno;
CDS_1.DisableControls;
with CDS_1 do
begin
First;
j := 0;
while not Eof do
begin
if CDS_1.FieldByName('SSel').AsBoolean = True then
begin
if j = 0 then
begin
for i := 0 to Length(RTValues) - 1 do
begin
RTValues[i] := Trim(CDS_1.fieldbyname(Keys[i]).AsString) + ',';
end;
end
else
begin
for i := 0 to Length(RTValues) - 1 do
begin
RTValues[i] := RTValues[i] + Trim(CDS_1.fieldbyname(Keys[i]).AsString) + ',';
end;
end;
j := j + 1;
end;
CDS_1.Next;
end;
end;
CDS_1.recno := CurRow;
CDS_1.EnableControls;
for i := 0 to Length(RTValues) - 1 do
begin
RTValues[i] := copy(RTValues[i], 1, Length(RTValues[i]) - 1);
end;
Result := RTValues;
end;
// <20><><EFBFBD><EFBFBD>TV<54><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure CopyTVFocusValue(Tv1: TcxGridDBTableView);
var
MVlaue: string;
begin
if not Assigned(Tv1.Controller.FocusedItem) then
exit;
MVlaue := vartoStr(Tv1.Controller.FocusedItem.EditValue);
Clipboard.SetTextBuf(PChar(MVlaue));
end;
procedure SelTVToCDS(Tv1: TcxGridDBTableView; CDS1: TclientDataSet; KeyId: string);
var
i, k, CurRow: Integer;
mvalue: string;
begin
try
CurRow := Tv1.Controller.FocusedRowIndex;
Tv1.DataController.DataSet.DisableControls;
Tv1.DataController.DataSet.First;
CDS1.DisableControls;
with CDS1 do
begin
First;
while not eof do
begin
Edit;
FieldByName('ssel').Value := 0;
Post;
Next;
end;
end;
for k := 0 to Tv1.DataController.GetSelectedCount - 1 do
begin
mvalue := Tv1.DataController.GetValue(Tv1.DataController.GetSelectedRowIndex(k), Tv1.GetColumnByFieldName(KeyId).Index);
if CDS1.Locate(KeyId, mvalue, []) then
begin
with CDS1 do
begin
Edit;
FieldByName('ssel').Value := 1;
Post;
end;
end;
end;
finally
CDS1.EnableControls;
Tv1.Controller.FocusedRowIndex := CurRow;
Tv1.DataController.DataSet.EnableControls;
end;
end;
function SelTVKey(Tv1: TcxGridDBTableView; Keys: TArray<string>): TArray<string>; // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>key
var
RTValues: TArray<string>;
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<string>): TArray<string>; // <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>key
var
RTValues: TArray<string>;
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.DataController.GetSelectedCount - 1 do
begin
if j = 0 then
begin
for i := 0 to Length(RTValues) - 1 do
begin
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.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; }
procedure HiddenTVColumn(Tv1: TcxGridDBTableView; FieldName: string);
begin
Tv1.GetColumnByFieldName(FieldName).Visible := False;
Tv1.GetColumnByFieldName(FieldName).VisibleForCustomization := False;
// Tv1.GetColumnByFieldName(FieldName).Hidden := True;
end;
function FormatTitle(S: string): string;
{ <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>еİ<D0B5><C4B0><EFBFBD><EFBFBD><EFBFBD><E6BBBB>ȫ<EFBFBD><C8AB><EFBFBD>ַ<EFBFBD> }
var
OldStr, NewStr: AnsiString;
i: Integer;
const
SiStr = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=\~!#$%^&()_+|[]{};'':",./<>?';
DoStr = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£ãģţƣǣȣɣʣˣ̣ͣΣϣУѣңӣԣգ֣ףأ٣ڣࣱ<DAA3><E0A3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD>ۣݣ<DBA3><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
begin
for i := 1 to 95 do
begin
OldStr := Copy(SiStr, i, 1);
NewStr := Copy(DoStr, 2 * i - 1, 2);
S := StringReplace(S, OldStr, NewStr, [rfReplaceAll]);
end;
S := Trim(S);
Result := S;
end;
////////////////////////////
procedure selectDataRow(Sender: TcxCustomGridTableView; mKeyField: string);
var
idx, i: integer;
mvalue: string;
begin
if TcxGridDbTableView(Sender).GetColumnByFieldName('ssel') = nil then
exit;
if TcxGridDbTableView(Sender).GetColumnByFieldName(mKeyField) = nil then
exit;
idx := TcxGridDbTableView(Sender).GetColumnByFieldName(mKeyField).Index;
try
TcxGridDbTableView(Sender).BeginUpdate();
TcxGridDbTableView(Sender).DataController.DataSet.DisableControls;
TcxGridDbTableView(Sender).DataController.DataSet.First;
while not TcxGridDbTableView(Sender).DataController.DataSet.eof do
begin
if TcxGridDbTableView(Sender).DataController.GetItemByFieldName('ssel').EditValue = true then
begin
TcxGridDbTableView(Sender).DataController.DataSet.Edit;
TcxGridDbTableView(Sender).DataController.DataSet.FieldByName('ssel').value := false;
TcxGridDbTableView(Sender).DataController.DataSet.Post();
end;
TcxGridDbTableView(Sender).DataController.DataSet.next;
end;
/////////////////////
for i := 0 to TcxGridDbTableView(Sender).DataController.GetSelectedCount - 1 do
begin
mvalue := TcxGridDbTableView(Sender).DataController.GetValue(TcxGridDbTableView(Sender).Controller.SelectedRows[i].RecordIndex, idx);
if TcxGridDbTableView(Sender).DataController.DataSet.Locate(mKeyField, mvalue, []) then
begin
TcxGridDbTableView(Sender).DataController.DataSet.Edit;
TcxGridDbTableView(Sender).DataController.DataSet.FieldByName('ssel').value := true;
TcxGridDbTableView(Sender).DataController.DataSet.Post;
end;
end;
finally
TcxGridDbTableView(Sender).DataController.DataSet.EnableControls;
TcxGridDbTableView(Sender).EndUpdate;
end;
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 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]).Text := fieldByName(mfield).AsString;
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 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
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;
end;
end.