⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bustracityjlunit.pas

📁 公交行业的管理系统
💻 PAS
字号:
unit BusTraCityJLUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, DB, ADODB;

type
  TBusTraCityJLFm = 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
  BusTraCityJLFm: TBusTraCityJLFm;

implementation

uses BusTradeDataModuleUnit, PrintInfoUnit, PrintProc;

{$R *.dfm}

procedure TBusTraCityJLFm.BitBtn3Click(Sender: TObject);
begin
        Close;
end;

procedure TBusTraCityJLFm.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;

                ADOQuery1.next;
         end;
         BitBtn2.Enabled:=true;

end;

procedure TBusTraCityJLFm.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 24 do
        begin
                iRow:=iRecNum+8;
                iCol:=4;
                WriteCell(iRow,iCol,ListView1.Items[iRecNum].SubItems[2]);
        end;

        for iRecNum := 0 to 23 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,4,'统计人员:' + PrnInfoFrm.StatPerson);
        WriteCell(33,6,'填报日期:'+ DateToStr(PrnInfoFrm.StatDate));

        PrintExcelShow;
        PrintPreview;
        //PrintOut;
        CloseActiveBook;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -