📄 bustrazhyearlrunit.pas
字号:
end;
sqlString:= ' select a.指标代码,a.测算值 as 全年实际,b.测算值 as 去年同期,(全年实际-去年同期)/去年同期*100 as 比较'
+ ' from 公交行业综合年报_z a,公交行业综合年报_z b'
+ ' where a.统计年份=' + iYear + ' and b.统计年份=' + iLYear
+ ' and b.指标代码=a.指标代码 order by a.指标代码';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sqlString);
ADOQuery1.Open;
ADOQuery1.First;
{数据写入ListView}
for iRow:=0 to ADOQuery1.RecordCount-1 do
begin
if (iRow>=0) and (iRow<=21) then
begin
ListView1.Items[iRow].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView1.Items[iRow].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView1.Items[iRow].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=22) and (iRow<=43) then
begin
ListView2.Items[iRow-22].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView2.Items[iRow-22].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView2.Items[iRow-22].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=44) and (iRow<=65) then
begin
ListView3.Items[iRow-44].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView3.Items[iRow-44].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView3.Items[iRow-44].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=66) and (iRow<=87) then
begin
ListView4.Items[iRow-66].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView4.Items[iRow-66].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView4.Items[iRow-66].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=88) and (iRow<=109) then
begin
ListView5.Items[iRow-88].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView5.Items[iRow-88].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView5.Items[iRow-88].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=110) and (iRow<=132) then
begin
ListView6.Items[iRow-110].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView6.Items[iRow-110].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView6.Items[iRow-110].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=133) and (iRow<=155) then
begin
ListView7.Items[iRow-133].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView7.Items[iRow-133].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView7.Items[iRow-133].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end
else if (iRow>=156) and (iRow<=178) then
begin
ListView8.Items[iRow-156].SubItems[2]:= Converter(ADOQuery1.FieldByName('全年实际').AsString);
ListView8.Items[iRow-156].SubItems[3]:= Converter(ADOQuery1.FieldByName('去年同期').AsString);
ListView8.Items[iRow-156].SubItems[4]:= Converter(ADOQuery1.FieldByName('比较').AsString);
end;
ADOQuery1.Next;
end;
BitBtn2.Enabled:=true;
end;
procedure TBusTraZHYearLRFm.FormCreate(Sender: TObject);
begin
iExistFlag:=0;
end;
procedure TBusTraZHYearLRFm.BitBtn3Click(Sender: TObject);
begin
Close;
end;
procedure TBusTraZHYearLRFm.BitBtn2Click(Sender: TObject);
var
iRow:Integer;
iCol:Integer;
iRecNum:Integer;
iYear:String;
begin
{判断打印机状态}
if (DeviceDetect=0) then
begin
exit;
end;
iYear:=ComboBox1.Text;
{获得填表人等数据}
if(PrnInfoFrm.ShowModal<>mrOK)then
begin
exit;
end;
PrintInit(ExtractFilePath(Application.ExeName),'BusTradeZHYearTab');
iCol:=4;
for iRecNum := 0 to 178 do
begin
if (iRecNum>=0) and (iRecNum<=21) then
begin
iRow:=iRecNum+7;
WriteCell(iRow,iCol,ListView1.Items[iRecNum].SubItems[2]);
WriteCell(iRow,iCol+1,ListView1.Items[iRecNum].SubItems[3]);
WriteCell(iRow,iCol+2,ListView1.Items[iRecNum].SubItems[4]);
end
else if (iRecNum>=22) and (iRecNum<=43) then
begin
iRow:=iRecNum+14;
WriteCell(iRow,iCol,ListView2.Items[iRecNum-22].SubItems[2]);
WriteCell(iRow,iCol+1,ListView2.Items[iRecNum-22].SubItems[3]);
WriteCell(iRow,iCol+2,ListView2.Items[iRecNum-22].SubItems[4]);
end
else if (iRecNum>=44) and (iRecNum<=65) then
begin
iRow:=iRecNum+21;
WriteCell(iRow,iCol,ListView3.Items[iRecNum-44].SubItems[2]);
WriteCell(iRow,iCol+1,ListView3.Items[iRecNum-44].SubItems[3]);
WriteCell(iRow,iCol+2,ListView3.Items[iRecNum-44].SubItems[4]);
end
else if (iRecNum>=66) and (iRecNum<=87) then
begin
iRow:=iRecNum+28;
WriteCell(iRow,iCol,ListView4.Items[iRecNum-66].SubItems[2]);
WriteCell(iRow,iCol+1,ListView4.Items[iRecNum-66].SubItems[3]);
WriteCell(iRow,iCol+2,ListView4.Items[iRecNum-66].SubItems[4]);
end
else if (iRecNum>=88) and (iRecNum<=109) then
begin
iRow:=iRecNum+35;
WriteCell(iRow,iCol,ListView5.Items[iRecNum-88].SubItems[2]);
WriteCell(iRow,iCol+1,ListView5.Items[iRecNum-88].SubItems[3]);
WriteCell(iRow,iCol+2,ListView5.Items[iRecNum-88].SubItems[4]);
end
else if (iRecNum>=110) and (iRecNum<=132) then
begin
iRow:=iRecNum+41;
WriteCell(iRow,iCol,ListView6.Items[iRecNum-110].SubItems[2]);
WriteCell(iRow,iCol+1,ListView6.Items[iRecNum-110].SubItems[3]);
WriteCell(iRow,iCol+2,ListView6.Items[iRecNum-110].SubItems[4]);
end
else if (iRecNum>=133) and (iRecNum<=155) then
begin
iRow:=iRecNum+47;
WriteCell(iRow,iCol,ListView7.Items[iRecNum-133].SubItems[2]);
WriteCell(iRow,iCol+1,ListView7.Items[iRecNum-133].SubItems[3]);
WriteCell(iRow,iCol+2,ListView7.Items[iRecNum-133].SubItems[4]);
end
else if (iRecNum>=156) and (iRecNum<=178) then
begin
iRow:=iRecNum+53;
WriteCell(iRow,iCol,ListView8.Items[iRecNum-156].SubItems[2]);
WriteCell(iRow,iCol+1,ListView8.Items[iRecNum-156].SubItems[3]);
WriteCell(iRow,iCol+2,ListView8.Items[iRecNum-156].SubItems[4]);
end;
case iRecNum of
0,22,44,66,88:
begin
WriteCell(iRow-4,1,'汇总单位:客管办');
WriteCell(iRow-5,4,iYear+ ' 年');
WriteCell(iRow+22,1,'统计负责人:' + PrnInfoFrm.StatMainPerson);
WriteCell(iRow+22,4,'统计人员:' + PrnInfoFrm.StatPerson);
WriteCell(iRow+22,6,'填报日期:' + DateToStr(PrnInfoFrm.StatDate));
end;
110,133,156:
begin
WriteCell(iRow-4,1,'汇总单位:客管办');
WriteCell(iRow-4,4,iYear+ ' 年');
WriteCell(iRow+23,1,'统计负责人:' + PrnInfoFrm.StatMainPerson);
WriteCell(iRow+23,4,'统计人员:' + PrnInfoFrm.StatPerson);
WriteCell(iRow+23,6,'填报日期:' + DateToStr(PrnInfoFrm.StatDate));
end;
else ;
end;
end;
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -