📄 bustracityjllrunit.pas
字号:
unit BusTraCityJLLRUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, ComCtrls, ExtCtrls;
type
TBusTraCityJLLRFm = class(TForm)
Panel2: TPanel;
Panel5: TPanel;
ListView1: TListView;
Panel1: TPanel;
Panel4: TPanel;
Label6: TLabel;
Edit1: TEdit;
Panel3: TPanel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Panel6: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
ADOQuery1: TADOQuery;
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
BusTraCityJLLRFm: TBusTraCityJLLRFm;
implementation
uses BusTradeDataModuleUnit, PrintInfoUnit, PrintProc;
{$R *.dfm}
procedure TBusTraCityJLLRFm.BitBtn3Click(Sender: TObject);
begin
Close;
end;
procedure TBusTraCityJLLRFm.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,24,0,1,6);
BitBtn2.Enabled:=false;
exit;
end;
{数据写入ListView}
for iRow:=0 to ADOQuery1.RecordCount-1 do
begin
if (iRow>=0) and (iRow<=24) then
begin
ListView1.Items[iRow].SubItems[2]:= Converter(ADOQuery1.FieldByName('本年实际').AsString);
end
else if (iRow>=25) and (iRow<=48) then
begin
ListView1.Items[iRow-25].SubItems[6]:= Converter(ADOQuery1.FieldByName('本年实际').AsString);
end;
end;
BitBtn2.Enabled:=true;
end;
procedure TBusTraCityJLLRFm.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),'BusCityJLTab');
for iRecNum := 0 to 48 do
begin
if (iRecNum>=0) and (iRecNum<=24) then
begin
iRow:=iRecNum+4;
iCol:=4;
WriteCell(iRow,iCol,ListView1.Items[iRecNum].SubItems[2]);
end
else if (iRecNum>=25) and (iRecNum<=48) then
begin
iRow:=iRecNum-21;
iCol:=8;
WriteCell(iRow,iCol,ListView1.Items[iRecNum-25].SubItems[6]);
end;
end;
WriteCell(2,4,iYear+ ' 年');
WriteCell(29,1,'统计负责人:' + PrnInfoFrm.StatMainPerson);
WriteCell(29,4,'统计人员:' + PrnInfoFrm.StatPerson);
WriteCell(29,6,'填报日期:'+ DateToStr(PrnInfoFrm.StatDate));
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -