?? 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 + -