📄 namebookscalequeryunit.~pas
字号:
procedure TNameBookScaleQuery.sumXJ2(Spos:integer;Epos:integer;LView:TListView);{计算按类型分的各个规模小记XJ}
var
i,j:integer;
temp:single;
begin
for i:=2 to 6 do
begin
temp:=0;
for j:=Spos to Epos do
temp:=temp+StrToFloat(LView.Items[j].SubItems[i]);
LView.Items[Spos-1].SubItems[i]:=FloatToStr(temp);
end;
end;
procedure TNameBookScaleQuery.ZongSum(Col:integer;Input:string);
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select distinct 单位代码 from 公用事业单位基本情况表 where 企业规模='+''''+Input+''''
+' and 统计年份='+ComboBox1.Text);
ADOQuery1.Open;
ListView1.Items[0].SubItems[Col]:=IntToStr(ADOQuery1.RecordCount);
end;
procedure TNameBookScaleQuery.BitBtn1Click(Sender: TObject);
var
sString:String;
TempString:String;
ibus,isub,iboat,ilight:integer;
iCol,iRow:integer;
scale: array [0..4] of string;
i,j,temp:integer;
begin
if ComboBox1.Text='' then
begin
showmessage('请选择查询日期!');
exit;
end;
if (length(ComboBox1.Text)<>4) or (StrToInt(ComboBox1.Text)>2030) or (StrToInt(ComboBox1.Text)<1980) then
begin
showmessage('对不起!您输入的年份非法!请重新选择!');
exit;
end;
for i:=0 to 18 do
for j:=1 to 6 do
ListView1.Items[i].SubItems[j]:='0';
for i:=0 to 20 do
for j:=1 to 6 do
ListView2.Items[i].SubItems[j]:='0';
for i:=0 to 10 do
for j:=1 to 6 do
ListView3.Items[i].SubItems[j]:='0';
scale[0]:='特大型';
scale[1]:='大型';
scale[2]:='中型';
scale[3]:='小型';
scale[4]:='其他';
//............................MNS03-MNS06...................................//
sString:='select a.企业规模 as 企业规模,b.公共汽车、电车 as 公共汽车、电车,b.地铁 as 地铁,';
sString:=sString+'b.轻轨 as 轻轨,b.轮渡 as 轮渡 from 公用事业单位基本情况表 as a,主要业务活动表 as b';
sString:=sString+' where a.统计年份='+ComboBox1.Text+' and b.统计年份=a.统计年份';
sString:=sString+' and a.单位代码=b.企业代码 and a.城市代码='+''''+'022'+''''+' order by 企业规模';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sString);
ADOQuery1.Open;
ADOQuery1.First;
while (not ADOQuery1.Eof) do
begin
TempString:=ADOQuery1.fieldbyname('企业规模').AsString;
if FindCol(TempString)<>-1 then
begin
iCol:=FindCol(TempString);
end else
begin
showmessage('名录库中有错误!请检查名录库中的数据!');
exit;
end;
ibus:=StrToInt(ADOQuery1.fieldbyname('公共汽车、电车').AsString);
isub:=StrToInt(ADOQuery1.fieldbyname('地铁').AsString);
iboat:=StrToInt(ADOQuery1.fieldbyname('轮渡').AsString);
ilight:=StrToInt(ADOQuery1.fieldbyname('轻轨').AsString);
if ibus>0 then ListView1.Items[2].SubItems[iCol]:=IntToStr(StrToInt(ListView1.Items[2].SubItems[iCol])+1);
if isub>0 then ListView1.Items[3].SubItems[iCol]:=IntToStr(StrToInt(ListView1.Items[3].SubItems[iCol])+1);
if ilight>0 then ListView1.Items[4].SubItems[iCol]:=IntToStr(StrToInt(ListView1.Items[4].SubItems[iCol])+1);
if iboat>0 then ListView1.Items[5].SubItems[iCol]:=IntToStr(StrToInt(ListView1.Items[5].SubItems[iCol])+1);
ADOQuery1.Next;
end;
//...............MNS08-MNS19.......................//
StandardInput(ListView1,7,18,'[企业(单位)登记注册类型]');
//...........................MNS21-MNS40...................................//
StandardInput(ListView2,1,20,'单位坐落区域');
//...................MNS43-MNS47............................................//
StandardInput(ListView3,1,5,'营业状况');
//..................MNS01,MNS02,MNS07,MNS20,MNS42..............................//
sString:='select distinct 单位代码 from 公用事业单位基本情况表 where 统计年份='+ComboBox1.Text;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sString);
ADOQuery1.Open;
ListView1.Items[0].SubItems[1]:=IntToStr(ADOQuery1.RecordCount);
ListView1.Items[1].SubItems[1]:=IntToStr(ADOQuery1.RecordCount);
ListView1.Items[6].SubItems[1]:=IntToStr(ADOQuery1.RecordCount);
ListView2.Items[0].SubItems[1]:=IntToStr(ADOQuery1.RecordCount);
ListView3.Items[0].SubItems[1]:=IntToStr(ADOQuery1.RecordCount);
//.......................MNS49-MNS52.......................................//
moneySum('公共汽车、电车',7);
moneySum('地铁',8);
moneySum('轻轨',9);
moneySum('轮渡',10);
//.....................................合计.................................//
SumCa(2,5,ListView1);
SumCa(7,18,ListView1);
SumCa(1,20,ListView2);
SumCa(1,5,ListView3);
SumCa2(7,10,ListView3);
SumXJ(2,5,ListView1);
SumXJ(7,18,ListView1);
SumXJ(1,20,ListView2);
SumXJ(1,5,ListView3);
SumXJ2(7,10,ListView3);
ListView3.Items[6].SubItems[1]:='0';
for i:=7 to 10 do
begin
ListView3.Items[6].SubItems[1]:=FloatToStr(StrToFloat(ListView3.Items[6].SubItems[1])+StrToFloat(ListView3.Items[i].SubItems[1]))
end;
ZongSum(2,'特大型');
ZongSum(3,'大型');
ZongSum(4,'中型');
ZongSum(5,'小型');
ZongSum(6,'其他');
//.....................MNS48..............................//
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select sum(企业注册资本金) as 资本金 from 公用事业单位基本情况表'
+' where 统计年份='+ComboBox1.Text);
ADOQuery1.Open;
ListView3.Items[6].SubItems[1]:=ADOQuery1.fieldbyname('资本金').AsString;
//...................企业注册资本金的小数点问题..............//
for i:=6 to 10 do//行
begin
for j:=1 to 6 do//列
begin
ListView3.Items[i].SubItems[j]:=ConverterPercent(ListView3.Items[i].SubItems[j]);
end;
end;
BitBtn2.Enabled:=true;
end;
procedure TNameBookScaleQuery.ComboBox1Change(Sender: TObject);
var i,j:integer;
begin
for i:=0 to 18 do
for j:=1 to 6 do
ListView1.Items[i].SubItems[j]:='0';
for i:=0 to 20 do
for j:=1 to 6 do
ListView2.Items[i].SubItems[j]:='0';
for i:=0 to 10 do
for j:=1 to 6 do
ListView3.Items[i].SubItems[j]:='0';
end;
procedure TNameBookScaleQuery.BitBtn3Click(Sender: TObject);{返回}
begin
NameBookScaleQuery.Close;
end;
procedure TNameBookScaleQuery.BitBtn2Click(Sender: TObject);{打印}
var
iRow:Integer;
iCol:Integer;
begin
if PrnInfoFrm.ShowModal=mrOK then
begin
PrintInit(ExtractFilePath(application.exeName),'BusTradeNameBookQuery5');
for iRow:=0 to 18 do
for iCol:=1 to 6 do
WriteCell(iRow+5,iCol+2,ListView1.Items[iRow].SubItems[iCol]);
for iRow:=0 to 20 do
for iCol:=1 to 6 do
WriteCell(iRow+30,iCol+2,ListView2.Items[iRow].SubItems[iCol]);
for iRow:=0 to 10 do
for iCol:=1 to 6 do
WriteCell(iRow+56,iCol+2,ListView3.Items[iRow].SubItems[iCol]);
WriteCell(24,1,'统计负责人:'+PrnInfoFrm.StatMainPerson);
WriteCell(24,4,'统计人员:'+PrnInfoFrm.StatPerson);
WriteCell(24,7,'填报日期:'+DateToStr(PrnInfoFrm.StatDate));
WriteCell(51,1,'统计负责人:'+PrnInfoFrm.StatMainPerson);
WriteCell(51,4,'统计人员:'+PrnInfoFrm.StatPerson);
WriteCell(51,7,'填报日期:'+DateToStr(PrnInfoFrm.StatDate));
WriteCell(76,1,'统计负责人:'+PrnInfoFrm.StatMainPerson);
WriteCell(76,4,'统计人员:'+PrnInfoFrm.StatPerson);
WriteCell(76,7,'填报日期:'+DateToStr(PrnInfoFrm.StatDate));
WriteCell(2,4,ComboBox1.text+'年');
WriteCell(27,4,ComboBox1.text+'年');
WriteCell(53,4,ComboBox1.text+'年');
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -