📄 sys_global.pas
字号:
unit sys_global;
interface
uses
Windows,SysUtils ;
const
ID4442=1;
var
m_OpName: string ; // 操作者姓名
m_system: string ; // 维护权限
m_Card: string ; // 卡片权限
m_Report: string ; // 报表权限
m_mode : char;
m_Stop: char='0' ; // m_Stop='9' 意味着网络不通
m_flag : string ; // 表维护用
m_com: word=2 ; // 缺省的串口
m_CardType: string='普通卡'; // 缺省的卡型
m_sxrq: word = 365 ; // 卡的有效期缺省值
m_yj: word =10 ; //卡的押金缺省为10元
m_monTime: longword=1 ; // 缺省的读卡时间时间
m_syspara: string = '8888' ; // 缺省的系统参数
m_ICno: string ; // 卡上的卡号
m_ICtype: string ; // 卡上的卡型
m_ICmoney: currency ; // 卡上的剩余金额或剩余时间
m_ICdate: Tdatetime ; // 卡上的失效日期
m_icpass:string='FFFFFF';
function padl(s:string;len:integer):string;
function ServerDateTime: TDatetime ;
function SetPCSystemTime(tDati: TDateTime): Boolean;
function ComputerName : String;
Function CardInfo(var ICtype, ICno: string; var ICmoney: Currency; var ICdate: Tdatetime): integer ;
function GetHourMinute(M: integer): string ;
Function MoneyString(mon: real): string ;
Function DateTimeString(dt: Tdatetime): string ;
function DateTimeTostr(dt: Tdatetime): string ;
FUNCTION GETMSG(MSGINDEX:INTEGER):STRING;
implementation
uses sys_dm, Dlldef, main ;
FUNCTION GETMSG(MSGINDEX:INTEGER):STRING;
BEGIN
RESULT:='';
IF FRM_MAIN.LISTBOX4.ITEMS.COUNT>MSGINDEX THEN
RESULT:=FRM_MAIN.LISTBOX4.ITEMS[MSGINDEX];
END;
function padl(s:string;len:integer):string;
begin
result:=TRIM(s);
while length(result)<len do
result:='0'+result;
end;
function ServerDateTime: TDatetime ; // 取得服务器的时间, 如2002-05-26 17:23:55
begin
with frm_sys_dm.Qr_tmp1 do
begin
close;
sql.text := 'select getdate()' ;
try
open;
Result := fields[0].AsDateTime ; // 产生当前的时间
except
close;
m_Stop := '9' ; // 9=提示请检查电脑网络
result := now ;
end;
close;
end;
end;
// 用服务器的时间, 设定本机的时间
function SetPCSystemTime(tDati: TDateTime): Boolean;
var
tSetDati: TDateTime;
vDatiBias: Variant;
tTZI: TTimeZoneInformation;
tST: TSystemTime;
begin
GetTimeZoneInformation(tTZI);
vDatiBias := tTZI.Bias / 1440;
tSetDati := tDati + vDatiBias;
with tST do
begin
wYear := StrToInt(FormatDateTime('yyyy', tSetDati));
wMonth := StrToInt(FormatDateTime('mm', tSetDati));
wDay := StrToInt(FormatDateTime('dd', tSetDati));
wHour := StrToInt(FormatDateTime('hh', tSetDati));
wMinute := StrToInt(FormatDateTime('nn', tSetDati));
wSecond := StrToInt(FormatDateTime('ss', tSetDati));
wMilliseconds := 0;
end;
SetPCSystemTime := SetSystemTime(tST);
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 := '不知道!';
FreeMem(CNameBuffer,255);
Dispose(CLen);
end;
Function CardInfo(var ICtype, ICno: string; var ICmoney: Currency; var ICdate: Tdatetime): integer ;
var
i: integer ;
p: array[0..32] of char;
ICmoney1, ICdate1: string ;
begin
i := getno(m_com,p);
if i = 0 then begin // 如果读成功
ICtype := copy(p,1,1) ;
ICno := copy(p,2,5) ;
ICmoney1 := copy(p,7,4)+'.'+copy(p,11,2) ; // 记时卡可以考虑去掉小数点
ICdate1 := copy(p,13,2)+'-'+copy(p,15,2)+'-'+copy(p,17,2)+' '+copy(p,19,2)+':'+copy(p,21,2);
ICmoney := strTofloat(ICmoney1);
ICdate := strTodateTime(ICdate1);
result := 0 ;
end else
result := 1 ; // 可能卡坏
end;
function GetHourMinute(M: integer): string ; //将分钟数转变为小时分钟数
var
h, n: integer ;
begin
h := m div 60 ;
n := m mod 60 ;
result := intTostr(h)+'小时'+intTostr(n)+'分钟'
end ;
Function MoneyString(mon: real): string ;
var
strTmp: string ;
iPos: word ;
begin
if mon <0 then mon := 0 ;
str(mon:8:2,strTmp);
strTmp := trim(strTmp) ;
iPos := pos('.',strTmp) ;
delete(strTmp,iPos,1);
result := padl(strTmp,6) ;
end;
Function DateTimeString(dt: Tdatetime): string ;
var
s1, s2: string ;
begin
s1 := formatdatetime('yyyy"-"mm"-"dd', dt) ;
s2 := formatdatetime('hh":"nn":"ss', dt) ;
result := copy(s1,3,2)+copy(s1,6,2)+copy(s1,9,2)+copy(s2,1,2)+copy(s2,4,2);
end;
function DateTimeTostr(dt: Tdatetime): string ;
begin
result := formatdatetime('yyyy"-"mm"-"dd" "hh":"nn":"ss', dt) ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -