📄 ufunsys.pas
字号:
{$WARN SYMBOL_PLATFORM OFF}
{$WARN UNIT_PLATFORM OFF}
unit uFunSys;
{*********************************************************************
* 符林 2002-09-01
* 常用函数 MSFlexGrid ini文件 字符处理 SQL语句 ***
* 常用API函数 控件控制函数 填充树函数。。。。。。。 ***
*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
* 20030530 去掉 ADOdb ComObj ActiveX 符林
***********************************************************************}
interface
uses
//*自带*//
MSFlexGridLib_TLB,DBTables,Db,SysUtils,Graphics,IniFiles,Messages,Buttons,
StdCtrls,Controls,ComCtrls,Forms,Windows,Classes,FileCtrl,Dialogs,CheckLst,
Registry,ExtCtrls,ADOdb,Mask,ShellApI,ShlObj,ComObj,DBClient,{ActiveX,}
WinSock,Menus,DBCtrls,
dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid,
//*附加*//
uDataOA,uFunOASQL,uDMOA,uFrmInPutBox;
//<-------------------------------------------------------------------------->
//<..........................................................................>
//<-------------------------------------------------------------------------->
{***********************************************************************}
var
iReturn,iColx:integer; // 用于等待窗体的数据传递
iStateRow:integer; //用于记录上一次的当前列
iHideCol:array of integer; //用语传递网格不可见列
StrX:string; //用于传递字符;
sShiJianJianGe:String; //用于快捷键是否第二次执行
iKey:integer;
clrTree,clrBT,clrBTFont,clrBody,clrBKG:TColor; //用于颜色传递
sSYSDateYMD:String;
sSYSUser,sSYSUserName:String;
sSYSPassWord:String;
sSYSTempStr:String;
{***********************************************************************}
function FInitApp:Boolean;
Procedure PQuanXianChecK(FrmToCheck:TForm);
Procedure PDaoBanCheck();
{***********************************************************************}
{ =======MsFlexGrid=========== }
{***********************************************************************}
{ 填充第一行标题以及设置各列的对齐格式。}
procedure MyFillGridCaptionA(const MyCaptions:Array of string;
const MyAlignment:array of integer;
MsFlexGridName:TMsFlexGrid);
procedure MyFillGridCaptionB(const MyCaptions:Array of string;
MsFlexGridName:TMsFlexGrid);
procedure FillMsFlexGrid(Const MyFieldsList: Array of String;
MsFlexgridName:TMsFlexGrid;
QueryName:TDataSet);
procedure MyRowSelect(iRow:Integer;MsFlexGrid1:TMsFlexGrid);
procedure MySetGridColSize(const MySize:array of integer;
MsFlexGridName:TMsFlexGrid);
procedure MySetGridEditCol(const sCanEdit:Array of boolean;
const ConArray:Array of TWincontrol;
var ColConArray :Array of TGridColCon);
procedure FZSetGridEditCol(const sCanEdit: boolean;
const ConArray: TWincontrol;
var ColConArray : Array of TGridColCon;
const i:integer);
procedure InitGridA(GridName : TMsFlexGrid);
Procedure InitGridB(MsFlexGridName:TMsFlexGrid;iColor:Integer);
Procedure InitGridC(MsFlexGridName:TMsFlexGrid;iFixedRows:Integer;iColor:Integer);
Procedure PReDrawFxGrid(MsFlexGridName:TMsFlexGrid);
procedure MyGridScroll(var ColConArray : Array of TGridColCon;
var CurrGrid:TMsFlexGrid);
function MyGridClick(var ColConArray : Array of TGridColCon):boolean;
procedure MyGridEnterCell(var ColConArray : Array of TGridColCon;
CurrGrid:TMsFlexGrid);
procedure MyShowWinControl(MsFlexGridName:TMsFlexGrid;WinControlName:TWinControl);
procedure MyConEnter(var CurrCon:TEdit;var CurrGrid:TMsFlexGrid);overload;
procedure MyConEnter(var CurrCon:TComboBox;var CurrGrid:TMsFlexGrid);overload;
procedure MyConEnter(var CurrCon:TDateTimePicker;var CurrGrid:TMsFlexGrid);overload;
procedure MyConExit(var CurrCon:TEdit;var CurrGrid:TMsFlexGrid);overload;
procedure MyConExit(var CurrCon:TComboBox;var CurrGrid:TMsFlexGrid);overload;
procedure MyConExit(var CurrCon:TDateTimePicker;var CurrGrid:TMsFlexGrid);overload;
procedure FZReturnCol(var Key:Word;
wincontrol11:TObject;
bRowEnabled,bLetAddRow:boolean;
MsFlexGrid1:TMsFlexGrid;
Const EditColList:array of TGridColCon);
procedure GridHeJi(iCol:integer;grid1:TMsFlexGrid);
procedure MySumCount(WhyCol:integer;MsFlexGridName:TMsFlexGrid;sformat:string);
procedure MyRemoveEmpty(Var Grid1:TMsFlexGrid);
procedure MySelectGridRowA(var Grid1:TMsFlexGrid;iRow:integer;Shift: TShiftState);
procedure MySelectGridRowB(Grid1:TMsFlexGrid);
procedure MySelectAllRows(var Grid1:TMsFlexGrid);
function iSelectedRows(Const Grid1:TMsFlexGrid):integer;
procedure GetSelectedValues(var sValues :array of string;// 要返回的数组
Const Grid1:TMsFlexGrid;
iCol:integer); // 关键的列
procedure AddGridRow(sVlu:array of string;Grid1:TMsFlexGrid);
function iGridSameRowA(str:string;iCol:integer;Grid1:TMsFlexGrid):integer;
function iGridSameRowB(str:string;iCol:integer;Grid1:TMsFlexGrid):integer;
function FGetSameCol(iCol:Integer;fxGrid:TMsFlexGrid):integer;
function iGridRecords(iCol:integer;Grid1:TMsFlexGrid):integer;
function FGetGridNullRow(iCol:integer;fxGrid:TMsFlexGrid):integer;
procedure MoneyToGrid(Grid1:TMsFlexGrid);
procedure FMoneyToGridA(FxGrid:TMsFlexGrid;iCol:Integer);
function iGridGetBM(iCol:integer;Const iLength:integer;Grid1:TMsFlexGrid):string;
function sMaxGridColTXT(iCol:integer;Grid1:TMsFlexGrid):string;
procedure MyGridCutSameRow(iCol:integer;Grid1:TMsFlexGrid);
procedure ShowAllRows(Grid1:TMsFlexGrid);
procedure HideRows(iVlu:array of integer;Grid1:TMsFlexGrid);
Procedure PGridExChangeRows(FxGrid:TMsFlexGrid;iNo:array of integer);//iOrder数组 记录原序号与新序号
function FSetGridAndTreeColor(var clrTrv:Tcolor;FxGrid:TMsFlexGrid):Boolean;
{********************************** *.INI ************************************}
procedure SaveINIGrid(Const Grid1:TMSFlexGrid);
Function ReadINIGrid(Grid1:TMSFlexGrid):Boolean;
procedure SaveINIForm(Const Form1:TForm);
Function ReadINIForm(Form1:TForm):Boolean;
Procedure PSaveReadFormINI(FrmName:TForm;FxGrid:TMSFlexGrid;bRead:Boolean);
procedure FZGridSetA(Grid1:TMsFlexGrid;iCannotSetCol:array of integer);
procedure FZGridSetB(iFZCols:array of integer);
Procedure FZGrdiSetName(Grid1:TMsFlexGrid;sCaption:array of string);
function FZGetForm(sCtrlName:TControl):TForm;
Procedure PWriteINIStr(sFileName,sQuYu,sBiaoShi,sMainStr:String);
Procedure PWriteINIInt(sFileName,sQuYu,sBiaoShi:String;iMainInt:Integer);
function FReadINIStr(sFileName,sQuYu,sBiaoShi,sDefaultStr:String):String;
function FReadINIInt(sFileName,sQuYu,sBiaoShi:String;iDefaultInt:Integer):Integer;
{***********************************************************************
================字符串====================
***********************************************************************}
function MyEnterNumberA(var EditName: TEdit; Key: Char;Digits:Integer):Char;
function MyEnterNumberB(var Edit1:TEdit;Key:Char;iLength:Integer):Char;//FZ
function MyEnterNumberC(var EditName: TComboBox; Key: Char;Digits:Integer):Char;
function MyStrToFloat(stemp : String) : currency;
function L_RTrim(sStr:String):String;
function L_LTrim(sStr:String):String;
function L_RLTrim(sStr:String):String;
function MyReMoveChar(SubStr:Char;MainStr:String):string;
function MyCutString(bLeftStr:boolean;MainStr:string):string;
function MyReplaceStr(sMainStr,sBeingReplaceStr,sSubStr:String):String;
function MyReplaceStrA(sMainStr,sBeingReplaceStr,sSubStr:String):String;
function MyCopy(MainStr:string;iSta:integer;iLength:integer):string;
function MyCutOutStringA(Substr,Mainstr:string):string; //FZ
function MyCutOutStringB(Substr,Mainstr:string):string; //FZ
function MyChecKStr(iLength:integer;Str:string):string; //FZ
function MyAutoAdd(MainStr:string):string;
function MyTrim(Str:string):String; //FZ
function MoneyStr(StrtoMoney:string;bDouHao:boolean):String;//FZ
function bISNumber(str:string):boolean;
function FZGetOrderStr(sMainStr,sID:string;iNo:integer):string;
//---字符加密----//
function sJiaMi(Const sMainStr:string;Key:Word):String;
function sJieMi(Const sMainStr:string;Key:Word):String;
//--fzid--------//
function GetFZID10():String;
function FGetFZID15():String;
function GetFZID32():String;
Function FISChineseWord(sTxt:String):Boolean;
procedure PSetToolBarStyle(PnlTool:Tpanel;bFlag:Boolean);
{**********************-Time--***************************************}
function FZDateStr(DateTime1:TDateTime;bLongStr:boolean):string;//FZ;
function iBetweenDate(Date1, Date2: TDateTime): integer;
function sDateToMin(Date1:TDateTime):string;
function sDateToMax(Date1:TDateTime):string;
function sLongDate(dDate:TDateTime):string;
function dMonthFirst:TDateTime;
function FMonthLast(dDateX:TDate):TDate;
function FMonthFirst(dDateX:TDate):TDate;
function FZStrToFloat(MainStr:string):Currency;
function FISExistInArray(saMain:array of String;SubStr:String):Boolean;
Procedure PHanHuaDxDBGridGroupPanel(dxDBGridX:TdxDBGrid);
{******************************************************************************
* 有关数据库的 ADD EDIT DELETE
* 要能兼容SQLServer 与 Oracle
*******************************************************************************}
function FCarryOutSQL(DataSetX:TADOQuery;{****线程执行SQL*****}
const sSQL:String;
bResulted:Boolean):Boolean;
function FCreateInSertOneSQL(arrFields:array of String;
arrValues:array of String;
arrNo:array of Integer;
sTableName:String):String;
function FCreateInSertOneSQLHN(DBDataSet:TDataSet;sTableName:String):String;
function FCreateInSertManySQLHN(DBDataSet:TDataSet;sTableName:String):String;
Procedure PGiveFieldTxt(DBDataSet:TDataSet;sField,SVlu:String);
function FUpdateOneSQL(arrFieldAndValue:array of String;
arrFields:array of String;
arrValues:array of String;
arrNo:array of Integer;
sTableName:String):String;
procedure PGetFZIDToGrid(iCol:Integer;FxGrid:TMsFlexGrid);
Procedure PSetStrToOneCol(iCol:Integer;sTxT:String;FxGrid:TMsFlexGrid);
function GetGridDelSQL(Const Grid1:TMsFlexGrid;iCol:integer;sBiao:String):String;
function GetGridInsertSQL(saFields:array of string;iaCol:array of Integer;
iaNotStrFields:array of Integer;sBiao:String;
fxGrid:TMsFlexGrid):String;
function GetGridInsertSQLA(saFieldValuesFJ:array of string;
saFields:array of string;iaCol:array of Integer;
iaNotStrFields:array of Integer;sBiao:String;
fxGrid:TMsFlexGrid):String;
function FFromOneFieldGetAnotherVlu(DBDataSet:TDataSet;
sFiedlNme,sFieldValue,sFieldX:String):String;
function FFromOneFieldGetAnotherVluA(DBDataSet:TDataSet;
sFieldNameAndVlu:array of String;sFieldX:String):String;
Procedure PDataChartCountFromDataSet(sTitleA,sTitleB:String;DataSetX:TDataSet;
sFieldBarY:String;sFiedBarX:String);
{******************************************************************************
* =======树====其它控件=======
*******************************************************************************}
Procedure PTreeToListView(Trv:TTreeView;Lsv:TListView);
Procedure PListViewToTree(Trv:TTreeView;Lsv:TListView);
function FGetNewAddNode(Trv:TTreeView):Integer;
function FGetNodeIDByNode(Trv:TTreeView;SubNode:TTreeNode):Integer;
function FGetNodeIDByFZID(Trv:TTreeView;sFZID:String):Integer;
function FIsChildNode(MainNode,SubNode:TTreeNode):Boolean;
procedure PCuiFengFillTreeB(TrvName:TTreeView;
DBTable:TDataSet;
sFieldNameA,sFieldNameB,sFieldLevel:String);
procedure PCuiFengFillTreeC(TrvName:TTreeView;
DBTable:TDataSet;
sFieldName:String);
procedure PCuiFengFillTreeD(TrvName:TTreeView;
DBTable:TDataSet;
sFieldNameA,sFieldNameB:String);
procedure PFillComBoBoxA(CmBox:TComboBox;
sFieldName:string;
DBQry:TDataSet);
procedure PFillComBoBoxB(CmBox:TComboBox;
sFieldNameA,sFieldNameB:string;
DBQry:TDataSet);
procedure MySetComBoBoxTXT(ComBoBox1:TComboBox;sTXT:string);
Procedure PSetDBEditV(DBCtrl:TDBEdit;sTxt:String);
function FGetSaveTreeSQL(Trv:TTreeView;sBiaoShi:String):String;
Procedure PSetOrderPnlBtn(PnlTool:Tpanel);
Procedure PClearGrpBoxText(GBoxName:TGroupBox);//青空文本的属性
{******************************************************************************
=============焦点切换======================
******************************************************************************}
Procedure PBeginProgress;
Procedure PEndProgress(bSuccessed:Boolean);
Procedure PPrintFxGrid(sBiaoTi:string; //大标题
sSmallTile: array of string; //打印标题
Grid1: TMSFlexGrid; //网格
iPageRows: integer; //每页打印的行数
iFangXian:integer; //打印方向 1--45,0--25
bPrintNow:boolean);
Procedure PBandingSpbtnToEdit(EdtMain:TEdit;SPpbtnSub:TSpeedButton);
Procedure PAutoFocusChange(Key:Word;FrmName:TForm);
function FISSecondSend(Key:Word):Boolean;
function FChangeCursor:Thandle;
Procedure PTreeChangeToFxGrid(TrvName:TTreeView;fxGrid:TMsFlexGrid;sTrvTxt:String;iCol:Integer);
function FGetSQLRecordCount(sSQL:String):Integer;
FUnction FGetPYSP(sHZMain:String):String;
function Fget_hz_pywb(hzstr: string; pytype: integer): string;
function FGetHzPy(const AHzStr: string): string;
function FGetServerDateYMDHS():String;
{******************************************************************************
==============网络测试======================
******************************************************************************}
function MyGetComputerName:String;
function FindComputer(const winhandle : THANDLE; const title : string) : string;
function sGetPath:string;
function GetIPAddress: string;
{******************************************************************************
================Windows 技巧=================
******************************************************************************}
procedure DeadKeyBord;
procedure FreeKeyBord;
procedure HideTaskBar;
procedure ShowTaskBar;
procedure HideDesktop;
procedure ShowDesktop;
procedure LimitMouseMove(Form:TForm);
procedure FreeMouseMove;
procedure RestartComPuter;
procedure CloseComputer;
procedure CloseComputer1;
procedure GetJiSuQi;
{*******************************************************************************
=========常用提示信息框==============
********************************************************************************}
function DlgYesNo(Const sHint:string):boolean;
procedure DlgWarningA(Const sHint:string);
procedure DlgWarningB(Const sHint:string);
procedure DlgWarningX(Const sHint:string);
function DlgInPutBox(sCaption,Str:String):String;
//〈〈〈------------------------------------------------------------------------
//〈〈〈------------------------------------------------------------------------
//〈〈〈------------------------------------------------------------------------
const
iCenter :Integer=flexAlignCenterCenter;
iRight :Integer=flexAlignRightCenter;
iLeft :Integer=flexAlignLeftCenter;
clSelect :TColor=$00DEDEBC;
YCL_DATA_THREE:string ='1' ;
sconPriceFmt : String = '####0.00##'; //单价的显示格式
sconzk= '####0.00'; //折扣1
sconzk1= '####0.000'; //折扣2
sconTaxFmt : String = '####0.00##'; //税率的显示格式
sconMoneyFmt : String = '#,##0.00##'; //金额的显示格式
sconCountFmt : String = '####0.####'; //数量的显示格式
implementation
//〈〈〈------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -