?? bushymonthrepunit.pas
字號(hào):
end;
//BitBtn3Click(Sender);
exit;
end;
ADOQuery1.Next;
end;
}
{
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
sqlString:='select distinct 統(tǒng)計(jì)月份 from 公交行業(yè)統(tǒng)計(jì)月報(bào)_z'
+' where 統(tǒng)計(jì)年份='+LastYear+' and 統(tǒng)計(jì)月份>=1 and 統(tǒng)計(jì)月份<='+StartMon;
ADOQuery1.SQL.Add(sqlString);
ADOQuery1.Open;
MonTime:=IntToStr(ADOQuery1.RecordCount);
}
//------處理本年本月-------
iCityCode:='''' + '022'+'''';
sqlString:='select a.指標(biāo)代碼, max(a.' + sDataType + ') AS 本年本月實(shí)際,'
+' sum(b.' + sDataType + ') AS 本年累計(jì)'
+' from 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS a, 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS b'
+' where a.城市代碼=' + iCityCode + ' and b.城市代碼=a.城市代碼'
+' and a.統(tǒng)計(jì)年份='+ThisYear+' and a.統(tǒng)計(jì)月份='+StartMon
+' and b.統(tǒng)計(jì)年份=a.統(tǒng)計(jì)年份 and b.統(tǒng)計(jì)月份>=1 and b.統(tǒng)計(jì)月份<='+StartMon
+' and a.指標(biāo)代碼=b.指標(biāo)代碼'
+' GROUP BY a.指標(biāo)代碼'
+' ORDER BY a.指標(biāo)代碼';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
{sqlString:='select a.指標(biāo)代碼, max(a.' + sDataType + ') AS 本年本月實(shí)際,'
+' sum(b.' + sDataType + ')/'+MonTime+' AS 本年累計(jì), max(c.' + sDataType + ') AS 去年本月實(shí)際,'
+' sum(d.' + sDataType + ')/'+MonTime+' AS 去年累計(jì),'
+' (本年本月實(shí)際-去年本月實(shí)際)/去年本月實(shí)際*100 AS 本月比較百分比,'
+' (本年累計(jì)-去年累計(jì))/去年累計(jì)*100 AS 累計(jì)比較百分比'
+' from 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS a, 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS b, 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS c, 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS d'
+' where a.城市代碼=' + iCityCode + ' and b.城市代碼=a.城市代碼 and c.城市代碼=a.城市代碼 and d.城市代碼=a.城市代碼'
+' and a.統(tǒng)計(jì)年份='+ThisYear+' and a.統(tǒng)計(jì)月份='+StartMon
+' and b.統(tǒng)計(jì)年份=a.統(tǒng)計(jì)年份 and b.統(tǒng)計(jì)月份>=1 and b.統(tǒng)計(jì)月份<='+StartMon
+' and c.統(tǒng)計(jì)年份='+LastYear+' and c.統(tǒng)計(jì)月份='+StartMon
+' and d.統(tǒng)計(jì)年份=c.統(tǒng)計(jì)年份 and d.統(tǒng)計(jì)月份>=1 and d.統(tǒng)計(jì)月份<='+StartMon
+' and a.指標(biāo)代碼=b.指標(biāo)代碼 and b.指標(biāo)代碼=c.指標(biāo)代碼 and c.指標(biāo)代碼=d.指標(biāo)代碼'
+' GROUP BY a.指標(biāo)代碼'
+' ORDER BY a.指標(biāo)代碼';
}
ADOQuery1.SQL.Add(sqlString);
ADOQuery1.Open;
ADOQuery1.First;
WriteListView(ListView1,20,2,ADOQuery1);
WriteListView(ListView2,20,2,ADOQuery1);
WriteListView(ListView3,21,2,ADOQuery1);
WriteListView(ListView4,20,2,ADOQuery1);
//------處理去年本月-------
sqlString:='select a.指標(biāo)代碼, max(a.' + sDataType + ') AS 本年本月實(shí)際,'
+' sum(b.' + sDataType + ') AS 本年累計(jì)'
+' from 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS a, 公交行業(yè)統(tǒng)計(jì)月報(bào)_z AS b'
+' where a.城市代碼=' + iCityCode + ' and b.城市代碼=a.城市代碼'
+' and a.統(tǒng)計(jì)年份='+LastYear+' and a.統(tǒng)計(jì)月份='+StartMon
+' and b.統(tǒng)計(jì)年份=a.統(tǒng)計(jì)年份 and b.統(tǒng)計(jì)月份>=1 and b.統(tǒng)計(jì)月份<='+StartMon
+' and a.指標(biāo)代碼=b.指標(biāo)代碼'
+' GROUP BY a.指標(biāo)代碼'
+' ORDER BY a.指標(biāo)代碼';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sqlString);
ADOQuery1.Open;
ADOQuery1.First;
WriteListView(ListView1,20,4,ADOQuery1);
WriteListView(ListView2,20,4,ADOQuery1);
WriteListView(ListView3,21,4,ADOQuery1);
WriteListView(ListView4,20,4,ADOQuery1);
//------添加百分比-------
iListView:=ListView1;
for iRow := 0 to 19 do
begin
iListView.Items[iRow].SubItems[3]:=iListView.Items[iROw].SubItems[2];
iListView.Items[iRow].SubItems[5]:=iListView.Items[iROw].SubItems[4];
iListView.Items[iRow].SubItems[6]:=CalculatePercent(iListView.Items[iRow].SubItems[2],iListView.Items[iRow].SubItems[4],100);
iListView.Items[iRow].SubItems[7]:=CalculatePercent(iListView.Items[iRow].SubItems[3],iListView.Items[iRow].SubItems[5],100);
end;
iListView:=ListView2;
for iRow := 0 to 4 do
begin
iListView.Items[iRow].SubItems[3]:=iListView.Items[iROw].SubItems[2];
iListView.Items[iRow].SubItems[5]:=iListView.Items[iROw].SubItems[4];
iListView.Items[iRow].SubItems[6]:=CalculatePercent(iListView.Items[iRow].SubItems[2],iListView.Items[iRow].SubItems[4],100);
iListView.Items[iRow].SubItems[7]:=CalculatePercent(iListView.Items[iRow].SubItems[3],iListView.Items[iRow].SubItems[5],100);
end;
for iRow := 5 to 19 do
begin
iListView.Items[iRow].SubItems[6]:=CalculatePercent(iListView.Items[iRow].SubItems[2],iListView.Items[iRow].SubItems[4],100);
iListView.Items[iRow].SubItems[7]:=CalculatePercent(iListView.Items[iRow].SubItems[3],iListView.Items[iRow].SubItems[5],100);
end;
iListView:=ListView3;
for iRow := 0 to 20 do
begin
iListView.Items[iRow].SubItems[6]:=CalculatePercent(iListView.Items[iRow].SubItems[2],iListView.Items[iRow].SubItems[4],100);
iListView.Items[iRow].SubItems[7]:=CalculatePercent(iListView.Items[iRow].SubItems[3],iListView.Items[iRow].SubItems[5],100);
end;
//----第四頁(yè)特殊處理------
iListView:=ListView4;
iListView.Items[1].SubItems[3]:=SpecDataDiv(iListView.Items[2].SubItems[3],iListView.Items[3].SubItems[3],10000);
iListView.Items[1].SubItems[5]:=SpecDataDiv(iListView.Items[2].SubItems[5],iListView.Items[3].SubItems[5],10000);
iListView.Items[4].SubItems[3]:=SpecDataDiv(iListView.Items[5].SubItems[3],iListView.Items[6].SubItems[3],100);
iListView.Items[4].SubItems[5]:=SpecDataDiv(iListView.Items[5].SubItems[5],iListView.Items[6].SubItems[5],100);
iListView.Items[7].SubItems[3]:=SpecDataDiv(iListView.Items[8].SubItems[3],iListView.Items[9].SubItems[3],100);
iListView.Items[7].SubItems[5]:=SpecDataDiv(iListView.Items[8].SubItems[5],iListView.Items[9].SubItems[5],100);
iListView.Items[10].SubItems[3]:=SpecDataDiv(iListView.Items[11].SubItems[3],iListView.Items[12].SubItems[3],100);
iListView.Items[10].SubItems[5]:=SpecDataDiv(iListView.Items[11].SubItems[5],iListView.Items[12].SubItems[5],100);
iListView.Items[13].SubItems[3]:=SpecDataDiv(ListView3.Items[13].SubItems[3],iListView.Items[13].SubItems[3],1);
iListView.Items[13].SubItems[5]:=SpecDataDiv(ListView3.Items[13].SubItems[5],iListView.Items[13].SubItems[5],1);
for iRow := 0 to 19 do
begin
iListView.Items[iRow].SubItems[6]:=CalculatePercent(iListView.Items[iRow].SubItems[2],iListView.Items[iRow].SubItems[4],100);
iListView.Items[iRow].SubItems[7]:=CalculatePercent(iListView.Items[iRow].SubItems[3],iListView.Items[iRow].SubItems[5],100);
end;
{if ADOQuery1.RecordCount<>0 then
begin
WriteListView(ListView1,20,2,ADOQuery1);
WriteListView(ListView2,20,2,ADOQuery1);
WriteListView(ListView3,21,2,ADOQuery1);
WriteListView(ListView4,20,2,ADOQuery1);
ADOQuery1.First;
for j:=0 to 19 do
begin
ListView1.Items[j].SubItems[2]:=TwoDisim(ADOQuery1.fieldbyname('本年本月實(shí)際').AsString);
ListView1.Items[j].SubItems[3]:=TwoDisim(ADOQuery1.fieldbyname('本年本月實(shí)際').AsString);
ListView1.Items[j].SubItems[4]:=TwoDisim(ADOQuery1.fieldbyname('去年本月實(shí)際').AsString);
ListView1.Items[j].SubItems[5]:=TwoDisim(ADOQuery1.fieldbyname('去年本月實(shí)際').AsString);
ListView1.Items[j].SubItems[6]:=TwoDisim(ADOQuery1.fieldbyname('本月比較百分比').AsString);
ListView1.Items[j].SubItems[7]:=TwoDisim(ADOQuery1.fieldbyname('本月比較百分比').AsString);
ADOQuery1.Next;
end;
for j:=0 to 4 do
begin
ListView2.Items[j].SubItems[2]:=TwoDisim(ADOQuery1.fieldbyname('本年本月實(shí)際').AsString);
ListView2.Items[j].SubItems[3]:=TwoDisim(ADOQuery1.fieldbyname('本年本月實(shí)際').AsString);
ListView2.Items[j].SubItems[4]:=TwoDisim(ADOQuery1.fieldbyname('去年本月實(shí)際').AsString);
ListView2.Items[j].SubItems[5]:=TwoDisim(ADOQuery1.fieldbyname('去年本月實(shí)際').AsString);
ListView2.Items[j].SubItems[6]:=TwoDisim(ADOQuery1.fieldbyname('本月比較百分比').AsString);
ListView2.Items[j].SubItems[7]:=TwoDisim(ADOQuery1.fieldbyname('本月比較百分比').AsString);
ADOQuery1.Next;
end;
iAddFlag:=1;
end;}
BitBtn2.Enabled:=true;
end;
procedure TBusHYMonthRep.BitBtn3Click(Sender: TObject);
var
iRow,iCol:integer;
begin
//Edit4.Text:='';
Edit1.Text:='';
ComboBox1.Text:='';
ComboBox2.Text:='';
if ListView1.Items[0].SubItems.Count>2 then
begin
for iRow:=0 to 19 do
for iCol:=2 to 7 do
ListView1.Items[iRow].SubItems[iCol]:='';
end;
if ListView2.Items[0].SubItems.Count>2 then
begin
for iRow:=0 to 19 do
for iCol:=2 to 7 do
ListView2.Items[iRow].SubItems[iCol]:='';
end;
if ListView3.Items[0].SubItems.Count>2 then
begin
for iRow:=0 to 20 do
for iCol:=2 to 7 do
ListView3.Items[iRow].SubItems[iCol]:='';
end;
if ListView4.Items[0].SubItems.Count>2 then
begin
for iRow:=0 to 19 do
for iCol:=2 to 7 do
ListView4.Items[iRow].SubItems[iCol]:='';
end;
BitBtn2.Enabled:=false;
BusHYMonthRep.Close;
end;
procedure TBusHYMonthRep.BitBtn2Click(Sender: TObject);
var
iRow:Integer;
iCol:Integer;
begin
if (DeviceDetect=0) then
begin
exit;
end;
if(PrnInfoFrm.ShowModal<>mrOK)then
begin
exit;
end;
PrintInit(ExtractFilePath(application.exeName),'BusTradeCountMonTab');
for iRow:=0 to 19 do
begin
for iCol:=2 to 7 do
WriteCell(iRow+8,iCol+2,ListView1.Items[iRow].SubItems[iCol]);
WriteCell(4,1,'匯總單位:'+Edit1.Text);
WriteCell(28,1,'統(tǒng)計(jì)負(fù)責(zé)人:'+PrnInfoFrm.StatMainPerson);
WriteCell(28,6,PrnInfoFrm.StatPerson);
WriteCell(28,10,DateToStr(PrnInfoFrm.StatDate));
WriteCell(3,5,ComboBox1.Text+'年 '+ComboBox2.Text+'月');
end;
for iRow:=0 to 19 do
begin
for iCol:=2 to 7 do
WriteCell(iRow+8,iCol+12,ListView2.Items[iRow].SubItems[iCol]);
WriteCell(4,11,'匯總單位:'+Edit1.Text);
WriteCell(28,11,'統(tǒng)計(jì)負(fù)責(zé)人:'+PrnInfoFrm.StatMainPerson);
WriteCell(28,16,PrnInfoFrm.StatPerson);
WriteCell(28,20,DateToStr(PrnInfoFrm.StatDate));
WriteCell(3,15,ComboBox1.Text+'年 '+ComboBox2.Text+'月');
end;
for iRow:=0 to 20 do
begin
for iCol:=2 to 7 do
WriteCell(iRow+38,iCol+2,ListView3.Items[iRow].SubItems[iCol]);
WriteCell(34,1,'匯總單位:'+Edit1.Text);
WriteCell(59,1,'統(tǒng)計(jì)負(fù)責(zé)人:'+PrnInfoFrm.StatMainPerson);
WriteCell(59,6,PrnInfoFrm.StatPerson);
WriteCell(59,10,DateToStr(PrnInfoFrm.StatDate));
WriteCell(33,5,ComboBox1.Text+'年 '+ComboBox2.Text+'月');
end;
for iRow:=0 to 19 do
begin
for iCol:=2 to 7 do
WriteCell(iRow+38,iCol+12,ListView4.Items[iRow].SubItems[iCol]);
WriteCell(34,11,'匯總單位:'+Edit1.Text);
WriteCell(59,11,'統(tǒng)計(jì)負(fù)責(zé)人:'+PrnInfoFrm.StatMainPerson);
WriteCell(59,16,PrnInfoFrm.StatPerson);
WriteCell(59,20,DateToStr(PrnInfoFrm.StatDate));
WriteCell(33,15,ComboBox1.Text+'年 '+ComboBox2.Text+'月');
end;
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
procedure TBusHYMonthRep.FormShow(Sender: TObject);
begin
iAddFlag:=0;
iExistFlag:=0;
InitListview(ListView1,20,6);
InitListview(ListView2,20,6);
InitListview(ListView3,21,6);
InitListview(LIstView4,20,6);
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -