📄 bustracityscaleunit.pas
字号:
unit BusTraCityScaleUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, StdCtrls, Buttons, DB, ADODB;
type
TBusTraCityScaleFm = class(TForm)
Panel2: TPanel;
Panel1: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Label6: TLabel;
Edit1: TEdit;
Panel5: TPanel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Panel6: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
ListView1: TListView;
ADOQuery1: TADOQuery;
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
BusTraCityScaleFm: TBusTraCityScaleFm;
implementation
uses BusTradeDataModuleUnit, PrintProc, PrintInfoUnit;
{$R *.dfm}
procedure TBusTraCityScaleFm.BitBtn3Click(Sender: TObject);
begin
ClearData(ListView1,24,0,1,2);
ClearData(ListView1,25,0,1,6);
Close;
end;
procedure TBusTraCityScaleFm.BitBtn1Click(Sender: TObject);
var
iYear:String;
sqlString:String;
iRow:integer;
begin
iYear:=ComboBox1.Text;
if ((Length(iYear) <> 4) or (iYear<'1990') or (iYear >'2030')) then
begin
ShowMessage('请输入在时间范围1990-2030内的合法年份!');
exit;
end;
{查询}
sqlString:= 'select 指标代码,本年实际 from 公交行业城市规模指标表_z where '
+ ' 统计年份=' + iYear + ' and 城市代码=' + '''' + '022' + ''''
+ ' order by 指标代码';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sqlString);
ADOQuery1.Open;
if ADOQuery1.RecordCount=0 then
begin
ShowMessage('不存在' + iYear + '年的城市规模指标数据,请先录入!');
ClearData(ListView1,25,0,1,2);
ClearData(ListView1,25,0,1,6);
BitBtn2.Enabled:=false;
exit;
end;
{数据写入ListView}
for iRow:=0 to ADOQuery1.RecordCount-1 do
begin
if (iRow>=0) and (iRow<=23) then
begin
ListView1.Items[iRow].SubItems[2]:= Converter(ADOQuery1.FieldByName('本年实际').AsString);
end
else if (iRow>=24) and (iRow<=48) then
begin
ListView1.Items[iRow-24].SubItems[6]:= Converter(ADOQuery1.FieldByName('本年实际').AsString);
end;
ADOQuery1.Next;
end;
BitBtn2.Enabled:=true;
end;
procedure TBusTraCityScaleFm.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),'BusCityScaleTab');
for iRecNum := 0 to 23 do
begin
iRow:=iRecNum+8;
iCol:=4;
WriteCell(iRow,iCol,ListView1.Items[iRecNum].SubItems[2]);
end;
for iRecNum := 0 to 24 do
begin
iRow:=iRecNum+8;
iCol:=8;
WriteCell(iRow,iCol,ListView1.Items[iRecNum].SubItems[6]);
end;
WriteCell(3,4,iYear+ ' 年');
WriteCell(4,1,'填报单位:' + Edit1.text);
WriteCell(33,1,'统计负责人:' + PrnInfoFrm.StatMainPerson);
WriteCell(33,5,PrnInfoFrm.StatPerson);
WriteCell(33,8,DateToStr(PrnInfoFrm.StatDate));
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -