type TMenuList=packed Record Code:String; MenuItem:TMenuItem; end;
const CodeLen=3;
{数据转换时获取相应的ACCESS字段类型} function GetDataType(DataType:TFieldType):integer; {小写金额转换成大写金额} function SumSmallTOBig(small:double):string; {年份是否涧年} function IsLeapYear(AYear: Integer): Boolean; {取得每月的最后一天} function DaysPerMonth(ADate : TDateTime): Integer; {取得农历日期} function GetNDate(sDate: TDate): string; {取得星期几} function GetWeekofDay(sDate: TDate): string; {取得长型日期} function GetLongDate(sDate: TDate): string; {取得计算机机} function ComputerName : String; {加小数点} function Addradixpoint(s: string; digits: integer): string; {按拼音检索} function GetPyIndexChar( hzchar:string):char; {取出汉字拼音} function GetPy( HZString:string ):string;
{小写金额转换成大写金额} function SumSmallTOBig(small:double):string; var bigmoney,bigmoney_unit:string;// 大写金额数字和大写金额单位字符串 moneystring:string; //小写字母转化以后的固定格式的小写字符串 #####0.00 len:integer;//MONEYSTRING的长度 thisnumber_station:integer;//当前小写数字的位置 len_i:integer;// 用来标志bigmoney_unit和MONEYSTRING的长度,务必理解!!!! thisnumberstring:string;// 当前小写数字的字符串 nextnumber:integer;// 当前小写数字下一位 数字 thisnumber:integer;// 当前小写数字数字 returnstring:string;//返回值 temp_bigmoneystring :string;//某个数字的大写 temp_bigmoney_unitstring:string;//某个数字单位的大写 begin bigmoney:='零壹贰叁肆伍陆柒捌玖'; bigmoney_unit:='分角圆拾佰仟万拾佰仟亿拾佰仟'; if abs(small) >999999999999.99 then begin Application.MessageBox('恭喜恭喜!您已荣升为全球首富!!!','恭喜恭喜', MB_DEFBUTTON1+ MB_ICONINFORMATION+MB_ok); exit;//防止死机。 end; moneystring:=formatfloat('0.00',abs(small)); len:=length(moneystring);//长度 thisnumber_station:=1;//循环位置,起始为1。 nextnumber:=0;//下一个位置的数字。 len_i:=len; returnstring:=''; while thisnumber_station<=len do begin //-----------------------本位置上的数字字符串------------ thisnumberstring:=copy(moneystring,thisnumber_station,1); if thisnumberstring<>'.' then begin if thisnumber_stationbegin if copy(moneystring,thisnumber_station+1,1)<>'.' then nextnumber:=strtoint(copy(moneystring,thisnumber_station+1,1)) end; thisnumber:=strtoint(thisnumberstring);//本位置的数字。 temp_bigmoneystring:=copy(bigmoney,thisnumber*2+1,2);//本位置的大写数字 temp_bigmoney_unitstring:=copy(bigmoney_unit,len_i*2-3,2);//本位置的大写数字单位 //------------------------------------------------------------------------- if ((thisnumber=0) and (nextnumber=0)) or ((thisnumber=0) and ((len_i=4) or(len_i=8) or (len_i=12) )) then temp_bigmoneystring:=''; { 如果本位置和下一位置数字为零或者本位数字为零并且单位位置在圆、万、亿上, 本大写字符为空} //------------------------------------------------------------------------- if ((thisnumber=0) and (len_i<>4) and (len_i<>8) and (len_i<>12) or ((ABS(small)<1)and (len_i=4))) then temp_bigmoney_unitstring:=''; {如果本位置数字为零,圆、万、亿必须有 ,除非ABS(SMALL)为<1的小数, 本单位字符为空} //--------------------------------------------------------------------------------------------------------- if (temp_bigmoney_unitstring='万')and (copy(returnstring,length(returnstring)-1,2)='亿') then temp_bigmoney_unitstring:=''; //处理万为零,本单位字符为万,但RETURNSTRING最后字符为亿,本单位字符为空 //---------------------------------------------------------------------------- returnstring:=returnstring+temp_bigmoneystring+temp_bigmoney_unitstring; len_i:=len_i-1; end; inc(thisnumber_station); end;//while if strtoint(copy(moneystring,len,1))=0 then returnstring:=returnstring+'整'; if small=0 then returnstring:=''; //如果为0,什么也不显示 if small<0 then returnstring:='负'+returnstring; result:=returnstring; end;
{年份是否涧年} function IsLeapYear(AYear: Integer): Boolean; begin Result := (AYear mod 4 = 0) and ((AYear mod 100 <> 0) or (AYear mod 400 = 0)); end;
{获取每月的最后一天} function DaysPerMonth(ADate : TDateTime): Integer; var AYear, AMonth: integer; const DaysInMonth: array[1..12] of Integer = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); begin AYear:=YearOf(ADate); AMonth:=MonthOf(ADate); Result := DaysInMonth[AMonth]; if (AMonth = 2) and IsLeapYear(AYear) then Inc(Result);{如果是闰年则2月加1天} end;
var lYear, lMonth, lDay : integer; LMDay : array[1..13] of integer; InterMonth, InterMonthDays, SLRangeDay : integer;
procedure CovertLunarMonth(magicno : integer); var i, size, m : integer; begin m := magicno; for i := 12 downto 1 do begin size := m mod 2; if size = 0 then LMDay[i] := 29 else LMDay[i] := 30; m := m div 2; end; end;
procedure Solar2Lunar(SYear, SMonth, SDay : integer; var LYear, LMonth, LDay : integer); var i, Day : integer; begin Day := 0; ProcessMagicStr(SYear); if SMonth = 1 then Day := SDay else begin for i := 1 to SMonth-1 do Day := day + SMDay[i]; if IsLeapYear(SYear+1911) then Day:=Day+1; Day := Day + SDay; end; if Day <= SLRangeDay then begin Day := Day - SLRangeDay; processmagicstr(SYear-1); for i := 12 downto 1 do begin day := day + LMDay[i]; if day > 0 then Break; end; LYear := SYear - 1; LMonth := i; LDay := day; end else begin day := day - SLRangeDay; for i := 1 to InterMonth-1 do begin day := day - LMDay[i]; if day <= 0 then break; end; if day <= 0 then begin LYear := SYear; LMonth := i; LDay := day + LMDay[i]; end else begin day := day - LMDay[InterMonth]; if day <= 0 then begin LYear := SYear; LMonth := InterMonth; LDay := day + LMDay[InterMonth]; end else begin LMDay[InterMonth] := InterMonthDays; for i := InterMonth to 12 do begin day := day - LMDay[i]; if day <= 0 then break; end; if i = InterMonth then LMonth := 0 - InterMonth else LMonth := i; LYear := SYear; LDay := day + LMDay[i]; end; end; end; LYear:=LYear+1911; end;
function GetNlYear(Year: integer):string; var i: integer; begin for i:=1 to Length(IntToStr(Year)) do begin Result:=Result+LYearName[StrToInt(Copy(IntToStr(Year),I,1))]; end; end;
var y, m, d: integer; begin y:=YearOf(sDate); m:=MonthOf(sDate); d:=DayOf(sDate); Solar2Lunar(y-1911, m, d, lYear, lMonth, lDay); Result:=GetNlYear(lYear)+'年' +LMonthName[abs(lMonth)] +LDayName[lDay]; end;
function GetWeekofDay(sDate: TDate): string; var i: integer; begin i:=DayOfTheWeek(sDate); case i of 0:Result:='日'; 1:Result:='一'; 2:Result:='二'; 3:Result:='三'; 4:Result:='四'; 5:Result:='五'; 6:Result:='六'; end; Result:='星期'+Result; end;
function GetLongDate(sDate: TDatE): string; begin Result:=IntToStr(Yearof(sDate))+'年'+ IntToStr(Monthof(sDate))+'月'+ IntToStr(Dayof(sDATE))+'日'; end;
{取得计算机机} function ComputerName : String; var CNameBuffer : PChar; fl_loaded : Boolean; CLen : ^DWord; begin GetMem(CNameBuffer,255); New(CLen); CLen^:= 255;
fl_loaded := GetComputerName(CNameBuffer,CLen^); if fl_loaded then ComputerName := StrPas(CNameBuffer) else ComputerName := 'Unkown'; FreeMem(CNameBuffer,255); Dispose(CLen); end;
{字符加密}
function Addradixpoint(s: string; digits: integer): string; var i, dig: integer; begin dig:=Pos('.', s); Result:=s; if dig=0 then begin dig:=Length(s)+1; s:=s+'.'; end; //6613189 if dig=Length(s)-digits then Exit; for i:=0 to digits-(Length(s)-dig+1) do begin s:=s+'0'; end; Result:=s; end;
function GetPYIndexChar( hzchar:string):char; 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(32); end; end;
function GetPY( HZString:string ):string; var i:integer; Hz:string; begin i:=1; while i <= Length(HZString) do begin Hz := Copy(HZString, I , 1); if Hz >= Chr(128) then begin Inc(I); Hz := Hz+ Copy(HZString, I , 1); Result := Result + GetPYIndexChar(Hz); end else Result := Result + Hz; Inc(I); end; end;