D7szYidui/Z99Dependency/ThreeFun/Fun/U_Fun10.pas

3396 lines
108 KiB
ObjectPascal
Raw Normal View History

2025-07-19 14:23:30 +08:00
unit U_Fun10;
interface
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
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;
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 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);
2025-07-19 14:23:30 +08:00
// procedure SelExportData(FTv:TcxGridDBTableView;FAdoQry:TADOQuery;FTile:string);
2025-10-18 14:10:28 +08:00
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);
2025-07-19 14:23:30 +08:00
// procedure ColumnSet(TV10:TcxGridDBTableView;MKName10:String);
// procedure ColumnBandSet(TV10:TcxGridDBBandedTableView;MKName10:String);
2025-10-18 14:10:28 +08:00
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);
2025-07-19 14:23:30 +08:00
// procedure SelPrintData(FTv:TcxGridDBTableView;FAdoQry:TADOQuery;FTitle:string;FLTitle:string;FRTile:string);
// procedure SelPrintDataMore(FTv:TcxGridDBTableView;FAdoQry:TADOQuery;FTitle:string;FLTitle:string;FRTile:string;FKK:Integer;FiniName:string);
// procedure SelExportDataBand(FTv:TcxGridDBBandedTableView;FAdoQry:TADOQuery;FTile:string);
2025-10-18 14:10:28 +08:00
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 InitCDSToCDS(fromADO: TclientDataSet; toCDS: TclientDataSet);
procedure clearControl(Myparent: TWinControl; MyTag: integer);
procedure InitDllEvt(FromFile: string; FormID: Integer; Para: string; FormType: Integer; Title: string; Def1: string; Def2: string; Def3: string; Def4: string; Def5: string; Def6: string; Def7: string; Def8: string; Def9: string; Def10: string);
2025-07-19 14:23:30 +08:00
type
2025-10-18 14:10:28 +08:00
TMyF = function(App: TApplication; //<2F><>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD> (<28><>Delphi<68><69><EFBFBD><EFBFBD>)
FormH: HWND; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĸ<DAB5><C4B8><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD> (<28><>PB<50><42><EFBFBD><EFBFBD>)
FormID: Integer; //Ҫ<><D2AA><EFBFBD><EFBFBD>dll<6C>й<EFBFBD><D0B9>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD>Id<49><64>; <20><><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4>ڣ<EFBFBD>FormIDĬ<44><C4AC>Ϊ0
Language: Integer; //0=Delphi; 1=PB
WinStyle: Integer; //0=<3D>Ӵ<EFBFBD><D3B4><EFBFBD>; 1<><31><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD> (PB<50>ж<EFBFBD>Ϊ<EFBFBD><CEAA>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>)
UID: PChar; //<2F>û<EFBFBD>Id
UName: PChar; //<2F>û<EFBFBD><C3BB><EFBFBD>
Para: PChar; Title: PChar; Defstr1: PChar; Defstr2: PChar; Defstr3: PChar; Defstr4: PChar; Defstr5: PChar; Defstr6: PChar; Defstr7: PChar; Defstr8: PChar; Defstr9: PChar; Defstr10: PChar; Datalink: PChar): HWND; stdcall;
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
TP: FARPROC;
Tf: TMyF;
2025-07-19 14:23:30 +08:00
implementation
2025-10-18 14:10:28 +08:00
uses
U_DataLink;
procedure InitDllEvt(FromFile: string; FormID: Integer; Para: string; FormType: Integer; Title: string; Def1: string; Def2: string; Def3: string; Def4: string; Def5: string; Def6: string; Def7: string; Def8: string; Def9: string; Def10: string);
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
Th: HMODULE;
begin
Th := LoadLibrary(PChar(FromFile));
if Th > 0 then
begin
TP := GetProcAddress(Th, 'GetDllForm');
if TP <> nil then
begin
Tf := TMyF(Tp);
Tf(Application, 0, FormID, 0, FormType, PChar(DCode), PChar(DName), PChar(Para), PChar(Title), PChar(Def1), PChar(Def2), PChar(Def3), PChar(Def4), PChar(Def5), PChar(Def6), PChar(Def7), PChar(Def8), PChar(Def9), PChar(Def10), pchar(DConString));
end;
end
else
begin
Application.MessageBox(PChar('<27>򲻿<EFBFBD><F2B2BBBF>ļ<EFBFBD>' + FromFile + '<27><>'), '<27><><EFBFBD><EFBFBD>', MB_ICONERROR);
end;
end;
procedure clearControl(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
TEdit(Controls[i]).Text := '';
2025-07-19 14:23:30 +08:00
end;
if Controls[i] is TMemo then
begin
2025-10-18 14:10:28 +08:00
TMemo(Controls[i]).Lines.Text := '';
2025-07-19 14:23:30 +08:00
end;
if Controls[i] is TcxCurrencyEdit then
begin
2025-10-18 14:10:28 +08:00
TcxCurrencyEdit(Controls[i]).Text := '';
2025-07-19 14:23:30 +08:00
end;
if Controls[i] is TComboBox then
begin
2025-10-18 14:10:28 +08:00
TComboBox(Controls[i]).ItemIndex := 0;
2025-07-19 14:23:30 +08:00
end;
if Controls[i] is TDateTimePicker then
begin
2025-10-18 14:10:28 +08:00
TDateTimePicker(Controls[i]).Date := date();
2025-07-19 14:23:30 +08:00
end;
end;
end;
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>жϱ<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 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
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value:=null;
end};
2025-10-18 14:10:28 +08:00
end;
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;
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
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) = '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;
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;
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;
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;
2025-10-18 14:10:28 +08:00
function SGetServerDateTime(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 := 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
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
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)
else
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
begin
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
begin
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
begin
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
// if Trim(TEdit(Controls[i]).Text)<>'' then
2025-10-18 14:10:28 +08:00
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
begin
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
begin
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
begin
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
begin
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
begin
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
begin
if Trim(TEdit(Controls[i]).Hint) <> '' then
ADOQueryCmd.FieldByName(Trim(TEdit(Controls[i]).Hint)).Value := Trim(TEdit(Controls[i]).Text)
else
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text);
end;
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
if Trim(TMemo(Controls[i]).Hint) <> '' then
ADOQueryCmd.FieldByName(Trim(TMemo(Controls[i]).Hint)).Value := Trim(TMemo(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 := 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
begin
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).Text);
if (TBtnEditA(Controls[i]).Hint <> '') then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Pos('/', TBtnEditA(Controls[i]).Hint) > 0 then
begin
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
end
else
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
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
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;
2025-07-19 14:23:30 +08:00
end
2025-10-18 14:10:28 +08:00
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 := TcxCurrencyEdit(Controls[i]).Value;
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
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
///////////////////////////
//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)
2025-07-19 14:23:30 +08:00
else
2025-10-18 14:10:28 +08:00
TEdit(Controls[i]).Text := '';
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]).Text := trim(fieldByName(mfield).AsString);
2025-10-18 14:10:28 +08:00
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
if Pos('/', TBtnEditA(Controls[i]).Hint) > 0 then
2025-07-19 14:23:30 +08:00
begin
2025-10-18 14:10:28 +08:00
end
else
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
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
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
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]).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) + '%');
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
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
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;
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;
{fsj:=Trim(MyAdoQuery.fieldbyname('MaxNo').AsString);
with MyAdoQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select Max('+MyField+') MaxNo from '+MyTable);
SQL.Add('where '+MyField+' like '+QuotedStr('%'+copy(fsj,3,8)+'%'));
Open;
ShowMessage(copy(fsj,3,8));
if Trim(fieldbyname('MaxNo').AsString)='' then
begin
Result:=Trim(MyFlag)+Trim(Formatdatetime('yyyyMMdd',Now))+'1001';
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 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('XHNoTemp', ftFloat, 0);
mClientDataset.FieldDefs.Add('Sindex', ftInteger, 0);
mClientDataset.FieldDefs.Add('Ssel', ftBoolean, 0);
mClientDataset.FieldDefs.Add('SDefNote', ftString, 100);
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 InitCDSToCDS(fromADO: TclientDataSet; 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
k := 1;
2025-07-19 14:23:30 +08:00
try
2025-10-18 14:10:28 +08:00
with toCDS do
begin
Append;
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
Post;
end;
2025-07-19 14:23:30 +08:00
finally
end;
end;
2025-10-18 14:10:28 +08:00
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.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.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;
if not emptyFlag then
cb.Items.Add('');
while not EOF do
begin
cb.Items.Add(trim(fieldByName('Name').AsString));
next;
end;
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;
2025-10-18 14:10:28 +08:00
2025-07-19 14:23:30 +08:00
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);
2025-07-19 14:23:30 +08:00
2025-10-18 14:10:28 +08:00
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, false, false);
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: 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;
///////////////////////////////////////////////////////////////
//<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
ExportGridToExcel(saveDialog.FileName, gridName, false);
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 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 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');
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
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);
end;
while ss[1] = '0' do
begin
delete(ss, 1, 1);
if length(ss) = 0 then
exit;
end;
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 ');
begin
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 = ('0', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
2025-07-19 14:23:30 +08:00
var
2025-10-18 14:10:28 +08:00
p, i, j, x: integer;
s: 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) + '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;
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.