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

📄 share_date.pas

📁 DELPHI 编写个人工作计划事务管理软件
💻 PAS
字号:
unit Share_Date;

interface

uses Classes, SysUtils, Controls, Dialogs;

const SHAREINIFILE = 'AllPlan.ini';
      //CONNSTRING = 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=%s;Initial Catalog=%s;Data Source=%s;Auto Translate=False';
  TEMP_CONN1 = 'Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DBQ=%sJihuaDb.mdb;DefaultDir=%s;';
  CONNSTRING = TEMP_CONN1 + 'Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"';

var Share_LogName, Share_NameDesc : String;
    Share_Level : Integer;
    Share_DateCount : Integer;
    Share_Str : TStringList;
    Share_SqlStr : String;

    Procedure DecodeString(DS_Source : String; DS_Char : Char; var DS_Result : TStringList);
    Function GetMonthDay(GMD_Date : TDate) : String;       //---- 取得每月日期数 -----//
    Function GetMonthMaxDay(GMMD_Date : TDate) : Word;     //---- 获取每月的最大天数 ----//
    Function UnLineString(ULS_Source, ULS_String: String; Var ULS_Result: String): String;
    Function GetStantLenStr(GSL_IntSource : Integer; GSL_Tag : Integer) : String;
    Function GetLevelString(GLS_Tag : Integer) : String;
    Function GetLevelDate(GLD_Str : String) : Integer;
    Function GetStatueIndex(GSI_Str : String) : Integer;
    Function GetWeekDiffDay(GVDD_Str : String) : Integer;//---- 取得周相差天数----//
    Function GetUseLevelStr(GULS_Tag : Integer) : String;//--- 获取用户权限字串----//
    Function ReadParteFile(RPF_File : String; Var RPF_Str : TStringList) : Boolean;

implementation

//==== 按特定字符串分开字符串 ====//
Procedure DecodeString(DS_Source : String; DS_Char : Char; var DS_Result : TStringList);
var I : Integer;
    DS_TmpStr : String;
begin
  DS_TmpStr := '';
  DS_Result.Clear;
  for I := 1 to Length(DS_Source) do begin
    if DS_Source[I] = DS_Char then begin
      DS_Result.Add(Trim(DS_TmpStr));
      DS_TmpStr := '';
    end else DS_TmpStr := DS_TmpStr + DS_Source[I];
  end;
  DS_Result.Add(Trim(DS_TmpStr));
end;

//---- 取得每月日期数 -----//
Function GetMonthDay(GMD_Date : TDate) : String;
var GMD_Year, GMD_Month, GMD_Day : Word;
begin
  DecodeDate(GMD_Date, GMD_Year, GMD_Month, GMD_Day);
  Case GMD_Month of
    1 : Result := '1-31';
    2 : begin
      if (GMD_Year Mod 400 = 0) or ((GMD_Year Mod 4 = 0) and (GMD_Year Mod 10 <> 0)) then
        Result := '1-29'
      else Result := '1-28';
    end;
    3 : Result := '1-31';
    4 : Result := '1-30';
    5 : Result := '1-31';
    6 : Result := '1-30';
    7 : Result := '1-31';
    8 : Result := '1-31';
    9 : Result := '1-30';
    10 : Result := '1-31';
    11 : Result := '1-30';
    12 : Result := '1-31';
  end;
end;

//---- 获取每月的最大天数 ----//
Function GetMonthMaxDay(GMMD_Date : TDate) : Word;
var GMMD_Year, GMMD_Month, GMMD_Day : Word;
begin
  Result := 30;
  DecodeDate(GMMD_Date, GMMD_Year, GMMD_Month, GMMD_Day);
  Case GMMD_Month of
    1 : Result := 31;
    2 : begin
      if (GMMD_Year Mod 400 = 0) or ((GMMD_Year Mod 4 = 0) and (GMMD_Year Mod 10 <> 0)) then
        Result := 29
      else Result := 28;
    end;
    3 : Result := 31;
    4 : Result := 30;
    5 : Result := 31;
    6 : Result := 30;
    7 : Result := 31;
    8 : Result := 31;
    9 : Result := 30;
    10 : Result := 31;
    11 : Result := 30;
    12 : Result := 31;
  end;
end;

//---- 按要求分开字串 ----//
Function UnLineString(ULS_Source, ULS_String: String; Var ULS_Result: String): String;
var ULS_TempStr: String;
    ULS_StrInd: Integer;
begin
    for ULS_StrInd:= 1 to Length(ULS_Source) do begin
        ULS_TempStr:= Copy(ULS_Source,ULS_StrInd,Length(ULS_String));
        if CompareText(ULS_TempStr,ULS_String)= 0 then begin
            ULS_Result:= Trim(Copy(ULS_Source,1,ULS_StrInd - 1));
            Result:= Trim(Copy(ULS_Source,ULS_StrInd + Length(ULS_String),Length(ULS_Source)));
            Break;
        end;
    end;
    if ULS_StrInd>= Length(ULS_Source) then begin
        ULS_Result:= Trim(ULS_Source);
        Result:= '';
    end;
end;

//----- 按特定字串分解定符串 -----//
//Function DecodeString(DS_String, DS_TagStr : String; var DS_Str : TStringList) : Integer;
//begin

//end;

//----- 获取标准长度字串 -----//
Function GetStantLenStr(GSL_IntSource : Integer; GSL_Tag : Integer) : String;
var I, SumCount : Integer;
  GSL_TempStr : String;
begin
  SumCount := 1;
  GSL_TempStr := '';
  For I := 1 to GSL_Tag-1 do SumCount := SumCount * 10;
  While(GSL_IntSource < SumCount) do begin
      GSL_TempStr := GSL_TempStr + '0';
      SumCount := SumCount Div 10;
  end;
  Result := GSL_TempStr + IntToStr(GSL_IntSource);
end;

//---- 取得级别代表字串 ----//
Function GetLevelString(GLS_Tag : Integer) : String;
var GLS_Result : String;
begin
  Case GLS_Tag of
    1 : GLS_Result := '常规工作事宜';
    2 : GLS_Result := '规律性工作事宜';
    3 : GLS_Result := '重要工作事宜';
    4 : GLS_Result := '突发性工作事件';
    5 : GLS_Result := '取消、延时';
    else GLS_Result := '其它';
  end;
  Result := GLS_Result;
end;

//==== 获取缓急索引数 =====//
Function GetLevelDate(GLD_Str : String) : Integer;
var GLD_Result : Integer;
begin
  if CompareText('常规工作事宜', GLD_Str) = 0 then GLD_Result := 1
  else if CompareText('规律性工作事宜', GLD_Str) = 0 then GLD_Result := 2
  else if CompareText('重要工作事宜', GLD_Str) = 0 then GLD_Result := 3
  else if CompareText('突发性工作事件', GLD_Str) = 0 then GLD_Result := 4
  else if CompareText('取消、延时', GLD_Str) = 0 then GLD_Result := 5
  else GLD_Result := 6;

  Result := GLD_Result;
end;

//==== 获取完成状态数字索引 ====//
Function GetStatueIndex(GSI_Str : String) : Integer;
var GSI_Result : Integer;
begin
  if CompareText('创建', GSI_Str) = 0 then GSI_Result := 1
  else if CompareText('继续', GSI_Str) = 0 then GSI_Result := 2
  else if CompareText('未完成', GSI_Str) = 0 then GSI_Result := 3
  else if CompareText('暂缓', GSI_Str) = 0 then GSI_Result := 4
  else if CompareText('中止', GSI_Str) = 0 then GSI_Result := 5
  else if CompareText('完成', GSI_Str) = 0 then GSI_Result := 6
  else GSI_Result := 7;
  Result := GSI_Result;
end;

//---- 取得周相差天数----//
Function GetWeekDiffDay(GVDD_Str : String) : Integer;
begin
  if CompareText('星期一', GVDD_Str) = 0 then Result := 0
  else if CompareText('星期二', GVDD_Str) = 0 then Result := 1
  else if CompareText('星期三', GVDD_Str) = 0 then Result := 2
  else if CompareText('星期四', GVDD_Str) = 0 then Result := 3
  else if CompareText('星期五', GVDD_Str) = 0 then Result := 4
  else if CompareText('星期六', GVDD_Str) = 0 then Result := 5
  else Result := 6;
end;

//--- 获取用户权限字串----//
Function GetUseLevelStr(GULS_Tag : Integer) : String;
begin
  Case GULS_Tag of
    1 : Result := '完全';
    2 : Result := '普通';
    else Result := '未授权';
  end;
end;

Function ReadParteFile(RPF_File : String; Var RPF_Str : TStringList) : Boolean;
var Temp_Str : TStringList;
    I : Integer;
    Key_Str, Value_Str : String;
begin
  RPF_Str.Clear;
  if Not FileExists(RPF_File) then begin
    Result := FALSE;
    exit;
  end;
  Temp_Str := TStringList.Create;               //==== 创建字符串内存空间 ====//
  Try
    Try
      Temp_Str.LoadFromFile(RPF_File);
      For I := 0 to Temp_Str.Count - 1 do begin
        if (Trim(Temp_Str[I])='')OR(Trim(Temp_Str[I])[1] = '#') then Continue
        else if Pos('=', Temp_Str[I]) > 0 then begin
          Value_Str := UnLineString(Trim(Temp_Str[I]), '=', Key_Str);
          if StrToDate(Value_Str) >= Date() then RPF_Str.Add(Trim(Key_Str));
        end else RPF_Str.Add(Trim(Temp_Str[I]));
      end;
      Result := TRUE;
    Except
      Result := FALSE;
      Abort();
    end;
  Finally
    Temp_Str.Free;                              //==== 释放字符串内存空间 ====//
  end;
end;

end.

⌨️ 快捷键说明

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