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

📄 shareunit.pas

📁 三層源碼,DELPHI寫的三層源碼,三層源碼,
💻 PAS
字号:
{--------------------------公共单元---------------------------------------}

unit shareunit;

interface

 uses SysUtils,IdHash,IdHashMessageDigest,windows,Graphics;
///////////////////////////////////////////////////////////////////////////
  const
//*********************************************************************
//*****Funid 操作常量
  public_unkonw                                         =999;
  public_add                                            =100;
  public_modify                                         =101;
  public_del                                            =102;
  public_list                                           =103;
  public_infor                                          =104;

  public_add_temp                                       =105;
  public_del_temp                                       =106;
  public_clear_temp                                     =107;
  public_list_temp                                      =108;

  public_list_sub                                       =109;
  public_copy                                           =110;
  public_rebuild                                        =111;
  public_mathall                                        =112;

  public_list_ex01                                      =113;
  public_list_ex02                                      =114;
  public_list_ex03                                      =115;
  public_list_ex04                                      =116;
  public_list_ex05                                      =117;
  public_list_ex06                                      =118;
  public_list_ex07                                      =119;
  public_list_ex08                                      =120;

  private_infor_ext01                                   =900;
  private_infor_ext02                                   =901;
  private_change_passwd                                 =990;
  private_check_passwd                                  =991;


//*****Query 查询常量
  Query_unknow                                          =999;
  Query_user                                            =110;
  Query_dept                                            =120;
  Query_Parchives                                       =130;
  Query_dormitory                                       =160;
  Query_event                                           =210;
  Query_sysother                                        =250;
  Query_cess                                            =260;
  Query_medicare                                        =270;
  Query_insurance                                       =280;
  Query_incometax                                       =290;
//*********************************************************************
//*****authority 权限
  authority_blank                                       ='00000000000000000000'+
                                                         '00000000000000000000'+
                                                         '00000000000000000000'+
                                                         '00000000000000000000'+
                                                         '00000000000000000000'+
                                                         '00000000000000000000';
//*********************************************************************
  function monthday(m:word):word;
  function mothtoday(y,m:word):word;
  function datetomoth(d1:tdatetime):integer;
  function makemothday(d1:tdatetime;first:boolean):tdatetime;
  function makeyearday(d1: tdatetime; first: boolean): tdatetime;
  function md5encode(s:string):string;
  function XorEncode(const Key, Source: string): String;
  function XorDecode(const Key, Source: string): String;
  function nextyear(d:tdatetime):tdatetime;
  function nextmonth(d:tdatetime):tdatetime;
  function lastyear(d:tdatetime):tdatetime;
  function lastmonth(d:tdatetime):tdatetime;
  function datemonthtoday(d:tdatetime):integer;
  function datetoweek(d1:tdatetime):string;
  function datetoyear(d1:tdatetime):string;
  function datetostring(d1:tdatetime):string;
  function datetoyears(d1:tdatetime;first:boolean):tdatetime;
  //----------------------------------------------
  function getfieldtobgname(id:integer;s1:string):string;
  function monthtoeng(m:integer):string;
  function ischinseandeng(s:string):boolean;
  function makeparams(funid,param:string):string;  //组合字符
  function clearenter(s:string):string; // 删除回车符..
  function replaceSQLstr(s:String):string;  //替换 * 为 %
  function WhichLanguage:boolean;

var
     pagesizes,
     loginpassword,
     loginuser,
     pagecounts,
     lastusername,
     remotecomputer,
     localcomputer,

     company_name,
     company_tel,
     company_fax,
     company_mail,
     company_web,
     company_adder,
     company_other:string;
     loginok:boolean;

implementation


function WhichLanguage:boolean;
var
  ID:LangID;
begin
  ID:=GetSystemDefaultLangID;
  result:=ID=$0804;
end;

function ischinseandeng(s:string):boolean;
var i,n,m:integer;
begin
n:=length(s);m:=0;
for i:=1 to n do
  if ord(s[i])>127 then inc(m);
result:=m mod 2=0;
end;


function datetoweek(d1:tdatetime):string;
var s:String;
begin
case DayOfWeek(d1) of
  1:s:='天';
  2:s:='一';
  3:s:='二';
  4:s:='三';
  5:s:='四';
  6:s:='五';
  7:s:='六';
  end;
result:='星期'+s;
end;

function datetoyears(d1:tdatetime;first:boolean):tdatetime;
var y,m,d:word;
begin
decodedate(d1,y,m,d);
if first then result:=encodedate(y,1,1)
         else result:=encodedate(y,12,31);
end;

function getmycomputer:string;
var name:pchar;
    len:^dword;
    s:string;
begin
GetMem(Name,255);
New(Len);Len^:= 255;
GetComputerName(Name,Len^);
s:=StrPas(Name);
freemem(name,255);
dispose(len);
result:=md5encode(loginuser+'.'+s);
end;

function md5encode(s:string):string;
Var
  Digest: T4x4LongWordRecord;
  Sx,s1: String;
  i: Integer;
begin
  SetLength(Sx, 16);
   with TIdHashMessageDigest5.Create do
     begin
     Digest := HashValue(s);
     Move(Digest, Sx[1], 16);
     Free;
     end;
  for i := 1 to Length(Sx) do
    S1 := S1 + Format('%02x', [Byte(Sx[i])]);
  while Pos(' ', S1) > 0 do S1[Pos(' ', S1)] := '0';
result:=s1;
end;

function XorEncode(const Key, Source: string): String;
var
  I: Integer;
  C: Byte;
begin
  Result := '';
  for I := 1 to Length(Source) do begin
    if Length(Key) > 0 then
      C := Byte(Key[1 + ((I - 1) mod Length(Key))]) xor Byte(Source[I])
    else
      C := Byte(Source[I]);
    Result := Result + AnsiLowerCase(IntToHex(C, 2));
  end;
end;

function XorDecode(const Key, Source: string): String;
var
  I: Integer;
  C: Char;
begin
  Result := '';
  for I := 0 to Length(Source) div 2 - 1 do begin
    C := Chr(StrToIntDef('$' + Copy(Source, (I * 2) + 1, 2), Ord(' ')));
    if Length(Key) > 0 then
      C := Chr(Byte(Key[1 + (I mod Length(Key))]) xor Byte(C));
    Result := Result + C;
  end;
end;

function datemonthtoday(d:tdatetime):integer;
var y,m,r:word;
begin
decodedate(d,y,m,r);
result:=mothtoday(y,m);
end;

function monthday(m:word):word;
var y,d:word;
begin
decodedate(date,y,d,d);
result:=mothtoday(y,m);
end;

function datetomoth(d1:tdatetime):integer;
var y,m,d:word;
begin
decodedate(d1,y,m,d);
result:=m;
end;

function mothtoday(y,m:word):word;
var n:integer;
begin
n:=0;
case m of
  1:n:=31;
  2:begin
    if ((y mod 4)=0)and((y mod 100)>0)then
        n:=29 else n:=28;
    end;
  3:n:=31;
  4:n:=30;
  5:n:=31;
  6:n:=30;
  7:n:=31;
  8:n:=31;
  9:n:=30;
  10:n:=31;
  11:n:=30;
  12:n:=31;
  end;
result:=n;
end;

function monthtoeng(m:integer):string;
var s:string;
begin
case m of
  1:s:='Jan';
  2:s:='Feb';
  3:s:='Mar';
  4:s:='Apr';
  5:s:='May';
  6:s:='Jun';
  7:s:='Jul';
  8:s:='Aug';
  9:s:='Sep';
  10:s:='Oct';
  11:s:='Nov';
  12:s:='Dec';
  end;
result:=s;
end;

function datetoyear(d1:tdatetime):string;
var y,m,d:word;
begin
decodedate(d1,y,m,d);
result:=inttostr(y);
end;

function makemothday(d1:tdatetime;first:boolean):tdatetime;
var y,m,d:word;
begin
decodedate(d1,y,m,d);
if first then
result:=encodedate(y,m,1) else
result:=encodedate(y,m,mothtoday(y,m));
end;

function makeyearday(d1: tdatetime; first: boolean): tdatetime;
var y, m, d: word;
begin
  decodedate(d1, y, m, d);
  if first then
    result := encodedate(y, 1, 1) else
    result := encodedate(y, 12, 31);
end;


function nextyear(d:tdatetime):tdatetime;
var y,m,ds,dx:word;
begin
decodedate(d,y,m,ds);
dx:=mothtoday(y+1,m);
if ds>dx then ds:=dx;
result:=encodedate(y+1,m,ds);
end;

function lastyear(d:tdatetime):tdatetime;
var y,m,ds,dx:word;
begin
decodedate(d,y,m,ds);
dx:=mothtoday(y-1,m);
if ds>dx then ds:=dx;
result:=encodedate(y-1,m,ds);
end;

function lastmonth(d:tdatetime):tdatetime;
var y,m,ds,dx:word;
begin
decodedate(d,y,m,ds);
m:=m-1;
if m=0 then
  begin
  y:=y-1;
  m:=12;
  end;
dx:=mothtoday(y,m);
if ds>dx then ds:=dx;
result:=encodedate(y,m,ds);
end;


function nextmonth(d:tdatetime):tdatetime;
var y,m,ds,dx:word;
begin
decodedate(d,y,m,ds);
m:=m+1;
if m=13 then
  begin
  y:=y+1;
  m:=1;
  end;
dx:=mothtoday(y,m);
if ds>dx then ds:=dx;
result:=encodedate(y,m,ds);
end;

function datetostring(d1:tdatetime):string;
var y,m,d:word;
begin
decodedate(d1,y,m,d);
result:=inttostr(y)+'年'+inttostr(m)+'月份';
end;
//------------------------------------------------------------
function replaceSQLstr(s:String):string;  //替换 * 为 %
var i,n:integer;
begin
n:=length(s);
if n>0 then
for i:=1 to n do
  begin
  if s[i]='*' then s[i]:='%';
  if s[i]='?' then s[i]:='-';
  end;
result:=s;
end;

function makeparams(funid,param:string):string;  //组合字符
begin
result:=clearenter(Concat(funid,'=',param));
end;

function clearenter(s:string):string; // 删除回车符..
var i:integer;
begin
if length(s)>0 then
for i:=length(s) downto 1 do
  if ord(s[i])in[10,13] then delete(s,i,1);
result:=trim(s);
end;


function getfieldtobgname(id:integer;s1:string):string;
var s:string;
begin
s:=s1;
case id of
Query_event:
   begin
   if s1='autoid' then s:='序号';
   if s1='repeat' then s:='事件类型';
   if s1='inqt' then s:='事件周期';
   if s1='extday' then s:='提醒天数';
   if s1='filter' then s:='周期单位';
   if s1='personnel_id' then s:='工号';
   if s1='name' then s:='姓名';
   if s1='dept' then s:='部门';
   if s1='work_type' then s:='工种';
   if s1='remark' then s:='内容说明';
   if s1='inure_date' then s:='生效日期';
   if s1='start_date' then s:='入厂日期';
   if s1='cur_date' then s:='当前日期';
   end;

 Query_Parchives:
   begin
   if s1='personnel_id' then s:='工号';
   if s1='name' then s:='姓名';
   if s1='sex' then s:='性别';
   if s1='dept' then s:='部门';
   if s1='work_type' then s:='工种';
   if s1='idcard' then s:='身份证';
   if s1='school' then s:='学历';
   if s1='birthday' then s:='出生年月';
   if s1='marriage' then s:='婚姻状况';
   if s1='area' then s:='籍贯';
   if s1='tel' then s:='电话';
   if s1='start_date' then s:='进厂日期';
   if s1='over_date' then s:='离职日期';
   if s1='dimission' then s:='离职否';
   if s1='remark' then s:='备注';
   end;

 Query_dormitory:
   begin
   if s1='room_num' then s:='房号';
   if s1='sort' then s:='住房类别';
   if s1='locus' then s:='地点';
   if s1='bunk_total' then s:='床位总数';
   if s1='bunk_residual' then s:='可用床位';
   if s1='bunk' then s:='床铺';
   if s1='bureau' then s:='衣柜';
   if s1='desk' then s:='书桌';
   if s1='fan' then s:='风扇';
   if s1='remark' then s:='备注';
   if s1='personnel_id' then s:='工号';
   if s1='dept' then s:='部门';
   if s1='work_type' then s:='工种';
   if s1='name' then s:='姓名';
   if s1='bunk_num' then s:='房号';
   end;

 Query_cess:
   begin
   if s1='cmin' then s:='起始金额';
   if s1='cmax' then s:='上限金额';
   if s1='rate' then s:='税率';
   if s1='deduct' then s:='速扣数';
   end;

 Query_medicare,
 Query_incometax,
 Query_insurance:
   begin
   if s1='personnel_id' then s:='工号';
   if s1='name' then s:='姓名';
   if s1='dept' then s:='部门';
   if s1='work_type' then s:='工种';
   if s1='start_date' then s:='进厂日期';
   if s1='declare_salary' then s:='申报数';
   if s1='individual' then s:='个人供款比例';
   if s1='individualqt' then s:='个人供款额';
   if s1='company' then s:='公司供款比例';
   if s1='companyqt' then s:='公司供款额';
   if s1='declare_month' then s:='供款月份';
   if s1='residence_free' then s:='住房免税比例';
   if s1='residence_freeqt' then s:='住房免税额';
   if s1='tax_free' then s:='免税额';
   if s1='taxsum' then s:='税金';
   if s1='taxqt' then s:='应纳税额';
   if s1='insqt' then s:='养老金';
   if s1='medqt' then s:='医疗保险';
   if s1='medicqreqt' then s:='医疗保险';
   if s1='insuranceqt' then s:='养老金';
   if s1='meddate' then s:='申报日期';
   if s1='insdate' then s:='申报日期';
   if s1='taxdate' then s:='申报日期';
   if s1='remark' then s:='备注';
   end;

 end;
result:=s;
end;

initialization
DateSeparator:='-';
ShortDateFormat:='yyyy-mm-dd';
finalization


end.

⌨️ 快捷键说明

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