📄 globe.pas
字号:
unit globe;
interface
USES DM_UN,SysUtils,DateUtils,Dialogs,Variants,shellapi,forms,Classes;
var
user_name,user_id,user_pass,user_qx,use_dw,system_dw,SYS_OPER,sys_end_date:string;
sys_end,pub_var,system_ime:string;
DM:TDM;
procedure writetolog(log_je:string);
function telisno(tel_no:string):boolean;
function qfjc(tel_num,tel_sfzh,jcrq:string):boolean;
function backupdata(sour,dest:string):boolean;
procedure filecopy(const sourcefilename,targefilename:string);
function convertcurrtochineses(money:extended):string;
implementation
function telisno(tel_no:string):boolean;
var
dm1:tdm;
begin
dm1:=tdm.Create(nil);
telisno:=false;
with dm1 do
begin
q_3.Close;
q_3.SQL.Clear;
q_3.SQL.Add('select * from tel_user where tel_num=:tel_num');
q_3.Parameters.ParamByName('tel_num').Value:=trim(tel_no);
q_3.Prepared;
q_3.Open;
end;
if dm1.q_3.Recordset.RecordCount >0 then
begin
telisno:=true;
dm1.free;
end;
end;
procedure filecopy(const sourcefilename,targefilename:string);
var
s,t:tfilestream;
begin
dm.Free;
s:=tfilestream.Create(sourcefilename,fmopenread);
try
t:=tfilestream.Create(targefilename,fmopenwrite or fmcreate);
try
t.CopyFrom(s,s.Size );
finally
t.Free;
end;
finally
s.Free;
end;
end;
procedure writetolog(log_je:string);
begin
dm:=tdm.Create(nil);
with dm do
begin
q_a.Close;
q_a.SQL.Clear;
q_a.SQL.Add('insert into tel_log (log_nr,log_id,log_mark,log_time,log_je)');
q_a.SQL.Add('values(:log_nr,:log_id,:log_mark,:log_time,:log_je)');
q_a.Parameters.ParamByName('log_nr').Value:=sys_oper;
q_a.Parameters.ParamByName('log_id').Value:=user_id;
q_a.Parameters.ParamByName('log_mark').Value:='1';
q_a.Parameters.ParamByName('log_time').Value:=now;
q_a.Parameters.ParamByName('log_je').Value:=strtofloat(log_je);
q_a.Prepared;
q_a.ExecSQL;
end;
end;
function qfjc(tel_num,tel_sfzh,jcrq:string):boolean;
var
screen:tscreen;
dm1:tdm;
var
yhye,yhhf,yhfwf:real;
khrq,jzrq:tdatetime;
tel_fw:string;
begin
qfjc:=false;
dm1:=tdm.Create(nil);
yhhf:=0;
yhfwf:=0;
yhye:=0;
//main.stu.Caption:='系统正在进相关的统计,请稍候运行其它功能。。。。。';
screen.Cursor:=-1;
with dm1 do
begin
q_a.Close;
q_a.SQL.Clear;
q_a.SQL.Add('select * from tel_user where tel_num=:tel_num');
q_a.Parameters.ParamByName('tel_num').Value:=tel_num;
q_a.Prepared;
q_a.Open;
if VarIsNull(q_a.FieldValues ['TEL_YCFS']) then yhye:=0
else yhye:=q_a.FieldValues ['TEL_YCFS'];
khrq:=q_a.FieldValues ['TEL_TIME'];
tel_fw:=q_a.FieldValues ['TEL_FW'];
q_b.close;
q_b.SQL.Clear;
q_b.SQL.Add('select max(UP_DATE) as maxup from TEL_UP_MX where up_tel=:up_tel and up_sfzh=:up_sfzh');
q_b.Parameters.ParamByName('up_tel').Value:=tel_num;
q_b.Parameters.ParamByName('up_sfzh').Value:=tel_sfzh;
q_b.Prepared;
q_b.Open;
if q_b.Recordset.RecordCount >0 then
if not varisnull(q_b.FieldValues ['maxup']) then
jzrq:=q_b.FieldValues ['maxup']
else
jzrq:=khrq
else
jzrq:=khrq;
if khrq>jzrq then jzrq:=khrq;
//进行日期间的比较,当传入参数的日期小于当前的结帐日期时不产生服务费,取其中月值差.
yhfwf:=0;
if ((yearof(strtodatetime(jcrq))-yearof(jzrq))*12+(monthof(strtodatetime(jcrq))-monthof(jzrq)))>0 then
begin
//如果产生服务费,则对用户的服务费进行计算。
q_c.Close;
q_c.SQL.Clear;
q_c.SQL.Add('select * from tel_cgyw');
q_c.Prepared;
q_c.Open;
while not q_c.Eof do
begin
if pos(q_c.FieldValues ['yw_id'],tel_fw)<>0 then
yhfwf:=yhfwf+q_c.FieldValues ['yw_money'];
q_c.Next;
end;
yhfwf:=yhfwf*((yearof(strtodatetime(jcrq))-yearof(jzrq))*12+(monthof(strtodatetime(jcrq))-monthof(jzrq)));
end;
//对用户的话费进统计,
q_d.Close;
q_d.SQL.Clear;
q_d.SQL.Add('select sum(total_money) as sum1 from tel_no where zj_tel=:zj_tel and tel_sfzh=:tel_sfzh');
q_d.SQL.Add('and b_time<=:b_time');
q_d.Parameters.ParamByName('zj_tel').Value:=tel_num;
q_d.Parameters.ParamByName('tel_sfzh').Value:=tel_sfzh;
q_d.Parameters.ParamByName('b_time').Value:=strtodatetime(jcrq);
q_d.Prepared;
q_d.Open;
if q_d.Recordset.RecordCount >0 then
if VarIsNull(q_d.FieldValues ['sum1']) then
yhhf:=0
else
yhhf:=q_d.FieldValues ['sum1']
else
yhhf:=0;
//用户的各项费用收集完毕:
if yhfwf+yhhf-yhye>0 then
qfjc:=false
else
qfjc:=true;
end;
// main.stu.Caption:='系统数据统计完毕,可以正常使用....';
screen.Cursor:=-1;
dm1.Free;
end;
function backupdata(sour,dest:string):boolean;
var
opstruc:tshfileopstruct;
frombuf,tobuf:array[0..128] of char;
begin
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,pchar(sour));
strpcopy(tobuf,pchar(dest));
end;
function convertcurrtochineses(money:extended):string;
var
str1:array[0..13] of string;
str2:array[0..9] of string;
str3:array[0..3] of string;
j,m,n,nf:int64;
i:integer;
ff,f1,f2,f3,f4,f5,f6:Extended;
ss1,ss2,ss3,ss4,ss:string;
function deletestr(str:string):string; //用于去除不合规则的汉字字符
var
i,j:integer;
begin
j:=length(str);
for i:=1 to j do
begin
if copy(str,i,2)='零' then
if (copy(str,i+2,2)='拾') or (copy(str,i+2,2)='佰') or (copy(str,i+2,2)='仟') then
begin
delete(str,i+2,2);
insert('零',str,i+2);
end;
end;
for i:=1 to j do
begin
if (copy(str,i,2)='零') and (copy(str,i+2,2)='零') then
delete(str,i,2);
if (copy(str,i,2)='零') and (copy(str,i-2,2)='零') then
delete(str,i-2,2);
end;
j:=length(str);
for i:=1 to j do
begin
if (copy(str,i,2)='零') and (copy(str,i+2,2)='零') then
delete(str,i,2);
if (copy(str,i,2)='零') and (copy(str,i-2,2)='零') then
delete(str,i-2,2);
end;
j:=length(str);
for i:=1 to j do
if copy(str,i,2)='零' then
if (copy(str,i+2,2)='万') or (copy(str,i+2,2)='亿') or (copy(str,i+2,2)='圆') then
delete(str,i,2);
j:=length(str);
for i:=1 to j do
if copy(str,i,2)='零' then
if (copy(str,i+2,2)='万') or (copy(str,i+2,2)='亿') or (copy(str,i+2,2)='圆') then
delete(str,i,2);
j:=length(str);
for i:=1 to j do
if copy(str,i,2)='零' then
if (copy(str,i+2,2)='万') or (copy(str,i+2,2)='亿') or (copy(str,i+2,2)='圆') then
delete(str,i,2);
j:=length(str);
for i:=1 to j do
if (copy(str,i,2)='万') and (copy(str,i+2,2)='万') then
delete(str,i,2);
j:=length(str);
for i:=1 to j do
if (copy(str,i,2)='亿') and (copy(str,i+2,2)='万') then
delete(str,i+2,2);
result:=str;
end;
begin
ff:=money; //得到传入的数字 EXTENDED型
f6:=ff;
f2:=ff;
nf:=trunc(ff); //实型数转为整型数...即得到数字的整数部分..
f1:=frac(f2); //返回一个实型数的小数部分
f4:=round((f1+0.001)*100); //以四舍五入的方式返加整型.
if f4=100 then //如果四舍五入正好进位.
begin
nf:=nf+1;
f1:=0000;
end;
ss1:=inttostr(nf); //数字的整数部分
m:=length(ss1); //0
str1[0]:='拾';
str1[1]:='佰';
str1[2]:='仟';
str1[3]:='万';
str1[4]:='拾';
str1[5]:='佰';
str1[6]:='仟';
str1[7]:='亿';
str1[8]:='拾';
str1[9]:='佰';
str1[10]:='仟';
str1[11]:='拾万';
str1[12]:='佰万';
str1[13]:='仟万';
str2[0]:='零';
str2[1]:='壹';
str2[2]:='贰';
str2[3]:='叁';
str2[4]:='肆';
str2[5]:='伍';
str2[6]:='陆';
str2[7]:='柒';
str2[8]:='捌';
str2[9]:='玖';
str3[0]:='圆';
str3[1]:='角';
str3[2]:='分';
str3[3]:='整';
ss2:=str3[0];
j:=nf mod 10; //整数部分取余.
ss2:=str2[j]+ss2; //得到尾数.即几元.
nf:=nf div 10;
for i:=1 to m-1 do //整数部分长度减一.按每位数字写入字符串中.
begin
j:=nf mod 10;
ss2:=str2[j]+str1[i-1]+ss2;
nf:=nf div 10;
end;
ss:=floattostr(f2);
ss2:=deletestr(ss2); //得到经过处理符合读写规则的汉字串....整数部分.
f1:=f1*100;
nf:=round(f1+0.001);
i:=nf mod 10;
ss3:=str2[i]+str3[2];
nf:=nf div 10;
j:=nf mod 10;
if (i=0) and (j=0) then
ss2:=ss2+str3[3] //如果没有小数.取整.
else if j=0 then
ss2:=ss2+'零'+ss3 //如果小数第一位为0
else
ss2:=ss2+str2[j]+str3[1]+ss3; //不为0则加入角位
result:=ss2;
if nf =0 then
if (f1<0.005) and (f6<1) then
begin
ss2:='零圆整';
//result:=ss2;
end;
{else if round(f1*10+0.1)>=1 then}
ss:=floattostr(money);
if (copy(ss,1,1)='0') and (round(ff*100+0.1)<100) then
begin
if round(ff*100+0.1)<10 then
begin
ss2:=str2[strtoint(copy(inttostr(round(ff*100+0.1)),1,1))]+'分';
result:=ss2;
end
else
begin
ss2:=str2[strtoint(copy(inttostr(round(ff*100+0.1)),1,1))]+'角'+str2[strtoint(copy(inttostr(round(ff*100+0.1)),2,1))]+'分';
//ss2:=str2[strtoint(copy(inttostr(trunc(ff*100+0.1)),1,1))]+'角'+str2[strtoint(copy(inttostr(trunc(ff*100+0.1)),1,2))]+'分';
result:=ss2;
end;
end;
if (f1<0.005) and (f6<1) then
begin
ss2:='零圆整';
result:=ss2;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -