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

📄 unit_public.pas

📁 delphi开发的中国移动大客户管理系统,后台数据库为oracle
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        title:=Atitle;
        DataSource:=Atable;
        XLabelsSource:=x;
        YValues.ValueSource:=y;
        CheckDatasource;
      end;
    end;
    1:
    begin
      with Tbarseries.Create(Aparent) do  //直方图
      begin
        ParentChart:=Achart;
        name:='series'+inttostr(aflag)+inttostr(Aname);
        title:=Atitle;
        DataSource:=Atable;
        XLabelsSource:=x;
        YValues.ValueSource:=y;
        CheckDatasource;
        Marks.Style:=smsValue;
      end;
    end;
    2:
    begin
      with Tpieseries.Create(Aparent) do  //圆饼图
      begin
        ParentChart:=Achart;
        name:='series'+inttostr(aflag)+inttostr(Aname);
        title:=Atitle;
        DataSource:=Atable;
        XLabelsSource:=x;
        YValues.ValueSource:=y;
        CheckDatasource;
        Marks.Style:=smsLabelValue;
      end;
    end;
  end;
end;

procedure GP_FreeSeries(Achart:TcustomAxisPanel;Aflag:integer=0);
//释放所有的TCustomSeries对象
var
  i,j:integer;
begin
  j:=0;
  for i:= 0 to Achart.SeriesCount -1 do
  begin
    case Aflag of
      0:
      begin
        if Achart.Series[j] is TlineSeries then
          Achart.series[j].free
        else
          j:=j+1;
      end;
      1:
      begin
        if Achart.Series[j] is TbarSeries then
          Achart.series[j].free
        else
          j:=j+1;
      end;
      2:
      begin
        if Achart.Series[j] is TpieSeries then
          Achart.series[j].free
        else
          j:=j+1;
      end;
    end;
  end;
end;

function PingByName(ComputerName : String) : String;
var
  Const_Version_Major : Integer;
  Const_Version_Minor : Integer;
  Data : WSADATA;
  HostEntry : PHostEnt;
//  Address : DWORD ;
//  IPaddress : LPSTR;
  HostNameChar : array[0..63] of Char;
begin
  Const_Version_Major:=1;
  Const_Version_Minor:=1;
  if WSAStartup(MakeWord(Const_Version_Major,Const_Version_Minor),Data)<>0
   then Result:='对不起,你的winsock1.1没有安装';
  StrPCopy(HostNameChar,ComputerName);
  HostEntry := GetHostByName(HostNameChar);
  if HostEntry<>nil then
//    IPaddress:=Pchar(AnsiString(HostEntry^.h_addr^))
//  else
    Exit;
//  Address := inet_addr(IPaddress);
  WSACleanup;
  Result := '';
end;

Function Get_IP : String ;
var
   I,J : Integer ;
   S : String ;
   F : Tregistry;
begin
   //by zengzc
   Result := '' ;
   I := 0 ;
   F := TRegIstry.create ;
   F.RootKey := HKEY_LOCAL_MACHINE ;
   F.OpenKey('SYSTEM',false);
   F.OpenKey('CurrentControlSet',false);
   F.OpenKey('Services',false);
   F.OpenKey('Class',false);
   F.OpenKey('NetTrans',false);
   //打开注册表:HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Class/NetTrans
   S := IntToStr(I) ;
   for J :=1 to 4-length(S) do  S := S+'0' ;  //S='0000'

   while  ((F.OpenKey(S,false)) or (I<100))  do  //SET TO THE MAX NIC ADOPTER
     begin
       if (F.ReadString('IPAddress') <> '')  and (F.ReadString('IPAddress') <> '0.0.0.0')  then
       begin
          Result := F.ReadString('IPAddress') ;
          F.CloseKey ;
          F.Free ;
          Exit ;
       end;
       F.CloseKey ;
       F.OpenKey('SYSTEM',false);
       F.OpenKey('CurrentControlSet',false);
       F.OpenKey('Services',false);
       F.OpenKey('Class',false);
       F.OpenKey('NetTrans',false);
       I := I+1 ;
       S := IntToStr(I) ;
       for J :=1 to 4-length(S) do
            S := '0'+S ;
    end ;
   F.Free ;
end;

function GetPYIndexChar( hzchar:string):char;
// 获取指定汉字的拼音索引字母,如:“曾”的索引字母是“Z”
begin
  case WORD(hzchar[1]) shl 8 + WORD(hzchar[2]) of
    $B0A1..$B0C4 : result := 'A';
    $B0C5..$B2C0 : result := 'B';
    $B2C1..$B4ED : result := 'C';
    $B4EE..$B6E9 : result := 'D';
    $B6EA..$B7A1 : result := 'E';
    $B7A2..$B8C0 : result := 'F';
    $B8C1..$B9FD : result := 'G';
    $B9FE..$BBF6 : result := 'H';
    $BBF7..$BFA5 : result := 'J';
    $BFA6..$C0AB : result := 'K';
    $C0AC..$C2E7 : result := 'L';
    $C2E8..$C4C2 : result := 'M';
    $C4C3..$C5B5 : result := 'N';
    $C5B6..$C5BD : result := 'O';
    $C5BE..$C6D9 : result := 'P';
    $C6DA..$C8BA : result := 'Q';
    $C8BB..$C8F5 : result := 'R';
    $C8F6..$CBF9 : result := 'S';
    $CBFA..$CDD9 : result := 'T';
    $CDDA..$CEF3 : result := 'W';
    $CEF4..$D188 : result := 'X';
    $D1B9..$D4D0 : result := 'Y';
    $D4D1..$D7F9 : result := 'Z';
  else
    result := char(0);
  end;
end;

// 在指定的字符串列表SourceStrs中检索符合拼音索引字符串PYIndexStr的所有字符串,并返回。
function SearchByPYIndexStr(SourceStrs:TStrings;PYIndexStr:string):string;
label NotFound;
var
  i,j    :integer;
  hzchar :string;
begin
  for i:=0 to SourceStrs.Count-1 do
    begin
      for j:=1 to Length(PYIndexStr) do
        begin
          hzchar:=SourceStrs[i][2*j-1]+ SourceStrs[i][2*j];  //一个汉字两个字节, by zengzc 
          if (PYIndexStr[j]<>'?') and (UpperCase(PYIndexStr[j])<>GetPYIndexChar(hzchar))
           then goto NotFound;
        end;
      if result=''
      then result := SourceStrs[i]
      else result := result + Char(13) + SourceStrs[i];
      exit;
  NotFound: result:='';
    end;
end;

function GetNextSeq(FilePath : String ; Section : String ; KeyWord : String ; Step : integer ) : String;
  {输入:   FilePath : Sequence所在的路径和文件名  Section : 指定的区域 KeyWord : 指定的关键字
           Step : 步长
   结果:指定的序列号的内容.初始默认值为:1  }
var
  MyIniFile :  TIniFile;
  NextVal  : string;
begin
  {具体的例子如下:
   有一个文件(序列号),其名称:c:\program files\Sequences_Vip.ini
   其中详细的内容如下:
      [test_seq]

      kkk=1

   此时:  FilePath = c:\program files\Sequences_Vip.ini
          Section  = test_seq
          KeyWord  = kkk
          Step     = 需要增加的步长

    }

  MyIniFile:=TIniFile.Create(FilePath);
  GetNextSeq:=IntToStr(StrToInt(MyIniFile.ReadString(Section,KeyWord,'1'))+Step);
  NextVal:=IntToStr(StrToInt(MyIniFile.ReadString(Section,KeyWord,'1'))+Step);
  MyIniFile.WriteString(Section,KeyWord,NextVal);
  MyIniFile.Free;

end;

function GetNormal_Month( Current_Date : TDateTime):String;
//  输入  日期型数据,
//  输出  ’YYYYMM '  ,该数据为正常出帐的年月
//  错误  返回'190001'
Var
  Current_Year , Current_Month , Current_Day  : String;
begin
  //获取正常的出帐月
 Try
  Current_Year := Copy(DateTimeToStr(Current_Date),1,4);
  Current_Month := Copy(DateTimeToStr(Current_Date),6,2);
  Current_Day := Copy(DateTimeToStr(Current_Date),9,2);

  if (StrToInt(Current_Day)<=20) and (Current_Month='01') then
    //该月份为正常出帐月的12月
      Result:=IntToStr(StrToInt(Current_Year)-1)+'12'  //去年的12月
  else
  begin
    if ((StrToInt(Current_Day)>20) and (Current_Month='11')) or (Current_Month='12') then
       Result:=Current_Year+'11'  //正常的11月份
    else
      begin
        if StrToInt(Current_Month)=11 then  //正常的10月份,日期为两个位数
           Result:=Current_Year+'10'
        else
          begin
            if StrToInt(Current_Day)>20 then
               Result:=Current_Year+Current_Month
            else
               Result:=Current_Year+'0'+IntToStr(StrToInt(Current_Month)-1);
          end
      end;
  end;
 except
   Result := '190001';
 end;
end;

function GetCurrentMax_Month(  Current_Date_YYYYMMDD : String):String;
//输入:年月 ’ YYYYMMDD '  (年月日为当前年月日)
//输出:正常出帐月的最大的出帐日期
//错误的时候输出:111111
var
  Current_Year , Current_Month , Current_Day : String;
begin
 //获取指定月份的最大出帐年月日
 try
  Current_Year := Copy ( Current_Date_YYYYMMDD , 1 , 4 ) ;
  Current_Month := Copy ( Current_Date_YYYYMMDD ,  5 , 2 );
  Current_Day := Copy ( Current_Date_YYYYMMDD ,  7 , 2 );
  if (Current_Month='12') or ((Current_Month='11') and (StrToInt(Current_Day)>20)) then
    //正常出帐月为11月,其最大的出帐日期为:1120
    Result := Current_Year+'1120'
  else
  begin
    if (StrToInt(Current_Day)<=20) and (Current_Month='01') then
      //正常出帐月为12月,其最大的出帐日期为:去年的1231
      Result := IntToStr(StrToInt(Current_Year)-1) + '1231'
    else
      if  (StrToInt(Current_Month)>10) then
        Result:=Current_Year+IntToStr(StrToInt(Current_Month)-1)+'20'
      else
      begin
        if (StrToInt(Current_Day)>20) then  //正常的10月份,日期为两个位数
          Result:=Current_Year+Current_Month+'20'
        else
          Result:=Current_Year+'0'+IntToStr(StrToInt(Current_Month)-1)+'20';
      end;
  end;
 except
   Result := '111111';
 end;
end;

function GetCurrentMin_Month( Current_Date_YYYYMMDD : String):String;
//输入:年月 ’ YYYYMMDD '  (年月日为当前年月日)
//输出:正常出帐月的最小的出帐日期
//错误的时候输出:111111
var
  Current_Year , Current_Month , Current_Day : String;
begin
   //获取指定月份的最小出帐年月日
 try
  Current_Year := Copy ( Current_Date_YYYYMMDD , 1 , 4 ) ;
  Current_Month := Copy ( Current_Date_YYYYMMDD ,  5 , 2 );
  Current_Day := Copy ( Current_Date_YYYYMMDD ,  7 , 2 );
  if (Current_Month='12') or ((Current_Month='11') and (StrToInt(Current_Day)>20)) then
    //正常出帐月为11月,其最大的出帐日期为:1120
    Result := Current_Year+'1021'
  else
  begin
    if (StrToInt(Current_Day)<=20) and (Current_Month='01') then
      //正常出帐月为12月,其最大的出帐日期为:去年的1231
      Result := IntToStr(StrToInt(Current_Year)-1) + '1121'
    else
    begin
      if ((Current_Month='01') and (StrToInt(Current_Day)>20)) or ((Current_Month='01') and (StrToInt(Current_Day)>20)) then
          Result:=Current_Year+'0101'
      else
        if  (StrToInt(Current_Month)>11) then

⌨️ 快捷键说明

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