D7szYidui/Z99Dependency/ThreeFun/Fun/U_Fun.pas

4661 lines
146 KiB
ObjectPascal
Raw Normal View History

2025-07-19 14:23:30 +08:00
unit U_Fun;
interface
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
uses
2025-10-18 14:10:28 +08:00
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
2025-07-19 14:23:30 +08:00
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,
2025-10-18 14:10:28 +08:00
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, FTComboBox, cxDropDownEdit,
cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit,
IniFiles, WinSock, IdHTTP, dxcore;
2025-07-19 14:23:30 +08:00
//Function sendarp(ipaddr:ulong;temp:dword;ulmacaddr:pointer;ulmacaddrleng:pointer) : DWord; StdCall; External 'Iphlpapi.dll' Name 'SendARP';
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
type
2025-10-18 14:10:28 +08:00
TA = class(TComponent)
public
S: string;
end;
function SGetHintFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
function SGetMaxId(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; var MaxId: Integer): Boolean;
function SIsRepeated(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; MyCode: string): Boolean;
function SSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
function SSetSaveDataCDS10(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime;
procedure SSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
procedure SSetWinData(ADOQueryTmp: TADOQuery; mParent: TWinControl);
function SDelData(ADOQueryCmd: TADOQuery; mDelStr: string): Boolean;
function SGetFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
function SGetFiltersHint(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
function SGetMaxNo(MyAdoQuery: TADOQuery; MyTable: string; MyField: string; MyFlag: string): string;
procedure SCreateCDS20(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
procedure SInitCDSData20(fromADO: TADOQuery; toCDS: TclientDataSet);
procedure SInitFtComBoxBySql(ADOQueryTmp: TADOQuery; cb: TFtComboBox; FlagType: string; Boxtype: integer; showMsg: string; emptyFlag: Boolean; mSql: string);
procedure SInitComBoxBySql(ADOQueryTmp: TADOQuery; cb: TComboBox; emptyFlag: Boolean; mSql: string);
procedure SInitComBoxByCustCode(ADOQueryTmp: TADOQuery; cb: TComboBox; FlagType: string; Boxtype: integer; showMsg: string; emptyFlag: Boolean);
procedure SInitCxGridComboBoxByCustCode(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FlagType: string; PState: Integer; IsNull: Boolean; Shmeg: string);
procedure SSetsavedata10(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
procedure SSetWinData10(ADOQueryTmp: TADOQuery; mParent: TWinControl);
procedure SInitCxGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
function SSWR(s: real): real; //*****<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *****//
procedure SSetWinData20(ADOQueryTmp: TADOQuery; mParent: TWinControl);
procedure SSetWinData30(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
procedure SCSHData(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
procedure SSetsavedataNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
function SGetServerDate10(ADOQueryTmp: TADOQuery): TDateTime;
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TDateTime;
procedure SCreateCDSSel(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
procedure SInitCDSDataSel(fromADO: TADOQuery; toCDS: TclientDataSet);
procedure CopyAddRow(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>groupformat<61><74><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
procedure CopyAddRowBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet);
procedure OneKeyPost(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet); //һ<><D2BB><EFBFBD>滻ճ<E6BBBB><D5B3>
procedure CopyAddRowCDS(CDS_Sub: TClientDataSet);
function SSetSaveDataCDSNew(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
function SGetFinds(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
function SSetSaveDataCDSBandNew(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: integer; mtype: integer = 0): Boolean;
procedure SSetsaveSql(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
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>');
procedure CreateGroupSummarry(tv1: TcxGridDBTableView);
procedure TcxGridToExcel(mfileName: string; gridName: TcxGrid);
function ReadINIFileStr(ininame, TypeName: string; ValueName, ValueMR: string): string;
procedure SClearData(mParent: TWinControl; FTag: Integer);
procedure SelExportData(FTv: TcxGridDBTableView; FAdoQry: TADOQuery; FTile: string);
procedure SDofilter10(cds_Main: TClientDataSet; FilterStr: string);
procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
procedure ColumnView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBTableView; MKName10: string);
procedure ColumnSet(TV10: TcxGridDBTableView; MKName10: string);
procedure ColumnBandSet(TV10: TcxGridDBBandedTableView; MKName10: string);
procedure ColumnBandView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBBandedTableView; MKName10: string);
procedure SCSHDataWTag(ADOQueryTmp: TADOQuery; mParent: TWinControl);
procedure GetSWLDZ(IPStr: string);
procedure SCSHDataCDS(CDS_Main: TClientDataSet; mParent: TWinControl; FTag: Integer);
procedure SelPrintData(FTv: TcxGridDBTableView; FAdoQry: TADOQuery; FTitle: string; FLTitle: string; FRTile: string);
procedure SSetEditDataCDSNew(yClientDataset: TclientDataSet; mClientDataset: TclientDataSet);
procedure SelPrintDataMore(FTv: TcxGridDBTableView; FAdoQry: TADOQuery; FTitle: string; FLTitle: string; FRTile: string; FKK: Integer; FiniName: string);
procedure SelExportDataBand(FTv: TcxGridDBBandedTableView; FAdoQry: TADOQuery; FTile: string);
procedure SSetsaveSqlNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
procedure SCSHDataNew(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
function RTSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
function RTSetSaveDataCDSBand(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
procedure SCreateCDSOnly(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
procedure SInitCDSDataOnly(fromADO: TADOQuery; toCDS: TclientDataSet);
procedure SelOKNo(CDS_MainSel: TClientDataSet; FSel: Boolean);
function num2cengnum(strArabic: string): string;
function num2ceng(strArabic: string): string;
procedure RTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
procedure InitOrderColor(OrdMainId: string; Combox: TComboBox; FAdoQry: TADOQuery);
procedure InitBCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
procedure InitRCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
procedure DelCDS(ClientDataSet1: TClientDataSet; ADOCmd: TADOQuery; DelSql: string);
function GetKw(ADOQueryTmp: TADOQuery; C_CodeName, C_Color: string): string;
procedure InitAdoToCds(Ado1: TADOQuery; Cds1: TclientDataSet);
function SGetCDSFilters(Tv1: TcxGridDBTableView; CDS1: TclientDataSet): string; // ƴ<>Ӳ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>TclientDataSet
procedure CreateAdoToCds(Ado1: TADOQuery; Cds1: TclientDataSet);
function num2cengnumZS(strArabic: string): string;
procedure HJ(mClientDataset: TclientDataSet; Label1: TLabel; mfieldName: double);
procedure SetDate(adoquery: TADOQuery; FromName, UserName: string; begdate, enddate: TDateTime);
function GetBEDate(adoquery: TADOQuery; FromName, UserName: string): Integer;
procedure SCreateCDSYS(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
procedure SInitCDSDataYS(fromADO: TADOQuery; toCDS: TclientDataSet);
procedure GetHTTP(IdHttp: TIdHTTP; FUrl: string);
function RoundFloat(f: double; i: integer): double;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡָ<C8A1><D6B8>λС<CEBB><D0A1>
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;
procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime);
procedure initBtnColor(panel12: TPanel; clMenu: TColor);
procedure ClearOrHideControls(TMPanel: TPanel; HintValue: string; IsClear: Boolean; IsHide: Boolean);
procedure AssignmentControls(TMPanel: TPanel; TMClientDataset: TclientDataSet; Hintvalue: string);
procedure IsVisibleTV(TMPanel: TPanel; MTV: TcxGridDBTableView; Hintvalue: string; IsVisible: Boolean);
function Utf8Encode(const WS: WideString): UTF8String;
procedure WriteCxGridAll(fileName: string; cxgrid: TcxGridDBTableView; ADOQueryCmdSC: TADOQuery; ADOQueryTmp: TADOQuery);
procedure ReadCxGridAll(fileName: string; cxgrid: TcxGridDBTableView);
procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean);
2025-07-19 14:23:30 +08:00
implementation
2025-10-18 14:10:28 +08:00
uses
U_DataLink, U_SelExportField, U_ColumnSet, U_ColumnBandSet, U_SelPrintFieldNew;
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD>
///////////////////////////////////////////////////////
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
procedure SelOKNoFiler(Tv1: TcxGridDBTableView; FSel: Boolean);
var
i: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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 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;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Trim(Result) <> '' then
Result := Trim(RightStr(Result, Length(Result) - 4));
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
function SGetCDSFilters(Tv1: TcxGridDBTableView; CDS1: TclientDataSet): string;
var
i: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := '';
if CDS1.isEmpty then
exit;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Trim(Result) <> '' then
Result := Trim(RightStr(Result, Length(Result) - 4));
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
procedure WriteCxGridAll(fileName: string; cxgrid: TcxGridDBTableView; ADOQueryCmdSC: TADOQuery; ADOQueryTmp: TADOQuery);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
mFileName, fFileName, fpathFileName: string;
Stream: TMemoryStream;
mfileSize: integer;
mCreationTime: TdateTime;
mWriteTime: TdateTime;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg';
if not DirectoryExists(ExtractFileDir(mFileName)) then
CreateDir(ExtractFileDir(mFileName));
//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
cxgrid.StoreToIniFile(mFileName);
fFileName := fileName + '.dbg';
fpathFileName := Trim(ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg');
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
ADOQueryCmdSC.Connection.BeginTrans;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
with ADOQueryCmdSC do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
close;
sql.Clear;
sql.Add('delete from RT_FileUpdate');
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
execsql;
end;
with ADOQueryCmdSC 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(Trim(fpathFileName), mfileSize, mCreationTime, mWriteTime);
if RecordCount <= 0 then
begin
Append;
fieldByName('FileName').AsString := trim(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 := SGetServerDateTime(ADOQueryTmp);
fieldByName('FilePath').Value := 'LayOut';
fieldByName('FileType').Value := '<27><><EFBFBD><EFBFBD>';
//<2F><>OLE<4C><45><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
tblobfield(FieldByName('Files')).LoadFromFile(fpathFileName);
post;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
finally
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
ADOQueryCmdSC.Connection.CommitTrans;
except
ADOQueryCmdSC.Connection.RollbackTrans;
application.MessageBox(pchar('<27><EFBFBD>ļ<EFBFBD>[' + trim(fFileName) + ']ʧ<><CAA7>!'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
procedure ReadCxGridAll(fileName: string; cxgrid: TcxGridDBTableView);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
mFileName: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg';
//<2F>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>лָ<D0BB>
if FileExists(mFileName) then
cxgrid.RestoreFromIniFile(mFileName);
CreateGroupSummarry(cxgrid);
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(PChar(Temp), Length(Temp) + 1, PWideChar(WS), Length(WS));
if L > 0 then
SetLength(Temp, L - 1)
else
Temp := '';
Result := Temp;
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TMPanel.Controls[j] is TEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(TMPanel.Controls[j]).Hint) = Hintvalue then
begin
with MTV do
begin
for i := 0 to MTV.ColumnCount - 1 do
begin
if Trim(TEdit(TMPanel.Controls[j]).Name) = Trim(MTV.Columns[i].DataBinding.FieldName) then
begin
MTV.Columns[i].Visible := IsVisible;
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
if Trim(TComboBox(TMPanel.Controls[j]).Name) = Trim(MTV.Columns[i].DataBinding.FieldName) then
begin
MTV.Columns[i].Visible := IsVisible;
Continue;
end;
end;
end;
end;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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;
if Controls[i] is TComboBox then
begin
if Trim(TEdit(Controls[i]).Hint) = Hintvalue then
begin
TComboBox(Controls[i]).ItemIndex := TComboBox(Controls[i]).Items.IndexOf(Trim(TMClientDataset.FieldByName(TComboBox(Controls[i]).Name).AsString));
end;
end;
2025-07-19 14:23:30 +08:00
end;
end;
end;
2025-10-18 14:10:28 +08:00
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///////////////////////////////////////////////////////
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
procedure ClearOrHideControls(TMPanel: TPanel; HintValue: string; IsClear: Boolean; IsHide: Boolean);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with TMPanel do
begin
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TCheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TCheckBox(Controls[i]).Hint = HintValue then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
if Controls[i] is TEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Hint) = HintValue then
begin
TEdit(Controls[i]).Visible := IsHide;
if IsClear then
TEdit(Controls[i]).Text := '';
end;
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>ˢ<EFBFBD>°<EFBFBD>ť<EFBFBD><C5A5>ɫ
///////////////////////////////////////////////////////
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
procedure initBtnColor(panel12: TPanel; clMenu: TColor);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with panel12 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to panel12.ControlCount - 1 do
begin
if Controls[i] is TEdit then
begin
TEdit(Controls[i]).Color := clMenu;
TEdit(Controls[i]).ReadOnly := True;
end
else if Controls[i] is TMemo then
begin
TMemo(Controls[i]).Color := clMenu;
TMemo(Controls[i]).ReadOnly := True;
end
else if Controls[i] is TComboBox then
begin
TComboBox(Controls[i]).Color := clMenu;
TComboBox(Controls[i]).Enabled := False;
end
else if Controls[i] is TDateTimePicker then
begin
TDateTimePicker(Controls[i]).Color := clMenu;
TDateTimePicker(Controls[i]).Enabled := False;
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).Color := clMenu;
TBtnEditA(Controls[i]).Enabled := False;
end;
end;
2025-07-19 14:23:30 +08:00
end;
end;
///////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
///////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
function ExportFtErpFile(mFileName: string; ADORead: TADOQuery): boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
Stream: TMemoryStream;
ff: TADOBlobstream;
mfileSize: integer;
mCreationTime: TdateTime;
mWriteTime: TdateTime;
IsFileHas: boolean;
mChildPath: string;
mFilePath: string;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
result := false;
mChildPath := '';
2025-07-19 14:23:30 +08:00
///////////////////////////////////////////////
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>·<EFBFBD><C2B7>
with ADORead do
begin
close;
2025-10-18 14:10:28 +08:00
sql.Clear;
2025-07-19 14:23:30 +08:00
sql.Add('select FilePath ');
sql.Add('from RT_FileUpdate');
2025-10-18 14:10:28 +08:00
sql.Add('where FileName=' + quotedStr(mFileName));
2025-07-19 14:23:30 +08:00
Open;
2025-10-18 14:10:28 +08:00
if RecordCount > 0 then
2025-07-19 14:23:30 +08:00
begin
// if not fieldByName('valid').AsBoolean then exit;
2025-10-18 14:10:28 +08:00
if trim(fieldByName('FilePath').AsString) <> '' then
mChildPath := trim(fieldByName('FilePath').AsString) + '\';
2025-07-19 14:23:30 +08:00
end;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>
2025-10-18 14:10:28 +08:00
mFilePath := ExtractFilePath(Paramstr(0)) + mChildPath;
IsFileHas := FileExists(mFilePath + mFileName);
2025-07-19 14:23:30 +08:00
if IsFileHas then
begin
//////////////////////////
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
2025-10-18 14:10:28 +08:00
GetFileInfo(mFilePath + mFileName, mfileSize, mCreationTime, mWriteTime);
2025-07-19 14:23:30 +08:00
end;
//////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
if IsFileHas then
begin
with ADORead do
begin
close;
2025-10-18 14:10:28 +08:00
sql.Clear;
2025-07-19 14:23:30 +08:00
sql.Add('select count(FileName) as cnt ');
sql.Add('from RT_FileUpdate');
2025-10-18 14:10:28 +08:00
sql.Add('where FileName=' + quotedStr(mFileName));
2025-07-19 14:23:30 +08:00
// sql.Add('and fileEditDate>'''+formatDateTime('yyyy-MM-dd hh:mm',mWriteTime)+'''');
2025-10-18 14:10:28 +08:00
sql.Add(' and DATEDIFF(minute,' + quotedStr(formatDateTime('yyyy-MM-dd hh:mm', mWriteTime)) + ',fileEditDate)>0');
2025-07-19 14:23:30 +08:00
Open;
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
2025-10-18 14:10:28 +08:00
if fieldByName('cnt').AsInteger > 0 then
2025-07-19 14:23:30 +08:00
begin
close;
2025-10-18 14:10:28 +08:00
sql.Clear;
2025-07-19 14:23:30 +08:00
sql.Add('select * ');
sql.Add('from RT_FileUpdate');
2025-10-18 14:10:28 +08:00
sql.Add('where FileName=' + quotedStr(mFileName));
2025-07-19 14:23:30 +08:00
Open;
ff := TADOBlobstream.Create(fieldByName('Files') as TblobField, bmRead);
end
else
begin
exit;
end;
2025-10-18 14:10:28 +08:00
if trim(fieldByName('FilePath').AsString) <> '' then
mChildPath := trim(fieldByName('FilePath').AsString) + '\';
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end //////////////////////////////////////
2025-07-19 14:23:30 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
else
begin
with ADORead do
begin
close;
2025-10-18 14:10:28 +08:00
sql.Clear;
2025-07-19 14:23:30 +08:00
sql.Add('select * ');
sql.Add('from RT_FileUpdate');
2025-10-18 14:10:28 +08:00
sql.Add('where FileName=' + quotedStr(mFileName));
2025-07-19 14:23:30 +08:00
Open;
2025-10-18 14:10:28 +08:00
if recordCount > 0 then
2025-07-19 14:23:30 +08:00
begin
ff := TADOBlobstream.Create(fieldByName('Files') as TblobField, bmRead);
end
else
begin
exit;
end;
2025-10-18 14:10:28 +08:00
if trim(fieldByName('FilePath').AsString) <> '' then
mChildPath := trim(fieldByName('FilePath').AsString) + '\';
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
if ff <> nil then
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
mFileName := trim(ADORead.fieldByName('FileName').asString);
if not DirectoryExists(ExtractFileDir(mFilePath + mFileName)) then
ForceDirectories(ExtractFileDir(mFilePath + mFileName));
Stream := TMemoryStream.Create;
2025-07-19 14:23:30 +08:00
//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)
2025-10-18 14:10:28 +08:00
Stream.SaveToFile(mFilePath + mFileName); //+'\tmpFile\'
2025-07-19 14:23:30 +08:00
//OleContainer1.SaveToFile('tmp');
finally
2025-10-18 14:10:28 +08:00
Stream.Free;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
UpdateFileTime(mFilePath + mFileName, ADORead.fieldByName('FileCreateDate').AsDateTime, ADORead.fieldByName('FileEditDate').AsDateTime, ADORead.fieldByName('FileEditDate').AsDateTime);
Result := true;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
application.MessageBox(pchar('<27><>ȡ<EFBFBD>ļ<EFBFBD>' + mFileName + <><CAA7>!'), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
vSearchRec: TSearchRec;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FindFirst(mFile, faAnyFile, vSearchRec);
mfileSize := vSearchRec.Size;
CreationTime := CovFileDate(vSearchRec.FindData.ftCreationTime); //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
2025-07-19 14:23:30 +08:00
//vSearchRec.FindData.ftLastAccessTime//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
2025-10-18 14:10:28 +08:00
WriteTime := CovFileDate(vSearchRec.FindData.ftLastWriteTime); //<2F>޸<EFBFBD>ʱ<EFBFBD><CAB1>
FindClose(vSearchRec);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
procedure GetFileEditTime(mFile: string; var editTime: tdatetime);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
vSearchRec: TSearchRec;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FindFirst(mFile, faAnyFile, vSearchRec);
2025-07-19 14:23:30 +08:00
//mfileSize:=vSearchRec.Size;
// CreationTime:=CovFileDate(vSearchRec.FindData.ftCreationTime);//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
//vSearchRec.FindData.ftLastAccessTime//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
2025-10-18 14:10:28 +08:00
editTime := CovFileDate(vSearchRec.FindData.ftLastWriteTime); //<2F>޸<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;
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)); //<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
result := StrToFloat(FormatFloat(s, ef));
end;
procedure GetHTTP(IdHttp: TIdHTTP; FUrl: string);
var
ResponseStream: TStringStream; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
ResponseStr: string;
begin
//<2F><><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); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
except
on e: Exception do
begin
ShowMessage(e.Message);
end;
end;
//<2F><>ȡ<EFBFBD><C8A1>ҳ<EFBFBD><D2B3><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Ϣ
ResponseStr := ResponseStream.DataString;
//<2F><>ҳ<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;
procedure SInitCDSDataYS(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;
inc(k);
Post;
end;
fromADO.Next;
end;
if not toCDS.IsEmpty then
begin
toCDS.First;
end;
finally
toCDS.EnableControls;
end;
end;
procedure SCreateCDSYS(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.Close;
mClientDataset.CreateDataSet;
end;
function GetBEDate(adoquery: TADOQuery; FromName, UserName: string): Integer;
var
bedate: Integer;
begin
with adoquery do
begin
Close;
SQL.Clear;
SQL.Add('select * from Set_Date where FromName=' + quotedstr(Trim(FromName)));
SQL.add(' and UserName=' + quotedstr(Trim(UserName)));
Open;
end;
if adoquery.IsEmpty then
begin
bedate := 30;
end
else
begin
bedate := adoquery.fieldbyname('BEDate').asinteger;
end;
Result := bedate;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
procedure SetDate(adoquery: TADOQuery; FromName, UserName: string; begdate, enddate: TDateTime);
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with adoquery do
begin
Close;
sql.Clear;
SQL.Add('delete Set_Date where FromName=' + quotedstr(Trim(FromName)));
SQL.Add('and UserName=' + quotedstr(Trim(UserName)));
ExecSQL;
end;
with adoquery do
begin
Close;
sql.Clear;
SQL.Add('insert into Set_Date(FromName,UserName,BEDate) values(:FromName,:UserName,:BEDate)');
Parameters.ParamByName('FromName').Value := Trim(FromName);
Parameters.ParamByName('UserName').Value := Trim(UserName);
Parameters.ParamByName('BEDate').Value := enddate - begdate;
ExecSQL;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
procedure CreateAdoToCds(Ado1: TADOQuery; Cds1: TclientDataSet);
var
i: integer;
mfieldName: string;
mSize: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldName := '';
Cds1.FieldDefs.Clear;
with Ado1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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);
Cds1.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
end;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
Cds1.FieldDefs.Add('flag', ftString, 1);
Cds1.FieldDefs.Add('index', ftInteger, 0);
Cds1.Close;
Cds1.CreateDataSet;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
procedure InitAdoToCds(Ado1: TADOQuery; Cds1: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
k: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Ado1.DisableControls;
Cds1.DisableControls;
Ado1.first;
k := 1;
while not Ado1.Eof do
begin
with Cds1 do
begin
Append;
for i := 0 to Ado1.FieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fields[i].value := Ado1.Fields[i].Value;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
fieldByName('flag').AsString := '1';
fieldByName('index').value := k;
inc(k);
Post;
end;
Ado1.Next;
end;
if not Cds1.IsEmpty then
begin
Cds1.First;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
Ado1.EnableControls;
Cds1.EnableControls;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
function GetKw(ADOQueryTmp: TADOQuery; C_CodeName, C_Color: string): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
kw: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
kw := '';
2025-07-19 14:23:30 +08:00
try
with ADOQueryTmp do
begin
close;
SQL.Clear;
sql.add(' select zdyCode from KH_Zdy_Attachment ');
2025-10-18 14:10:28 +08:00
sql.add(' where defstr1=' + quotedstr(trim(C_CodeName)));
sql.add(' and defstr2=' + quotedstr(trim(C_Color)));
2025-07-19 14:23:30 +08:00
sql.add(' and Type=''CPKW'' ');
sql.add(' and isnull(DEFstr3,'''')=''<27>̶<EFBFBD><CCB6><EFBFBD>'' ');
open;
2025-10-18 14:10:28 +08:00
if not isEmpty then
kw := trim(fieldbyname('zdyCode').asstring);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
result := kw;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
result := kw;
2025-07-19 14:23:30 +08:00
end;
end;
///////////////////ȡ<><C8A1><EFBFBD><EFBFBD>Int<6E><74><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>ֵ///////////////////////////////////////
2025-10-18 14:10:28 +08:00
function SGetMaxId(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; var MaxId: Integer): Boolean;
2025-07-19 14:23:30 +08:00
begin
try
with AdoQueryTemp do
begin
Close;
SQL.Clear;
2025-10-18 14:10:28 +08:00
SQL.Add('select Max(' + MyField + ')+1 MaxId from ' + MyTable);
2025-07-19 14:23:30 +08:00
Open;
end;
with AdoQueryTemp do
begin
2025-10-18 14:10:28 +08:00
if (Trim(FieldByName('MaxId').AsString) = '') or (Trim(FieldByName('MaxId').AsString) = NULL) then
MaxId := 1
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
MaxId := (fieldbyname('MaxId').AsInteger);
2025-07-19 14:23:30 +08:00
Close;
SQL.Clear;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD>ֵʧ<D6B5>ܣ<EFBFBD>', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
procedure InitBCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
fsj: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fsj := 'select distinct(AOrdDefStr1) Code from JYOrder_Sub_AnPai ' + ' where Subid=''' + Trim(OrdSubId) + '''';
2025-07-19 14:23:30 +08:00
with FAdoQry do
begin
Close;
sql.Clear;
sql.Add(fsj);
Open;
end;
Combox.Clear;
with FAdoQry do
begin
First;
while not Eof do
begin
Combox.Items.Add(Trim(FAdoQry.fieldbyname('Code').AsString));
Next;
end;
end;
Combox.Items.Add('');
end;
2025-10-18 14:10:28 +08:00
procedure InitRCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
fsj: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fsj := 'select distinct(gangno) Code from JYOrder_Sub_AnPai ' + ' where Subid=''' + Trim(OrdSubId) + '''';
2025-07-19 14:23:30 +08:00
with FAdoQry do
begin
Close;
sql.Clear;
sql.Add(fsj);
Open;
end;
Combox.Clear;
with FAdoQry do
begin
First;
while not Eof do
begin
Combox.Items.Add(Trim(FAdoQry.fieldbyname('Code').AsString));
Next;
end;
end;
Combox.Items.Add('');
end;
2025-10-18 14:10:28 +08:00
procedure InitOrderColor(OrdMainId: string; Combox: TComboBox; FAdoQry: TADOQuery);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
fsj: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fsj := 'select distinct(PRTColor) Code from JYOrder_Sub ' + ' where Mainid=''' + Trim(OrdMainId) + '''';
2025-07-19 14:23:30 +08:00
with FAdoQry do
begin
Close;
sql.Clear;
sql.Add(fsj);
Open;
end;
Combox.Clear;
with FAdoQry do
begin
First;
while not Eof do
begin
Combox.Items.Add(Trim(FAdoQry.fieldbyname('Code').AsString));
Next;
end;
end;
Combox.Items.Add('');
end;
////<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ӡ
2025-10-18 14:10:28 +08:00
procedure SelPrintData(FTv: TcxGridDBTableView; FAdoQry: TADOQuery; FTitle: string; FLTitle: string; FRTile: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, j, k, KK: Integer;
fsj: string;
FOrder, fcolumnName: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FAdoQry.IsEmpty then
Exit;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew := TfrmSelPrintFieldNew.Create(Application);
2025-07-19 14:23:30 +08:00
with frmSelPrintFieldNew do
begin
with frmSelPrintFieldNew.PrnGrid do
begin
PrnGrid.Columns.Clear;
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew.IniName := FTitle;
for i := 0 to FTv.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FTv.Columns[i].Visible = True then
2025-07-19 14:23:30 +08:00
begin
PrnGrid.Columns.Add;
2025-10-18 14:10:28 +08:00
j := PrnGrid.Columns.Count - 1;
PrnGrid.Columns[j].Title.Caption := FTv.Columns[i].Caption;
PrnGrid.Columns[j].FieldName := FTv.Columns[i].DataBinding.FieldName;
PrnGrid.Columns[j].Width := FTv.Columns[i].Width;
if FTv.Columns[i].SortOrder = soAscending then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FOrder := ' ' + FTv.Columns[i].DataBinding.FieldName + ' ';
end
else if FTv.Columns[i].SortOrder = soDescending then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FOrder := ' ' + FTv.Columns[i].DataBinding.FieldName + ' DESC';
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
FAdoQry.Sort := FOrder;
2025-07-19 14:23:30 +08:00
frmSelPrintFieldNew.RMPrintDBGrid1.PageCaptionMsg.TitleMemo.Add(FTitle);
frmSelPrintFieldNew.RMPrintDBGrid1.PageCaptionMsg.CaptionMsg.LeftMemo.Add(FLTitle);
frmSelPrintFieldNew.RMPrintDBGrid1.PageCaptionMsg.CaptionMsg.RightMemo.Add(FRTile);
2025-10-18 14:10:28 +08:00
SCreatecds20(FAdoQry, frmSelPrintFieldNew.ClientDataSet1);
SInitCDSData20(FAdoQry, frmSelPrintFieldNew.ClientDataSet1);
if FTv.OptionsView.Footer = True then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FTv.DataController.Summary.FooterSummaryItems.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
frmSelPrintFieldNew.ClientDataSet1.Append;
//frmSelPrintFieldNew.ClientDataSet1.FieldByName('Sindex').Value:=frmSelPrintFieldNew.ClientDataSet1.RecNo+1;
frmSelPrintFieldNew.ClientDataSet1.Post;
2025-10-18 14:10:28 +08:00
KK := 0;
for i := 0 to FTv.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FTv.Columns[i].Visible = False then
Continue;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
fcolumnName := FTv.Columns[i].Name;
if FTv.Columns[i].Summary.FooterKind <> sknone then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for k := 0 to FTv.DataController.Summary.FooterSummaryItems.Count - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TcxGridDBTableSummaryItem(FTv.DataController.Summary.FooterSummaryItems.Items[k]).Column.Name = fcolumnName then
2025-07-19 14:23:30 +08:00
begin
frmSelPrintFieldNew.ClientDataSet1.edit;
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew.ClientDataSet1.FieldByName(FTv.Columns[i].DataBinding.FieldName).Value := FTv.DataController.Summary.FooterSummaryValues[k];
2025-07-19 14:23:30 +08:00
frmSelPrintFieldNew.ClientDataSet1.Post;
end;
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
if ShowModal = 1 then
2025-07-19 14:23:30 +08:00
begin
end;
end;
finally
frmSelPrintFieldNew.Free;
end;
end;
////<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ӡ
2025-10-18 14:10:28 +08:00
procedure SelPrintDataMore(FTv: TcxGridDBTableView; FAdoQry: TADOQuery; FTitle: string; FLTitle: string; FRTile: string; FKK: Integer; FiniName: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, j, k, KK: Integer;
fsj: string;
FOrder, fcolumnName: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FAdoQry.IsEmpty then
Exit;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew := TfrmSelPrintFieldNew.Create(Application);
2025-07-19 14:23:30 +08:00
with frmSelPrintFieldNew do
begin
with frmSelPrintFieldNew.PrnGrid do
begin
PrnGrid.Columns.Clear;
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew.IniName := FiniName;
for i := 0 to FTv.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FTv.Columns[i].Visible = True then
2025-07-19 14:23:30 +08:00
begin
PrnGrid.Columns.Add;
2025-10-18 14:10:28 +08:00
j := PrnGrid.Columns.Count - 1;
PrnGrid.Columns[j].Title.Caption := FTv.Columns[i].Caption;
PrnGrid.Columns[j].FieldName := FTv.Columns[i].DataBinding.FieldName;
PrnGrid.Columns[j].Width := FTv.Columns[i].Width;
if FTv.Columns[i].SortOrder = soAscending then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FOrder := ' ' + FTv.Columns[i].DataBinding.FieldName + ' ';
end
else if FTv.Columns[i].SortOrder = soDescending then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FOrder := ' ' + FTv.Columns[i].DataBinding.FieldName + ' DESC';
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
FAdoQry.Sort := FOrder;
2025-07-19 14:23:30 +08:00
frmSelPrintFieldNew.RMPrintDBGrid1.PageCaptionMsg.TitleMemo.Add(FTitle);
frmSelPrintFieldNew.RMPrintDBGrid1.PageCaptionMsg.CaptionMsg.LeftMemo.Add(FLTitle);
frmSelPrintFieldNew.RMPrintDBGrid1.PageCaptionMsg.CaptionMsg.RightMemo.Add(FRTile);
2025-10-18 14:10:28 +08:00
SCreatecds20(FAdoQry, frmSelPrintFieldNew.ClientDataSet1);
SInitCDSData20(FAdoQry, frmSelPrintFieldNew.ClientDataSet1);
if FTv.OptionsView.Footer = True then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FTv.DataController.Summary.FooterSummaryItems.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
frmSelPrintFieldNew.ClientDataSet1.Append;
frmSelPrintFieldNew.ClientDataSet1.Post;
2025-10-18 14:10:28 +08:00
KK := 0;
for i := 0 to FTv.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fcolumnName := FTv.Columns[i].Name;
if FTv.Columns[i].Summary.FooterKind <> sknone then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if KK = 0 then
2025-07-19 14:23:30 +08:00
begin
frmSelPrintFieldNew.ClientDataSet1.edit;
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew.ClientDataSet1.FieldByName(FTv.Columns[i - FKK].DataBinding.FilterFieldName).Value := 'Total';
2025-07-19 14:23:30 +08:00
frmSelPrintFieldNew.ClientDataSet1.Post;
2025-10-18 14:10:28 +08:00
KK := 99;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
for k := 0 to FTv.DataController.Summary.FooterSummaryItems.Count - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TcxGridDBTableSummaryItem(FTv.DataController.Summary.FooterSummaryItems.Items[k]).Column.Name = fcolumnName then
2025-07-19 14:23:30 +08:00
begin
frmSelPrintFieldNew.ClientDataSet1.edit;
2025-10-18 14:10:28 +08:00
frmSelPrintFieldNew.ClientDataSet1.FieldByName(FTv.Columns[i].DataBinding.FieldName).Value := FTv.DataController.Summary.FooterSummaryValues[k];
2025-07-19 14:23:30 +08:00
frmSelPrintFieldNew.ClientDataSet1.Post;
end;
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
if ShowModal = 1 then
2025-07-19 14:23:30 +08:00
begin
end;
end;
finally
frmSelPrintFieldNew.Free;
end;
end;
///////////////////////<2F>жϱ<D0B6><CFB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ظ<EFBFBD>///////////////////////////////////
2025-10-18 14:10:28 +08:00
function SIsRepeated(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; MyCode: string): Boolean;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
2025-07-19 14:23:30 +08:00
with AdoQueryTemp do
begin
Close;
SQL.Clear;
2025-10-18 14:10:28 +08:00
SQL.Add('select * from ' + MyTable + ' where ' + MyField + '=''' + Trim(MyCode) + '''');
2025-07-19 14:23:30 +08:00
Open;
2025-10-18 14:10:28 +08:00
if IsEmpty then
Result := True;
2025-07-19 14:23:30 +08:00
Close;
SQL.Clear;
end;
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
////////////////////<2F><><EFBFBD><EFBFBD>ClientDataSet<65>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>Ϣ/////////////////////////////
2025-10-18 14:10:28 +08:00
function SSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
2025-07-19 14:23:30 +08:00
end;
end;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
////////////////////<2F><><EFBFBD><EFBFBD>ClientDataSet<65>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>Ϣ/////////////////////////////
2025-10-18 14:10:28 +08:00
function SSetSaveDataCDSNew(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Visible = True then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '1' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
2025-07-19 14:23:30 +08:00
end
else
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := null;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
if Trim(Tv1.Columns[i].Summary.GroupFormat) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].Summary.GroupFormat).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).Value;
end; { else
2025-07-19 14:23:30 +08:00
begin
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value:=null;
end; }
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
function RTSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if trim(Tv1.Columns[i].DataBinding.FieldName) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
2025-07-19 14:23:30 +08:00
end
else
begin
2025-10-18 14:10:28 +08:00
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) = '0' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := 0;
end
else
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := null;
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
function RTSetSaveDataCDSBand(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
end
else
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '' then
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := 0
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := Trim(Tv1.Columns[i].Summary.GroupFooterFormat);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
function SSetSaveDataCDSBandNew(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '1' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end;
if Trim(Tv1.Columns[i].Summary.GroupFormat) <> '' then
begin
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).AsString) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AdoQueryCmd.FieldByName(Tv1.Columns[i].Summary.GroupFormat).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).Value;
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
////////////////////<2F><><EFBFBD><EFBFBD>ClientDataSet<65>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>Ϣ/////////////////////////////
2025-10-18 14:10:28 +08:00
function SSetSaveDataCDS10(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
Result := False;
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Tv1.Columns[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
Result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>Cds<64><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>!', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
///////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////////////////
2025-10-18 14:10:28 +08:00
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime;
//var
// FSetting: TFormatSettings;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
// try
// FSetting := TFormatSettings.Create(LOCALE_USER_DEFAULT);
// FSetting.ShortDateFormat := 'yyyy-MM-dd';
// FSetting.DateSeparator := '-';
// with ADOQueryTmp do
// begin
// close;
// sql.Clear;
// sql.Add('select getDate()as dt');
// open;
// result := StrToDateTime(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime), FSetting);
// end;
// except
// application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
// end;
2025-07-19 14:23:30 +08:00
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
open;
2025-10-18 14:10:28 +08:00
result := StrToDate(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime));
2025-07-19 14:23:30 +08:00
close;
SQL.Clear;
end;
except
2025-10-18 14:10:28 +08:00
application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime;
//var
// FSetting: TFormatSettings;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
// try
// FSetting := TFormatSettings.Create(LOCALE_USER_DEFAULT);
// FSetting.ShortDateFormat := 'yyyy-MM-dd';
// FSetting.DateSeparator := '-';
// with ADOQueryTmp do
// begin
// close;
// sql.Clear;
// sql.Add('select getDate()as dt');
// open;
// result := StrToDateTime(formatdatetime('yyyy-MM-dd HH:mm:ss', fieldByName('dt').AsDatetime), FSetting);
// end;
// except
// application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
// end;
2025-07-19 14:23:30 +08:00
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
open;
2025-10-18 14:10:28 +08:00
result := fieldByName('dt').AsDatetime;
2025-07-19 14:23:30 +08:00
close;
SQL.Clear;
end;
except
2025-10-18 14:10:28 +08:00
application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
function SGetServerDate10(ADOQueryTmp: TADOQuery): TdateTime;
2025-07-19 14:23:30 +08:00
begin
try
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
open;
2025-10-18 14:10:28 +08:00
result := StrToDate(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime));
2025-07-19 14:23:30 +08:00
close;
SQL.Clear;
end;
except
2025-10-18 14:10:28 +08:00
application.MessageBox('<27><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
/////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ֶθ<D6B6>ֵ
/////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure SSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
with Myparent do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text);
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
end
else if Controls[i] is TcxRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TcxRichEdit(Controls[i]).Text;
end
else if Controls[i] is TMemo then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TFTComboBox(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TFTComboBox(Controls[i]).Item2);
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
end
else if Controls[i] is TCheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TCheckBox(Controls[i]).Checked = True then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 1
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 0;
end
else if Controls[i] is TDateTimePicker then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).ShowCheckbox then
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TBtnEditA(Controls[i]).Hint = '<27><><EFBFBD><EFBFBD>' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).Text)
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
end
else if Controls[i] is TcxTimeEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SSetsavedataNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
with Myparent do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text);
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
end
else if Controls[i] is TMemo then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TFTComboBox(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TFTComboBox(Controls[i]).Item2);
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
end
else if Controls[i] is TDateTimePicker then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).ShowCheckbox then
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
if (TBtnEditA(Controls[i]).Hint <> '') and (TBtnEditA(Controls[i]).ParentCtl3D = True) then
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).Text);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
2025-07-19 14:23:30 +08:00
//if (TBtnEditC(Controls[i]).Hint<>'') and (TBtnEditC(Controls[i]).ParentCtl3D=True)then
//ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value:=Trim(TBtnEditC(Controls[i]).Text);
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TcxTimeEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure RTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
with Myparent do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text)
else
ADOQueryCmd.FieldByName(Controls[i].Name).Value := '';
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
end
else if Controls[i] is TMemo then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TFTComboBox(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TFTComboBox(Controls[i]).Item2);
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
end
else if Controls[i] is TDateTimePicker then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).ShowCheckbox then
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
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 TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).Text);
if (TBtnEditA(Controls[i]).Hint <> '') then
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).Text);
if (TBtnEditC(Controls[i]).Hint <> '') then
ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
end
else if Controls[i] is TcxTimeEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SSetsaveSql(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
MCode: string;
2025-07-19 14:23:30 +08:00
begin
with Myparent do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text);
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
end
else if Controls[i] is TcxRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TcxRichEdit(Controls[i]).Text;
end
else if Controls[i] is TMemo then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
end
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TFTComboBox(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TFTComboBox(Controls[i]).Item2);
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
end
else if Controls[i] is TDateTimePicker then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).ShowCheckbox then
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
end
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
if (TBtnEditA(Controls[i]).Hint <> '') and (TBtnEditA(Controls[i]).ParentCtl3D = True) then
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).Text);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
2025-07-19 14:23:30 +08:00
//if (TBtnEditC(Controls[i]).Hint<>'') and (TBtnEditC(Controls[i]).ParentCtl3D=True)then
//ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value:=Trim(TBtnEditC(Controls[i]).Text);
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TcxTimeEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
end
else if Controls[i] is TcxButtonEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TcxButtonEdit(Controls[i]).BeepOnEnter = True) or (TcxButtonEdit(Controls[i]).ParentShowHint = True) then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxButtonEdit(Controls[i]).Text);
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
MCode := Copy(Trim(Controls[i].Name), 1, Length(Trim(Controls[i].Name)) - 4);
ADOQueryCmd.FieldByName(MCode).Value := Trim(TcxButtonEdit(Controls[i]).Hint);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SSetsaveSqlNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
MCode: string;
2025-07-19 14:23:30 +08:00
begin
with Myparent do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text)
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Null;
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
end
else if Controls[i] is TCheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if TCheckBox(Controls[i]).Checked = True then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 1
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 0;
end
else if Controls[i] is TcxRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TcxRichEdit(Controls[i]).Text;
end
else if Controls[i] is TMemo then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
end
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TFTComboBox(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TFTComboBox(Controls[i]).Item2);
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
end
else if Controls[i] is TDateTimePicker then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).ShowCheckbox then
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
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 TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).Text);
if (TBtnEditA(Controls[i]).Hint <> '') then
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).Text);
if (TBtnEditC(Controls[i]).Hint <> '') then
begin
if Pos('/', TBtnEditC(Controls[i]).Hint) > 0 then
begin
end
else
ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
end;
end
else if Controls[i] is TcxTimeEdit then
begin
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
end
else if Controls[i] is TcxCurrencyEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(Controls[i].Name).Value := strtofloatdef((TcxCurrencyEdit(Controls[i]).Text), 0);
end
else if Controls[i] is TcxButtonEdit then
begin
if (TcxButtonEdit(Controls[i]).BeepOnEnter = True) or (TcxButtonEdit(Controls[i]).ParentShowHint = True) then
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxButtonEdit(Controls[i]).Text);
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
MCode := Copy(Trim(Controls[i].Name), 1, Length(Trim(Controls[i].Name)) - 4);
ADOQueryCmd.FieldByName(MCode).Value := Trim(TcxButtonEdit(Controls[i]).Hint);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SSetsavedata10(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
FFName: string;
2025-07-19 14:23:30 +08:00
begin
with Myparent do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FFName := Trim(Copy(Controls[i].Name, 1, (Length(Controls[i].Name) - 1)));
if Controls[i].Tag = MyTag then
2025-07-19 14:23:30 +08:00
begin
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(FFName).Value := Trim(TEdit(Controls[i]).Text);
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(FFName).Value := TRichEdit(Controls[i]).Text;
end
else if Controls[i] is TMemo then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(FFName).Value := TMemo(Controls[i]).Text;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (TFTComboBox(Controls[i]).Text) <> '' then
ADOQueryCmd.FieldByName(FFName).Value := Trim(TFTComboBox(Controls[i]).Item2);
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(FFName).Value := Trim(TComboBox(Controls[i]).Text);
end
else if Controls[i] is TDateTimePicker then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).ShowCheckbox then
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(FFName).Value := TDateTimePicker(Controls[i]).DateTime;
end
else
ADOQueryCmd.FieldByName(FFName).Value := TDateTimePicker(Controls[i]).DateTime;
end
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(FFName).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ADOQueryCmd.FieldByName(FFName).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
/////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure SSetWinData(ADOQueryTmp: TADOQuery; mParent: TWinControl);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag >= 999 then
continue;
mfield := Controls[i].Name;
2025-07-19 14:23:30 +08:00
///////////////////////////
//EDIT
if Controls[i] is TEdit then
begin
{ if Trim(Controls[i].Hint)='<27><>ֵ' then
continue
else }
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
{ if Trim(Controls[i].Hint)='<27><>ֵ' then
continue
else }
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = 99 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
//idx:=getCombIdx(TComboBox(Controls[i]),i,trim(fieldByName(mfield).AsString));
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
2025-10-18 14:10:28 +08:00
if TBtnEditA(Controls[i]).Tag = 1 then
2025-07-19 14:23:30 +08:00
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
2025-07-19 14:23:30 +08:00
end
else
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end;
end
else if Controls[i] is TBtnEditC then
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditC(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if IsEmpty or fieldByName(mfield).IsNull then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
2025-07-19 14:23:30 +08:00
end;
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SSetWinData30(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag <> FTag then
continue;
mfield := Controls[i].Name;
2025-07-19 14:23:30 +08:00
///////////////////////////
//EDIT
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if IsEmpty or fieldByName(mfield).IsNull then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
end
else if Controls[i] is TRichEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TRichEdit(Controls[i]).Text := fieldbyname(mfield).AsString;
2025-07-19 14:23:30 +08:00
end;
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SClearData(mParent: TWinControl; FTag: Integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag <> FTag then
continue;
2025-07-19 14:23:30 +08:00
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
TEdit(Controls[i]).Text := '';
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TRichEdit then
begin
2025-10-18 14:10:28 +08:00
TRichEdit(Controls[i]).Text := '';
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
TcxRichEdit(Controls[i]).Text := '';
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditC then
begin
2025-10-18 14:10:28 +08:00
TBtnEditC(Controls[i]).Text := '';
TBtnEditC(Controls[i]).TxtCode := '';
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).Text := '';
TBtnEditA(Controls[i]).TxtCode := '';
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SCSHData(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield, mfieldCode: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag <> FTag then
continue;
mfield := Controls[i].Name;
2025-07-19 14:23:30 +08:00
///////////////////////////
//EDIT
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Checked := False;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxButtonEdit then
begin
2025-10-18 14:10:28 +08:00
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
end;
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SCSHDataNew(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield, mfieldCode: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag <> FTag then
continue;
mfield := Controls[i].Name;
2025-07-19 14:23:30 +08:00
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString)
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
TEdit(Controls[i]).Text := '';
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
TBtnEditC(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Pos('/', TBtnEditC(Controls[i]).Hint) > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
end
else
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
2025-07-19 14:23:30 +08:00
end;
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Checked := False;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FieldByName(mfield).Value = null then
TcheckBox(Controls[i]).Checked := False
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
end
else if Controls[i] is TcxButtonEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
end;
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SCSHDataCDS(CDS_Main: TClientDataSet; mParent: TWinControl; FTag: Integer);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield, mfieldCode: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with CDS_Main do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag <> FTag then
continue;
mfield := Controls[i].Name;
2025-07-19 14:23:30 +08:00
///////////////////////////
//EDIT
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Checked := False;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
end
else if Controls[i] is TcxButtonEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
end;
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SCSHDataWTag(ADOQueryTmp: TADOQuery; mParent: TWinControl);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield, mfieldCode: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
2025-07-19 14:23:30 +08:00
//if Controls[i].Tag<>FTag then continue;
2025-10-18 14:10:28 +08:00
mfield := Controls[i].Name;
2025-07-19 14:23:30 +08:00
///////////////////////////
//EDIT
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxRichEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Checked := False;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
end
else if Controls[i] is TcxButtonEdit then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
end;
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SSetWinData10(ADOQueryTmp: TADOQuery; mParent: TWinControl);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag >= 999 then
continue;
2025-07-19 14:23:30 +08:00
//mfield:=Copy(Trim(Controls[i].Name),1,(Length(Trim(Controls[i].Name))-1));
2025-10-18 14:10:28 +08:00
mfield := Trim(Controls[i].Name);
2025-07-19 14:23:30 +08:00
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = 99 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
2025-10-18 14:10:28 +08:00
if TBtnEditA(Controls[i]).Tag = 1 then
2025-07-19 14:23:30 +08:00
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
2025-07-19 14:23:30 +08:00
end
else
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end;
end
else if Controls[i] is TBtnEditC then
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditC(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if IsEmpty or fieldByName(mfield).IsNull then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
end {else if Controls[i] is TcxLookupComboBox then
2025-07-19 14:23:30 +08:00
begin
TcxLookupComboBox(Controls[i]).EditValue:=fieldByName(mfield).AsString;
TcxLookupComboBox(Controls[i]).EditingText:=fieldByName(mfield+'name').AsString;
end};
end; // end for
end; // end with
end; //end for with
end;
2025-10-18 14:10:28 +08:00
procedure SSetWinData20(ADOQueryTmp: TADOQuery; mParent: TWinControl);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, idx: integer;
mfield: string;
ma: TA;
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
2025-10-18 14:10:28 +08:00
if isEmpty then
exit;
with mParent do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
continue;
if Controls[i].Tag >= 999 then
continue;
mfield := Copy(Trim(Controls[i].Name), 1, (Length(Trim(Controls[i].Name)) - 1));
2025-07-19 14:23:30 +08:00
//mfield:=Trim(Controls[i].Name);
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldByName(mfield).AsString) <> '' then
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
end //ftcombobox
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i].Tag = 99 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else
begin
2025-10-18 14:10:28 +08:00
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end //combobox
2025-07-19 14:23:30 +08:00
else if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
if TComboBox(Controls[i]).Items.Count > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
idx := -1;
TComboBox(Controls[i]).ItemIndex := idx;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TBtnEditA then
begin
2025-10-18 14:10:28 +08:00
if TBtnEditA(Controls[i]).Tag = 1 then
2025-07-19 14:23:30 +08:00
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
2025-07-19 14:23:30 +08:00
end
else
begin
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end;
end
else if Controls[i] is TBtnEditC then
begin
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
TBtnEditC(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
if IsEmpty or fieldByName(mfield).IsNull then
2025-07-19 14:23:30 +08:00
begin
if TDateTimePicker(Controls[i]).Checked then
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := fieldByName(mfield).AsDateTime;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is Tmemo then
begin
2025-10-18 14:10:28 +08:00
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxDateEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and not fieldByName(mfield).IsNull then
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxTimeEdit then
begin
2025-10-18 14:10:28 +08:00
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
else if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TcheckBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
end {else if Controls[i] is TcxLookupComboBox then
2025-07-19 14:23:30 +08:00
begin
TcxLookupComboBox(Controls[i]).EditValue:=fieldByName(mfield).AsString;
TcxLookupComboBox(Controls[i]).EditingText:=fieldByName(mfield+'name').AsString;
end};
end; // end for
end; // end with
end; //end for with
end;
//////////////////////////////////////////////
//////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>SQL<51><4C><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
function SDelData(ADOQueryCmd: TADOQuery; mDelStr: string): Boolean;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
result := False;
2025-07-19 14:23:30 +08:00
with ADOQueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(mDelStr);
ExecSQL;
end;
2025-10-18 14:10:28 +08:00
result := True;
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
result := False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
////////////////////////////////////////////
////************<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********/////
////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
function SGetFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, j, k: Integer;
fsj, fsj1: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := '';
2025-07-19 14:23:30 +08:00
with TMPanel do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
Continue;
2025-07-19 14:23:30 +08:00
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
j := Pos(' ', Trim(TEdit(Controls[i]).Text));
if j > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
j := Pos(' ', Trim(fsj1));
if j > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(fsj1) + '%');
fsj1 := '';
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
end
else
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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]).Text))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].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) + '%')
else if Controls[i].Tag = 100 then
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%');
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).TxtCode) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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) + '%');
2025-07-19 14:23:30 +08:00
end;
end
2025-10-18 14:10:28 +08:00
else if Controls[i] is TFTComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(TFTComboBox(Controls[i]).Text) <> '' then
if Controls[i].Tag = EquTag then
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TFTComboBox(Controls[i]).Item2))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TFTComboBox(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) + '%');
2025-07-19 14:23:30 +08:00
end;
end;
end;
2025-10-18 14:10:28 +08:00
if Trim(Result) <> '' then
Result := Trim(RightBStr(Result, Length(Result) - 4));
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
function SGetFiltersHint(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, j, k: Integer;
fsj, fsj1: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := '';
2025-07-19 14:23:30 +08:00
with TMPanel do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
Continue;
2025-07-19 14:23:30 +08:00
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
j := Pos(' ', Trim(TEdit(Controls[i]).Text));
if j > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
j := Pos(' ', Trim(fsj1));
if j > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := Result + 'and ' + Controls[i].Hint + ' like ' + QuotedStr('%' + Trim(fsj1) + '%');
fsj1 := '';
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
end
else
Result := Result + 'and ' + Controls[i].Hint + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
if Trim(Result) <> '' then
Result := Trim(RightBStr(Result, Length(Result) - 4));
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
function SGetFinds(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := '';
2025-07-19 14:23:30 +08:00
with TMPanel do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to ControlCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Controls[i] is TLabel then
Continue;
2025-07-19 14:23:30 +08:00
if Controls[i] is TEdit then
begin
2025-10-18 14:10:28 +08:00
if Trim(TEdit(Controls[i]).Text) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TBtnEditA then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditA(Controls[i]).Text) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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) + '%');
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TBtnEditC then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditC(Controls[i]).TxtCode) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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) + '%');
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
end
else if Controls[i] is TFTComboBox then
begin
if Trim(TFTComboBox(Controls[i]).Text) <> '' then
if Controls[i].Tag = EquTag then
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TFTComboBox(Controls[i]).Item2))
else if Controls[i].Tag = LikeTag then
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TFTComboBox(Controls[i]).Item2) + '%');
end
else if Controls[i] is TComboBox then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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) + '%');
2025-07-19 14:23:30 +08:00
end;
end;
end;
end;
////////////////////////////////////////////////////////////
//<2F><><EFBFBD>ù<EFBFBD><C3B9>˺<EFBFBD><CBBA><EFBFBD>
////////////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
2025-07-19 14:23:30 +08:00
begin
try
ADOQry.DisableControls;
with ADOQry do
begin
2025-10-18 14:10:28 +08:00
if Trim(FilterStr) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Filtered := False;
end
else
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Filtered := False;
Filter := FilterStr;
Filtered := True;
2025-07-19 14:23:30 +08:00
end;
end;
finally
ADOQry.EnableControls;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SDofilter10(cds_Main: TClientDataSet; FilterStr: string);
2025-07-19 14:23:30 +08:00
begin
try
cds_Main.DisableControls;
with cds_Main do
begin
2025-10-18 14:10:28 +08:00
if Trim(FilterStr) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Filtered := False;
end
else
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Filtered := False;
Filter := FilterStr;
Filtered := True;
2025-07-19 14:23:30 +08:00
end;
end;
finally
cds_Main.EnableControls;
end;
end;
2025-10-18 14:10:28 +08:00
function SGetMaxNo(MyAdoQuery: TADOQuery; MyTable: string; MyField: string; MyFlag: string): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
fsj: string;
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
result := '';
fsj := Trim(Formatdatetime('yyyyMMdd', Now));
i := Length(Trim(MyFlag));
2025-07-19 14:23:30 +08:00
with MyAdoQuery do
begin
Close;
SQL.Clear;
2025-10-18 14:10:28 +08:00
sql.Add('select Max(' + MyField + ') MaxNo from ' + MyTable);
SQL.Add('where ' + MyField + ' like ' + QuotedStr('%' + fsj + '%'));
2025-07-19 14:23:30 +08:00
Open;
end;
with MyAdoQuery do
begin
2025-10-18 14:10:28 +08:00
if Trim(fieldbyname('MaxNo').AsString) = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
Result := Trim(MyFlag) + Trim(Formatdatetime('yyyyMMdd', Now)) + '1001';
2025-07-19 14:23:30 +08:00
Exit;
end;
end;
2025-10-18 14:10:28 +08:00
fsj := Trim(MyAdoQuery.fieldbyname('MaxNo').AsString);
result := Trim(MyFlag) + Trim(Formatdatetime('yyyyMMdd', Now)) + IntToStr(StrtoInt(Copy(fsj, i + 9, Length(fsj) - i - 8)) + 1);
2025-07-19 14:23:30 +08:00
except
2025-10-18 14:10:28 +08:00
Result := '';
Application.MessageBox(PChar('<27>ֶ<EFBFBD>ȡֵMaxNo<4E><6F><EFBFBD>󣬲鿴<F3A3ACB2><E9BFB4><' + Trim(MyTable) + '><3E><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><' + MyField + '>'), '<27><>ʾ', 0);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
procedure HJ(mClientDataset: TclientDataSet; Label1: TLabel; mfieldName: double);
begin
if mClientDataset.IsEmpty then
exit;
with mClientDataset do
begin
if fieldbyname('Ssel').AsBoolean = true then
Label1.Caption := currtostr(strtoCurr(Label1.Caption) + mfieldName)
else
Label1.Caption := currtostr(strtoCurr(Label1.Caption) - mfieldName);
end;
end;
procedure SCreateCDS20(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
mfieldName: string;
mSize: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldName := '';
2025-07-19 14:23:30 +08:00
mClientDataset.FieldDefs.Clear;
with SADOQry do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to fieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mSize := 1;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
mSize := Fields[i].Size;
mfieldName := trim(fields[i].FieldName);
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
mClientDataset.FieldDefs.Add('Sflag', ftString, 1);
mClientDataset.FieldDefs.Add('Sindex', ftInteger, 0);
mClientDataset.FieldDefs.Add('Ssel', ftBoolean, 0);
mClientDataset.FieldDefs.Add('SDefNote', ftString, 20);
2025-07-19 14:23:30 +08:00
mClientDataset.Close;
mClientDataset.CreateDataSet;
end;
2025-10-18 14:10:28 +08:00
procedure SCreateCDSOnly(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
mfieldName: string;
mSize: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldName := '';
2025-07-19 14:23:30 +08:00
mClientDataset.FieldDefs.Clear;
with SADOQry do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to fieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mSize := 1;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
mSize := Fields[i].Size;
mfieldName := trim(fields[i].FieldName);
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
2025-07-19 14:23:30 +08:00
end;
end;
mClientDataset.Close;
mClientDataset.CreateDataSet;
end;
2025-10-18 14:10:28 +08:00
procedure SSetEditDataCDSNew(yClientDataset: TclientDataSet; mClientDataset: TclientDataSet);
var
i: integer;
k: integer;
mfieldName: string;
begin
if yClientDataset.IsEmpty then
exit;
k := 1;
try
mClientDataset.DisableControls;
mClientDataset.Filtered := false;
with mClientDataset do
begin
Append;
for i := 0 to yClientDataset.FieldCount - 1 do
begin
mfieldName := trim(yClientDataset.fields[i].FieldName);
fieldbyname(mfieldName).Value := yClientDataset.Fields[i].Value;
end;
post;
inc(k);
end;
if not mClientDataset.IsEmpty then
begin
mClientDataset.First;
end;
finally
mClientDataset.First;
mClientDataset.EnableControls;
end;
end;
procedure SInitCDSData20(fromADO: TADOQuery; toCDS: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
k: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if fromADO.IsEmpty then
exit;
2025-07-19 14:23:30 +08:00
fromADO.DisableControls;
fromADO.first;
2025-10-18 14:10:28 +08:00
k := 1;
2025-07-19 14:23:30 +08:00
try
toCDS.DisableControls;
2025-10-18 14:10:28 +08:00
toCDS.Filtered := false;
2025-07-19 14:23:30 +08:00
while not fromADO.Eof do
begin
with toCDS do
begin
Append;
2025-10-18 14:10:28 +08:00
for i := 0 to fromADO.FieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fields[i].value := fromADO.Fields[i].Value;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
fieldByName('Sflag').AsString := '1';
fieldByName('Sindex').value := k;
fieldByName('Ssel').value := false;
fieldByName('SDefNote').value := '';
2025-07-19 14:23:30 +08:00
inc(k);
Post;
end;
fromADO.Next;
end;
if not toCDS.IsEmpty then
begin
2025-10-18 14:10:28 +08:00
toCDS.First;
2025-07-19 14:23:30 +08:00
end;
finally
toCDS.First;
toCDS.EnableControls;
fromADO.EnableControls;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SInitCDSDataOnly(fromADO: TADOQuery; toCDS: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
k: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if fromADO.IsEmpty then
exit;
2025-07-19 14:23:30 +08:00
fromADO.first;
2025-10-18 14:10:28 +08:00
k := 1;
2025-07-19 14:23:30 +08:00
try
toCDS.DisableControls;
2025-10-18 14:10:28 +08:00
toCDS.Filtered := false;
2025-07-19 14:23:30 +08:00
while not fromADO.Eof do
begin
with toCDS do
begin
Append;
2025-10-18 14:10:28 +08:00
for i := 0 to fromADO.FieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fields[i].value := fromADO.Fields[i].Value;
2025-07-19 14:23:30 +08:00
end;
inc(k);
Post;
end;
fromADO.Next;
end;
if not toCDS.IsEmpty then
begin
2025-10-18 14:10:28 +08:00
toCDS.First;
2025-07-19 14:23:30 +08:00
end;
finally
toCDS.EnableControls;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SInitFtComBoxBySql(ADOQueryTmp: TADOQuery; cb: TFtComboBox; FlagType: string; Boxtype: integer; showMsg: string; emptyFlag: Boolean; mSql: string);
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
close;
sql.clear;
sql.Add(mSql);
Open;
if isEmpty then
begin
2025-10-18 14:10:28 +08:00
application.MessageBox(pChar(showMsg), '', 0);
2025-07-19 14:23:30 +08:00
exit;
end;
cb.Clear;
while not EOF do
begin
2025-10-18 14:10:28 +08:00
if Boxtype = 0 then
2025-07-19 14:23:30 +08:00
begin
cb.Items.Add(trim(fieldByName('Name').AsString));
end
else
begin
2025-10-18 14:10:28 +08:00
cb.AddItem2(trim(fieldByName('Name').AsString), nil, trim(fieldByName('code').AsString));
2025-07-19 14:23:30 +08:00
end;
next;
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
if not emptyFlag then
cb.Items.Add('');
2025-10-18 14:10:28 +08:00
if emptyFlag and (cb.Items.Count > 0) then
cb.ItemIndex := 0;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
procedure SInitComBoxBySql(ADOQueryTmp: TADOQuery; cb: TComboBox; emptyFlag: Boolean; mSql: string);
2025-07-19 14:23:30 +08:00
begin
with ADOQueryTmp do
begin
close;
sql.clear;
sql.Add(mSql);
Open;
if isEmpty then
begin
//plication.MessageBox(pChar(showMsg),'',0);
exit;
end;
cb.Clear;
while not EOF do
begin
cb.Items.Add(trim(fieldByName('Name').AsString));
next;
end;
2025-10-18 14:10:28 +08:00
if not emptyFlag then
cb.Items.Add('');
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
if emptyFlag and (cb.Items.Count > 0) then
cb.ItemIndex := 0;
2025-07-19 14:23:30 +08:00
end;
end;
//////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>combox<6F>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
//<2F><>XC_CustCode<64><65><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//Boxtype:0; <20><><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>1;
//////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure SInitComBoxByCustCode(ADOQueryTmp: TADOQuery; cb: TComboBox; FlagType: string; Boxtype: integer; showMsg: string; emptyFlag: Boolean);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
A: TA;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
cb.Items.Clear;
2025-07-19 14:23:30 +08:00
with ADOQueryTmp do
begin
close;
sql.clear;
sql.Add('exec P_Get_XC_Custcode');
2025-10-18 14:10:28 +08:00
sql.Add(quotedStr(trim(FlagType)));
2025-07-19 14:23:30 +08:00
Open;
if isEmpty then
begin
2025-10-18 14:10:28 +08:00
application.MessageBox(pChar('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣά<CFA2><CEAC>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>' + showMsg), '', 0);
2025-07-19 14:23:30 +08:00
exit;
end;
while not EOF do
begin
2025-10-18 14:10:28 +08:00
if Boxtype = 0 then
2025-07-19 14:23:30 +08:00
begin
cb.Items.Add(trim(fieldByName('name').AsString));
end
else
begin
2025-10-18 14:10:28 +08:00
A := TA.Create(nil);
A.s := trim(fieldByName('code').AsString);
cb.Items.AddObject(trim(fieldByName('name').AsString), TObject(A));
2025-07-19 14:23:30 +08:00
end;
next;
end;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
if not emptyFlag then
cb.Items.Add('');
2025-10-18 14:10:28 +08:00
if emptyFlag and (cb.Items.Count > 0) then
cb.ItemIndex := 0;
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
procedure SInitCxGridComboBoxByCustCode(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FlagType: string; PState: Integer; IsNull: Boolean; Shmeg: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
A: TA;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
(c3.Properties as TcxComboBoxProperties).Items.Clear;
2025-07-19 14:23:30 +08:00
with ADOQueryTmp do
begin
close;
sql.clear;
2025-10-18 14:10:28 +08:00
sql.Add(' select * from XC_CustCode ' + ' where Flag=''' + trim(FlagType) + ''' ' + ' order by orderno ');
2025-07-19 14:23:30 +08:00
Open;
if isEmpty then
begin
2025-10-18 14:10:28 +08:00
Application.MessageBox(PChar('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣά<CFA2><CEAC>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD>:' + Shmeg), '', 0);
2025-07-19 14:23:30 +08:00
exit;
end;
while not EOF do
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
begin
(c3.Properties as TcxComboBoxProperties).Items.Add(trim(fieldByName('name').AsString));
end;
next;
end;
if not IsNull then
(c3.Properties as TcxComboBoxProperties).Items.Add('');
end;
end;
2025-10-18 14:10:28 +08:00
procedure SInitCxGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
A: TA;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
(c3.Properties as TcxComboBoxProperties).Items.Clear;
2025-07-19 14:23:30 +08:00
with ADOQueryTmp do
begin
close;
sql.clear;
sql.Add(FSql);
Open;
if isEmpty then
begin
//Application.MessageBox(PChar('δ<>ҵ<EFBFBD>:'+shmeg),'',0);
exit;
end;
while not EOF do
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
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;
2025-10-18 14:10:28 +08:00
procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
A: TA;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
(c3.Properties as TcxComboBoxProperties).Items.Clear;
2025-07-19 14:23:30 +08:00
with ADOQueryTmp do
begin
close;
sql.clear;
sql.Add(FSql);
Open;
if isEmpty then
begin
2025-10-18 14:10:28 +08:00
Application.MessageBox(PChar(<>ҵ<EFBFBD>:' + Shmeg), '', 0);
2025-07-19 14:23:30 +08:00
exit;
end;
while not EOF do
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
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;
///////////////////////////////////////////////////
//*****<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ***** //
/////////////////////////////////////////////////
function SSWR(s: real): real;
2025-10-18 14:10:28 +08:00
var
r1, r2: real;
s1, s2: string;
begin
r1 := int(s);
r2 := frac(s);
s1 := copy(floattostr(r1), 1, length(floattostr(r1)));
2025-07-19 14:23:30 +08:00
if length(floattostr(r2)) >= 5 then
begin
if strtoint(copy((floattostr(r2)), 5, 1)) >= 5 then
if strtoint(copy((floattostr(r2)), 4, 1)) = 9 then
if strtoint(copy((floattostr(r2)), 3, 1)) = 9 then
begin
2025-10-18 14:10:28 +08:00
s1 := inttostr(strtoint(s1) + 1);
s2 := '';
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
s2 := inttostr(strtoint(copy((floattostr(r2)), 3, 1)) + 1)
else if copy((floattostr(r2)), 3, 1) = '0' then
s2 := '0' + inttostr(strtoint(copy(floattostr(r2), 3, 2)) + 1)
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
s2 := inttostr(strtoint(copy(floattostr(r2), 3, 2)) + 1)
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
s2 := copy(floattostr(r2), 3, 2);
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
s2 := copy(floattostr(r2), 3, 2);
2025-07-19 14:23:30 +08:00
result := strtofloat(s1 + '.' + s2);
end;
2025-10-18 14:10:28 +08:00
procedure SInitCDSDataSel(fromADO: TADOQuery; toCDS: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
k: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if fromADO.IsEmpty then
exit;
2025-07-19 14:23:30 +08:00
fromADO.first;
2025-10-18 14:10:28 +08:00
k := 1;
2025-07-19 14:23:30 +08:00
try
toCDS.DisableControls;
2025-10-18 14:10:28 +08:00
toCDS.Filtered := false;
2025-07-19 14:23:30 +08:00
while not fromADO.Eof do
begin
with toCDS do
begin
Append;
2025-10-18 14:10:28 +08:00
for i := 0 to fromADO.FieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
fields[i].value := fromADO.Fields[i].Value;
2025-07-19 14:23:30 +08:00
end;
//fieldByName('Sflag').AsString :='1';
//fieldByName('Sindex').value :=k;
2025-10-18 14:10:28 +08:00
fieldByName('Ssel').value := false;
2025-07-19 14:23:30 +08:00
inc(k);
Post;
end;
fromADO.Next;
end;
if not toCDS.IsEmpty then
begin
2025-10-18 14:10:28 +08:00
toCDS.First;
2025-07-19 14:23:30 +08:00
end;
finally
toCDS.EnableControls;
end;
end;
2025-10-18 14:10:28 +08:00
procedure SCreateCDSSel(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: integer;
mfieldName: string;
mSize: integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mfieldName := '';
2025-07-19 14:23:30 +08:00
mClientDataset.FieldDefs.Clear;
with SADOQry do
begin
2025-10-18 14:10:28 +08:00
for i := 0 to fieldCount - 1 do //
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mSize := 1;
2025-07-19 14:23:30 +08:00
end
else
2025-10-18 14:10:28 +08:00
mSize := Fields[i].Size;
mfieldName := trim(fields[i].FieldName);
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
mClientDataset.FieldDefs.Add('Sflag', ftString, 1);
mClientDataset.FieldDefs.Add('Sindex', ftInteger, 0);
mClientDataset.FieldDefs.Add('Ssel', ftBoolean, 0);
mClientDataset.FieldDefs.Add('SDefNote', ftString, 10);
2025-07-19 14:23:30 +08:00
mClientDataset.Close;
mClientDataset.CreateDataSet;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-10-18 14:10:28 +08:00
procedure CopyAddRow(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
AA: array[0..50] of string;
i, j: Integer;
2025-07-19 14:23:30 +08:00
begin
if CDS_Sub.IsEmpty then
begin
CDS_Sub.Append;
CDS_Sub.Post;
Exit;
end;
2025-10-18 14:10:28 +08:00
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AA[i] := Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString);
2025-07-19 14:23:30 +08:00
end;
with CDS_Sub do
begin
Append;
2025-10-18 14:10:28 +08:00
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if AA[i] <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := AA[i];
2025-07-19 14:23:30 +08:00
end;
end;
Post;
end;
end;
2025-10-18 14:10:28 +08:00
procedure CopyAddRowBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
AA: array[0..50] of string;
i, j: Integer;
2025-07-19 14:23:30 +08:00
begin
if CDS_Sub.IsEmpty then
begin
CDS_Sub.Append;
CDS_Sub.Post;
Exit;
end;
2025-10-18 14:10:28 +08:00
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AA[i] := Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString);
2025-07-19 14:23:30 +08:00
end;
with CDS_Sub do
begin
Append;
2025-10-18 14:10:28 +08:00
for i := 0 to Tv1.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if AA[i] <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := AA[i];
2025-07-19 14:23:30 +08:00
end;
end;
Post;
end;
end;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-10-18 14:10:28 +08:00
procedure CopyAddRowCDS(CDS_Sub: TClientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
AA: array[0..100] of string;
i, j: Integer;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if CDS_Sub.IsEmpty then
Exit;
for i := 0 to CDS_Sub.FieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
AA[i] := Trim(CDS_Sub.fieldbyname(CDS_Sub.Fields[i].FieldName).AsString);
2025-07-19 14:23:30 +08:00
end;
with CDS_Sub do
begin
Append;
2025-10-18 14:10:28 +08:00
for i := 0 to CDS_Sub.FieldCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if AA[i] <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(CDS_Sub.Fields[i].FieldName).Value := AA[i];
2025-07-19 14:23:30 +08:00
end;
end;
Post;
end;
end;
2025-10-18 14:10:28 +08:00
procedure OneKeyPost(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
FValue, FFValue, FColumn, FFColumn: string;
2025-07-19 14:23:30 +08:00
begin
//FColumn:=tv1.Columns[Tv1.Controller.FocusedColumnIndex].DataBinding.FieldName;
//FFColumn:=Tv1.Columns[Tv1.Controller.FocusedColumnIndex].Summary.GroupFormat;
2025-10-18 14:10:28 +08:00
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
FFColumn := Tv1.Controller.FocusedColumn.Summary.GroupFormat;
FValue := Trim(CDS_Sub.fieldbyname(FColumn).AsString);
if Trim(FFColumn) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FFValue := Trim(CDS_Sub.fieldbyname(FFColumn).AsString);
2025-07-19 14:23:30 +08:00
end;
with CDS_Sub do
begin
DisableControls;
First;
while not Eof do
begin
Edit;
2025-10-18 14:10:28 +08:00
if FValue = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(FColumn).Value := null;
end
else
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(FColumn).Value := FValue;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if Trim(FFColumn) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FFValue = '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(FFColumn).Value := null;
end
else
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
CDS_Sub.FieldByName(FFColumn).Value := FFValue;
2025-07-19 14:23:30 +08:00
end;
end;
Post;
Next;
end;
EnableControls;
end;
end;
///////////////////////////////////////////////////
//<2F><><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>
///////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: integer; mtype: integer = 0): Boolean;
2025-07-19 14:23:30 +08:00
begin
try
with ADOQueryTmp do
begin
Close;
2025-10-18 14:10:28 +08:00
sql.Clear;
2025-07-19 14:23:30 +08:00
sql.Add('exec Get_SY_MaxBH ');
2025-10-18 14:10:28 +08:00
sql.Add(' ' + quotedStr(mFlag));
sql.Add(',' + quotedStr(mTable));
sql.Add(',' + intTostr(mlen));
sql.Add(',' + intTostr(mtype));
// ShowMessage(SQL.Text);
2025-07-19 14:23:30 +08:00
Open;
2025-10-18 14:10:28 +08:00
if RecordCount > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mMaxNo := trim(fieldByName('MaxBH').AsString);
if mMaxNo <> '' then
result := true
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
Result := false;
2025-07-19 14:23:30 +08:00
end
else
begin
2025-10-18 14:10:28 +08:00
result := false;
2025-07-19 14:23:30 +08:00
end;
end;
if not Result then
2025-10-18 14:10:28 +08:00
application.MessageBox(Pchar('<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>(' + mFlag + ')'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONINFORMATION);
except
result := false;
application.MessageBox(Pchar('<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>(' + mFlag + ')'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONINFORMATION);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
procedure ReadCxGrid(fileName: string; cxgrid: TcxGridDBTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
mFileName: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
2025-07-19 14:23:30 +08:00
//<2F>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>лָ<D0BB>
if FileExists(mFileName) then
2025-10-18 14:10:28 +08:00
cxgrid.RestoreFromIniFile(mFileName, false, false);
2025-07-19 14:23:30 +08:00
CreateGroupSummarry(cxgrid);
end;
///////////////////////////////////////////////////////////////
//<2F><><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>
///////////////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure ReadCxBandedGrid(fileName: string; cxgrid: TcxGridDBBandedTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
mFileName: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
2025-07-19 14:23:30 +08:00
//<2F>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>лָ<D0BB>
if FileExists(mFileName) then
2025-10-18 14:10:28 +08:00
cxgrid.RestoreFromIniFile(mFileName);
2025-07-19 14:23:30 +08:00
end;
///////////////////////////////////////////////////////////////
//<2F><><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>
///////////////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure WriteCxGrid(fileName: string; cxgrid: TcxGridDBTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
mFileName, FolderPath: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FolderPath := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack;
if not DirectoryExists(FolderPath) then
begin
ForceDirectories(FolderPath);
end;
mFileName := FolderPath + '\' + trim(fileName) + '.dbg';
2025-07-19 14:23:30 +08:00
if not DirectoryExists(ExtractFileDir(mFileName)) then
2025-10-18 14:10:28 +08:00
CreateDir(ExtractFileDir(mFileName));
2025-07-19 14:23:30 +08:00
//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
cxgrid.StoreToIniFile(mFileName);
end;
///////////////////////////////////////////////////////////////
//<2F><><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>
///////////////////////////////////////////////////////////////
2025-10-18 14:10:28 +08:00
procedure WriteCxBandedGrid(fileName: string; cxgrid: TcxGridDBBandedTableView; filePack: string = '<27><><EFBFBD><EFBFBD>');
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
mFileName: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
2025-07-19 14:23:30 +08:00
if not DirectoryExists(ExtractFileDir(mFileName)) then
2025-10-18 14:10:28 +08:00
CreateDir(ExtractFileDir(mFileName));
2025-07-19 14:23:30 +08:00
//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
cxgrid.StoreToIniFile(mFileName);
end;
2025-10-18 14:10:28 +08:00
procedure CreateGroupSummarry(tv1: TcxGridDBTableView);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
csg: TcxDataSummaryGroup;
csglink: TcxDataSummaryGroupItemLink;
csgItem: TcxDataSummaryItem;
i: integer;
mFieldName: string;
2025-07-19 14:23:30 +08:00
begin
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-10-18 14:10:28 +08:00
with tv1.DataController.Summary do
begin
try
csg := DataController.Summary.SummaryGroups.Add; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
csg.Links.Clear;
for i := 0 to tv1.ColumnCount - 1 do
begin
if not tv1.Columns[i].Visible then
continue;
mFieldName := tv1.Columns[i].DataBinding.FieldName;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
if tv1.Columns[i].Summary.FooterKind = skSum then
begin
2025-07-19 14:23:30 +08:00
// (tv1.DataController.DataSet.Fields[i] as TNumericField).DisplayFormat := '#,0.00;-#,0.00;#';
//tv1.Columns[i].Summary.FooterFormat:='0.0';
//tv1.Columns[i].Summary.FooterKind := skSum;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Group Row<6F>ϵĻ<CFB5><C4BB><EFBFBD>ͬʱʹ<CAB1><CAB9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ч
//<2F><><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĻ<CFB5><C4BB><EFBFBD><EFBFBD><EFBFBD>
2025-10-18 14:10:28 +08:00
csgItem := csg.SummaryItems.Add;
csgItem.ItemLink := tv1.Columns[i]; //<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>1
csgItem.Position := spGroup;
csgItem.Kind := skSum;
csgItem.Format := trim(tv1.Columns[i].Caption) + 'С<><D0A1>=#,0.0';
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
tv1.Columns[i].Summary.GroupFooterKind := skSum;
tv1.Columns[i].Summary.GroupFooterFormat := '#,0.00';
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
end
else if tv1.Columns[i].Summary.FooterKind = skCount then
begin
2025-07-19 14:23:30 +08:00
// (tv1.DataController.DataSet.Fields[i] as TNumericField).DisplayFormat := '#,0.00;-#,0.00;#';
//tv1.Columns[i].Summary.FooterFormat:='0.0';
2025-10-18 14:10:28 +08:00
tv1.Columns[i].Summary.FooterKind := skCount;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
tv1.Columns[i].Summary.GroupFooterKind := skCount;
2025-07-19 14:23:30 +08:00
//tv1.Columns[i].Summary.GroupFooterFormat := '#,0.00';
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Group Row<6F>ϵĻ<CFB5><C4BB><EFBFBD>ͬʱʹ<CAB1><CAB9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ч
//<2F><><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵĻ<CFB5><C4BB><EFBFBD><EFBFBD><EFBFBD>
2025-10-18 14:10:28 +08:00
csgItem := csg.SummaryItems.Add;
csgItem.ItemLink := tv1.Columns[i]; //<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>1
csgItem.Kind := skCount;
2025-07-19 14:23:30 +08:00
//csgItem.Format := 'С<><D0A1>=#,0.0';
2025-10-18 14:10:28 +08:00
end
else
begin
csglink := csg.Links.Add;
csglink.ItemLink := tv1.Columns[i]; //<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
2025-07-19 14:23:30 +08:00
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5>ж<EFBFBD><D0B6>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EBBDAB>Щ<EFBFBD>м<EFBFBD><D0BC>
//SummaryGroupItemLink<6E>У<EFBFBD>û<EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
2025-10-18 14:10:28 +08:00
end;
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
end;
2025-07-19 14:23:30 +08:00
finally
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure TcxGridToExcel(mfileName: string; gridName: TcxGrid);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
saveDialog: TSaveDialog;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
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
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
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;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
function ReadINIFileStr(ininame, TypeName: string; ValueName, ValueMR: string): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
programIni: Tinifile; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
FileName, ValueZS: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
FileName := ExtractFilePath(Paramstr(0)) + ininame;
programIni := Tinifile.create(FileName);
ValueZS := programIni.ReadString(TypeName, ValueName, ValueMR);
Result := ValueZS;
2025-07-19 14:23:30 +08:00
programIni.Free;
end;
2025-10-18 14:10:28 +08:00
procedure SelExportData(FTv: TcxGridDBTableView; FAdoQry: TADOQuery; FTile: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, j: Integer;
fsj: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FAdoQry.IsEmpty then
Exit;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
frmSelExportField := TfrmSelExportField.Create(Application);
2025-07-19 14:23:30 +08:00
with frmSelExportField do
begin
with frmSelExportField.ExpGrid do
begin
// ExpGrid.Columns.Clear;
ExpGrid.ClearItems;
2025-10-18 14:10:28 +08:00
frmSelExportField.IniName := FTile;
2025-07-19 14:23:30 +08:00
{if FTv.OptionsView.Footer=true then
begin
ExpGrid.OptionsView.Footer:=True;
end else
begin
ExpGrid.OptionsView.Footer:=False;
end; }
2025-10-18 14:10:28 +08:00
ExpGrid.OptionsView.Footer := FTv.OptionsView.Footer;
for i := 0 to FTv.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
//if FTv.Columns[i].Visible=True then
begin
ExpGrid.CreateColumn;
2025-10-18 14:10:28 +08:00
j := ExpGrid.ColumnCount - 1;
ExpGrid.Columns[j].Caption := FTv.Columns[i].Caption;
ExpGrid.Columns[i].Visible := FTv.Columns[i].Visible;
ExpGrid.Columns[j].DataBinding.FieldName := FTv.Columns[i].DataBinding.FieldName;
ExpGrid.Columns[j].Width := FTv.Columns[i].Width;
ExpGrid.Columns[i].Summary.FooterKind := FTv.Columns[i].Summary.FooterKind;
2025-07-19 14:23:30 +08:00
end;
end;
end;
2025-10-18 14:10:28 +08:00
ExportDataSource.DataSet := FAdoQry;
2025-07-19 14:23:30 +08:00
FAdoQry.Open;
2025-10-18 14:10:28 +08:00
if ShowModal = 1 then
2025-07-19 14:23:30 +08:00
begin
end;
end;
frmSelExportField.Free;
except
end;
end;
2025-10-18 14:10:28 +08:00
procedure SelExportDataBand(FTv: TcxGridDBBandedTableView; FAdoQry: TADOQuery; FTile: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i, j: Integer;
fsj: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FAdoQry.IsEmpty then
Exit;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
frmSelExportField := TfrmSelExportField.Create(Application);
2025-07-19 14:23:30 +08:00
with frmSelExportField do
begin
with frmSelExportField.ExpGrid do
begin
// ExpGrid.Columns.Clear;
ExpGrid.ClearItems;
2025-10-18 14:10:28 +08:00
frmSelExportField.IniName := FTile;
2025-07-19 14:23:30 +08:00
{if FTv.OptionsView.Footer=true then
begin
ExpGrid.OptionsView.Footer:=True;
end else
begin
ExpGrid.OptionsView.Footer:=False;
end; }
2025-10-18 14:10:28 +08:00
ExpGrid.OptionsView.Footer := FTv.OptionsView.Footer;
for i := 0 to FTv.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if FTv.Columns[i].Visible = True then
2025-07-19 14:23:30 +08:00
begin
ExpGrid.CreateColumn;
2025-10-18 14:10:28 +08:00
j := ExpGrid.ColumnCount - 1;
ExpGrid.Columns[j].Caption := FTv.Columns[i].Caption;
ExpGrid.Columns[j].DataBinding.FieldName := FTv.Columns[i].DataBinding.FieldName;
ExpGrid.Columns[j].Width := FTv.Columns[i].Width;
ExpGrid.Columns[i].Summary.FooterKind := FTv.Columns[i].Summary.FooterKind;
2025-07-19 14:23:30 +08:00
end;
end;
end;
2025-10-18 14:10:28 +08:00
ExportDataSource.DataSet := FAdoQry;
2025-07-19 14:23:30 +08:00
FAdoQry.Open;
2025-10-18 14:10:28 +08:00
if ShowModal = 1 then
2025-07-19 14:23:30 +08:00
begin
end;
end;
frmSelExportField.Free;
except
end;
end;
2025-10-18 14:10:28 +08:00
procedure ColumnView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBTableView; MKName10: string);
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with AdoQueryTemp do
2025-07-19 14:23:30 +08:00
begin
Close;
sql.Clear;
2025-10-18 14:10:28 +08:00
sql.Add('select * from Table_Column where CxTabName=''' + Trim(MKName10) + ''' and Owner=''' + Trim(DCode) + '''');
2025-07-19 14:23:30 +08:00
sql.Add(' and TCNotVisble=1 ');
open;
end;
2025-10-18 14:10:28 +08:00
if AdoQueryTemp.IsEmpty = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with AdoQueryTemp do
2025-07-19 14:23:30 +08:00
begin
First;
while not eof do
begin
2025-10-18 14:10:28 +08:00
Tv1.GetColumnByFieldName(AdoQueryTemp.fieldbyname('ColName').AsString).Visible := False;
Tv1.GetColumnByFieldName(AdoQueryTemp.fieldbyname('ColName').AsString).Hidden := True;
2025-07-19 14:23:30 +08:00
Next;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure ColumnBandView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBBandedTableView; MKName10: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
fsj: string;
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with AdoQueryTemp do
2025-07-19 14:23:30 +08:00
begin
Close;
sql.Clear;
2025-10-18 14:10:28 +08:00
sql.Add('select * from Table_Column where CxTabName=''' + Trim(MKName10) + ''' and Owner=''' + Trim(DCode) + '''');
2025-07-19 14:23:30 +08:00
sql.Add(' and TCNotVisble=1 ');
open;
end;
2025-10-18 14:10:28 +08:00
if AdoQueryTemp.IsEmpty = False then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
with AdoQueryTemp do
2025-07-19 14:23:30 +08:00
begin
First;
while not eof do
begin
2025-10-18 14:10:28 +08:00
fsj := Trim(AdoQueryTemp.fieldbyname('ColName').AsString);
2025-07-19 14:23:30 +08:00
// Tv1.Controller.ge
2025-10-18 14:10:28 +08:00
Tv1.GetColumnByFieldName(fsj).Visible := False;
Tv1.GetColumnByFieldName(fsj).Hidden := True;
2025-07-19 14:23:30 +08:00
Next;
end;
end;
end;
end;
2025-10-18 14:10:28 +08:00
procedure ColumnSet(TV10: TcxGridDBTableView; MKName10: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
frmColumnSet := TfrmColumnSet.Create(Application);
2025-07-19 14:23:30 +08:00
with frmColumnSet do
begin
ADOQuery2.DisableControls;
with ADOQuery2 do
begin
Close;
sql.Clear;
2025-10-18 14:10:28 +08:00
sql.Add('select * from Table_Column where 1=2');
2025-07-19 14:23:30 +08:00
Open;
end;
2025-10-18 14:10:28 +08:00
SCreateCDS20(ADOQuery2, ClientDataSet2);
SInitCDSData20(ADOQuery2, ClientDataSet2);
2025-07-19 14:23:30 +08:00
ADOQuery2.EnableControls;
2025-10-18 14:10:28 +08:00
MKName := MKName10;
for i := 0 to TV10.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
with ClientDataSet2 do
begin
Append;
2025-10-18 14:10:28 +08:00
FieldByName('CxTabName').Value := MKName;
FieldByName('CxColName').Value := Trim(TV10.Columns[i].Caption);
FieldByName('ColName').Value := Trim(TV10.Columns[i].DataBinding.FieldName);
2025-07-19 14:23:30 +08:00
Post;
end;
end;
2025-10-18 14:10:28 +08:00
if ShowModal = 1 then
2025-07-19 14:23:30 +08:00
begin
end;
end;
finally
frmColumnSet.Free;
end;
end;
2025-10-18 14:10:28 +08:00
procedure ColumnBandSet(TV10: TcxGridDBBandedTableView; MKName10: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
i: Integer;
2025-07-19 14:23:30 +08:00
begin
try
2025-10-18 14:10:28 +08:00
frmColumnBandSet := TfrmColumnBandSet.Create(Application);
2025-07-19 14:23:30 +08:00
with frmColumnBandSet do
begin
ADOQuery2.DisableControls;
with ADOQuery2 do
begin
Close;
sql.Clear;
2025-10-18 14:10:28 +08:00
sql.Add('select * from Table_Column where 1=2');
2025-07-19 14:23:30 +08:00
Open;
end;
2025-10-18 14:10:28 +08:00
SCreateCDS20(ADOQuery2, ClientDataSet2);
SInitCDSData20(ADOQuery2, ClientDataSet2);
2025-07-19 14:23:30 +08:00
ADOQuery2.EnableControls;
2025-10-18 14:10:28 +08:00
MKName := MKName10;
for i := 0 to TV10.ColumnCount - 1 do
2025-07-19 14:23:30 +08:00
begin
with ClientDataSet2 do
begin
Append;
2025-10-18 14:10:28 +08:00
FieldByName('CxTabName').Value := Trim(TV10.Bands[TV10.Columns[i].Position.BandIndex].Caption);
FieldByName('CxColName').Value := Trim(TV10.Columns[i].Caption);
FieldByName('ColName').Value := Trim(TV10.Columns[i].DataBinding.FieldName);
FieldByName('OrderNo').Value := i;
2025-07-19 14:23:30 +08:00
Post;
end;
end;
ADOQuery5.DisableControls;
with ADOQuery5 do
begin
Close;
sql.Clear;
2025-10-18 14:10:28 +08:00
sql.Add('select * from Table_Name where 1=2');
2025-07-19 14:23:30 +08:00
Open;
end;
2025-10-18 14:10:28 +08:00
SCreateCDS20(ADOQuery5, CDSName);
SInitCDSData20(ADOQuery5, CDSName);
2025-07-19 14:23:30 +08:00
ADOQuery2.EnableControls;
2025-10-18 14:10:28 +08:00
MKName := MKName10;
for i := 0 to TV10.Bands.Count - 1 do
2025-07-19 14:23:30 +08:00
begin
with CDSName do
begin
Append;
2025-10-18 14:10:28 +08:00
FieldByName('CxTabName').Value := Trim(TV10.Bands[i].Caption);
FieldByName('OrderNo').Value := i;
2025-07-19 14:23:30 +08:00
Post;
end;
end;
2025-10-18 14:10:28 +08:00
if ShowModal = 1 then
2025-07-19 14:23:30 +08:00
begin
end;
end;
finally
frmColumnBandSet.Free;
end;
end;
2025-10-18 14:10:28 +08:00
procedure GetSWLDZ(IPStr: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
myip: ulong;
mymac: array[0..5] of byte;
mymaclength: ulong;
r: integer;
2025-07-19 14:23:30 +08:00
begin
{myip:=inet_addr(PChar(Trim(IPStr)));
mymaclength:=length(mymac);
r:=sendarp(myip,0,@mymac,@mymaclength);
IpCall:=r;
IpWLDZStr:=format('%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x',[mymac[0],mymac[1],mymac[2],mymac[3],mymac[4],mymac[5]]);}
end;
2025-10-18 14:10:28 +08:00
procedure SelOKNo(CDS_MainSel: TClientDataSet; FSel: Boolean);
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if CDS_MainSel.IsEmpty then
Exit;
2025-07-19 14:23:30 +08:00
CDS_MainSel.DisableControls;
with CDS_MainSel do
begin
First;
while not Eof do
begin
2025-10-18 14:10:28 +08:00
if FieldByName('SSel').AsBoolean = not FSel then
2025-07-19 14:23:30 +08:00
begin
Edit;
2025-10-18 14:10:28 +08:00
FieldByName('SSel').Value := FSel;
2025-07-19 14:23:30 +08:00
Post;
end;
Next;
end;
end;
CDS_MainSel.EnableControls;
end;
2025-10-18 14:10:28 +08:00
function num2ceng(strArabic: string): string;//<2F><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ӣ<EFBFBD><D3A2>
2025-07-19 14:23:30 +08:00
const
2025-10-18 14:10:28 +08:00
sw: array[2..9] of string = ('twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');
gw: array[1..19] of string = ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen');
exp: array[1..4] of string = ('', 'thousand', 'million', 'billion');
var
t, j, glb, t1: integer;
ts: string;
function readu1000(ss: string): string;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
t, code: integer;
begin
result := '';
while ss[1] = '0' do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
delete(ss, 1, 1);
if length(ss) = 0 then
exit; //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>0<EFBFBD><30><EFBFBD><EFBFBD>
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if length(ss) = 3 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
appendstr(result, gw[ord(ss[1]) - ord('0')]);
2025-07-19 14:23:30 +08:00
//appendstr(result,' hundred ');
2025-10-18 14:10:28 +08:00
appendstr(result, ' hundred ');
delete(ss, 1, 1);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
while ss[1] = '0' do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
delete(ss, 1, 1);
if length(ss) = 0 then
exit;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if length(ss) <> 0 then
if result <> '' then
appendstr(result, 'and ');
if (glb = 1) and (t1 <> 1) then //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λʱ<CEBB><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if result = '' then
appendstr(result, 'and ');
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
val(ss, t, code);
if t < 20 then
result := result + gw[t]
else if t mod 10 = 0 then
result := result + sw[t div 10]
2025-07-19 14:23:30 +08:00
else
//result := result+sw[trunc(t/10)]+'-'+gw[t mod 10];
2025-10-18 14:10:28 +08:00
result := result + sw[trunc(t / 10)] + ' ' + gw[t mod 10];
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
begin
result := '';
t := pos('.', strArabic);
if t = 0 then
t := length(strArabic) + 1;
while (t mod 3 <> 1) do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
t := t + 1;
strArabic := '0' + strArabic;
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
t1 := (t - 1) div 3;
for glb := t1 downto 1 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ts := '';
for j := 1 to 3 do
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
ts := ts + strArabic[1];
delete(strArabic, 1, 1);
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
result := result + readu1000(ts);
if ts <> '000' then
result := result + ' ' + exp[glb] + ' ';
2025-07-19 14:23:30 +08:00
end;
2025-10-18 14:10:28 +08:00
if length(strArabic) <> 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
delete(strArabic, 1, 1);
appendstr(result, 'and ');
result := result + readu1000(strArabic);
2025-07-19 14:23:30 +08:00
end;
end;
2025-10-18 14:10:28 +08:00
function num2cengnum(strArabic: string): string;
2025-07-19 14:23:30 +08:00
const
2025-10-18 14:10:28 +08:00
gw: array[1..10] of string = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
var
p, i, j, x: integer;
s: string;
begin
result := '';
s := strArabic;
p := pos('.', strArabic);
if p = 0 then
begin
result := num2ceng(strArabic) + 'DOLLARS ONLY';
exit;
end
else
begin
i := length(s) - p; //<2F><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>λ
delete(strArabic, p, i + 1); //ɾ<><C9BE>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
result := num2ceng(strArabic) + 'POINT';
end;
for x := 1 to i do //ת<><D7AA>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
begin
j := strtoint(copy(s, p + x, 1));
case j of
0:
result := result + ' ' + gw[1];
1:
result := result + ' ' + gw[2];
2:
result := result + ' ' + gw[3];
3:
result := result + ' ' + gw[4];
4:
result := result + ' ' + gw[5];
5:
result := result + ' ' + gw[6];
6:
result := result + ' ' + gw[7];
7:
result := result + ' ' + gw[8];
8:
result := result + ' ' + gw[9];
9:
result := result + ' ' + gw[10];
end;
end;
end;
function num2cengnumZS(strArabic: string): string;
var
p, i, j, x: integer;
s, Y: string;
begin
result := '';
s := strArabic;
p := pos('.', strArabic);
if p = 0 then
begin
result := num2ceng(strArabic) + 'Only';
exit;
end
else
begin
i := length(s) - p; //<2F><><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>λ
delete(strArabic, p, i + 1); //ɾ<><C9BE>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
result := num2ceng(strArabic) + 'DOLLORS';
end;
Y := copy(s, p, i + 1);
result := result + ' ' + num2ceng(Y) + ' CENTS';
end;
procedure DelCDS(ClientDataSet1: TClientDataSet; ADOCmd: TADOQuery; DelSql: string);
begin
if ClientDataSet1.IsEmpty then
Exit;
if Trim(ClientDataSet1.fieldbyname('ZSID').AsString) <> '' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
2025-07-19 14:23:30 +08:00
with ADOCmd do
begin
Close;
SQL.Clear;
sql.Add(DelSql);
ExecSQL;
end;
end;
ClientDataSet1.Delete;
end;
end.