⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globalunit.pas

📁 实达企业在线EOL源码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
unit GlobalUnit;

 {**********************************************************************
 ******************Date:2000/01/25~2000/01/26***************************
 ******************by: MSJ, HGR, WXM, JHH     ***************************
 ******************Form: Nil                 ***************************
 ******************Design: 定义系统中的各个通用过程和全局变常量*********
 ******************History record:
 ******************Other:
 ***********************************************************************}

interface
 uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, ExtCtrls,registry, StdCtrls, DBCtrls, Mask, dbtables,Db,ADOdb,dbclient,
  provider, comobj,
 {$IFDEF WIN32}
     BDE,
  {$ELSE}
  {$ENDIF}

  ShellApi;



const
    DosDelimSet : set of Char = ['\', ':', #0];
    cbMaxFileNameLen = 64;
    cbFileExtLen = cbMaxFileNameLen;
    HEXdigits : array[0..$F] of Char = '0123456789ABCDEF';
    NullString  : string[1] = '';
    cSpaceStr   = ' ';
    cPointStr   = '.';
    DoubleQuote = '"';
    cbFileNameLen    = cbMaxFileNameLen;

    cKeyCode1=1234;  //密钥1
    cKeyCode2=2345;  //密钥2
    cKeyCode3=9999;  //密钥3

Type
   //================================================================
   //处理数据库类的通用过程;
   TSortType = (stNone, stASC, stDESC);
   TAccessDB=Class
     private


{Change by Masj 2000.05.25 begin}
        ISRunTime:Boolean;
        ErrorCode:integer;
        ErrorMessage:string;
{Change by Masj 2000.05.25 end}


//change by Masj 2000.05.25
        procedure ProcessError(E:Exception);
        procedure ClearError;


     public
       Constructor  Create;
       destructor  Destroy;Override;
//Add by Masj 2000.05.25
        procedure DBSetRunState(mIsRunTime:Boolean=True);
        function  DBGetRunState:boolean;
        function  DBIsError(var mErrorCode:Word;var mErrorMessage:string):boolean;
       //创建MSSQL类型别名
       function CreateMSSQLAlias(AliasName,ServerName,DataBaseName,UserName:string):boolean;

       //创建 PARADOX类型别名
       function CreatePARADOXAlias(AliasName,Path:string):boolean;

       //创建ACCESS类型别名
       function CreateACCESSAlias(AliasName,Path:string):boolean;

       //创建书签
       function SetToBookmark(ADataSet: TDataSet; ABookmark: TBookmark): Boolean;

   end;

   //================================================================
   //处理系统类的通用过程;

   TAccessSystem=Class
     private
     public
        Constructor  Create;
        destructor  Destroy;Override;

        //口令加密。
        function Encrypt(const S:ShortString):ShortString;

        //口令解密。
        function Decrypt(const S:ShortString):ShortString;

        //重新启动Windows操作系统。if Result=True then execute success,else falied.
        function RestartWindows:Integer;

        //获得本机名称
        function ComputerName : String;

        // 获得系统的临时目录
        function GetTempDirectory: String;

        //获得SQLServer服务器名称
        function GetServerName(AliasName:string):string;

        //打开链接
        procedure Link(Url:string);

        //返回Windows系统路径,引用了b_string的slash函数
        function GetWinSysDir:string;

        //返回Windows路径,引用了b_string的slash函数
        function GetWinDir:string;

        //返回正在使用的EXE文件安装路径
        function GetInstallDir:string;

        //读取一个注册值
        function GetRegValue(Root:integer;Key,Value:string):string;

        //返回一个激活的数据集Dataset(TTabel 或 TQuery)的数据库别名对应的DOS路径
        function GetAliasPath(DBSet:TDataset):string;

        //返回一个文件的日期(使用日期格式TDataTime)
        function GetFileDate(filename:string):Tdatetime;

   end;

   //================================================================
   //处理字符串类 的通用过程;
   TChrSet = set of char;

   TLong =record
          LowWord,
          HighWord : Word;
   end;

   TAccessString=Class
     private
     public
        Constructor  Create;
        destructor  Destroy;Override;

        //判断指定串是否是数字串
        function IsInt(AString: String): Boolean;

        //返回字符在指定字符串中出现第n次的位置
        function Pos2(SubStr,AStr:string;Inx:Integer):Integer;

        //返回指定字符的重复串
        function Str(Astr:string;Num:integer):string;

        //返回字符串中指定字符左边的部分
        function StrLeft(SubStr,AStr:string):string;

        //返回字符串中指定字符右边的部分
        function StrRight(SubStr,AStr:string):string;

        //确保字符串最后一个字符中有'\'(例如目录字符串)
        function Slash(Value:string):string;

        //单词的第一个字符大写,其它小写
        function CapFirst(Value:string):string;

        //去掉HTML标识符
        function StripTags(Value:string):string;

        //截取从s字符串中第一个以c字符开始的l个字符
        function CopyFromChar(s:string;c:char;l:integer):string;

         function DigiLeftPadCh( D: longint; Ch : Char; Len : Byte) : string;

        //以下为转换byte,word,longint,pointer,为一个十六进制的字符串
      function HexB(B : Byte) : string;
      function HexW(W : Word) : string;
      function HexL(L : LongInt) : string;
      function HexPtr(P : Pointer) : string;

      //以下为转换byte,word,longint,为一个二进制的字符串
      function BinaryB(B : Byte) : string;
      function BinaryW(W : Word) : string;
      function BinaryL(L : LongInt) : string;

      //以下为转换byte,word,longint,为一个八进制的字符串
      function OctalB(B : Byte) : string;
      function OctalW(W : Word) : string;
      function OctalL(L : LongInt) : string;

      //以下为转换string to integer
      function Str2Int(const S : string; var I : Integer) : Boolean;

      //以下为转换string to word
      function Str2Word(const S : string; var I : Word) : Boolean;

      //以下为转换string to Longint
      function Str2Long(const S : string; var I : LongInt) : Boolean;

      //以下为转换string to Double
      function Str2Real(const S : string; var R : Double) : Boolean;

      //以下为转换long/word/integer/byte/shortint to a string
      function Long2Str(L : LongInt) : string;

      //返回一个用某一字符添满的string
      function CharStr(Ch : Char; Len : Byte) : string;

      //返回一个字符,其右边用长度为Len的Ch字符填充
      function PadCh(const S : string; Ch : Char; Len : Byte) : string;

      //返回一个字符,其右边用长度为Len的空格字符填充
      function Pad(const S : string; Len : Byte) : string;

      //返回一个字符,其左边用长度为Len的Ch字符填充
      function LeftPadCh(const S : string; Ch : Char; Len : Byte) : string;

      //返回一个字符,其左边用长度为Len的空格字符填充
      function LeftPad(const S : string; Len : Byte) : string;

      //返回一个字符,取掉左边的空格和控制字符
      function TrimLead(const S : string) : string;

      //返回一个字符,取掉右边的空格和控制字符
      function TrimTrail(const S : string) : string;

      //计算一个String中的单词(word)数,单词的分隔符号由WordDelims指定
      function WordCount(const S : string; WordDelims : TChrSet) : longint;

      //计算一个String中的第N个单词,单词的分隔符号由WordDelims指定
      function ExtractWord(N : longint; const S : string; WordDelims : TChrSet) : string;

      //清除一个字符串中指定的某一字符,'abc','b'--->'ac'
      function RemoveCharacter( const S: string; C: char ): string;

      //清除一个字符串中多个空格,只流一个空格,'abc    d' ->'abc d'
      function CompactSpaces( S : string ):string;

      //清除一个字符串中所有的空格
      function RemoveSpaces( S : string ): string;

      function DigiPadCh( D: longint; Ch : Char; Len : Byte) : string;      {*}

      //把一个数字转换为右边用空格填充为Len长字符串:123,3-->'123'
      function DigiPad( D: longint; Len : Byte) : string;

      //把一个数字转换为左边用空格填充为Len长字符串:123,,3-->'   123'
      function DigiLeftPad( D: longint; Len : Byte) : string;

      //返回一个pathname中的盘符
      function JustDriveName( FName : string ):char;

      //返回一个pathname中的文件名除取扩展名部分
      function JustMainFileName( FName : string ):string;

      //清除一个pathname中的'\'
      function RemoveBackSlash( P : string ): string;

      //返回String中左边Len长度的字符串
      function TruncLine( S : string; Len : byte ): string;

      //返回String中右边Len长度的字符串
      function TruncLineRt( S : string; Len : byte ): string;

      //比较两个String是否相等,大小写敏感
      function StringsIsEqual( S1, S2 : string ): boolean;

      //使一个String的第一个字符变成大写
      function FormAsName(S:string): string;

      //使一个String的每一个单词的第一个字符变成大写
      function FormAmericanString(S:string) : string;

      //转换一个String to 数字
      function  nxStrToInt(const S: string): longint;

      //判断一个String是否为NULL
      function  StrIsNull(const S: string): boolean;

      //统计一个String中某一字符的个数
      function  CharCount(C: char; const S: string): integer;

      //取一个字符串中双引号中间的字符串
      //如果没有双引号,则取全集
      //如果有一个双引号,则取双引号右边的字符串
      function  GetQuotedString(const S: string): string;

      //用一个字符替换String中另一字符
      procedure ReplaceChar(SrcChar, DstChar: char; var S: string);

      //转换十六进制的字符串为一个数字
      function  HexToInt(const H: string; Digits: integer; var I: longint): boolean;

      //转换integer to String
      function IntToNStr(int:integer;n:integer;ch:string):string;

      // 比较两个 StringLists 的内容是否一样
      function ListIdentical(l1,l2:TStringList):Boolean;

   end;

   //================================================================
   //处理数字类的通用过程;

   TAccessNum=Class
     private
     public
        Constructor  Create;
        destructor  Destroy;Override;

        {转换字符串s为数字。如果不能转换,则返回预定义的def值。}
        function StrToFloatDef(const s:string;def:Extended):Extended;

        {返回数组中最小值}
        function MinExt(const A:array of Extended):Extended;

        {返回数组中最大值}
        function MaxExt(const A:array of Extended):Extended;

   end;

   //================================================================
   //处理财务类数据库类的通用过程;
   TAccessFinance=Class
     private
     public
        Constructor  Create;
        destructor  Destroy;Override;

         {涨价后的实价(销售价)}
         {例:SellingPrice(199.50,22.5) = 244.3875}
         function SellingPrice(net:double;markup:single):double;

         {返回含税价}
         {例:NetPrice(199.99,17.5) = 170.204255319149}
         function NetPrice(gross:double;taxrate:single):double;

   end;

   //================================================================
   //处理日期时间类的通用过程;
   TAccessDateTime=Class
     private
     public
        Constructor  Create;
        destructor  Destroy;Override;

       //设置系统时间日期格式
       procedure  SetDatetimeFormat;

       //返回汉字月份名
       function CMonth(y:Integer):string;

       // 返回当月的天数
       function  DaysOfCurrntMonth:Integer;

       // 返回指定日期增加(减少)指定天数的日期
       function   IncDay(const Date: TDateTime;NumberofDays:Integer):TdateTime;

       // 返回指定年月的天数
       function  DaysOfMonth(const Year:word;Month:integer):Integer;

   end;

   //================================================================
   //处理对话窗类的通用过程;
   TAccessDialog=Class
     private
     public
        Constructor  Create;
        destructor  Destroy;Override;

       //显示确认对话窗
       function ShowYesNo(Msg:string;Title:string):boolean;

       //显示确认对话窗
       function  ShowYesNoCancel(Msg:string;Title:string):integer;

       //显示指定类型的对话窗
       function ShowMsg(Msg:string;aType:TMsgDlgType): integer;

       //警告对话窗
       function  ShowWarning(Msg:string): integer;

       //错误对话窗
       function ShowError(Msg:string): integer;

       //信息对话窗
       function ShowInformation(Msg:string): integer;
       //询问对话窗
       function ShowQuestion(MSG:string): integer;
   end;

   //================================================================
   //处理窗体类的通用过程;
   TAccessForm=Class
     private
     public
        Constructor  Create; 
        destructor  Destroy;Override; 

        //判断MDI子窗体是否存在
        function IsExistForm(MDIForm:TForm;MDIChildFormName:string):boolean;

        //在指定的MDI父窗体打开MDI子窗体
        procedure OpenMDIChildForm(MDIForm:TForm;MDIChildFormName: string);

        //在指定的MDI父窗体上关闭所有MDI子窗体
        procedure  CloseAllMDIChildForm(MDIForm:TForm;NeedFree:Boolean);

   end;

   //================================================================
   //处理文件名类的通用过程;
   TAccessFile=Class
     private
     public
        Constructor  Create; 
        destructor  Destroy;Override; 

        //判断一个PathName中是否有扩展名                                *
          function HasExtension(const Name : string; var DotPos : integer) : Boolean;

        //返回一个带扩展名的PathName,有Ext指定                         *
          function DefaultExtension(const Name, Ext : string) : string;

        //强制返回一个带扩展名的PathName,有Ext指定                         *
          function ForceExtension(const Name, Ext : string) : string;

        //只返回一个PathName的扩展名
          function JustExtension(const Name : string) : string;

        //返回一个PathName中的文件名,不带路径
          function JustFilename(const PathName : string) : string;

        //返回一个PathName的路径部分:'c:\'、'c:\dos'                                  *
          function JustPathname(const PathName : string) : string;

        //给一个PathName,在末尾增加一个'\'                             *
          function AddBackSlash(const DirName : string) : string;

   end;

   //================================================================
   //处理其它类的通用过程;
   TAccessOthers=Class
     private
     public
        Constructor  Create; 
        destructor  Destroy;Override; 

        //大小写金额转换
        function SmallToBig(small:real):string;

        //格式化整数
        function GetString(AInt:integer;Len:integer):string;

   end;

   //================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -