4755 lines
149 KiB
ObjectPascal
4755 lines
149 KiB
ObjectPascal
unit U_RTFun;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DBGrids, DB, cxDBData,
|
||
cxGridLevel, cxClasses, cxControls, cxGridCustomView, ADODB, StrUtils, Midas,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxTimeEdit,
|
||
cxTreeView, cxGrid, cxDBLookupComboBox, cxCalendar, cxCurrencyEdit,
|
||
cxGridExportLink, ExtCtrls, Buttons, DBClient, FTComboBox, cxDropDownEdit,
|
||
cxGridBandedTableView, cxGridDBBandedTableView, cxRichEdit, cxButtonEdit,
|
||
IniFiles, WinSock, IdHTTP, OleServer;
|
||
//Function sendarp(ipaddr:ulong;temp:dword;ulmacaddr:pointer;ulmacaddrleng:pointer) : DWord; StdCall; External 'Iphlpapi.dll' Name 'SendARP';
|
||
|
||
type
|
||
TA = class(TComponent)
|
||
public
|
||
S: string;
|
||
end;
|
||
TStringArray = array of string; // ¶¨Òå×Ö·û´®Êý×éÀàÐÍ
|
||
|
||
function SGetMaxId(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; var MaxId: Integer): Boolean;
|
||
|
||
function SIsRepeated(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; MyCode: string): Boolean;
|
||
|
||
function SSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
|
||
function SSetSaveDataCDS10(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
|
||
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime;
|
||
|
||
function SGetServerDateMBeg(ADOQueryTmp: TADOQuery): TdateTime;
|
||
|
||
function SGetServerDateMEnd(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; //*****ËÄÉáÎåÈë *****//
|
||
|
||
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); //¸´ÖÆÔöÐС££¨groupformat±ê¼ÇÖµ£©
|
||
|
||
procedure CopyAddRowBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet);
|
||
|
||
procedure OneKeyPost(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet); //Ò»¼üÌæ»»Õ³Ìù
|
||
|
||
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;
|
||
|
||
function GetLSNoHZ(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: integer; mtype: integer = 0; HZype: integer = 0): Boolean;
|
||
|
||
procedure SSetsaveSql(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
|
||
procedure ReadCxGrid(fileName: string; cxgrid: TcxGridDBTableView; filePack: string = '¹«ÓÃ');
|
||
|
||
procedure ReadCxBandedGrid(fileName: string; cxgrid: TcxGridDBBandedTableView; filePack: string = '¹«ÓÃ');
|
||
|
||
procedure WriteCxGrid(fileName: string; cxgrid: TcxGridDBTableView; filePack: string = '¹«ÓÃ');
|
||
|
||
procedure WriteCxBandedGrid(fileName: string; cxgrid: TcxGridDBBandedTableView; filePack: string = '¹«ÓÃ');
|
||
|
||
procedure CreateGroupSummarry(tv1: TcxGridDBTableView);
|
||
|
||
procedure CreateBandedGroupSummarry(tv1: TcxGridDBBandedTableView);
|
||
|
||
procedure TcxGridToExcel(mfileName: string; gridName: TcxGrid);
|
||
|
||
function ReadINIFileStr(ininame, TypeName: string; ValueName, ValueMR: string): string;
|
||
|
||
procedure SClearData(mParent: TWinControl; FTag: Integer);
|
||
|
||
procedure SDofilter10(cds_Main: TClientDataSet; FilterStr: string);
|
||
|
||
procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
|
||
|
||
procedure ColumnView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBTableView; MKName10: string);
|
||
|
||
procedure ColumnBandView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBBandedTableView; MKName10: string);
|
||
|
||
procedure SCSHDataWTag(ADOQueryTmp: TADOQuery; mParent: TWinControl);
|
||
|
||
procedure GetSWLDZ(IPStr: string);
|
||
|
||
procedure SCSHDataCDS(CDS_Main: TClientDataSet; mParent: TWinControl; FTag: Integer);
|
||
|
||
procedure SSetsaveSqlNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
|
||
procedure SCSHDataNew(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
|
||
|
||
function RTSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
|
||
function RTSetSaveDataCDSBand(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
|
||
procedure SCreateCDSOnly(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
|
||
|
||
procedure SInitCDSDataOnly(fromADO: TADOQuery; toCDS: TclientDataSet);
|
||
|
||
procedure SelOKNo(CDS_MainSel: TClientDataSet; FSel: Boolean);
|
||
|
||
function num2cengnum(strArabic: string): string;
|
||
|
||
function num2ceng(strArabic: string): string;
|
||
|
||
procedure RTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
|
||
procedure InitOrderColor(OrdMainId: string; Combox: TComboBox; FAdoQry: TADOQuery);
|
||
|
||
procedure InitBCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
|
||
|
||
procedure InitRCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
|
||
|
||
procedure DelCDS(ClientDataSet1: TClientDataSet; ADOCmd: TADOQuery; DelSql: string);
|
||
|
||
procedure OneKeyPostBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet);
|
||
|
||
procedure SInitComBoxByTvColumns(cb: TComboBox; Tv1: TcxGridDBTableView; ColumnTag: Integer; TowFlag: Boolean; emptyFlag: Boolean);
|
||
|
||
procedure TcxGridToHTML(mfileName: string; gridName: TcxGrid);
|
||
|
||
function FormatTitle(S: string): string;
|
||
|
||
function ValidatePID(const APID: string): string; //ÅжÏÉí·ÝÖ¤ºÅ
|
||
|
||
function RoundFloat(f: double; i: integer): double;
|
||
|
||
procedure initBtnColor(panel12: TPanel; clMenu: TColor);
|
||
|
||
function SGetWhereFinds(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
|
||
|
||
function CovFileDate(Fd: _FileTime): TDateTime;
|
||
|
||
procedure GetFileEditTime(mFile: string; var editTime: tdatetime);
|
||
|
||
procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime);
|
||
|
||
function ExportFtErpFile(mFileName: string; ADORead: TADOQuery): boolean;
|
||
|
||
procedure UpdateFileTime(FileName: string; CreationTime, LastAccessTime, LastWriteTime: TDateTime);
|
||
|
||
procedure SSetEditDataCDSNew(yClientDataset: TclientDataSet; mClientDataset: TclientDataSet);
|
||
|
||
procedure RTsavedataCDS(ADOQueryCmd: TClientDataSet; Myparent: TWinControl; MyTag: integer);
|
||
|
||
procedure GetHTTP(IdHttp: TIdHTTP; FUrl: string);
|
||
//procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime);
|
||
//function ExportFtErpFile(mFileName: string; ADORead: TADOQuery): boolean;
|
||
|
||
procedure InitDllEvt(FromFile: string; FormID: Integer; Para: string; FormType: Integer; Title: string; Def1: string; Def2: string; Def3: string; Def4: string; Def5: string; Def6: string; Def7: string; Def8: string; Def9: string; Def10: string);
|
||
|
||
procedure ClearOrHideControls(TMPanel: TPanel; HintValue: string; IsClear: Boolean; IsHide: Boolean);
|
||
|
||
procedure AssignmentControls(TMPanel: TPanel; TMClientDataset: TclientDataSet; Hintvalue: string);
|
||
|
||
procedure IsVisibleTV(TMPanel: TPanel; MTV: TcxGridDBTableView; Hintvalue: string; IsVisible: Boolean);
|
||
|
||
function GetKw(ADOQueryTmp: TADOQuery; C_CodeName, C_Color: string): string;
|
||
|
||
procedure WriteCxGridAll(fileName: string; cxgrid: TcxGridDBTableView; ADOQueryCmdSC: TADOQuery; ADOQueryTmp: TADOQuery);
|
||
|
||
procedure WriteCxBandedGridAll(fileName: string; cxgrid: TcxGridDBBandedTableView; ADOQueryCmdSC: TADOQuery; ADOQueryTmp: TADOQuery);
|
||
|
||
procedure ReadCxGridAll(fileName: string; cxgrid: TcxGridDBTableView);
|
||
|
||
procedure ReadCxBandedGridAll(fileName: string; cxgrid: TcxGridDBBandedTableView);
|
||
|
||
procedure SelOKNoFilter(Tv1: TcxGridDBTableView; FSel: Boolean);
|
||
|
||
procedure SelOKNoFilterBand(Tv1: TcxGridDBBandedTableView; FSel: Boolean);
|
||
|
||
function SelCDSKey(CDS_1: TClientDataSet; Keys: array of string): TStringArray;
|
||
|
||
type
|
||
TMyF = function(App: TApplication; //Ö÷Ó¦ÓóÌÐò (¶ÔDelphi¶øÑÔ)
|
||
FormH: HWND; //´´½¨´°¿ÚµÄ¸¸´°¿Ú¾ä±ú (¶ÔPB¶øÑÔ)
|
||
FormID: Integer; //Òªµ÷ÓÃdllÖй¦ÄÜ´°ÌåµÄIdºÅ; Èç¹ûÖ»ÓÐÒ»¸ö¹¦ÄÜ´°¿Ú£¬FormIDĬÈÏΪ0
|
||
Language: Integer; //0=Delphi; 1=PB
|
||
WinStyle: Integer; //0=×Ó´°¿Ú; 1£ºÆÕͨ´°¿Ú (PBÖж¼ÎªÆÕͨ´°¿Ú)
|
||
UID: PChar; //Óû§Id
|
||
UName: PChar; //Óû§Ãû
|
||
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;
|
||
|
||
var
|
||
TP: FARPROC;
|
||
Tf: TMyF;
|
||
|
||
implementation
|
||
|
||
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);
|
||
var
|
||
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('´ò²»¿ªÎļþ' + FromFile + '£¡'), '´íÎó', MB_ICONERROR);
|
||
end;
|
||
end;
|
||
|
||
procedure SelOKNoFilter(Tv1: TcxGridDBTableView; FSel: Boolean);
|
||
var
|
||
i: integer;
|
||
begin
|
||
Tv1.BeginUpdate();
|
||
Tv1.DataController.GotoFirst;
|
||
for i := 0 to Tv1.DataController.FilteredRecordCount do
|
||
begin
|
||
Tv1.DataController.GetItemByFieldName('ssel').EditValue := FSel;
|
||
Tv1.DataController.GotoNext;
|
||
end;
|
||
Tv1.DataController.GotoFirst;
|
||
Tv1.EndUpdate;
|
||
end;
|
||
|
||
procedure SelOKNoFilterBand(Tv1: TcxGridDBBandedTableView; FSel: Boolean);
|
||
var
|
||
i: integer;
|
||
begin
|
||
Tv1.BeginUpdate();
|
||
Tv1.DataController.GotoFirst;
|
||
for i := 0 to Tv1.DataController.FilteredRecordCount do
|
||
begin
|
||
Tv1.DataController.GetItemByFieldName('ssel').EditValue := FSel;
|
||
Tv1.DataController.GotoNext;
|
||
end;
|
||
Tv1.DataController.GotoFirst;
|
||
Tv1.EndUpdate;
|
||
end;
|
||
|
||
function GetKw(ADOQueryTmp: TADOQuery; C_CodeName, C_Color: string): string;
|
||
var
|
||
kw: string;
|
||
begin
|
||
kw := '';
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
SQL.Clear;
|
||
sql.add(' select zdyCode from KH_Zdy_Attachment ');
|
||
sql.add(' where defstr1=' + quotedstr(trim(C_CodeName)));
|
||
sql.add(' and defstr2=' + quotedstr(trim(C_Color)));
|
||
sql.add(' and Type=''CPKW'' ');
|
||
sql.add(' and isnull(DEFstr3,'''')=''¹Ì¶¨¼Ü'' ');
|
||
open;
|
||
if not isEmpty then
|
||
kw := trim(fieldbyname('zdyCode').asstring);
|
||
end;
|
||
result := kw;
|
||
except
|
||
result := kw;
|
||
end;
|
||
|
||
end;
|
||
|
||
///////////////////////////////////////////////////////
|
||
//°´ÕÕËÑË÷¿îÒþ²Ø±í¸ñÁÐ
|
||
///////////////////////////////////////////////////////
|
||
|
||
procedure IsVisibleTV(TMPanel: TPanel; MTV: TcxGridDBTableView; Hintvalue: string; IsVisible: Boolean);
|
||
var
|
||
i, j: integer;
|
||
begin
|
||
|
||
with TMPanel do
|
||
begin
|
||
for j := 0 to TMPanel.ControlCount - 1 do
|
||
begin
|
||
if TMPanel.Controls[j] is TEdit then
|
||
begin
|
||
if Trim(TEdit(TMPanel.Controls[j]).Hint) = Hintvalue then
|
||
begin
|
||
with MTV do
|
||
begin
|
||
for i := 0 to MTV.ColumnCount - 1 do
|
||
begin
|
||
if Trim(TEdit(TMPanel.Controls[j]).Name) = Trim(MTV.Columns[i].DataBinding.FieldName) then
|
||
begin
|
||
MTV.Columns[i].Visible := IsVisible;
|
||
Continue;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
if TMPanel.Controls[j] is TComboBox then
|
||
begin
|
||
if Trim(TComboBox(TMPanel.Controls[j]).Hint) = Hintvalue then
|
||
begin
|
||
with MTV do
|
||
begin
|
||
for i := 0 to MTV.ColumnCount - 1 do
|
||
begin
|
||
if Trim(TComboBox(TMPanel.Controls[j]).Name) = Trim(MTV.Columns[i].DataBinding.FieldName) then
|
||
begin
|
||
MTV.Columns[i].Visible := IsVisible;
|
||
Continue;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
///////////////////////////////////////////////////////
|
||
//½«±í¸ñÄÚÈÝÌîÈëËÑË÷¿ò
|
||
///////////////////////////////////////////////////////
|
||
|
||
procedure AssignmentControls(TMPanel: TPanel; TMClientDataset: TclientDataSet; Hintvalue: string);
|
||
var
|
||
i: integer;
|
||
begin
|
||
with TMPanel do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Hint) = Hintvalue then
|
||
begin
|
||
TEdit(Controls[i]).Text := Trim(TMClientDataset.FieldByName(TEdit(Controls[i]).Name).AsString);
|
||
end;
|
||
end;
|
||
if Controls[i] is TComboBox then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Hint) = Hintvalue then
|
||
begin
|
||
TComboBox(Controls[i]).ItemIndex := TComboBox(Controls[i]).Items.IndexOf(Trim(TMClientDataset.FieldByName(TComboBox(Controls[i]).Name).AsString));
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure GetHTTP(IdHttp: TIdHTTP; FUrl: string);
|
||
var
|
||
ResponseStream: TStringStream; //·µ»ØÐÅÏ¢
|
||
ResponseStr: string;
|
||
begin
|
||
//´´½¨IDHTTP¿Ø¼þ
|
||
IdHttp := TIdHTTP.Create(nil);
|
||
IdHttp.HTTPOptions := IdHttp.HTTPOptions + [hoKeepOrigProtocol];
|
||
//TStringStream¶ÔÏóÓÃÓÚ±£´æÏìÓ¦ÐÅÏ¢
|
||
ResponseStream := TStringStream.Create('');
|
||
try
|
||
try
|
||
IdHttp.Get(FUrl, ResponseStream); //ÇëÇóµØÖ·
|
||
except
|
||
on e: Exception do
|
||
begin
|
||
ShowMessage(e.Message);
|
||
end;
|
||
end;
|
||
//»ñÈ¡ÍøÒ³·µ»ØµÄÐÅÏ¢
|
||
ResponseStr := ResponseStream.DataString;
|
||
//ÍøÒ³ÖеĴæÔÚÖÐÎÄʱ£¬ÐèÒª½øÐÐUTF8½âÂë
|
||
ResponseStr := UTF8Decode(ResponseStr);
|
||
// ShowMessage(ResponseStr);
|
||
finally
|
||
IdHttp.Free;
|
||
ResponseStream.Free;
|
||
end;
|
||
end;
|
||
///////////////////////////////////////////////////////
|
||
//Çå³ý»òÕßÒþ²ØËÑË÷¿ò
|
||
///////////////////////////////////////////////////////
|
||
|
||
procedure ClearOrHideControls(TMPanel: TPanel; HintValue: string; IsClear: Boolean; IsHide: Boolean);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with TMPanel do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TCheckBox then
|
||
begin
|
||
if TCheckBox(Controls[i]).Hint = HintValue then
|
||
begin
|
||
TCheckBox(Controls[i]).Visible := IsHide;
|
||
end;
|
||
end;
|
||
if Controls[i] is TLabel then
|
||
begin
|
||
if TLabel(Controls[i]).Hint = HintValue then
|
||
begin
|
||
TLabel(Controls[i]).Visible := IsHide;
|
||
end;
|
||
end;
|
||
if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Hint = HintValue then
|
||
begin
|
||
TComboBox(Controls[i]).Visible := IsHide;
|
||
if IsClear then
|
||
TComboBox(Controls[i]).ItemIndex := -1;
|
||
end;
|
||
end;
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
|
||
if Trim(TEdit(Controls[i]).Hint) = HintValue then
|
||
begin
|
||
TEdit(Controls[i]).Visible := IsHide;
|
||
if IsClear then
|
||
TEdit(Controls[i]).Text := '';
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure RTsavedataCDS(ADOQueryCmd: TClientDataSet; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TBtnEditA then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).Text);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
begin
|
||
if Pos('/', Trim(TBtnEditC(Controls[i]).Hint)) > 0 then
|
||
Continue;
|
||
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).Text);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
begin
|
||
if Pos('/', Trim(TBtnEditC(Controls[i]).Hint)) > 0 then
|
||
Continue;
|
||
ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
|
||
end;
|
||
end
|
||
else if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text)
|
||
else
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Hint) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Hint)
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := null;
|
||
end;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TCheckBox then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TCheckBox(Controls[i]).Checked;
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := null;
|
||
end
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TcxButtonEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxButtonEdit(Controls[i]).Text);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure SSetEditDataCDSNew(yClientDataset: TclientDataSet; mClientDataset: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
k: integer;
|
||
mfieldName: string;
|
||
begin
|
||
if yClientDataset.IsEmpty then
|
||
exit;
|
||
k := 1;
|
||
try
|
||
mClientDataset.DisableControls;
|
||
mClientDataset.Filtered := false;
|
||
with mClientDataset do
|
||
begin
|
||
Append;
|
||
for i := 0 to yClientDataset.FieldCount - 1 do
|
||
begin
|
||
mfieldName := trim(yClientDataset.fields[i].FieldName);
|
||
fieldbyname(mfieldName).Value := yClientDataset.Fields[i].Value;
|
||
end;
|
||
post;
|
||
inc(k);
|
||
end;
|
||
if not mClientDataset.IsEmpty then
|
||
begin
|
||
mClientDataset.First;
|
||
end;
|
||
finally
|
||
mClientDataset.First;
|
||
mClientDataset.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
function ExportFtErpFile(mFileName: string; ADORead: TADOQuery): boolean;
|
||
var
|
||
Stream: TMemoryStream;
|
||
ff: TADOBlobstream;
|
||
mfileSize: integer;
|
||
mCreationTime: TdateTime;
|
||
mWriteTime: TdateTime;
|
||
IsFileHas: boolean;
|
||
mChildPath: string;
|
||
mFilePath: string;
|
||
begin
|
||
try
|
||
result := false;
|
||
mChildPath := '';
|
||
///////////////////////////////////////////////
|
||
//»ñÈ¡ÎļþÏÂÔØµÄ×Ó·¾¶
|
||
with ADORead do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select FilePath ');
|
||
sql.Add('from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(mFileName));
|
||
Open;
|
||
if RecordCount > 0 then
|
||
begin
|
||
// if not fieldByName('valid').AsBoolean then exit;
|
||
if trim(fieldByName('FilePath').AsString) <> '' then
|
||
mChildPath := trim(fieldByName('FilePath').AsString) + '\';
|
||
end;
|
||
end;
|
||
//Èç¹û²úÆ·´æÔÚ
|
||
mFilePath := ExtractFilePath(Paramstr(0)) + mChildPath;
|
||
IsFileHas := FileExists(mFilePath + mFileName);
|
||
if IsFileHas then
|
||
begin
|
||
//////////////////////////
|
||
//»ñÈ¡ÎļþÐÅÏ¢
|
||
GetFileInfo(mFilePath + mFileName, mfileSize, mCreationTime, mWriteTime);
|
||
end;
|
||
//////////////////////////////////////////
|
||
//´æÔÚÎļþ
|
||
if IsFileHas then
|
||
begin
|
||
with ADORead do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select count(FileName) as cnt ');
|
||
sql.Add('from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(mFileName));
|
||
// sql.Add('and fileEditDate>'''+formatDateTime('yyyy-MM-dd hh:mm',mWriteTime)+'''');
|
||
sql.Add(' and DATEDIFF(minute,' + quotedStr(formatDateTime('yyyy-MM-dd hh:mm', mWriteTime)) + ',fileEditDate)>0');
|
||
Open;
|
||
|
||
|
||
//ÊÇ·ñ´æÔÚеÄÎļþ
|
||
if fieldByName('cnt').AsInteger > 0 then
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * ');
|
||
sql.Add('from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(mFileName));
|
||
|
||
Open;
|
||
|
||
ff := TADOBlobstream.Create(fieldByName('Files') as TblobField, bmRead);
|
||
end
|
||
else
|
||
begin
|
||
exit;
|
||
end;
|
||
|
||
if trim(fieldByName('FilePath').AsString) <> '' then
|
||
mChildPath := trim(fieldByName('FilePath').AsString) + '\';
|
||
end;
|
||
end //////////////////////////////////////
|
||
//²»´æÔÚ
|
||
else
|
||
begin
|
||
with ADORead do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * ');
|
||
sql.Add('from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(mFileName));
|
||
Open;
|
||
|
||
if recordCount > 0 then
|
||
begin
|
||
ff := TADOBlobstream.Create(fieldByName('Files') as TblobField, bmRead);
|
||
end
|
||
else
|
||
begin
|
||
exit;
|
||
end;
|
||
|
||
if trim(fieldByName('FilePath').AsString) <> '' then
|
||
mChildPath := trim(fieldByName('FilePath').AsString) + '\';
|
||
end;
|
||
|
||
end;
|
||
|
||
if ff <> nil then
|
||
begin
|
||
try
|
||
mFileName := trim(ADORead.fieldByName('FileName').asString);
|
||
if not DirectoryExists(ExtractFileDir(mFilePath + mFileName)) then
|
||
ForceDirectories(ExtractFileDir(mFilePath + mFileName));
|
||
Stream := TMemoryStream.Create;
|
||
//OleContainer1.SaveToStream(Stream);
|
||
//ADOQuery1FileContent.SaveToFile('tmp'); //Êý¾Ý´æÈëÁÙʱÎļþ
|
||
//OleContainer1.LoadFromFile('tmp'); //´ÓÁÙʱÎļþÖжÁÈ¡OLE¶ÔÏó
|
||
ff.SaveToStream(Stream);
|
||
//OleContainer1.SaveToFile(ExtractFilePath(Paramstr(0))+mfielName)
|
||
Stream.SaveToFile(mFilePath + mFileName); //+'\tmpFile\'
|
||
//OleContainer1.SaveToFile('tmp');
|
||
finally
|
||
Stream.Free;
|
||
end;
|
||
end;
|
||
UpdateFileTime(mFilePath + mFileName, ADORead.fieldByName('FileCreateDate').AsDateTime, ADORead.fieldByName('FileEditDate').AsDateTime, ADORead.fieldByName('FileEditDate').AsDateTime);
|
||
Result := true;
|
||
except
|
||
application.MessageBox(pchar('¶ÁÈ¡Îļþ' + mFileName + 'ʧ°Ü!'), 'ÌáʾÐÅÏ¢', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure UpdateFileTime(FileName: string; CreationTime, LastAccessTime, LastWriteTime: TDateTime);
|
||
var
|
||
FileHnd: Integer;
|
||
SysTime: TSystemTime;
|
||
tTzi: TTimezoneInformation;
|
||
FCreationTime, FLastAccessTime, FLastWriteTime: TFileTime;
|
||
begin
|
||
GetTimezoneInformation(tTzi);
|
||
CreationTime := CreationTime + tTzi.Bias / 1440;
|
||
DateTimeToSystemTime(CreationTime, SysTime);
|
||
SystemTimeToFileTime(SysTime, FCreationTime);
|
||
//LastAccessTime := LastAccessTime + Ttzi.Bias/1440;
|
||
//DateTimeToSystemTime(LastAccessTime,SysTime);
|
||
//SystemTimeToFileTime(SysTime,FLastAccessTime);
|
||
LastWriteTime := LastWriteTime + tTzi.Bias / 1440;
|
||
DateTimeToSystemTime(LastWriteTime, SysTime);
|
||
SystemTimeToFileTime(SysTime, FLastWriteTime);
|
||
try
|
||
FileHnd := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
|
||
SetFileTime(FileHnd, @FCreationTime, nil, @FLastWriteTime);
|
||
finally
|
||
FileClose(FileHnd);
|
||
end;
|
||
end;
|
||
////////////////////////////////////////////////////////
|
||
//
|
||
///////////////////////////////////////////////////////
|
||
|
||
procedure GetFileInfo(mFile: string; var mfileSize: integer; var CreationTime: tdatetime; var WriteTime: tdatetime);
|
||
var
|
||
vSearchRec: TSearchRec;
|
||
begin
|
||
FindFirst(mFile, faAnyFile, vSearchRec);
|
||
mfileSize := vSearchRec.Size;
|
||
CreationTime := CovFileDate(vSearchRec.FindData.ftCreationTime); //´´½¨Ê±¼ä
|
||
//vSearchRec.FindData.ftLastAccessTime//·ÃÎÊʱ¼ä
|
||
WriteTime := CovFileDate(vSearchRec.FindData.ftLastWriteTime); //ÐÞ¸Äʱ¼ä
|
||
FindClose(vSearchRec);
|
||
end;
|
||
|
||
procedure GetFileEditTime(mFile: string; var editTime: tdatetime);
|
||
var
|
||
vSearchRec: TSearchRec;
|
||
begin
|
||
FindFirst(mFile, faAnyFile, vSearchRec);
|
||
//mfileSize:=vSearchRec.Size;
|
||
// CreationTime:=CovFileDate(vSearchRec.FindData.ftCreationTime);//´´½¨Ê±¼ä
|
||
//vSearchRec.FindData.ftLastAccessTime//·ÃÎÊʱ¼ä
|
||
editTime := CovFileDate(vSearchRec.FindData.ftLastWriteTime); //ÐÞ¸Äʱ¼ä
|
||
FindClose(vSearchRec);
|
||
end;
|
||
///////////////////////////////////////////////
|
||
//
|
||
/////////////////////////////////////////////
|
||
|
||
function CovFileDate(Fd: _FileTime): TDateTime;
|
||
var
|
||
Tct: _SystemTime;
|
||
Temp: _FileTime;
|
||
begin
|
||
FileTimeToLocalFileTime(Fd, Temp);
|
||
FileTimeToSystemTime(Temp, Tct);
|
||
CovFileDate := SystemTimeToDateTime(Tct);
|
||
end;
|
||
|
||
procedure initBtnColor(panel12: TPanel; clMenu: TColor);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with panel12 do
|
||
begin
|
||
for i := 0 to panel12.ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
TEdit(Controls[i]).Color := clMenu;
|
||
TEdit(Controls[i]).ReadOnly := True;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
TMemo(Controls[i]).Color := clMenu;
|
||
TMemo(Controls[i]).ReadOnly := True;
|
||
end
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
TComboBox(Controls[i]).Color := clMenu;
|
||
TComboBox(Controls[i]).Enabled := False;
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
TDateTimePicker(Controls[i]).Color := clMenu;
|
||
TDateTimePicker(Controls[i]).Enabled := False;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).Color := clMenu;
|
||
TBtnEditA(Controls[i]).Enabled := False;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
function RoundFloat(f: double; i: integer): double;
|
||
var
|
||
s: string;
|
||
ef: Extended;
|
||
begin
|
||
if f = 0 then
|
||
begin
|
||
Result := 0;
|
||
Exit;
|
||
end;
|
||
s := '#.' + StringOfChar('0', i);
|
||
if s = '#.' then
|
||
s := '#';
|
||
ef := StrToFloat(FloatToStr(f)); //·ÀÖ¹¸¡µãÔËËãµÄÎó²î
|
||
result := StrToFloat(FormatFloat(s, ef));
|
||
end;
|
||
///////////////////È¡±íÖÐIntÐÍ×Ö¶Î×î´óÖµ///////////////////////////////////////
|
||
|
||
function SGetMaxId(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; var MaxId: Integer): Boolean;
|
||
begin
|
||
try
|
||
with AdoQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select Max(' + MyField + ')+1 MaxId from ' + MyTable);
|
||
Open;
|
||
end;
|
||
with AdoQueryTemp do
|
||
begin
|
||
if (Trim(FieldByName('MaxId').AsString) = '') or (Trim(FieldByName('MaxId').AsString) = NULL) then
|
||
MaxId := 1
|
||
else
|
||
MaxId := (fieldbyname('MaxId').AsInteger);
|
||
Close;
|
||
SQL.Clear;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('È¡×î´óֵʧ°Ü£¡', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
function ValidatePID(const APID: string): string;
|
||
{ÄÚ²¿º¯Êý,È¡Éí·ÝÖ¤ºÅУÑéλ,×îºóһλ,¶Ô18λÓÐЧ}
|
||
|
||
function GetVerifyBit(sIdentityNum: string): Char;
|
||
var
|
||
nNum: Integer;
|
||
begin
|
||
Result := #0;
|
||
nNum := StrToInt(sIdentityNum[1]) * 7 + StrToInt(sIdentityNum[2]) * 9 + StrToInt(sIdentityNum[3]) * 10 + StrToInt(sIdentityNum[4]) * 5 + StrToInt(sIdentityNum[5]) * 8 + StrToInt(sIdentityNum[6]) * 4 + StrToInt(sIdentityNum[7]) * 2 + StrToInt(sIdentityNum[8]) * 1 + StrToInt(sIdentityNum[9]) * 6 + StrToInt(sIdentityNum[10]) * 3 + StrToInt(sIdentityNum[11]) * 7 + StrToInt(sIdentityNum[12]) * 9 + StrToInt(sIdentityNum[13]) * 10 + StrToInt(sIdentityNum[14]) * 5 + StrToInt(sIdentityNum[15]) * 8 + StrToInt(sIdentityNum[16]) * 4 + StrToInt(sIdentityNum[17]) * 2;
|
||
nNum := nNum mod 11;
|
||
case nNum of
|
||
0:
|
||
Result := '1';
|
||
1:
|
||
Result := '0';
|
||
2:
|
||
Result := 'X';
|
||
3:
|
||
Result := '9';
|
||
4:
|
||
Result := '8';
|
||
5:
|
||
Result := '7';
|
||
6:
|
||
Result := '6';
|
||
7:
|
||
Result := '5';
|
||
8:
|
||
Result := '4';
|
||
9:
|
||
Result := '3';
|
||
10:
|
||
Result := '2';
|
||
end;
|
||
end;
|
||
|
||
var
|
||
L: Integer;
|
||
sCentury: string;
|
||
sYear2Bit: string;
|
||
sMonth: string;
|
||
sDate: string;
|
||
iCentury: Integer;
|
||
iMonth: Integer;
|
||
iDate: Integer;
|
||
CRCFact: string; //18λ֤ºÅµÄʵ¼ÊÖµ
|
||
CRCTh: string; //18λ֤ºÅµÄÀíÂÛÖµ
|
||
FebDayAmt: Byte; //2ÔÂÌìÊý
|
||
begin
|
||
L := Length(APID);
|
||
if (L in [15, 18]) = False then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅ²»ÊÇ15λ»ò18λ(%0:s, ʵ¼ÊλÊý:%1:d)', [APID, L]);
|
||
Exit;
|
||
end;
|
||
CRCFact := '';
|
||
if L = 18 then
|
||
begin
|
||
sCentury := Copy(APID, 7, 2);
|
||
iCentury := StrToInt(sCentury);
|
||
if (iCentury in [18..20]) = False then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅÂëÎÞЧ:18λ֤ºÅµÄÄê·ÝǰÁ½Î»±ØÐëÔÚ18-20Ö®¼ä(%0:S)', [sCentury]);
|
||
Exit;
|
||
end;
|
||
sYear2Bit := Copy(APID, 9, 2);
|
||
sMonth := Copy(APID, 11, 2);
|
||
sDate := Copy(APID, 13, 2);
|
||
CRCFact := Copy(APID, 18, 1);
|
||
end
|
||
else
|
||
begin
|
||
sCentury := '19';
|
||
sYear2Bit := Copy(APID, 7, 2);
|
||
sMonth := Copy(APID, 9, 2);
|
||
sDate := Copy(APID, 11, 2);
|
||
end;
|
||
iMonth := StrToInt(sMonth);
|
||
iDate := StrToInt(sDate);
|
||
if (iMonth in [01..12]) = False then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅÂëÎÞЧ:Ô·ݱØÐëÔÚ01-12Ö®¼ä(%0:s)', [sMonth]);
|
||
Exit;
|
||
end;
|
||
if (iMonth in [1, 3, 5, 7, 8, 10, 12]) then
|
||
begin
|
||
if (iDate in [01..31]) = False then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅÂëÎÞЧ:ÈÕÆÚÎÞЧ,²»ÄÜΪÁã»ò³¬³öµ±ÔÂ×î´óÖµ(%0:s)', [sDate]);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if (iMonth in [4, 6, 9, 11]) then
|
||
begin
|
||
if (iDate in [01..30]) = False then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅÂëÎÞЧ:ÈÕÆÚÎÞЧ,²»ÄÜΪÁã»ò³¬³öµ±ÔÂ×î´óÖµ(%0:s)', [sDate]);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if IsLeapYear(StrToInt(sCentury + sYear2Bit)) = True then
|
||
begin
|
||
FebDayAmt := 29;
|
||
end
|
||
else
|
||
begin
|
||
FebDayAmt := 28;
|
||
end;
|
||
if (iMonth in [2]) then
|
||
begin
|
||
if (iDate in [01..FebDayAmt]) = False then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅÂëÎÞЧ:ÈÕÆÚÎÞЧ,²»ÄÜΪÁã»ò³¬³öµ±ÔÂ×î´óÖµ(%0:s)', [sDate]);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if CRCFact <> '' then
|
||
begin
|
||
CRCTh := GetVerifyBit(APID);
|
||
if CRCFact <> CRCTh then
|
||
begin
|
||
Result := Format('Éí·ÝÖ¤ºÅÂëÎÞЧ:УÑéλ(µÚ18λ)´í:(%0:s)', [APID]);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure InitBCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
fsj := 'select distinct(AOrdDefStr1) Code from JYOrder_Sub_AnPai ' + ' where Subid=''' + Trim(OrdSubId) + '''';
|
||
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;
|
||
|
||
procedure InitRCGangNo(OrdSubId: string; Combox: TComboBox; FAdoQry: TADOQuery);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
fsj := 'select distinct(gangno) Code from JYOrder_Sub_AnPai ' + ' where Subid=''' + Trim(OrdSubId) + '''';
|
||
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;
|
||
|
||
procedure InitOrderColor(OrdMainId: string; Combox: TComboBox; FAdoQry: TADOQuery);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
fsj := 'select distinct(PRTColor) Code from JYOrder_Sub ' + ' where Mainid=''' + Trim(OrdMainId) + '''';
|
||
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;
|
||
////×Ô¶¨Òå´òÓ¡
|
||
///////////////////////ÅжϱíÖÐÊý¾ÝÊÇ·ñÖØ¸´///////////////////////////////////
|
||
|
||
function SIsRepeated(AdoQueryTemp: TADOQuery; MyTable: string; MyField: string; MyCode: string): Boolean;
|
||
begin
|
||
try
|
||
Result := False;
|
||
with AdoQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add('select * from ' + MyTable + ' where ' + MyField + '=''' + Trim(MyCode) + '''');
|
||
Open;
|
||
if IsEmpty then
|
||
Result := True;
|
||
Close;
|
||
SQL.Clear;
|
||
end;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('±íÃû»ò×Ö¶ÎÃû´íÎó£¡', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
////////////////////ÉèÖÃClientDataSetµÄ±£´æÐÅÏ¢/////////////////////////////
|
||
|
||
function SSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
try
|
||
Result := False;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = MyTag then
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('ÉèÖÃCds±£´æÐÅϢʧ°Ü!', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
////////////////////ÉèÖÃClientDataSetµÄ±£´æÐÅÏ¢/////////////////////////////
|
||
|
||
function SSetSaveDataCDSNew(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
try
|
||
Result := False;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = MyTag then
|
||
begin
|
||
if Tv1.Columns[i].Visible = True then
|
||
begin
|
||
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '1' then
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
|
||
end{ else
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value:=null;
|
||
end};
|
||
end;
|
||
if Trim(Tv1.Columns[i].Summary.GroupFormat) <> '' then
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].Summary.GroupFormat).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).Value;
|
||
end; { else
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value:=null;
|
||
end; }
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('ÉèÖÃCds±£´æÐÅϢʧ°Ü!', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
function RTSetSaveDataCDS(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
try
|
||
Result := False;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = MyTag then
|
||
begin
|
||
//if Tv1.Columns[i].Visible=False then Continue;
|
||
if Trim(Tv1.Columns[i].DataBinding.FilterFieldName) = '' then
|
||
Continue;
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
|
||
end
|
||
else
|
||
begin
|
||
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) = '0' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := 0;
|
||
end
|
||
else
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := null;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('ÉèÖÃCds±£´æÐÅϢʧ°Ü!', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
function RTSetSaveDataCDSBand(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
try
|
||
Result := False;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = MyTag then
|
||
begin
|
||
if Tv1.Columns[i].Visible = False then
|
||
Continue;
|
||
if Trim(Tv1.Columns[i].DataBinding.FilterFieldName) = '' then
|
||
Continue;
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
|
||
end
|
||
else
|
||
begin
|
||
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '' then
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := 0
|
||
else
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := Null;
|
||
end;
|
||
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('ÉèÖÃCds±£´æÐÅϢʧ°Ü!', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
function SSetSaveDataCDSBandNew(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
try
|
||
Result := False;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = MyTag then
|
||
begin
|
||
if Trim(Tv1.Columns[i].Summary.GroupFooterFormat) <> '1' then
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).Value;
|
||
end;
|
||
end;
|
||
if Trim(Tv1.Columns[i].Summary.GroupFormat) <> '' then
|
||
begin
|
||
if Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).AsString) <> '' then
|
||
begin
|
||
AdoQueryCmd.FieldByName(Tv1.Columns[i].Summary.GroupFormat).Value := CDS_Sub.fieldbyname(Tv1.Columns[i].Summary.GroupFormat).Value;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('ÉèÖÃCds±£´æÐÅϢʧ°Ü!', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
////////////////////ÉèÖÃClientDataSetµÄ±£´æÐÅÏ¢/////////////////////////////
|
||
|
||
function SSetSaveDataCDS10(AdoQueryCmd: TADOQuery; Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet; MyTable: string; MyTag: Integer): Boolean;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
try
|
||
Result := False;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = MyTag then
|
||
begin
|
||
if 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;
|
||
end;
|
||
end;
|
||
Result := True;
|
||
except
|
||
Result := False;
|
||
Application.MessageBox('ÉèÖÃCds±£´æÐÅϢʧ°Ü!', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
///////////////////////////·þÎñÆ÷ÈÕÆÚ//////////////////////////////////////
|
||
|
||
function SGetServerDate(ADOQueryTmp: TADOQuery): TdateTime;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select getDate()as dt');
|
||
open;
|
||
result := StrToDate(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime));
|
||
close;
|
||
SQL.Clear;
|
||
end;
|
||
except
|
||
application.MessageBox('»ñÈ¡µ±Ç°ÈÕÆÚ·¢Éú´íÎó!', 'ÌáʾÐÅÏ¢', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
function SGetServerDateMBeg(ADOQueryTmp: TADOQuery): TdateTime;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select dateadd(dd,-day(getdate())+1,getdate()) as dt');
|
||
open;
|
||
result := StrToDate(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime));
|
||
close;
|
||
SQL.Clear;
|
||
end;
|
||
except
|
||
application.MessageBox('»ñÈ¡µ±Ç°ÈÕÆÚ·¢Éú´íÎó!', 'ÌáʾÐÅÏ¢', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
function SGetServerDateMEnd(ADOQueryTmp: TADOQuery): TdateTime;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('SELECT DATEADD(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0)) as dt');
|
||
open;
|
||
result := StrToDate(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime));
|
||
close;
|
||
SQL.Clear;
|
||
end;
|
||
except
|
||
application.MessageBox('»ñÈ¡µ±Ç°ÈÕÆÚ·¢Éú´íÎó!', 'ÌáʾÐÅÏ¢', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
function SGetServerDateTime(ADOQueryTmp: TADOQuery): TdateTime;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select getDate()as dt');
|
||
open;
|
||
result := fieldByName('dt').AsDatetime;
|
||
close;
|
||
SQL.Clear;
|
||
end;
|
||
except
|
||
application.MessageBox('»ñÈ¡µ±Ç°ÈÕÆÚ·¢Éú´íÎó!', 'ÌáʾÐÅÏ¢', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
function SGetServerDate10(ADOQueryTmp: TADOQuery): TdateTime;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select getDate()as dt');
|
||
open;
|
||
result := StrToDate(formatdatetime('yyyy-MM-dd', fieldByName('dt').AsDatetime));
|
||
close;
|
||
SQL.Clear;
|
||
end;
|
||
except
|
||
application.MessageBox('»ñÈ¡µ±Ç°ÈÕÆÚ·¢Éú´íÎó!', 'ÌáʾÐÅÏ¢', 0);
|
||
end;
|
||
|
||
end;
|
||
|
||
/////////////////////////////////////////////////////
|
||
//±£´æÊý¾Ýʱ×ֶθ³Öµ
|
||
/////////////////////////////////////////////////////
|
||
procedure SSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TcxRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
|
||
end;
|
||
if Controls[i] is TFTComboBox then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TCheckBox then
|
||
begin
|
||
if TCheckBox(Controls[i]).Checked = True then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 1
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 0;
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if TBtnEditA(Controls[i]).Hint = 'Ãû³Æ' 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
|
||
begin
|
||
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);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure SSetsavedataNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
|
||
end;
|
||
if Controls[i] is TFTComboBox then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
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);
|
||
//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);
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure RTSetsavedata(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TcxButtonEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxButtonEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditA(Controls[i]).Text);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
begin
|
||
if Pos('/', Trim(TBtnEditC(Controls[i]).Hint)) > 0 then
|
||
Continue;
|
||
ADOQueryCmd.FieldByName(Trim(TBtnEditA(Controls[i]).Hint)).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TBtnEditC(Controls[i]).Text);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
begin
|
||
if Pos('/', Trim(TBtnEditC(Controls[i]).Hint)) > 0 then
|
||
Continue;
|
||
ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
|
||
end;
|
||
end
|
||
else if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text)
|
||
else
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Hint) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Hint)
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := null;
|
||
end;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
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
|
||
begin
|
||
if Trim(TComboBox(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text)
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Null;
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox = True then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked = True then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := null;
|
||
end
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TCheckBox then
|
||
begin
|
||
if TCheckBox(Controls[i]).Checked = True then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := True;
|
||
end
|
||
else
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := False;
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure SSetsaveSql(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
MCode: string;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TcxRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
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);
|
||
//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);
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is 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
|
||
begin
|
||
MCode := Copy(Trim(Controls[i].Name), 1, Length(Trim(Controls[i].Name)) - 4);
|
||
ADOQueryCmd.FieldByName(MCode).Value := Trim(TcxButtonEdit(Controls[i]).Hint);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure SSetsaveSqlNew(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
MCode: string;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TEdit(Controls[i]).Text)
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Null;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TCheckBox then
|
||
begin
|
||
if TCheckBox(Controls[i]).Checked = True then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 1
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := 0;
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TcxRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TMemo(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
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
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TComboBox(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := null;
|
||
end
|
||
else
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else if Controls[i] is 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
|
||
begin
|
||
if Pos('/', TBtnEditC(Controls[i]).Hint) > 0 then
|
||
begin
|
||
|
||
end
|
||
else
|
||
ADOQueryCmd.FieldByName(Trim(TBtnEditC(Controls[i]).Hint)).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
|
||
end;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(Controls[i].Name).Value := Trim(TcxTimeEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is 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
|
||
begin
|
||
MCode := Copy(Trim(Controls[i].Name), 1, Length(Trim(Controls[i].Name)) - 4);
|
||
ADOQueryCmd.FieldByName(MCode).Value := Trim(TcxButtonEdit(Controls[i]).Hint);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure SSetsavedata10(ADOQueryCmd: TADOQuery; MyTable: string; Myparent: TWinControl; MyTag: integer);
|
||
var
|
||
i: Integer;
|
||
FFName: string;
|
||
begin
|
||
with Myparent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
FFName := Trim(Copy(Controls[i].Name, 1, (Length(Controls[i].Name) - 1)));
|
||
if Controls[i].Tag = MyTag then
|
||
begin
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(FFName).Value := Trim(TEdit(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
ADOQueryCmd.FieldByName(FFName).Value := TRichEdit(Controls[i]).Text;
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
ADOQueryCmd.FieldByName(FFName).Value := TMemo(Controls[i]).Text;
|
||
end;
|
||
if Controls[i] is TFTComboBox then
|
||
begin
|
||
if (TFTComboBox(Controls[i]).Text) <> '' then
|
||
ADOQueryCmd.FieldByName(FFName).Value := Trim(TFTComboBox(Controls[i]).Item2);
|
||
end
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
ADOQueryCmd.FieldByName(FFName).Value := Trim(TComboBox(Controls[i]).Text);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
ADOQueryCmd.FieldByName(FFName).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else
|
||
ADOQueryCmd.FieldByName(FFName).Value := TDateTimePicker(Controls[i]).DateTime;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
ADOQueryCmd.FieldByName(FFName).Value := Trim(TBtnEditA(Controls[i]).TxtCode);
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
ADOQueryCmd.FieldByName(FFName).Value := Trim(TBtnEditC(Controls[i]).TxtCode);
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
/////////////////////////////////////////////////////
|
||
//º¯Êý¹¦ÄÜ:³õʼ»¯´°¿ÚÊý¾Ý
|
||
/////////////////////////////////////////////////////
|
||
|
||
procedure SSetWinData(ADOQueryTmp: TADOQuery; mParent: TWinControl);
|
||
var
|
||
i, idx: integer;
|
||
mfield: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag >= 999 then
|
||
continue;
|
||
mfield := Controls[i].Name;
|
||
|
||
///////////////////////////
|
||
//EDIT
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
{ if Trim(Controls[i].Hint)='ÊýÖµ' then
|
||
continue
|
||
else }
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
{ if Trim(Controls[i].Hint)='ÊýÖµ' then
|
||
continue
|
||
else }
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
if Controls[i].Tag = 99 then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end;
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
//idx:=getCombIdx(TComboBox(Controls[i]),i,trim(fieldByName(mfield).AsString));
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if TBtnEditA(Controls[i]).Tag = 1 then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
|
||
end
|
||
else
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield).AsString);
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if IsEmpty or fieldByName(mfield).IsNull then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).Date := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end;
|
||
end; // end for
|
||
end; // end with
|
||
end; //end for with
|
||
|
||
end;
|
||
|
||
procedure SSetWinData30(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
|
||
var
|
||
i, idx: integer;
|
||
mfield: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag <> FTag then
|
||
continue;
|
||
mfield := Controls[i].Name;
|
||
|
||
///////////////////////////
|
||
//EDIT
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if IsEmpty or fieldByName(mfield).IsNull then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
TRichEdit(Controls[i]).Text := fieldbyname(mfield).AsString;
|
||
end;
|
||
end; // end for
|
||
end; // end with
|
||
end; //end for with
|
||
|
||
end;
|
||
|
||
procedure SClearData(mParent: TWinControl; FTag: Integer);
|
||
var
|
||
i, idx: integer;
|
||
begin
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag <> FTag then
|
||
continue;
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
TEdit(Controls[i]).Text := '';
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
TRichEdit(Controls[i]).Text := '';
|
||
end
|
||
else if Controls[i] is TMemo then
|
||
begin
|
||
TMemo(Controls[i]).Text := '';
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).ShowCheckbox = True then
|
||
begin
|
||
TDateTimePicker(Controls[i]).Checked := False;
|
||
end;
|
||
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
TcxRichEdit(Controls[i]).Text := '';
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).Text := '';
|
||
TBtnEditC(Controls[i]).TxtCode := '';
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).Text := '';
|
||
TBtnEditA(Controls[i]).TxtCode := '';
|
||
end
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure SCSHData(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
|
||
var
|
||
i, idx: integer;
|
||
mfield, mfieldCode: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag <> FTag then
|
||
continue;
|
||
mfield := Controls[i].Name;
|
||
|
||
///////////////////////////
|
||
//EDIT
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) = '' then
|
||
begin
|
||
TDateTimePicker(Controls[i]).Checked := False;
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end
|
||
else if Controls[i] is TcxButtonEdit then
|
||
begin
|
||
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
|
||
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
|
||
begin
|
||
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
|
||
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
|
||
end;
|
||
|
||
end;
|
||
end; // end for
|
||
end; // end with
|
||
end; //end for with
|
||
|
||
end;
|
||
|
||
procedure SCSHDataNew(ADOQueryTmp: TADOQuery; mParent: TWinControl; FTag: Integer);
|
||
var
|
||
i, idx: integer;
|
||
mfield, mfieldCode: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag <> FTag then
|
||
continue;
|
||
mfield := Controls[i].Name;
|
||
|
||
///////////////////////////
|
||
//EDIT
|
||
if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
begin
|
||
if Pos('/', TBtnEditC(Controls[i]).Hint) > 0 then
|
||
Continue;
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
begin
|
||
if Pos('/', TBtnEditC(Controls[i]).Hint) > 0 then
|
||
begin
|
||
|
||
end
|
||
else
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
|
||
end;
|
||
end
|
||
else if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString)
|
||
else
|
||
TEdit(Controls[i]).Text := '';
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString)
|
||
else
|
||
TRichEdit(Controls[i]).Text := '';
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString)
|
||
else
|
||
TcxRichEdit(Controls[i]).Text := '';
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Style = csDropDownList then
|
||
begin
|
||
if Trim(ADOQueryTmp.fieldByName(TComboBox(Controls[i]).Name).AsString) <> '' then
|
||
begin
|
||
TComboBox(Controls[i]).ItemIndex := TComboBox(Controls[i]).Items.IndexOf(trim(ADOQueryTmp.fieldByName(TComboBox(Controls[i]).Name).AsString));
|
||
end
|
||
else
|
||
begin
|
||
TComboBox(Controls[i]).ItemIndex := -1;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
TComboBox(Controls[i]).Text := trim(ADOQueryTmp.fieldByName(TComboBox(Controls[i]).Name).AsString);
|
||
end;
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) = '' then
|
||
begin
|
||
TDateTimePicker(Controls[i]).Checked := False;
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
if FieldByName(mfield).Value = null then
|
||
TcheckBox(Controls[i]).Checked := False
|
||
else
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end
|
||
else if Controls[i] is TcxButtonEdit then
|
||
begin
|
||
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
|
||
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
|
||
begin
|
||
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
|
||
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
|
||
end;
|
||
|
||
end;
|
||
end; // end for
|
||
end; // end with
|
||
end; //end for with
|
||
|
||
end;
|
||
|
||
procedure SCSHDataCDS(CDS_Main: TClientDataSet; mParent: TWinControl; FTag: Integer);
|
||
var
|
||
i, idx: integer;
|
||
mfield, mfieldCode: string;
|
||
ma: TA;
|
||
begin
|
||
with CDS_Main do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag <> FTag then
|
||
continue;
|
||
mfield := Controls[i].Name;
|
||
|
||
///////////////////////////
|
||
//EDIT
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) = '' then
|
||
begin
|
||
TDateTimePicker(Controls[i]).Checked := False;
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end
|
||
else if Controls[i] is TcxButtonEdit then
|
||
begin
|
||
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
|
||
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
|
||
begin
|
||
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
|
||
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
|
||
end;
|
||
|
||
end;
|
||
end; // end for
|
||
end; // end with
|
||
end; //end for with
|
||
|
||
end;
|
||
|
||
procedure SCSHDataWTag(ADOQueryTmp: TADOQuery; mParent: TWinControl);
|
||
var
|
||
i, idx: integer;
|
||
mfield, mfieldCode: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
//if Controls[i].Tag<>FTag then continue;
|
||
mfield := Controls[i].Name;
|
||
|
||
///////////////////////////
|
||
//EDIT
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxRichEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TcxRichEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditA(Controls[i]).Hint) <> '' then
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(Trim(TBtnEditA(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
if Trim(TBtnEditC(Controls[i]).Hint) <> '' then
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(Trim(TBtnEditC(Controls[i]).Hint)).AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) = '' then
|
||
begin
|
||
TDateTimePicker(Controls[i]).Checked := False;
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).DateTime := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end
|
||
else if Controls[i] is TcxButtonEdit then
|
||
begin
|
||
TcxButtonEdit(Controls[i]).Text := Trim(fieldbyname(mfield).AsString);
|
||
if TcxButtonEdit(Controls[i]).ParentShowHint = False then
|
||
begin
|
||
mfieldCode := Trim(Copy(mfield, 1, Length(mfield) - 4));
|
||
TcxButtonEdit(Controls[i]).Hint := Trim(fieldbyname(mfieldCode).AsString);
|
||
end;
|
||
|
||
end;
|
||
end; // end for
|
||
end; // end with
|
||
end; //end for with
|
||
|
||
end;
|
||
|
||
procedure SSetWinData10(ADOQueryTmp: TADOQuery; mParent: TWinControl);
|
||
var
|
||
i, idx: integer;
|
||
mfield: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag >= 999 then
|
||
continue;
|
||
//mfield:=Copy(Trim(Controls[i].Name),1,(Length(Trim(Controls[i].Name))-1));
|
||
mfield := Trim(Controls[i].Name);
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
if Controls[i].Tag = 99 then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end;
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if TBtnEditA(Controls[i]).Tag = 1 then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
|
||
end
|
||
else
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield).AsString);
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if IsEmpty or fieldByName(mfield).IsNull then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).Date := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end {else if Controls[i] is TcxLookupComboBox then
|
||
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;
|
||
|
||
procedure SSetWinData20(ADOQueryTmp: TADOQuery; mParent: TWinControl);
|
||
var
|
||
i, idx: integer;
|
||
mfield: string;
|
||
ma: TA;
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
if isEmpty then
|
||
exit;
|
||
with mParent do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
continue;
|
||
if Controls[i].Tag >= 999 then
|
||
continue;
|
||
mfield := Copy(Trim(Controls[i].Name), 1, (Length(Trim(Controls[i].Name)) - 1));
|
||
//mfield:=Trim(Controls[i].Name);
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(fieldByName(mfield).AsString) <> '' then
|
||
TEdit(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end //ftcombobox
|
||
else if Controls[i] is TFTComboBox then
|
||
begin
|
||
if Controls[i].Tag = 99 then
|
||
begin
|
||
idx := TftComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else
|
||
begin
|
||
idx := TftComboBox(Controls[i]).IndexOfItem2(trim(fieldByName(mfield).AsString));
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end;
|
||
end //combobox
|
||
else if Controls[i] is TComboBox then
|
||
begin
|
||
if TComboBox(Controls[i]).Items.Count > 0 then
|
||
begin
|
||
idx := TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString));
|
||
end
|
||
else
|
||
idx := -1;
|
||
TComboBox(Controls[i]).ItemIndex := idx;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if TBtnEditA(Controls[i]).Tag = 1 then
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
|
||
end
|
||
else
|
||
begin
|
||
TBtnEditA(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditA(Controls[i]).text := trim(fieldByName(mfield).AsString);
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
TBtnEditC(Controls[i]).TxtCode := trim(fieldByName(mfield).AsString);
|
||
TBtnEditC(Controls[i]).text := trim(fieldByName(mfield + 'Name').AsString);
|
||
end
|
||
else if Controls[i] is TDateTimePicker then
|
||
begin
|
||
if IsEmpty or fieldByName(mfield).IsNull then
|
||
begin
|
||
if TDateTimePicker(Controls[i]).Checked then
|
||
TDateTimePicker(Controls[i]).Date := strToDate('1990-01-01');
|
||
end
|
||
else
|
||
TDateTimePicker(Controls[i]).Date := fieldByName(mfield).AsDateTime;
|
||
end
|
||
else if Controls[i] is Tmemo then
|
||
begin
|
||
Tmemo(Controls[i]).Text := trim(fieldByName(mfield).AsString);
|
||
end
|
||
else if Controls[i] is TcxDateEdit then
|
||
begin
|
||
if not IsEmpty and not fieldByName(mfield).IsNull then
|
||
TcxDateEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxTimeEdit then
|
||
begin
|
||
if not IsEmpty and (fieldByName(mfield).AsString <> '') then
|
||
TcxTimeEdit(Controls[i]).text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcxCurrencyEdit then
|
||
begin
|
||
TcxCurrencyEdit(Controls[i]).Text := fieldByName(mfield).AsString;
|
||
end
|
||
else if Controls[i] is TcheckBox then
|
||
begin
|
||
TcheckBox(Controls[i]).Checked := fieldByName(mfield).asBoolean;
|
||
end {else if Controls[i] is TcxLookupComboBox then
|
||
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;
|
||
|
||
//////////////////////////////////////////////
|
||
//////º¯Êý¹¦ÄÜ£º¸ù¾ÝSQLÓï¾äɾ³ýÊý¾Ý
|
||
//////////////////////////////////////////////
|
||
function SDelData(ADOQueryCmd: TADOQuery; mDelStr: string): Boolean;
|
||
begin
|
||
try
|
||
result := False;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
SQL.Add(mDelStr);
|
||
ExecSQL;
|
||
end;
|
||
result := True;
|
||
except
|
||
result := False;
|
||
Application.MessageBox('Êý¾Ýɾ³ýʧ°Ü£¡', 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
////////////////////////////////////////////
|
||
////************»ñÈ¡¹ýÂËÌõ¼þ***********/////
|
||
////////////////////////////////////////////
|
||
function SGetFilters(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
|
||
var
|
||
i, j, k: Integer;
|
||
fsj, fsj1: string;
|
||
begin
|
||
Result := '';
|
||
with TMPanel do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
Continue;
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TEdit(Controls[i]).Text))
|
||
else if Controls[i].Tag = LikeTag then
|
||
begin
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
|
||
end;
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if Trim(TBtnEditA(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TBtnEditA(Controls[i]).TxtCode))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + 'Name' + ' like ' + QuotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%')
|
||
else if Controls[i].Tag = 99 then
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr(Trim(TBtnEditA(Controls[i]).TxtCode) + '%');
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
if Trim(TBtnEditC(Controls[i]).TxtCode) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TBtnEditC(Controls[i]).TxtCode))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + 'Name' + ' like ' + QuotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%')
|
||
else if Controls[i].Tag = 888 then
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%');
|
||
end
|
||
else if Trim(TBtnEditC(Controls[i]).Text) <> '' then
|
||
begin
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%');
|
||
end;
|
||
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) + '%');
|
||
end;
|
||
end;
|
||
end;
|
||
if Trim(Result) <> '' then
|
||
Result := Trim(RightBStr(Result, Length(Result) - 4));
|
||
end;
|
||
|
||
function SGetFiltersHint(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
|
||
var
|
||
i, j, k: Integer;
|
||
fsj, fsj1: string;
|
||
begin
|
||
Result := '';
|
||
with TMPanel do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
Continue;
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Hint + '=' + QuotedStr(Trim(TEdit(Controls[i]).Text))
|
||
else if Controls[i].Tag = LikeTag then
|
||
begin
|
||
j := Pos(' ', Trim(TEdit(Controls[i]).Text));
|
||
if j > 0 then
|
||
begin
|
||
Result := Result + 'and ' + Controls[i].Hint + ' like ' + QuotedStr('%' + Copy(Trim(TEdit(Controls[i]).Text), 1, j - 1) + '%');
|
||
fsj1 := Copy(Trim(TEdit(Controls[i]).Text), j + 1, Length(Trim(TEdit(Controls[i]).Text)));
|
||
while Trim(fsj1) <> '' do
|
||
begin
|
||
j := Pos(' ', Trim(fsj1));
|
||
if j > 0 then
|
||
begin
|
||
Result := Result + 'and ' + Controls[i].Hint + ' like ' + QuotedStr('%' + Copy(Trim(fsj1), 1, j - 1) + '%');
|
||
fsj1 := Copy(Trim(fsj1), j + 1, Length(Trim(fsj1)));
|
||
end
|
||
else
|
||
begin
|
||
Result := Result + 'and ' + Controls[i].Hint + ' like ' + QuotedStr('%' + Trim(fsj1) + '%');
|
||
fsj1 := '';
|
||
end;
|
||
end;
|
||
end
|
||
else
|
||
Result := Result + 'and ' + Controls[i].Hint + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
if Trim(Result) <> '' then
|
||
Result := Trim(RightBStr(Result, Length(Result) - 4));
|
||
end;
|
||
|
||
function SGetFinds(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
Result := '';
|
||
with TMPanel do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
Continue;
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TEdit(Controls[i]).Text))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if Trim(TBtnEditA(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TBtnEditA(Controls[i]).TxtCode))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + 'Name' + ' like ' + QuotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%');
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
if Trim(TBtnEditC(Controls[i]).TxtCode) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TBtnEditC(Controls[i]).TxtCode))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + 'Name' + ' like ' + QuotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%');
|
||
end;
|
||
end
|
||
else if Controls[i] is 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) + '%');
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
function SGetWhereFinds(TMPanel: TPanel; EquTag, LikeTag: Integer): string;
|
||
var
|
||
i: Integer;
|
||
begin
|
||
Result := '';
|
||
with TMPanel do
|
||
begin
|
||
for i := 0 to ControlCount - 1 do
|
||
begin
|
||
if Controls[i] is TLabel then
|
||
Continue;
|
||
if Controls[i] is TEdit then
|
||
begin
|
||
if Trim(TEdit(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TEdit(Controls[i]).Text))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TEdit(Controls[i]).Text) + '%');
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditA then
|
||
begin
|
||
if Trim(TBtnEditA(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TBtnEditA(Controls[i]).Text))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TBtnEditA(Controls[i]).Text) + '%');
|
||
end;
|
||
end
|
||
else if Controls[i] is TBtnEditC then
|
||
begin
|
||
if Trim(TBtnEditC(Controls[i]).Text) <> '' then
|
||
begin
|
||
if Controls[i].Tag = EquTag then
|
||
Result := Result + 'and ' + Controls[i].Name + '=' + QuotedStr(Trim(TBtnEditC(Controls[i]).Text))
|
||
else if Controls[i].Tag = LikeTag then
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%');
|
||
end
|
||
else if Trim(TBtnEditC(Controls[i]).Text) <> '' then
|
||
begin
|
||
Result := Result + 'and ' + Controls[i].Name + ' like ' + QuotedStr('%' + Trim(TBtnEditC(Controls[i]).Text) + '%');
|
||
end;
|
||
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) + '%');
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
////////////////////////////////////////////////////////////
|
||
//¹«ÓùýÂ˺¯Êý
|
||
////////////////////////////////////////////////////////////
|
||
procedure SDofilter(ADOQry: TADOQuery; FilterStr: string);
|
||
begin
|
||
try
|
||
ADOQry.DisableControls;
|
||
with ADOQry do
|
||
begin
|
||
if Trim(FilterStr) = '' then
|
||
begin
|
||
Filtered := False;
|
||
end
|
||
else
|
||
begin
|
||
Filtered := False;
|
||
Filter := FilterStr;
|
||
Filtered := True;
|
||
end;
|
||
end;
|
||
finally
|
||
ADOQry.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure SDofilter10(cds_Main: TClientDataSet; FilterStr: string);
|
||
begin
|
||
try
|
||
cds_Main.DisableControls;
|
||
with cds_Main do
|
||
begin
|
||
if Trim(FilterStr) = '' then
|
||
begin
|
||
Filtered := False;
|
||
end
|
||
else
|
||
begin
|
||
Filtered := False;
|
||
Filter := FilterStr;
|
||
Filtered := True;
|
||
end;
|
||
end;
|
||
finally
|
||
cds_Main.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
function SGetMaxNo(MyAdoQuery: TADOQuery; MyTable: string; MyField: string; MyFlag: string): string;
|
||
var
|
||
fsj: string;
|
||
i: Integer;
|
||
begin
|
||
try
|
||
result := '';
|
||
fsj := Trim(Formatdatetime('yyyyMMdd', Now));
|
||
i := Length(Trim(MyFlag));
|
||
with MyAdoQuery do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select Max(' + MyField + ') MaxNo from ' + MyTable);
|
||
SQL.Add('where ' + MyField + ' like ' + QuotedStr('%' + fsj + '%'));
|
||
Open;
|
||
end;
|
||
with MyAdoQuery do
|
||
begin
|
||
if Trim(fieldbyname('MaxNo').AsString) = '' then
|
||
begin
|
||
Result := Trim(MyFlag) + Trim(Formatdatetime('yyyyMMdd', Now)) + '1001';
|
||
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;}
|
||
fsj := Trim(MyAdoQuery.fieldbyname('MaxNo').AsString);
|
||
result := Trim(MyFlag) + Trim(Formatdatetime('yyyyMMdd', Now)) + IntToStr(StrtoInt(Copy(fsj, i + 9, Length(fsj) - i - 8)) + 1);
|
||
|
||
except
|
||
Result := '';
|
||
Application.MessageBox(PChar('×Ö¶ÎȡֵMaxNoÓÐÎ󣬲鿴±í<' + Trim(MyTable) + '>¼°±í×Ö¶Î<' + MyField + '>'), 'Ìáʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure SCreateCDS20(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
mfieldName: string;
|
||
mSize: integer;
|
||
begin
|
||
mfieldName := '';
|
||
mClientDataset.FieldDefs.Clear;
|
||
with SADOQry do
|
||
begin
|
||
for i := 0 to fieldCount - 1 do //
|
||
begin
|
||
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
|
||
begin
|
||
mSize := 1;
|
||
end
|
||
else
|
||
mSize := Fields[i].Size;
|
||
mfieldName := trim(fields[i].FieldName);
|
||
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
|
||
|
||
end;
|
||
end;
|
||
mClientDataset.FieldDefs.Add('Sflag', ftString, 1);
|
||
mClientDataset.FieldDefs.Add('Sindex', ftInteger, 0);
|
||
mClientDataset.FieldDefs.Add('Ssel', ftBoolean, 0);
|
||
mClientDataset.FieldDefs.Add('SDefNote', ftString, 10);
|
||
mClientDataset.Close;
|
||
mClientDataset.CreateDataSet;
|
||
end;
|
||
|
||
procedure SCreateCDSOnly(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
mfieldName: string;
|
||
mSize: integer;
|
||
begin
|
||
mfieldName := '';
|
||
mClientDataset.FieldDefs.Clear;
|
||
with SADOQry do
|
||
begin
|
||
for i := 0 to fieldCount - 1 do //
|
||
begin
|
||
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
|
||
begin
|
||
mSize := 1;
|
||
end
|
||
else
|
||
mSize := Fields[i].Size;
|
||
mfieldName := trim(fields[i].FieldName);
|
||
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
|
||
|
||
end;
|
||
end;
|
||
mClientDataset.Close;
|
||
mClientDataset.CreateDataSet;
|
||
end;
|
||
|
||
procedure SInitCDSData20(fromADO: TADOQuery; toCDS: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
k: integer;
|
||
begin
|
||
if fromADO.IsEmpty then
|
||
exit;
|
||
fromADO.first;
|
||
k := 1;
|
||
try
|
||
toCDS.DisableControls;
|
||
toCDS.Filtered := false;
|
||
|
||
while not fromADO.Eof do
|
||
begin
|
||
with toCDS do
|
||
begin
|
||
Append;
|
||
for i := 0 to fromADO.FieldCount - 1 do
|
||
begin
|
||
fields[i].value := fromADO.Fields[i].Value;
|
||
end;
|
||
fieldByName('Sflag').AsString := '1';
|
||
fieldByName('Sindex').value := k;
|
||
fieldByName('Ssel').value := false;
|
||
fieldByName('SDefNote').value := '';
|
||
inc(k);
|
||
Post;
|
||
end;
|
||
fromADO.Next;
|
||
end;
|
||
if not toCDS.IsEmpty then
|
||
begin
|
||
toCDS.First;
|
||
end;
|
||
finally
|
||
toCDS.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure SInitCDSDataOnly(fromADO: TADOQuery; toCDS: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
k: integer;
|
||
begin
|
||
if fromADO.IsEmpty then
|
||
exit;
|
||
fromADO.first;
|
||
k := 1;
|
||
try
|
||
toCDS.DisableControls;
|
||
toCDS.Filtered := false;
|
||
|
||
while not fromADO.Eof do
|
||
begin
|
||
with toCDS do
|
||
begin
|
||
Append;
|
||
for i := 0 to fromADO.FieldCount - 1 do
|
||
begin
|
||
fields[i].value := fromADO.Fields[i].Value;
|
||
end;
|
||
inc(k);
|
||
Post;
|
||
end;
|
||
fromADO.Next;
|
||
end;
|
||
if not toCDS.IsEmpty then
|
||
begin
|
||
toCDS.First;
|
||
end;
|
||
finally
|
||
toCDS.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure SInitFtComBoxBySql(ADOQueryTmp: TADOQuery; cb: TFtComboBox; FlagType: string; Boxtype: integer; showMsg: string; emptyFlag: Boolean; mSql: string);
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add(mSql);
|
||
Open;
|
||
if isEmpty then
|
||
begin
|
||
application.MessageBox(pChar(showMsg), '', 0);
|
||
exit;
|
||
end;
|
||
cb.Clear;
|
||
while not EOF do
|
||
begin
|
||
if Boxtype = 0 then
|
||
begin
|
||
cb.Items.Add(trim(fieldByName('Name').AsString));
|
||
end
|
||
else
|
||
begin
|
||
cb.AddItem2(trim(fieldByName('Name').AsString), nil, trim(fieldByName('code').AsString));
|
||
end;
|
||
next;
|
||
end;
|
||
|
||
if not emptyFlag then
|
||
cb.Items.Add('');
|
||
|
||
if emptyFlag and (cb.Items.Count > 0) then
|
||
cb.ItemIndex := 0;
|
||
end;
|
||
end;
|
||
|
||
procedure SInitComBoxBySql(ADOQueryTmp: TADOQuery; cb: TComboBox; emptyFlag: Boolean; mSql: string);
|
||
begin
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add(mSql);
|
||
Open;
|
||
if isEmpty then
|
||
begin
|
||
//plication.MessageBox(pChar(showMsg),'',0);
|
||
exit;
|
||
end;
|
||
cb.Clear;
|
||
while not EOF do
|
||
begin
|
||
cb.Items.Add(trim(fieldByName('Name').AsString));
|
||
next;
|
||
end;
|
||
|
||
if not emptyFlag then
|
||
cb.Items.Add('');
|
||
|
||
if emptyFlag and (cb.Items.Count > 0) then
|
||
cb.ItemIndex := 0;
|
||
end;
|
||
end;
|
||
//////////////////////////////////////////////
|
||
//º¯Êý£º³õÊÔ»¯comboxÖеÄÊý¾Ý
|
||
//´ÓXC_CustCode±íÖÐÈ¡¶¨ÒåÊý¾Ý
|
||
//Boxtype:0; ´ø±àºÅ£º1;
|
||
//////////////////////////////////////////////
|
||
|
||
procedure SInitComBoxByCustCode(ADOQueryTmp: TADOQuery; cb: TComboBox; FlagType: string; Boxtype: integer; showMsg: string; emptyFlag: Boolean);
|
||
var
|
||
A: TA;
|
||
begin
|
||
cb.Items.Clear;
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add('exec P_Get_XC_Custcode');
|
||
sql.Add(quotedStr(trim(FlagType)));
|
||
Open;
|
||
if isEmpty then
|
||
begin
|
||
application.MessageBox(pChar('¿Í»§»ù´¡ÐÅϢά»¤Ä£¿éÖÐδÕÒµ½£º' + showMsg), '', 0);
|
||
exit;
|
||
end;
|
||
|
||
while not EOF do
|
||
begin
|
||
if Boxtype = 0 then
|
||
begin
|
||
cb.Items.Add(trim(fieldByName('name').AsString));
|
||
end
|
||
else
|
||
begin
|
||
A := TA.Create(Nil);
|
||
A.s := trim(fieldByName('code').AsString);
|
||
cb.Items.AddObject(trim(fieldByName('name').AsString), TObject(A));
|
||
end;
|
||
next;
|
||
end;
|
||
|
||
if not emptyFlag then
|
||
cb.Items.Add('');
|
||
|
||
if emptyFlag and (cb.Items.Count > 0) then
|
||
cb.ItemIndex := 0;
|
||
end;
|
||
end;
|
||
|
||
procedure SInitComBoxByTvColumns(cb: TComboBox; Tv1: TcxGridDBTableView; ColumnTag: Integer; TowFlag: Boolean; emptyFlag: Boolean);
|
||
var
|
||
A: TA;
|
||
i: Integer;
|
||
begin
|
||
cb.Items.Clear;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Tv1.Columns[i].Tag = ColumnTag then
|
||
begin
|
||
if TowFlag = False then
|
||
begin
|
||
cb.Items.Add(trim(Tv1.Columns[i].Caption));
|
||
end
|
||
else
|
||
begin
|
||
A := TA.Create(Nil);
|
||
A.s := Trim(Tv1.Columns[i].DataBinding.FieldName);
|
||
cb.Items.AddObject(Trim(Tv1.Columns[i].Caption), TObject(A));
|
||
end;
|
||
end;
|
||
end;
|
||
if emptyFlag = False then
|
||
cb.Items.Add('');
|
||
if cb.Items.Count > 0 then
|
||
cb.ItemIndex := 0;
|
||
end;
|
||
|
||
procedure SInitCxGridComboBoxByCustCode(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FlagType: string; PState: Integer; IsNull: Boolean; Shmeg: string);
|
||
var
|
||
A: TA;
|
||
begin
|
||
|
||
(c3.Properties as TcxComboBoxProperties).Items.Clear;
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add(' select * from XC_CustCode ' + ' where Flag=''' + trim(FlagType) + ''' ' + ' order by orderno ');
|
||
Open;
|
||
if isEmpty then
|
||
begin
|
||
Application.MessageBox(PChar('¿Í»§»ù´¡ÐÅϢά»¤Ä£¿éÖÐδÕÒµ½:' + Shmeg), '', 0);
|
||
exit;
|
||
end;
|
||
while not EOF do
|
||
begin
|
||
A := TA.Create(Nil);
|
||
A.s := trim(fieldByName('Code').AsString);
|
||
if PState = 1 then
|
||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(trim(fieldByName('name').AsString), TObject(A))
|
||
else if PState = 0 then
|
||
begin
|
||
(c3.Properties as TcxComboBoxProperties).Items.Add(trim(fieldByName('name').AsString));
|
||
end;
|
||
next;
|
||
end;
|
||
if not IsNull then
|
||
(c3.Properties as TcxComboBoxProperties).Items.Add('');
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure SInitCxGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGriddbColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
|
||
var
|
||
A: TA;
|
||
begin
|
||
|
||
(c3.Properties as TcxComboBoxProperties).Items.Clear;
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add(FSql);
|
||
Open;
|
||
if isEmpty then
|
||
begin
|
||
//Application.MessageBox(PChar('δÕÒµ½:'+shmeg),'',0);
|
||
exit;
|
||
end;
|
||
while not EOF do
|
||
begin
|
||
A := TA.Create(Nil);
|
||
A.s := trim(fieldByName('Code').AsString);
|
||
if PState = 1 then
|
||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(trim(fieldByName('name').AsString), TObject(A))
|
||
else if PState = 0 then
|
||
begin
|
||
(c3.Properties as TcxComboBoxProperties).Items.Add(trim(fieldByName('name').AsString));
|
||
end;
|
||
next;
|
||
end;
|
||
if not IsNull then
|
||
begin
|
||
(c3.Properties as TcxComboBoxProperties).Items.Add('');
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure SInitCxBandGridComboBoxBySql(ADOQueryTmp: TADOQuery; c3: TcxGridDBBandedColumn; FSql: string; PState: Integer; IsNull: Boolean; Shmeg: string);
|
||
var
|
||
A: TA;
|
||
begin
|
||
(c3.Properties as TcxComboBoxProperties).Items.Clear;
|
||
with ADOQueryTmp do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.Add(FSql);
|
||
Open;
|
||
if isEmpty then
|
||
begin
|
||
Application.MessageBox(PChar('δÕÒµ½:' + Shmeg), '', 0);
|
||
exit;
|
||
end;
|
||
while not EOF do
|
||
begin
|
||
A := TA.Create(Nil);
|
||
A.s := trim(fieldByName('Code').AsString);
|
||
if PState = 1 then
|
||
(c3.Properties as TcxComboBoxProperties).Items.AddObject(trim(fieldByName('name').AsString), TObject(A))
|
||
else if PState = 0 then
|
||
begin
|
||
(c3.Properties as TcxComboBoxProperties).Items.Add(trim(fieldByName('name').AsString));
|
||
end;
|
||
next;
|
||
end;
|
||
if not IsNull then
|
||
begin
|
||
(c3.Properties as TcxComboBoxProperties).Items.Add('');
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
|
||
///////////////////////////////////////////////////
|
||
//*****ËÄÉáÎåÈë ***** //
|
||
/////////////////////////////////////////////////
|
||
function SSWR(s: real): real;
|
||
var
|
||
r1, r2: real;
|
||
s1, s2: string;
|
||
begin
|
||
r1 := int(s);
|
||
r2 := frac(s);
|
||
if s < 0 then
|
||
begin
|
||
s1 := '-' + copy(floattostr(r1), 1, length(floattostr(r1)));
|
||
end
|
||
else
|
||
begin
|
||
s1 := copy(floattostr(r1), 1, length(floattostr(r1)));
|
||
end;
|
||
|
||
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
|
||
s1 := inttostr(strtoint(s1) + 1);
|
||
s2 := '';
|
||
end
|
||
else
|
||
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)
|
||
else
|
||
s2 := inttostr(strtoint(copy(floattostr(r2), 3, 2)) + 1)
|
||
else
|
||
s2 := copy(floattostr(r2), 3, 2);
|
||
end
|
||
else
|
||
s2 := copy(floattostr(r2), 3, 2);
|
||
if Pos('.', s2) > 0 then
|
||
begin
|
||
result := strtofloat(s1 + s2);
|
||
end
|
||
else
|
||
begin
|
||
result := strtofloat(s1 + '.' + s2);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure SInitCDSDataSel(fromADO: TADOQuery; toCDS: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
k: integer;
|
||
begin
|
||
if fromADO.IsEmpty then
|
||
exit;
|
||
fromADO.first;
|
||
k := 1;
|
||
try
|
||
toCDS.DisableControls;
|
||
toCDS.Filtered := false;
|
||
|
||
while not fromADO.Eof do
|
||
begin
|
||
with toCDS do
|
||
begin
|
||
Append;
|
||
for i := 0 to fromADO.FieldCount - 1 do
|
||
begin
|
||
fields[i].value := fromADO.Fields[i].Value;
|
||
end;
|
||
//fieldByName('Sflag').AsString :='1';
|
||
//fieldByName('Sindex').value :=k;
|
||
fieldByName('Ssel').value := false;
|
||
inc(k);
|
||
Post;
|
||
end;
|
||
fromADO.Next;
|
||
end;
|
||
if not toCDS.IsEmpty then
|
||
begin
|
||
toCDS.First;
|
||
end;
|
||
finally
|
||
toCDS.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure SCreateCDSSel(SADOQry: TADOQuery; mClientDataset: TclientDataSet);
|
||
var
|
||
i: integer;
|
||
mfieldName: string;
|
||
mSize: integer;
|
||
begin
|
||
mfieldName := '';
|
||
mClientDataset.FieldDefs.Clear;
|
||
with SADOQry do
|
||
begin
|
||
for i := 0 to fieldCount - 1 do //
|
||
begin
|
||
if (Fields[i].DataType = ftString) and (Fields[i].Size = 0) then
|
||
begin
|
||
mSize := 1;
|
||
end
|
||
else
|
||
mSize := Fields[i].Size;
|
||
mfieldName := trim(fields[i].FieldName);
|
||
mClientDataset.FieldDefs.Add(mfieldName, Fields[i].DataType, mSize);
|
||
|
||
end;
|
||
end;
|
||
mClientDataset.FieldDefs.Add('Sflag', ftString, 1);
|
||
mClientDataset.FieldDefs.Add('Sindex', ftInteger, 0);
|
||
mClientDataset.FieldDefs.Add('Ssel', ftBoolean, 0);
|
||
mClientDataset.FieldDefs.Add('SDefNote', ftString, 10);
|
||
mClientDataset.Close;
|
||
mClientDataset.CreateDataSet;
|
||
end;
|
||
//¸´ÖÆÔöÐÐ
|
||
|
||
procedure CopyAddRow(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet);
|
||
var
|
||
AA: array[0..50] of string;
|
||
i, j: Integer;
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
begin
|
||
CDS_Sub.Append;
|
||
CDS_Sub.Post;
|
||
Exit;
|
||
end;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if Trim((Tv1.Columns[i].DataBinding.FieldName)) <> '' then
|
||
begin
|
||
AA[i] := Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString);
|
||
end
|
||
else
|
||
begin
|
||
AA[i] := '';
|
||
end;
|
||
end;
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if AA[i] <> '' then
|
||
begin
|
||
CDS_Sub.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := AA[i];
|
||
end;
|
||
end;
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
procedure CopyAddRowBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet);
|
||
var
|
||
AA: array[0..50] of string;
|
||
i, j: Integer;
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
begin
|
||
CDS_Sub.Append;
|
||
CDS_Sub.Post;
|
||
Exit;
|
||
end;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
AA[i] := Trim(CDS_Sub.fieldbyname(Tv1.Columns[i].DataBinding.FieldName).AsString);
|
||
end;
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
for i := 0 to Tv1.ColumnCount - 1 do
|
||
begin
|
||
if AA[i] <> '' then
|
||
begin
|
||
CDS_Sub.FieldByName(Tv1.Columns[i].DataBinding.FieldName).Value := AA[i];
|
||
end;
|
||
end;
|
||
Post;
|
||
end;
|
||
end;
|
||
//¸´ÖÆÔöÐÐ
|
||
|
||
procedure CopyAddRowCDS(CDS_Sub: TClientDataSet);
|
||
var
|
||
AA: array[0..200] of string;
|
||
i, j: Integer;
|
||
begin
|
||
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
for i := 0 to CDS_Sub.FieldCount - 1 do
|
||
begin
|
||
AA[i] := Trim(CDS_Sub.fieldbyname(CDS_Sub.Fields[i].FieldName).AsString);
|
||
end;
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
for i := 0 to CDS_Sub.FieldCount - 1 do
|
||
begin
|
||
if AA[i] <> '' then
|
||
begin
|
||
CDS_Sub.FieldByName(CDS_Sub.Fields[i].FieldName).Value := AA[i];
|
||
end;
|
||
end;
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
function SelCDSKey(CDS_1: TClientDataSet; Keys: array of string): TStringArray;
|
||
var
|
||
RTValues: TStringArray;
|
||
i, j, CurRow: Integer;
|
||
begin
|
||
// ³õʼ»¯½á¹ûÊý×é
|
||
SetLength(RTValues, Length(Keys));
|
||
|
||
// ±£´æµ±Ç°Î»Öò¢½ûÓÿؼþË¢ÐÂ
|
||
CurRow := CDS_1.RecNo;
|
||
CDS_1.DisableControls;
|
||
|
||
try
|
||
with CDS_1 do
|
||
begin
|
||
First;
|
||
j := 0;
|
||
|
||
// ±éÀúÊý¾Ý¼¯
|
||
while not Eof do
|
||
begin
|
||
// ¼ì²éSSel×Ö¶ÎÊÇ·ñΪTrue
|
||
if FieldByName('SSel').AsBoolean then
|
||
begin
|
||
// ´¦Àíÿ¸ö¼ü×Ö¶Î
|
||
for i := 0 to Length(Keys) - 1 do
|
||
begin
|
||
if j = 0 then
|
||
// µÚÒ»¸öÆ¥Åä¼Ç¼£¬³õʼ»¯×Ö·û´®
|
||
RTValues[i] := Trim(FieldByName(Keys[i]).AsString) + ','
|
||
else
|
||
// ºóÐøÆ¥Åä¼Ç¼£¬×·¼Óµ½×Ö·û´®
|
||
RTValues[i] := RTValues[i] + Trim(FieldByName(Keys[i]).AsString) + ',';
|
||
end;
|
||
Inc(j); // Ôö¼ÓÆ¥Å伯Êý
|
||
end;
|
||
Next; // ÒÆ¶¯µ½ÏÂÒ»Ìõ¼Ç¼
|
||
end;
|
||
end;
|
||
finally
|
||
// »Ö¸´Î»Öò¢ÆôÓÿؼþ
|
||
CDS_1.RecNo := CurRow;
|
||
CDS_1.EnableControls;
|
||
end;
|
||
|
||
// ÒÆ³ýÿ¸ö×Ö·û´®Ä©Î²µÄ¶ººÅ
|
||
for i := 0 to Length(RTValues) - 1 do
|
||
begin
|
||
if Length(RTValues[i]) > 0 then
|
||
RTValues[i] := Copy(RTValues[i], 1, Length(RTValues[i]) - 1);
|
||
end;
|
||
|
||
// ·µ»Ø½á¹û
|
||
Result := RTValues;
|
||
end;
|
||
|
||
procedure OneKeyPost(Tv1: TcxGridDBTableView; CDS_Sub: TClientDataSet);
|
||
var
|
||
FValue, FFValue, FColumn, FFColumn: string;
|
||
begin
|
||
//FColumn:=tv1.Columns[Tv1.Controller.FocusedColumnIndex].DataBinding.FieldName;
|
||
//FFColumn:=Tv1.Columns[Tv1.Controller.FocusedColumnIndex].Summary.GroupFormat;
|
||
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
FFColumn := Tv1.Controller.FocusedColumn.Summary.GroupFormat;
|
||
FValue := Trim(CDS_Sub.fieldbyname(FColumn).AsString);
|
||
if Trim(FFColumn) <> '' then
|
||
begin
|
||
FFValue := Trim(CDS_Sub.fieldbyname(FFColumn).AsString);
|
||
end;
|
||
with CDS_Sub do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
Edit;
|
||
if FValue = '' then
|
||
begin
|
||
CDS_Sub.FieldByName(FColumn).Value := null;
|
||
end
|
||
else
|
||
begin
|
||
CDS_Sub.FieldByName(FColumn).Value := FValue;
|
||
end;
|
||
if Trim(FFColumn) <> '' then
|
||
begin
|
||
if FFValue = '' then
|
||
begin
|
||
CDS_Sub.FieldByName(FFColumn).Value := null;
|
||
end
|
||
else
|
||
begin
|
||
CDS_Sub.FieldByName(FFColumn).Value := FFValue;
|
||
end;
|
||
end;
|
||
|
||
Post;
|
||
Next;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure OneKeyPostBand(Tv1: TcxGridDBBandedTableView; CDS_Sub: TClientDataSet);
|
||
var
|
||
FValue, FFValue, FColumn, FFColumn: string;
|
||
begin
|
||
//FColumn:=tv1.Columns[Tv1.Controller.FocusedColumnIndex].DataBinding.FieldName;
|
||
//FFColumn:=Tv1.Columns[Tv1.Controller.FocusedColumnIndex].Summary.GroupFormat;
|
||
FColumn := Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
FFColumn := Tv1.Controller.FocusedColumn.Summary.GroupFormat;
|
||
FValue := Trim(CDS_Sub.fieldbyname(FColumn).AsString);
|
||
if Trim(FFColumn) <> '' then
|
||
begin
|
||
FFValue := Trim(CDS_Sub.fieldbyname(FFColumn).AsString);
|
||
end;
|
||
with CDS_Sub do
|
||
begin
|
||
DisableControls;
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
Edit;
|
||
if FValue = '' then
|
||
begin
|
||
CDS_Sub.FieldByName(FColumn).Value := null;
|
||
end
|
||
else
|
||
begin
|
||
CDS_Sub.FieldByName(FColumn).Value := FValue;
|
||
end;
|
||
if Trim(FFColumn) <> '' then
|
||
begin
|
||
if FFValue = '' then
|
||
begin
|
||
CDS_Sub.FieldByName(FFColumn).Value := null;
|
||
end
|
||
else
|
||
begin
|
||
CDS_Sub.FieldByName(FFColumn).Value := FFValue;
|
||
end;
|
||
end;
|
||
|
||
Post;
|
||
Next;
|
||
end;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
|
||
///////////////////////////////////////////////////
|
||
//º¯Êý¹¦ÄÜ£ºÈ¡Á÷Ë®ºÅ
|
||
//mFlag:ǰ׺£»mTable:±íÃû
|
||
//mlen:Á÷Ë®ºÅ³¤¶È; mtype:ÊÇ·ñ´øÈÕÆÚ 1£º´ø 0 ²»´ø
|
||
///////////////////////////////////////////////////
|
||
function GetLSNo(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: integer; mtype: integer = 0): Boolean;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec Get_SY_MaxBH ');
|
||
sql.Add(' ' + quotedStr(mFlag));
|
||
sql.Add(',' + quotedStr(mTable));
|
||
sql.Add(',' + intTostr(mlen));
|
||
sql.Add(',' + intTostr(mtype));
|
||
//ShowMessage(SQL.Text);
|
||
Open;
|
||
|
||
if RecordCount > 0 then
|
||
begin
|
||
mMaxNo := trim(fieldByName('MaxBH').AsString);
|
||
if mMaxNo <> '' then
|
||
result := true
|
||
else
|
||
Result := false;
|
||
end
|
||
else
|
||
begin
|
||
result := false;
|
||
end;
|
||
|
||
end;
|
||
if not Result then
|
||
application.MessageBox(Pchar('ÎÞ·¨Éú³ÉÁ÷Ë®ºÅ(' + mFlag + ')'), 'ÌáʾÐÅÏ¢', MB_ICONINFORMATION);
|
||
|
||
except
|
||
result := false;
|
||
application.MessageBox(Pchar('ÎÞ·¨Éú³ÉÁ÷Ë®ºÅ(' + mFlag + ')'), 'ÌáʾÐÅÏ¢', MB_ICONINFORMATION);
|
||
|
||
end;
|
||
end;
|
||
|
||
///////////////////////////////////////////////////
|
||
//º¯Êý¹¦ÄÜ£ºÈ¡Á÷Ë®ºÅ
|
||
//mFlag:ǰ׺£»mTable:±íÃû
|
||
//mlen:Á÷Ë®ºÅ³¤¶È;
|
||
//mtype:ÊÇ·ñ´øÈÕÆÚ 1£º´ø 0 ²»´ø
|
||
//HZype 0 °´ÄêÔÂÈÕÈ¡ÐòºÅ£¬1°´ÄêÔÂÈ¡ÐòºÅ£¬2°´ÄêÈ¡ÐòºÅ,3°´ÄêÔÂÈÕÈ¡ÔÂÐòºÅ,4°´ÄêÔÂÈÕÈ¡ÄêÐòºÅ
|
||
///////////////////////////////////////////////////
|
||
function GetLSNoHZ(ADOQueryTmp: TADOQuery; var mMaxNo: string; mFlag: string; mTable: string; mlen: integer; mtype: integer = 0; HZype: integer = 0): Boolean;
|
||
begin
|
||
try
|
||
with ADOQueryTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec Get_SY_MaxBH_HZ ');
|
||
sql.Add(' ' + quotedStr(mFlag));
|
||
sql.Add(',' + quotedStr(mTable));
|
||
sql.Add(',' + intTostr(mlen));
|
||
sql.Add(',' + intTostr(mtype));
|
||
sql.Add(',' + intTostr(HZype));
|
||
// ShowMessage(SQL.Text);
|
||
Open;
|
||
|
||
if RecordCount > 0 then
|
||
begin
|
||
mMaxNo := trim(fieldByName('MaxBH').AsString);
|
||
if mMaxNo <> '' then
|
||
result := true
|
||
else
|
||
Result := false;
|
||
end
|
||
else
|
||
begin
|
||
result := false;
|
||
end;
|
||
|
||
end;
|
||
if not Result then
|
||
application.MessageBox(Pchar('ÎÞ·¨Éú³É»ã×ÜÁ÷Ë®ºÅ(' + mFlag + ')'), 'ÌáʾÐÅÏ¢', MB_ICONINFORMATION);
|
||
|
||
except
|
||
result := false;
|
||
application.MessageBox(Pchar('ÎÞ·¨Éú³É»ã×ÜÁ÷Ë®ºÅ(' + mFlag + ')'), 'ÌáʾÐÅÏ¢', MB_ICONINFORMATION);
|
||
|
||
end;
|
||
end;
|
||
|
||
procedure ReadCxGrid(fileName: string; cxgrid: TcxGridDBTableView; filePack: string = '¹«ÓÃ');
|
||
var
|
||
mFileName: string;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
|
||
//´Ó²¼¾ÖÎļþÖлָ´
|
||
if FileExists(mFileName) then
|
||
cxgrid.RestoreFromIniFile(mFileName);
|
||
CreateGroupSummarry(cxgrid);
|
||
end;
|
||
///////////////////////////////////////////////////////////////
|
||
//º¯Êý¹¦ÄÜ£º´ÓÎļþÖжÁÈ¡cxGridColÉèÖÃ
|
||
//fileName ÍÆ¼öΪ´°¿ÚµÄcaptionÃû×ÖcaptionÃû×Ö
|
||
///////////////////////////////////////////////////////////////
|
||
|
||
procedure ReadCxBandedGrid(fileName: string; cxgrid: TcxGridDBBandedTableView; filePack: string = '¹«ÓÃ');
|
||
var
|
||
mFileName: string;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
|
||
//´Ó²¼¾ÖÎļþÖлָ´
|
||
if FileExists(mFileName) then
|
||
cxgrid.RestoreFromIniFile(mFileName);
|
||
end;
|
||
///////////////////////////////////////////////////////////////
|
||
//º¯Êý¹¦ÄÜ£ºÐ´cxGridColÉèÖõ½.dbgÎļþÖÐ
|
||
//ĬÈÏÍÆ¼öΪ´°¿ÚµÄcaptionÃû×Ö
|
||
///////////////////////////////////////////////////////////////
|
||
|
||
procedure WriteCxGrid(fileName: string; cxgrid: TcxGridDBTableView; filePack: string = '¹«ÓÃ');
|
||
var
|
||
mFileName: string;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
|
||
if not DirectoryExists(ExtractFileDir(mFileName)) then
|
||
CreateDir(ExtractFileDir(mFileName));
|
||
//±£´æÎª²¼¾ÖÎļþ
|
||
cxgrid.StoreToIniFile(mFileName);
|
||
|
||
end;
|
||
|
||
procedure WriteCxGridAll(fileName: string; cxgrid: TcxGridDBTableView; ADOQueryCmdSC: TADOQuery; ADOQueryTmp: TADOQuery);
|
||
var
|
||
mFileName, fFileName, fpathFileName: string;
|
||
Stream: TMemoryStream;
|
||
mfileSize: integer;
|
||
mCreationTime: TdateTime;
|
||
mWriteTime: TdateTime;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg';
|
||
if not DirectoryExists(ExtractFileDir(mFileName)) then
|
||
CreateDir(ExtractFileDir(mFileName));
|
||
//±£´æÎª²¼¾ÖÎļþ
|
||
cxgrid.StoreToIniFile(mFileName);
|
||
fFileName := fileName + '.dbg';
|
||
fpathFileName := Trim(ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg');
|
||
try
|
||
ADOQueryCmdSC.Connection.BeginTrans;
|
||
try
|
||
with ADOQueryCmdSC do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
|
||
execsql;
|
||
end;
|
||
with ADOQueryCmdSC do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
|
||
Open;
|
||
//////////////////////////
|
||
//»ñÈ¡ÎļþÐÅÏ¢
|
||
GetFileInfo(Trim(fpathFileName), mfileSize, mCreationTime, mWriteTime);
|
||
|
||
if RecordCount <= 0 then
|
||
begin
|
||
Append;
|
||
fieldByName('FileName').AsString := trim(fFileName);
|
||
end
|
||
else
|
||
begin
|
||
edit;
|
||
end;
|
||
|
||
fieldByName('FileEditDate').Value := mWriteTime;
|
||
fieldByName('FileCreateDate').Value := mCreationTime;
|
||
fieldByName('FileSize').Value := mfileSize;
|
||
fieldByName('Filler').Value := Dname;
|
||
fieldByName('LastEditer').Value := Dname;
|
||
// fieldByName('LastEditTime').Value :=SGetServerDateTime(ADOQueryTmp);
|
||
fieldByName('FilePath').Value := 'LayOut';
|
||
fieldByName('FileType').Value := '¹«ÓÃ';
|
||
//½«OLEÊý¾Ý´æÈëÊý¾Ý¿â
|
||
tblobfield(FieldByName('Files')).LoadFromFile(fpathFileName);
|
||
post;
|
||
end;
|
||
finally
|
||
end;
|
||
ADOQueryCmdSC.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmdSC.Connection.RollbackTrans;
|
||
application.MessageBox(pchar('Ìá½»Îļþ[' + trim(fFileName) + ']ʧ°Ü!'), 'ÌáʾÐÅÏ¢', MB_ICONERROR);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure WriteCxBandedGridAll(fileName: string; cxgrid: TcxGridDBBandedTableView; ADOQueryCmdSC: TADOQuery; ADOQueryTmp: TADOQuery);
|
||
var
|
||
mFileName, fFileName, fpathFileName: string;
|
||
Stream: TMemoryStream;
|
||
mfileSize: integer;
|
||
mCreationTime: TdateTime;
|
||
mWriteTime: TdateTime;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg';
|
||
if not DirectoryExists(ExtractFileDir(mFileName)) then
|
||
CreateDir(ExtractFileDir(mFileName));
|
||
//±£´æÎª²¼¾ÖÎļþ
|
||
cxgrid.StoreToIniFile(mFileName);
|
||
fFileName := fileName + '.dbg';
|
||
fpathFileName := Trim(ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg');
|
||
try
|
||
ADOQueryCmdSC.Connection.BeginTrans;
|
||
try
|
||
with ADOQueryCmdSC do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
|
||
execsql;
|
||
end;
|
||
with ADOQueryCmdSC do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from RT_FileUpdate');
|
||
sql.Add('where FileName=' + quotedStr(trim(fFileName)));
|
||
Open;
|
||
//////////////////////////
|
||
//»ñÈ¡ÎļþÐÅÏ¢
|
||
GetFileInfo(Trim(fpathFileName), mfileSize, mCreationTime, mWriteTime);
|
||
|
||
if RecordCount <= 0 then
|
||
begin
|
||
Append;
|
||
fieldByName('FileName').AsString := trim(fFileName);
|
||
end
|
||
else
|
||
begin
|
||
edit;
|
||
end;
|
||
|
||
fieldByName('FileEditDate').Value := mWriteTime;
|
||
fieldByName('FileCreateDate').Value := mCreationTime;
|
||
fieldByName('FileSize').Value := mfileSize;
|
||
fieldByName('Filler').Value := Dname;
|
||
fieldByName('LastEditer').Value := Dname;
|
||
//fieldByName('LastEditTime').Value :=SGetServerDateTime(ADOQueryTmp);
|
||
fieldByName('FilePath').Value := 'LayOut';
|
||
fieldByName('FileType').Value := '¹«ÓÃ';
|
||
//½«OLEÊý¾Ý´æÈëÊý¾Ý¿â
|
||
tblobfield(FieldByName('Files')).LoadFromFile(fpathFileName);
|
||
post;
|
||
end;
|
||
finally
|
||
end;
|
||
ADOQueryCmdSC.Connection.CommitTrans;
|
||
except
|
||
ADOQueryCmdSC.Connection.RollbackTrans;
|
||
application.MessageBox(pchar('Ìá½»Îļþ[' + trim(fFileName) + ']ʧ°Ü!'), 'ÌáʾÐÅÏ¢', MB_ICONERROR);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure ReadCxGridAll(fileName: string; cxgrid: TcxGridDBTableView);
|
||
var
|
||
mFileName: string;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg';
|
||
//´Ó²¼¾ÖÎļþÖлָ´
|
||
if FileExists(mFileName) then
|
||
cxgrid.RestoreFromIniFile(mFileName);
|
||
CreateGroupSummarry(cxgrid);
|
||
end;
|
||
|
||
procedure ReadCxBandedGridAll(fileName: string; cxgrid: TcxGridDBBandedTableView);
|
||
var
|
||
mFileName: string;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + trim(fileName) + '.dbg';
|
||
//´Ó²¼¾ÖÎļþÖлָ´
|
||
if FileExists(mFileName) then
|
||
cxgrid.RestoreFromIniFile(mFileName);
|
||
CreateBandedGroupSummarry(cxgrid);
|
||
end;
|
||
///////////////////////////////////////////////////////////////
|
||
//º¯Êý¹¦ÄÜ£ºÐ´cxGridColÉèÖõ½.dbgÎļþÖÐ
|
||
//ĬÈÏÍÆ¼öΪ´°¿ÚµÄcaptionÃû×Ö
|
||
///////////////////////////////////////////////////////////////
|
||
|
||
procedure WriteCxBandedGrid(fileName: string; cxgrid: TcxGridDBBandedTableView; filePack: string = '¹«ÓÃ');
|
||
var
|
||
mFileName: string;
|
||
begin
|
||
mFileName := ExtractFilePath(Application.ExeName) + 'Layout\' + filePack + '\' + trim(fileName) + '.dbg';
|
||
if not DirectoryExists(ExtractFileDir(mFileName)) then
|
||
CreateDir(ExtractFileDir(mFileName));
|
||
//±£´æÎª²¼¾ÖÎļþ
|
||
cxgrid.StoreToIniFile(mFileName);
|
||
end;
|
||
|
||
procedure CreateGroupSummarry(tv1: TcxGridDBTableView);
|
||
var
|
||
csg: TcxDataSummaryGroup;
|
||
csglink: TcxDataSummaryGroupItemLink;
|
||
csgItem: TcxDataSummaryItem;
|
||
i: integer;
|
||
mFieldName: string;
|
||
begin
|
||
///´´½¨»ã×ÜÁÐ
|
||
with tv1.DataController.Summary do
|
||
begin
|
||
try
|
||
csg := DataController.Summary.SummaryGroups.Add; //´´½¨»ã×ÜÏî
|
||
|
||
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;
|
||
|
||
if tv1.Columns[i].Summary.FooterKind = skSum then
|
||
begin
|
||
// (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;
|
||
//Õâ¸öÓëGroup RowÉϵĻã×ÜͬʱʹÓÃʱºÃÏóÖ»ÄÜÓÐÒ»¸öÓÐЧ
|
||
//´´½¨ÐзÖ×éÐÐÉϵĻã×ÜÏî
|
||
|
||
csgItem := csg.SummaryItems.Add;
|
||
csgItem.ItemLink := tv1.Columns[i]; //»ã×Ü×Ö¶Î1
|
||
csgItem.Position := spGroup;
|
||
csgItem.Kind := skSum;
|
||
csgItem.Format := trim(tv1.Columns[i].Caption) + 'С¼Æ=#,0.0';
|
||
|
||
tv1.Columns[i].Summary.GroupFooterKind := skSum;
|
||
tv1.Columns[i].Summary.GroupFooterFormat := '#,0.00';
|
||
|
||
end
|
||
else if tv1.Columns[i].Summary.FooterKind = skCount then
|
||
begin
|
||
// (tv1.DataController.DataSet.Fields[i] as TNumericField).DisplayFormat := '#,0.00;-#,0.00;#';
|
||
//tv1.Columns[i].Summary.FooterFormat:='0.0';
|
||
tv1.Columns[i].Summary.FooterKind := skCount;
|
||
|
||
tv1.Columns[i].Summary.GroupFooterKind := skCount;
|
||
|
||
//tv1.Columns[i].Summary.GroupFooterFormat := '#,0.00';
|
||
//Õâ¸öÓëGroup RowÉϵĻã×ÜͬʱʹÓÃʱºÃÏóÖ»ÄÜÓÐÒ»¸öÓÐЧ
|
||
//´´½¨ÐзÖ×éÐÐÉϵĻã×ÜÏî
|
||
csgItem := csg.SummaryItems.Add;
|
||
csgItem.ItemLink := tv1.Columns[i]; //»ã×Ü×Ö¶Î1
|
||
csgItem.Kind := skCount;
|
||
//csgItem.Format := 'С¼Æ=#,0.0';
|
||
|
||
end
|
||
else
|
||
begin
|
||
csglink := csg.Links.Add;
|
||
csglink.ItemLink := tv1.Columns[i]; //·ÖÀà×Ö¶Î
|
||
//ËùÓв»²ÎÓë»ã×ܵÄÁж¼ÓпÉÄÜÓÃÀ´·Ö×飬±ØÐ뽫ÕâЩÁмÓÈëµ½
|
||
//SummaryGroupItemLinkÖУ¬Ã»ÓмÓÈë¸ÃÁ¬½ÓµÄÁÐÓÃÀ´·Ö×éʱ
|
||
//»ã×ÜÖµ²»»áÏÔʾ
|
||
end;
|
||
|
||
end;
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure CreateBandedGroupSummarry(tv1: TcxGridDBBandedTableView);
|
||
var
|
||
csg: TcxDataSummaryGroup;
|
||
csglink: TcxDataSummaryGroupItemLink;
|
||
csgItem: TcxDataSummaryItem;
|
||
i: integer;
|
||
mFieldName: string;
|
||
begin
|
||
///´´½¨»ã×ÜÁÐ
|
||
with tv1.DataController.Summary do
|
||
begin
|
||
try
|
||
csg := DataController.Summary.SummaryGroups.Add; //´´½¨»ã×ÜÏî
|
||
|
||
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;
|
||
|
||
if tv1.Columns[i].Summary.FooterKind = skSum then
|
||
begin
|
||
// (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;
|
||
//Õâ¸öÓëGroup RowÉϵĻã×ÜͬʱʹÓÃʱºÃÏóÖ»ÄÜÓÐÒ»¸öÓÐЧ
|
||
//´´½¨ÐзÖ×éÐÐÉϵĻã×ÜÏî
|
||
|
||
csgItem := csg.SummaryItems.Add;
|
||
csgItem.ItemLink := tv1.Columns[i]; //»ã×Ü×Ö¶Î1
|
||
csgItem.Position := spGroup;
|
||
csgItem.Kind := skSum;
|
||
csgItem.Format := trim(tv1.Columns[i].Caption) + 'С¼Æ=#,0.0';
|
||
|
||
tv1.Columns[i].Summary.GroupFooterKind := skSum;
|
||
tv1.Columns[i].Summary.GroupFooterFormat := '#,0.00';
|
||
|
||
end
|
||
else if tv1.Columns[i].Summary.FooterKind = skCount then
|
||
begin
|
||
// (tv1.DataController.DataSet.Fields[i] as TNumericField).DisplayFormat := '#,0.00;-#,0.00;#';
|
||
//tv1.Columns[i].Summary.FooterFormat:='0.0';
|
||
tv1.Columns[i].Summary.FooterKind := skCount;
|
||
|
||
tv1.Columns[i].Summary.GroupFooterKind := skCount;
|
||
|
||
//tv1.Columns[i].Summary.GroupFooterFormat := '#,0.00';
|
||
//Õâ¸öÓëGroup RowÉϵĻã×ÜͬʱʹÓÃʱºÃÏóÖ»ÄÜÓÐÒ»¸öÓÐЧ
|
||
//´´½¨ÐзÖ×éÐÐÉϵĻã×ÜÏî
|
||
csgItem := csg.SummaryItems.Add;
|
||
csgItem.ItemLink := tv1.Columns[i]; //»ã×Ü×Ö¶Î1
|
||
csgItem.Kind := skCount;
|
||
//csgItem.Format := 'С¼Æ=#,0.0';
|
||
|
||
end
|
||
else
|
||
begin
|
||
csglink := csg.Links.Add;
|
||
csglink.ItemLink := tv1.Columns[i]; //·ÖÀà×Ö¶Î
|
||
//ËùÓв»²ÎÓë»ã×ܵÄÁж¼ÓпÉÄÜÓÃÀ´·Ö×飬±ØÐ뽫ÕâЩÁмÓÈëµ½
|
||
//SummaryGroupItemLinkÖУ¬Ã»ÓмÓÈë¸ÃÁ¬½ÓµÄÁÐÓÃÀ´·Ö×éʱ
|
||
//»ã×ÜÖµ²»»áÏÔʾ
|
||
end;
|
||
|
||
end;
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TcxGridToExcel(mfileName: string; gridName: TcxGrid);
|
||
var
|
||
saveDialog: TSaveDialog;
|
||
begin
|
||
try
|
||
saveDialog := TSaveDialog.Create(nil);
|
||
saveDialog.Filter := 'xls(*.xls)|*.xls|È«²¿(*.*)|*.*';
|
||
saveDialog.Options := [ofOverwritePrompt];
|
||
saveDialog.FileName := mfileName;
|
||
if saveDialog.Execute then
|
||
if Assigned(gridName) then
|
||
begin
|
||
try
|
||
|
||
ExportGridToExcel(saveDialog.FileName, gridName);
|
||
except
|
||
application.MessageBox('´´½¨Ê§°Ü,Ô´Îļþ¿ÉÄÜ´¦ÓÚ±à¼×´Ì¬!', 'ÌáʾÐÅÏ¢', 0);
|
||
exit;
|
||
end;
|
||
application.MessageBox('³É¹¦µ¼³ö!', 'ÌáʾÐÅÏ¢', 0);
|
||
end
|
||
else
|
||
application.MessageBox('µ¼³öʧ°Ü!', 'ÌáʾÐÅÏ¢', 0);
|
||
finally
|
||
saveDialog.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TcxGridToHTML(mfileName: string; gridName: TcxGrid);
|
||
var
|
||
saveDialog: TSaveDialog;
|
||
begin
|
||
try
|
||
saveDialog := TSaveDialog.Create(nil);
|
||
saveDialog.Filter := 'HTML(*.HTML)|*.HTML|È«²¿(*.*)|*.*';
|
||
saveDialog.Options := [ofOverwritePrompt];
|
||
saveDialog.FileName := mfileName;
|
||
if saveDialog.Execute then
|
||
if Assigned(gridName) then
|
||
begin
|
||
try
|
||
|
||
ExportGridToHTML(saveDialog.FileName, gridName);
|
||
except
|
||
application.MessageBox('´´½¨Ê§°Ü,Ô´Îļþ¿ÉÄÜ´¦ÓÚ±à¼×´Ì¬!', 'ÌáʾÐÅÏ¢', 0);
|
||
exit;
|
||
end;
|
||
application.MessageBox('³É¹¦µ¼³ö!', 'ÌáʾÐÅÏ¢', 0);
|
||
end
|
||
else
|
||
application.MessageBox('µ¼³öʧ°Ü!', 'ÌáʾÐÅÏ¢', 0);
|
||
finally
|
||
saveDialog.Free;
|
||
end;
|
||
end;
|
||
|
||
function ReadINIFileStr(ininame, TypeName: string; ValueName, ValueMR: string): string;
|
||
var
|
||
programIni: Tinifile; //ÅäÖÃÎļþÃû
|
||
FileName, ValueZS: string;
|
||
begin
|
||
FileName := ExtractFilePath(Paramstr(0)) + ininame;
|
||
programIni := Tinifile.create(FileName);
|
||
ValueZS := programIni.ReadString(TypeName, ValueName, ValueMR);
|
||
Result := ValueZS;
|
||
programIni.Free;
|
||
end;
|
||
|
||
procedure ColumnView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBTableView; MKName10: string);
|
||
begin
|
||
with AdoQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Table_Column where CxTabName=''' + Trim(MKName10) + ''' and Owner=''' + Trim(DCode) + '''');
|
||
sql.Add(' and TCNotVisble=1 ');
|
||
open;
|
||
end;
|
||
if AdoQueryTemp.IsEmpty = False then
|
||
begin
|
||
with AdoQueryTemp do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
|
||
Tv1.GetColumnByFieldName(AdoQueryTemp.fieldbyname('ColName').AsString).Visible := False;
|
||
Tv1.GetColumnByFieldName(AdoQueryTemp.fieldbyname('ColName').AsString).Hidden := True;
|
||
Next;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure ColumnBandView(AdoQueryTemp: TADOQuery; Tv1: TcxGridDBBandedTableView; MKName10: string);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
with AdoQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from Table_Column where CxTabName=''' + Trim(MKName10) + ''' and Owner=''' + Trim(DCode) + '''');
|
||
sql.Add(' and TCNotVisble=1 ');
|
||
open;
|
||
end;
|
||
if AdoQueryTemp.IsEmpty = False then
|
||
begin
|
||
with AdoQueryTemp do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
fsj := Trim(AdoQueryTemp.fieldbyname('ColName').AsString);
|
||
// Tv1.Controller.ge
|
||
Tv1.GetColumnByFieldName(fsj).Visible := False;
|
||
Tv1.GetColumnByFieldName(fsj).Hidden := True;
|
||
Next;
|
||
end;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure GetSWLDZ(IPStr: string);
|
||
var
|
||
myip: ulong;
|
||
mymac: array[0..5] of byte;
|
||
mymaclength: ulong;
|
||
r: integer;
|
||
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;
|
||
|
||
procedure SelOKNo(CDS_MainSel: TClientDataSet; FSel: Boolean);
|
||
begin
|
||
if CDS_MainSel.IsEmpty then
|
||
Exit;
|
||
CDS_MainSel.DisableControls;
|
||
with CDS_MainSel do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if FieldByName('SSel').AsBoolean = not FSel then
|
||
begin
|
||
Edit;
|
||
FieldByName('SSel').Value := FSel;
|
||
Post;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_MainSel.EnableControls;
|
||
end;
|
||
|
||
function num2ceng(strArabic: string): string;//²»´øÐ¡ÊýµãÊý×Öת»»Ó¢ÎÄ
|
||
const
|
||
sw: array[2..9] of string = ('twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');
|
||
gw: array[1..19] of string = ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen');
|
||
exp: array[1..4] of string = ('', 'thousand', 'million', 'billion');
|
||
var
|
||
t, j, glb, t1: integer;
|
||
ts: string;
|
||
|
||
function readu1000(ss: string): string;
|
||
var
|
||
t, code: integer;
|
||
begin
|
||
result := '';
|
||
while ss[1] = '0' do
|
||
begin
|
||
delete(ss, 1, 1);
|
||
if length(ss) = 0 then
|
||
exit; //¿ØÖÆÈ«ÊÇ0Çé¿ö
|
||
end;
|
||
if length(ss) = 3 then
|
||
begin
|
||
appendstr(result, gw[ord(ss[1]) - ord('0')]);
|
||
//appendstr(result,' hundred ');
|
||
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 //³¬¹ý°Ùλʱºò´¦Àí×îºó3λ
|
||
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]
|
||
else
|
||
//result := result+sw[trunc(t/10)]+'-'+gw[t mod 10];
|
||
result := result + sw[trunc(t / 10)] + ' ' + gw[t mod 10];
|
||
end;
|
||
end;
|
||
|
||
begin
|
||
result := '';
|
||
t := pos('.', strArabic);
|
||
if t = 0 then
|
||
t := length(strArabic) + 1;
|
||
while (t mod 3 <> 1) do
|
||
begin
|
||
t := t + 1;
|
||
strArabic := '0' + strArabic;
|
||
end;
|
||
t1 := (t - 1) div 3;
|
||
for glb := t1 downto 1 do
|
||
begin
|
||
ts := '';
|
||
for j := 1 to 3 do
|
||
begin
|
||
ts := ts + strArabic[1];
|
||
delete(strArabic, 1, 1);
|
||
end;
|
||
result := result + readu1000(ts);
|
||
if ts <> '000' then
|
||
result := result + ' ' + exp[glb] + ' ';
|
||
end;
|
||
if length(strArabic) <> 0 then
|
||
begin
|
||
delete(strArabic, 1, 1);
|
||
appendstr(result, 'and ');
|
||
result := result + readu1000(strArabic);
|
||
end;
|
||
end;
|
||
|
||
function num2cengnum(strArabic: string): string;
|
||
const
|
||
gw: array[1..10] of string = ('0', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
|
||
var
|
||
p, i, j, x: integer;
|
||
s: string;
|
||
begin
|
||
result := '';
|
||
s := strArabic;
|
||
p := pos('.', strArabic);
|
||
if p = 0 then
|
||
begin
|
||
result := num2ceng(strArabic) + 'Only';
|
||
exit;
|
||
end
|
||
else
|
||
begin
|
||
i := length(s) - p; //¼ÆËãСÊýµãºóÃæÓм¸Î»
|
||
delete(strArabic, p, i + 1); //ɾ³ýСÊýµãºóÃæÊý×Ö
|
||
result := num2ceng(strArabic) + 'Point';
|
||
end;
|
||
for x := 1 to i do //ת»»Ð¡ÊýµãºóÃæÊý×Ö
|
||
begin
|
||
j := strtoint(copy(s, p + x, 1));
|
||
case j of
|
||
0:
|
||
result := result + ' ' + gw[1];
|
||
1:
|
||
result := result + ' ' + gw[2];
|
||
2:
|
||
result := result + ' ' + gw[3];
|
||
3:
|
||
result := result + ' ' + gw[4];
|
||
4:
|
||
result := result + ' ' + gw[5];
|
||
5:
|
||
result := result + ' ' + gw[6];
|
||
6:
|
||
result := result + ' ' + gw[7];
|
||
7:
|
||
result := result + ' ' + gw[8];
|
||
8:
|
||
result := result + ' ' + gw[9];
|
||
9:
|
||
result := result + ' ' + gw[10];
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure DelCDS(ClientDataSet1: TClientDataSet; ADOCmd: TADOQuery; DelSql: string);
|
||
begin
|
||
if ClientDataSet1.IsEmpty then
|
||
Exit;
|
||
if Trim(ClientDataSet1.fieldbyname('ZSID').AsString) <> '' then
|
||
begin
|
||
if Application.MessageBox('È·¶¨ÒªÉ¾³ýÊý¾ÝÂð£¿', 'Ìáʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(DelSql);
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
ClientDataSet1.Delete;
|
||
end;
|
||
|
||
function FormatTitle(S: string): string;
|
||
|
||
{½«×Ö·û´®Öеİë½ÇÌæ»»³ÉÈ«½Ç×Ö·û}
|
||
|
||
var
|
||
OldStr, NewStr: AnsiString;
|
||
i: Integer;
|
||
const
|
||
SiStr = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=\~!#$%^&()_+|[]{};'':",./<>?';
|
||
DoStr = '£á£â£ã£ä£å£æ£ç£è£é£ê£ë£ì£í£î£ï£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú£à£±£²£³£´£µ£¶£·£¸£¹£°££½£Ü¡«£¡££¡ç£¥£Þ£¦£¨£©£ß£«£ü£Û£Ý£û£ý£»£§£º£¢£¬¡££¯£¼£¾£¿';
|
||
begin
|
||
|
||
for i := 1 to 95 do
|
||
|
||
begin
|
||
|
||
OldStr := copy(SiStr, i, 1);
|
||
|
||
NewStr := copy(DoStr, 2 * i - 1, 2);
|
||
|
||
S := StringReplace(S, OldStr, NewStr, [rfReplaceAll]);
|
||
|
||
end;
|
||
|
||
S := Trim(S);
|
||
|
||
result := S;
|
||
|
||
end;
|
||
|
||
end.
|
||
|