📄 main.~pas
字号:
begin
close;
sql.Clear;
sql.add('select '''+formatdatetime('yyyymm',dtp1.date)+''' as 月份,a.客户编号,a.客户名称,a.拼音字头,a.顺序号,0,0,b.名称,0,0,case 特征码一 when '''+inttostr(10000000)+''' then '''+inttostr(1)+''' else '''+inttostr(0)+''' end as 是否居光,');
sql.add('a.特征码一,a.用户性质,a.用户性质1,0,备注,0 from gdf_dfsj'+formatdatetime('yyyymm',dtp1.date)+' a,bs_gdsda b where a.所编号=b.所编号 and a.台区编号='''+''' and a.所编号 in ('''+inttostr(22)+''','''+inttostr(23)+''','''+inttostr(24)+''')');
sql.add(str);
open;
end;
if (recordcount>0) and (pos='') then
pos := '0';
if recordcount<=0 then
begin
Close;
SQL.Clear;
SQL.Add('select '''+formatdatetime('yyyymm',dtp1.date)+''' as 月份,a.客户编号,a.客户名称,a.拼音字头,a.顺序号,0,0,b.名称,0,d.抄表本名称,case 特征码一 when '''+inttostr(10000000)+''' then ''');
sql.add(inttostr(1)+''' else '''+inttostr(0)+''' end as 是否居光,a.特征码一,a.用户性质,a.用户性质1,0,备注,0 from df_dfsj'+formatdatetime('yyyymm',dtp1.date)+' a,bs_gdsda b,df_zcda d ');
sql.add('where a.所编号=b.所编号 and a.台区编号 is null and a.抄表本号=d.抄表本号 and d.年月='''+formatdatetime('yyyymm',dtp1.date)+''' and a.所编号 in ('''+inttostr(22)+''','''+inttostr(23)+''')');
SQL.Add(str);
Open;
end;
if (recordcount>0) and (pos='') then
pos := fieldbyname('抄表本名称').asstring;
if recordcount>0 then
begin
if addr='' then
addr := '0';
if lname='' then
lname := '0';
if tname='' then
tname := '0';
if added3='' then
added3:='0';
id := fieldbyname('客户编号').asstring;
nam := fieldbyname('客户名称').asstring;
namepy := fieldbyname('拼音字头').asstring;
cid := fieldbyname('顺序号').asstring;
sname := fieldbyname('名称').asstring;
bname := fieldbyname('备注').asstring;
only := fieldbyname('是否居光').asstring;
user := '0';
added1 := fieldbyname('特征码一').asstring;
added2 := fieldbyname('用户性质').asstring;
added4 := fieldbyname('用户性质1').asstring;
flag := '0';
addrpy := GetPYStr(addr);
end;
if recordcount<=0 then
begin
ShowMessage('无此用户信息,请检查月份、用户编号、或用户名称是否正确');
exit;
end
else
date := formatdatetime('yyyymm',dtp1.date);
except
showmessage('查询期间出现错误,请检查月份是否正确且数据库联接正确。');
exit;
end;
with qry2 do
try
close;
sql.clear;
sql.add('select '''+date+''' as 月份,a.客户编号,合计电量,退补电费,有功变损,变损电费,基本电费,调整电费,a.分类电量1,b.电量电价p1,分类金额1,a.分类电量5,b.电量电价p5,a.分类金额5,a.分类电量2,b.电量电价p2,a.分类金额2,结算金额,');
sql.add('集资金额1,结算金额,上月余额,本月余额,'''+inttostr(9999)+'-'+inttostr(12)+'-'+inttostr(30)+''' from df_dfsj'+formatdatetime('yyyymm',dtp1.date)+' a,df_cdjk b where b.id1=(select max(d.id1) from df_cdjk d where d.电价代码=a.特征码四 ');
sql.add('and d.年月='''+date+''') and a.所编号 in ('''+inttostr(22)+''','''+inttostr(23)+''')');
sql.add(str);
open;
if recordcount<=0 then
begin
close;
sql.clear;
sql.add('select '''+date+''' as 月份,a.客户编号,合计电量,退补电费,有功变损,变损电费,基本电费,调整电费,a.分类电量1,b.电量电价p1,分类金额1,a.分类电量5,b.电量电价p5,a.分类金额5,a.分类电量2,b.电量电价p2,a.分类金额2,结算金额,集资金额1,结算金额,上月余额,');
sql.add('本月余额,'''+inttostr(9999)+'-'+inttostr(12)+'-'+inttostr(30)+''' from df_dfsj'+date+' a,df_cdjk b where b.id1=(select max(d.id1) from df_cdjk d where d.电价代码=a.特征码四 and d.年月='''+date+''') and a.所编号='''+inttostr(21)+''' and a.抄表本号='''+inttostr(60)+'''');
sql.add(str);
open;
end;
if recordcount<=0 then
begin
close;
sql.clear;
sql.add('select '''+date+''' as 月份,a.客户编号,合计电量,退补电费,有功变损,变损电费,基本电费,调整电费,a.分类电量1,b.电量电价p1,分类金额1,a.分类电量5,b.电量电价p5,a.分类金额5,a.分类电量2,b.电量电价p2,a.分类金额2,结算金额,集资金额1,结算金额,上月余额,本月余额,'''+inttostr(9999));
sql.add('-'+inttostr(12)+'-'+inttostr(30)+''' from gdf_dfsj'+date+' a,df_cdjk b where b.id1=(select max(d.id1) from df_cdjk d where d.电价代码=a.特征码四 and d.年月='''+date+''') and a.所编号 in ('''+inttostr(22)+''',+'''+inttostr(23)+''','''+inttostr(24)+''') and 集资金额4=0');
sql.add(str);
open;
end;
if recordcount<=0 then
begin
close;
sql.Clear;
sql.Add('select '''+date+''' as 月份,a.客户编号,合计电量,退补电费,有功变损,变损电费,基本电费,调整电费,a.分类电量1,b.电量电价p1,分类金额1,a.分类电量5,b.电量电价p5,(a.分类金额5+集资金额4) as 分类金额5,a.分类电量2,b.电量电价p2,a.分类金额2,结算金额,集资金额1,');
sql.add('结算金额,上月余额,本月余额,'''+inttostr(9999)+'-'+inttostr(12)+'-'+inttostr(30)+''' from gdf_dfsj'+date+' a,df_cdjk b where b.id1=(select max(d.id1) from df_cdjk d where d.电价代码=a.特征码四 and d.年月='''+date+''') and a.所编号 ');
sql.add('in ('''+inttostr(22)+''','''+inttostr(23)+''','''+inttostr(24)+''') and 用户性质=''大工业'' and 集资金额4>0'+str);
open;
end;
if recordcount<=0 then
begin
close;
sql.Clear;
sql.add('select '''+date+''' as 月份,a.客户编号,合计电量,退补电费,有功变损,变损电费,基本电费,调整电费,a.分类电量1,b.电量电价p1,分类金额1,a.分类电量5,b.电量电价p5,a.分类金额5,a.分类电量2,b.电量电价p2,(a.分类金额2+集资金额4) as 分类金额2,结算金额,集资金额1,');
sql.add('结算金额,上月余额,本月余额,'''+inttostr(9999)+'-'+inttostr(12)+'-'+inttostr(30)+''' from gdf_dfsj'+date+' a,df_cdjk b where b.id1=(select max(d.id1) from df_cdjk d where d.电价代码=a.特征码四 and d.年月='''+date+''') and a.所编号 in ('''+inttostr(22)+''','''+inttostr(23)+''','''+inttostr(24)+''') and 用户性质=''一般工商业'' and 集资金额4>0');
sql.add(str);
open;
end;
if recordcount<=0 then
begin
close;
sql.clear;
sql.add('select '''+date+''' as 月份,a.客户编号,合计电量,退补电费,有功变损,变损电费,基本电费,调整电费,a.分类电量1,b.电量电价p1,分类金额1,a.分类电量5,b.电量电价p5,a.分类金额5,a.分类电量2,b.电量电价p2,a.分类金额2,结算金额,集资金额1,结算金额,上月余额,本月余额,'''+inttostr(9999)+'-'+inttostr(12)+'-'+inttostr(30)+''' from gdf_dfsj'+date);
sql.add(' a,df_cdjk b where b.id1=(select max(d.id1) from df_cdjk d where d.电价代码=a.特征码四 and d.年月='''+date+''') and a.所编号 in ('''+inttostr(22)+''','''+inttostr(23)+''','''+inttostr(24)+''') and 集资金额4>0 and 用户性质 not in (''一般工商业'',''大工业'')');
sql.add(str);
open;
end;
if recordcount>0 then
begin
term := '9999-12-30' ;
if trim(fieldbyname('合计电量').asstring)<>'' then
sum_a := fieldbyname('合计电量').asstring
else
sum_a := '0';
dra := '0';
if trim(fieldbyname('退补电费').asstring)<>'' then
repair_f := fieldbyname('退补电费').asstring
else
repair_f := '0';
power_a := '0';
power_lose := '0';
power_sum := '0';
useless_a := '0';
useless_lose := '0';
useless_sum := '0';
capacity_a := '0';
capacity_p := '0';
base_fee := fieldbyname('基本电费').asstring;
cos_fee := fieldbyname('调整电费').asstring;
tran_lose_a := fieldbyname('有功变损').asstring;
tran_lose_f := fieldbyname('变损电费').asstring;
life_a := fieldbyname('分类电量1').asstring;
life_p := fieldbyname('电量电价p1').asstring;
life_f := fieldbyname('分类金额1').asstring;
nlife_a := '0';
nlife_p := '0';
nlife_f := '0';
ind_a := fieldbyname('分类电量2').asstring;
ind_p := fieldbyname('电量电价p2').asstring;
ind_f := fieldbyname('分类金额2').asstring;
farm_a := '0';
farm_p := '0';
farm_f := '0';
trade_a := '0';
trade_p := '0';
trade_f := '0';
hind_a := fieldbyname('分类电量5').asstring;
hind_p := fieldbyname('电量电价p5').asstring;
hind_f := fieldbyname('分类金额5').asstring;
peak_a := '0';
peak_p := '0';
peak_f := '0';
norm_a := '0';
norm_p := '0';
norm_f := '0';
vale_a := '0';
vale_p := '0';
vale_f := '0';
other1_a := '0';
Other1_p := '0';
Other1_f := '0';
other2_a := '0';
Other2_p := '0';
Other2_f := fieldbyname('集资金额1').asstring;
other3_a := '0';
Other3_p := '0';
Other3_f := '0';
other4_a := '0';
Other4_p := '0';
Other4_f := '0';
other5_a := '0';
Other5_p := '0';
Other5_f := '0';
other6_a := '0';
Other6_p := '0';
Other6_f := '0';
other7_a := '0';
Other7_p := '0';
Other7_f := '0';
other8_a := '0';
Other8_p := '0';
Other8_f := '0';
other9_a := '0';
Other9_p := '0';
Other9_f := '0';
other10_a := '0';
Other10_p := '0';
Other10_f := '0';
if trim(fieldbyname('结算金额').asstring)<>'' then
sum_f := fieldbyname('结算金额').asstring
else
sum_f := '0';
should_charge := fieldbyname('结算金额').asstring;
write_back_flag := '0';
end;
if recordcount<=0 then
begin
ShowMessage('无此用户信息,请检查月份、用户编号、或用户名称是否正确-');
exit;
end
except
showmessage('查询期间出现错误,请检查月份是否正确且数据库联接正确。');
end;
with qry3 do
try
close;
sql.clear;
sql.add('select '''+date+''' as 月份,a.客户编号,a.电表编号,a.倍率,a.起码,a.止码,a.表量,CONVERT(float, 止码)-CONVERT(float, 起码) as 差数,b.有功加度 from df_dbk'+date+' a,df_dfsj'+date+' b where a.客户编号=b.客户编号 and a.所编号=b.所编号 and b.所编号 ');
sql.add('in ('''+inttostr(22)+''','''+inttostr(23)+''') ');
sql.add(str);
sql.add('order by 电表编号');
open;
if recordcount<=0 then
begin
close;
sql.Clear;
sql.add('select '''+date+''' as 月份,a.客户编号,a.电表编号,a.倍率,a.起码,a.止码,a.表量,CONVERT(float, 止码)-CONVERT(float, 起码) as 差数,b.有功加度 from df_dbk'+date+''' a,df_dfsj'+date+' b where a.客户编号=b.客户编号 and b.所编号='''+inttostr(21)+''' ');
sql.add(' and b.抄表本号='''+inttostr(60)+''' ');
sql.add(str);
sql.add('order by 电表编号');
open;
end;
if recordcount<=0 then
begin
close;
sql.clear;
sql.add('select '''+date+''' as 月份,a.客户编号,a.电表编号,a.倍率,a.起码,a.止码,a.表量,CONVERT(float, 止码)-CONVERT(float, 起码) as 差数,b.有功加度 from gdf_dbk'+date+' a,gdf_dfsj'+date+' b where a.客户编号=b.客户编号 and a.所编号=b.所编号 and b.所编号 ');
sql.add('in ('''+inttostr(22)+''','''+inttostr(23)+''','''+inttostr(24)+''') ');
sql.add(str);
sql.add('order by 电表编号');
open;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -