📄 bustradecszhyearrepunit.pas
字号:
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView1.Items[j+3].SubItems[2]:='0';
end else
ListView1.Items[j+3].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
if(j>=12) and (j<=15) then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView1.Items[j+6].SubItems[2]:='0';
end else
ListView1.Items[j+6].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
//添加第二页数据
if(j>=16)and (j<=26)then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView2.Items[j-16].SubItems[2]:='0';
end else
ListView2.Items[j-16].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
if (j>=27)and (j<=34)then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView2.Items[j-13].SubItems[2]:='0';
end else
ListView2.Items[j-13].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
//添加第三页数据
if(j>=35)and(j<=45)then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView3.Items[j-35].SubItems[2]:='0';
end else
ListView3.Items[j-35].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
if(j=46)then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView3.Items[21].SubItems[2]:='0';
end else
ListView3.Items[21].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').AsString);
end;
//添加第四页数据
if(j>=47)and (j<=54)then
begin
if (ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView4.Items[j-47].SubItems[2]:='0';
end else
ListView4.Items[j-47].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
//添加第六页数据
if(j>=55)and (j<=64)then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView6.Items[j-42].SubItems[2]:='0';
end else
ListView6.Items[j-42].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
//添加第八页数据
if (j>=65)and (j<=85)then
begin
if(ADOQuery1.Fieldbyname('测算值').asstring='')then
begin
ListView8.Items[j-63].SubItems[2]:='0';
end else
ListView8.Items[j-63].SubItems[2]:=Converter(ADOQuery1.Fieldbyname('测算值').asstring);
end;
ADOQuery1.Next;
end;
FillMonDataToList();
//添加城市规模指标值
Insertnum3();
//添加三个特殊数据
Insertnum1();
Insertnum2();
//向数据库公交行业综合年报_z中添加数据
sqlstr:='select * from 公交行业综合年报_z where 统计年份='+combobox1.text;
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add(sqlstr);
ADOQuery.Open;
if(ADOQuery.RecordCount<=0)then
begin
ADOCommand1.CommandText:= 'insert into 公交行业综合年报_z (统计年份,指标代码,测算值,全年实际) select '
+Combobox1.text+','+'指标代码,0,0 from'
+' 公交行业综合年报指标定义表';
ADOCommand1.Execute;
end;
FillDatatoTable(ListView1);
FillDatatoTable(ListView2);
FillDatatoTable(ListView3);
FillDatatoTable(ListView4);
FillDatatoTable(ListView5);
FillDatatoTable(ListView6);
FillDatatoTable(ListView7);
FillDatatoTable(ListView8);
//添加到纵表
FillDatatoZTable();
BitBtn17.enabled:=true;
end;
end;
procedure TBusTradeCSZHYearRepFrm.FillDatatoTable(List:TListView);
var j:integer;
sqlstr:string;
begin
if(List<>ListView6)or (List<>ListView7) or (List<>ListView8) then
begin
for j:=0 to 21 do
begin
ADOCommand1.CommandText:='update 公交行业综合年报_z set 测算值='
+List.Items[j].Subitems[2]+' where 统计年份='
+ combobox1.Text + ' and 指标代码='+''''+List.Items[j].subitems[0]+'''';
ADOCommand1.Execute;
end;
end else
begin
for j:=0 to 22 do
begin
ADOCommand1.CommandText:='update 公交行业综合年报_z set 测算值='
+List.Items[j].Subitems[2]+' where 统计年份='
+ combobox1.Text + ' and 指标代码='+''''+List.Items[j].subitems[0]+'''';
ADOCommand1.Execute;
end;
end;
end;
procedure TBusTradeCSZHYearRepFrm.initialcolumn(List:TListView);
var j:integer;
begin
if(List=ListView1)or(List=ListView2)or (List=ListView3)
or (List=ListView4) or(List=ListView5)then
begin
for j:=0 to 21 do
begin
if List.Items[j].SubItems.Count<3 then
begin
List.Items[j].SubItems.Add(' ');
end else
List.Items[j].SubItems[2]:='';
end;
end else
begin
for j:=0 to 22 do
begin
if List.Items[j].SubItems.Count<3 then
begin
List.Items[j].SubItems.Add(' ');
end else
List.Items[j].SubItems[2]:='';
end;
end;
end;
procedure TBusTradeCSZHYearRepFrm.Insertnum1();
var Indexnum1,Indexnum2,Indexnum3,Indexnum4,Indexnum:single;
begin
//添加GZ035
Indexnum1:=strtofloat(ListView1.Items[6].SubItems[2])+strtofloat(ListView1.Items[7].SubItems[2]);;
Indexnum2:=strtofloat(ListView1.Items[9].SubItems[2])+strtofloat(ListView1.Items[10].SubItems[2]);
Indexnum3:=strtofloat(ListView1.Items[11].SubItems[2])+strtofloat(ListView1.Items[12].SubItems[2]);
Indexnum4:=strtofloat(ListView1.Items[13].SubItems[2]);
Indexnum:=Indexnum1+Indexnum2+Indexnum3+Indexnum4;
if(Indexnum=0)then
begin
ListView2.Items[12].SubItems[2]:='0';
end else
ListView2.Items[12].SubItems[2]:=Converter(floattostr(Indexnum));
//添加GZ036
Indexnum1:=strtofloat(ListView1.Items[19].SubItems[2])+strtofloat(ListView1.Items[20].SubItems[2]);;
Indexnum2:=strtofloat(ListView2.Items[0].SubItems[2])+strtofloat(ListView2.Items[1].SubItems[2]);
Indexnum3:=strtofloat(ListView2.Items[2].SubItems[2])+strtofloat(ListView2.Items[3].SubItems[2]);
Indexnum4:=strtofloat(ListView2.Items[4].SubItems[2]);
Indexnum:=Indexnum1+Indexnum2+Indexnum3+Indexnum4;
if(Indexnum=0)then
begin
ListView2.Items[13].SubItems[2]:='0';
end else
ListView2.Items[13].SubItems[2]:=Converter(floattostr(Indexnum));
//添加GZ34
Indexnum1:=strtofloat(ListView2.Items[12].SubItems[2]);
if(Indexnum1+Indexnum=0)then
begin
ListView2.Items[11].SubItems[2]:='0';
end else
ListView2.Items[11].SubItems[2]:=Converter(floattostr(Indexnum1+Indexnum));
end;
procedure TBusTradeCSZHYearRepFrm.Insertnum2();
var Indexnum1,Indexnum2,Indexnum:single;
begin
//添加GZ140
Indexnum1:=strtofloat(ListView7.Items[7].SubItems[2]);
Indexnum2:=strtofloat(ListView7.Items[8].SubItems[2]);
if(Indexnum2=0)or (Indexnum1=0)then
begin
ListView7.Items[6].SubItems[2]:='0';
end
else begin
Indexnum:=(Indexnum1*10000)/Indexnum2;
ListView7.Items[6].SubItems[2]:=ConverterPercent(floattostr(Indexnum));
end;
//添加GZ143
Indexnum1:=strtofloat(ListView7.Items[10].SubItems[2]);
Indexnum2:=strtofloat(ListView7.Items[11].SubItems[2]);
if(Indexnum2=0)or(Indexnum1=0)then
begin
ListView7.Items[9].SubItems[2]:='0';
end else
begin
Indexnum:=(Indexnum1/Indexnum2)*100;
ListView7.Items[9].SubItems[2]:=ConverterPercent(floattostr(Indexnum));
end;
//添加GZ146
Indexnum1:=strtofloat(ListView7.Items[13].SubItems[2]);
Indexnum2:=strtofloat(ListView7.Items[14].SubItems[2]);
if(Indexnum2=0)or (Indexnum1=0)then
begin
ListView7.Items[12].subitems[2]:='0';
end else
begin
Indexnum:=(Indexnum1/Indexnum2)*100;
ListView7.Items[12].SubItems[2]:=ConverterPercent(floattostr(Indexnum));
end;
//添加GZ149
Indexnum1:=strtofloat(ListView7.Items[16].SubItems[2]);
Indexnum2:=strtofloat(ListView7.Items[17].SubItems[2]);
if(Indexnum2=0)or(Indexnum1=0)then
begin
ListView7.Items[15].SubItems[2]:='0';
end else
begin
Indexnum:=(Indexnum1/Indexnum2)*100;
ListView7.Items[15].SubItems[2]:=ConverterPercent(floattostr(Indexnum));
end;
//添加GZ153
Indexnum1:=strtofloat(ListView6.Items[4].SubItems[2]);
Indexnum2:=strtofloat(ListView7.Items[18].SubItems[2]);
if(Indexnum2=0)or(Indexnum1=0)then
begin
ListView7.Items[19].SubItems[2]:='0';
end else
begin
Indexnum:=Indexnum1/Indexnum2;
ListView7.Items[19].SubItems[2]:=ConverterPercent(floattostr(Indexnum));
end;
end;
procedure TBusTradeCSZHYearRepFrm.FormShow(Sender: TObject);
begin
BitBtn4.Enabled:=false;
PageControl1.ActivePage:=TabSheet1;
PageControl1.ActivePage:=TabSheet2;
PageControl1.ActivePage:=TabSheet3;
PageControl1.ActivePage:=TabSheet4;
PageControl1.ActivePage:=TabSheet5;
PageControl1.ActivePage:=TabSheet6;
PageControl1.ActivePage:=TabSheet7;
PageControl1.ActivePage:=TabSheet8;
end;
procedure TBusTradeCSZHYearRepFrm.Insertnum3();
var sqlstr3:string;
numstr1,numstr2,numstr:single;
begin
sqlstr3:='select 指标代码,本年实际 from 公交行业城市规模指标表_z where 城市代码='
+''''+'022'+''''+' and 统计年份='+combobox1.text+' order by 指标代码';
ADOQuery3.Close;
ADOQuery3.SQL.Clear;
ADOQuery3.SQL.Add(sqlstr3);
ADOQuery3.Open;
//添加GZ056指标值
if(ADOQuery3.Locate('指标代码','TO02',[]))then
numstr1:=ADOQuery3.fieldbyname('本年实际').asfloat;
numstr2:=strtofloat(ListView2.items[14].subitems[2]);
if(numstr1=0) or (numstr2=0)then
begin
ListView3.Items[11].subitems[2]:='0';
end else
begin
numstr:=(numstr2/numstr1);
ListView3.items[11].subitems[2]:=ConverterPercent(floattostr(numstr));
end;
//添加GZ083、GZ08指标值
if(ADOQuery3.Locate('指标代码','TO45',[]))then
numstr1:=ADOQuery3.fieldbyname('本年实际').asfloat;
if(ADOQuery3.locate('指标代码','TO46',[]))then
numstr2:=ADOQuery3.fieldbyname('本年实际').asfloat;
if(numstr1=0) or (numstr2=0)then
begin
ListView4.items[15].subitems[2]:='0';
ListView4.items[16].subitems[2]:='0';
end else
begin
numstr:=numstr2/numstr1;
ListView4.items[15].subitems[2]:=ConverterPercent(floattostr(numstr));
ListView4.items[16].subitems[2]:=converter(floattostr(numstr2));
end;
//添加GZ084指标值
if(ADOQuery3.Locate('指标代码','T008',[]))then
numstr1:=ADOQuery3.fieldbyname('本年实际').asfloat;
if(numstr1=0) or (numstr2=0)then
begin
ListView4.items[17].subitems[2]:='0';
end else
begin
numstr:=(numstr2/numstr1);
ListView4.items[17].subitems[2]:=ConverterPercent(floattostr(numstr));
end;
//添加GZ085指标值
numstr1:=strtofloat(ListView4.items[8].subitems[2]);
if(numstr2=0) or(numstr1=0)then
begin
ListView4.items[18].subitems[2]:='0';
end else
begin
numstr:=numstr1/numstr2;
ListView4.items[18].subitems[2]:=ConverterPercent(floattostr(numstr));
end;
//添加GZ101指标值
if(ADOQuery3.locate('指标代码','TO47',[]))then
numstr1:=ADOQuery3.fieldbyname('本年实际').asfloat;
if(numstr1=0)then
begin
ListView5.items[12].subitems[2]:='0';
end else
ListView5.items[12].subitems[2]:=ConverterPercent(floattostr(numstr1));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -