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

📄 hymonthcompareunit.~pas

📁 公交行业的管理系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit HYMonthCompareUnit;

interface

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

type
  THYMonthCompareFrm = class(TForm)
    ADOQuery3: TADOQuery;
    ADOQuery6: TADOQuery;
    Panel1: TPanel;
    Panel2: TPanel;
    Label7: TLabel;
    Label9: TLabel;
    Label8: TLabel;
    Label3: TLabel;
    ComboBox2: TComboBox;
    ComboBox1: TComboBox;
    ComboBox5: TComboBox;
    Panel11: TPanel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label5: TLabel;
    ComboBox4: TComboBox;
    ComboBox3: TComboBox;
    ComboBox6: TComboBox;
    Panel12: TPanel;
    ComboBox7: TComboBox;
    Label1: TLabel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    ListView1: TListView;
    TabSheet2: TTabSheet;
    ListView2: TListView;
    TabSheet3: TTabSheet;
    ListView3: TListView;
    TabSheet4: TTabSheet;
    ListView4: TListView;
    Panel3: TPanel;
    Label14: TLabel;
    Panel4: TPanel;
    Panel5: TPanel;
    BitBtn3: TBitBtn;
    BBPrint2: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BBPrint2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure ComboBox5Change(Sender: TObject);
    procedure ComboBox4Change(Sender: TObject);
    procedure ComboBox3Change(Sender: TObject);
    procedure ComboBox6Change(Sender: TObject);
    procedure ComboBox7Change(Sender: TObject);
  private
    { Private declarations }
  public
    procedure IninLView(LView:TListView;sRow,eRow,sCol,eCol:Integer);
    procedure ClearLView(LView:TListView;sRow,eRow,sCol,eCol:Integer);
    procedure WriteListView(LView:TListView;Row:Integer;Source:TADOQuery);
    procedure WritePercent(LView:TListView;Row:Integer);
  end;

var
  HYMonthCompareFrm: THYMonthCompareFrm;

implementation
 uses {Code,} PrintInfoUnit,
  BusTradeDataModuleUnit, PrintProc2;

{$R *.dfm}

procedure THYMonthCompareFrm.WriteListView(LView:TListView;Row:Integer;Source:TADOQuery);
var
        i:integer;
begin
        for i:=0 to Row-1 do
        begin
                if LView.Items[i].SubItems.Count<3 then
                begin
                        if (Source.FieldByName('报告期实际').AsString<>'') then
                                LView.Items[i].SubItems.Add(Converter(Source.fieldbyname('报告期实际').AsFloat))
                        else
                                LView.Items[i].SubItems.Add('0');
                        if (Source.FieldByName('基期实际').AsString<>'') then
                                LView.Items[i].SubItems.Add(Converter(Source.fieldbyname('基期实际').AsFloat))
                        else
                                LView.Items[i].SubItems.Add('0');
                        if (Source.fieldbyname('比较量').AsString<>'') then
                                LView.Items[i].SubItems.Add(Converter(Source.fieldbyname('比较量').AsFloat))
                        else
                                LView.Items[i].SubItems.Add('0');
                        LView.Items[i].SubItems.Add('0');
                        Source.Next;
                end
                else
                begin
                        if (Source.FieldByName('报告期实际').AsString<>'') then
                                LView.Items[i].SubItems[2]:=Converter(Source.fieldbyname('报告期实际').AsFloat)
                        else
                                LView.Items[i].SubItems[2]:='0';
                        if (Source.FieldByName('基期实际').AsString<>'') then
                                LView.Items[i].SubItems[3]:=Converter(Source.fieldbyname('基期实际').AsFloat)
                        else
                                LView.Items[i].SubItems[3]:='0';
                        if (Source.fieldbyname('比较量').AsString<>'') then
                                LView.Items[i].SubItems[4]:=Converter(Source.fieldbyname('比较量').AsFloat)
                        else
                                LView.Items[i].SubItems[4]:='0';
                        LView.Items[i].SubItems[5]:='0';
                        Source.Next;
                end;
        end;
end;

procedure THYMonthCompareFrm.WritePercent(LView:TListView;Row:Integer);
VAR
        IDIV,IDIVD:single;
        i:integer;
begin
        for i:=0 to Row-1 do
        begin
                if LView.Items[i].SubItems[3]<>'0' then
                begin
                        iDiv:=StrToFloat(LView.Items[i].SubItems[4]);
                        iDivD:=StrToFloat(LView.Items[i].SubItems[3]);
                        LView.Items[i].SubItems[5]:=ConverterPercent(FloatToStr(iDiv/iDivD*100));
                end else LView.Items[i].SubItems[5]:='0';
        end;
end;

procedure THYMonthCompareFrm.IninLView(LView:TListView;sRow,eRow,sCol,eCol:Integer);
var
        i,j:Integer;
begin
        for i:=sRow to eRow do
                for j:=sCol to eCol do
                        LView.Items[i].SubItems.Add('0');
end;

procedure THYMonthCompareFrm.ClearLView(LView:TListView;sRow,eRow,sCol,eCol:Integer);
var
        i,j:Integer;
begin
        for i:=sRow to eRow do
                for j:=sCol to eCol do
                        LView.Items[i].SubItems[j]:='0';
end;

procedure THYMonthCompareFrm.BBPrint2Click(Sender: TObject);{打印按钮}
var
        iRow:Integer;
        iCol:Integer;
begin
        if (DeviceDetect()=0) then
        begin
                exit;
        end;

        if PrnInfoFrm.ShowModal=mrOK then
        begin

                OpenForEdit(ExtractFilePath(application.exeName),'BusTradeSelfMonComTab');

                for iRow:=0 to 19 do
                begin
                        for iCol:=2 to 5 do
                                WriteCellForEdit(iRow+8,iCol+2,ListView1.Items[iRow].SubItems[iCol]);
                end;

                for iRow:=0 to 19 do
                begin
                        for iCol:=2 to 5 do
                                WriteCellForEdit(iRow+8,iCol+10,ListView2.Items[iRow].SubItems[iCol]);
                end;

                for iRow:=0 to 20 do
                begin
                        for iCol:=2 to 5 do
                                WriteCellForEdit(iRow+38,iCol+2,ListView3.Items[iRow].SubItems[iCol]);
                end;

                for iRow:=0 to 19 do
                begin
                        for iCol:=2 to 5 do
                                WriteCellForEdit(iRow+38,iCol+10,ListView2.Items[iRow].SubItems[iCol]);
                end;

                WriteCellForEdit(28,1,'统计负责人:'+PrnInfoFrm.StatMainPerson);
                WriteCellForEdit(28,5,PrnInfoFrm.StatPerson);
                WriteCellForEdit(28,8,DateToStr(PrnInfoFrm.StatDate));

                WriteCellForEdit(28,9,'统计负责人:'+PrnInfoFrm.StatMainPerson);
                WriteCellForEdit(28,13,PrnInfoFrm.StatPerson);
                WriteCellForEdit(28,16,DateToStr(PrnInfoFrm.StatDate));

                WriteCellForEdit(59,1,'统计负责人:'+PrnInfoFrm.StatMainPerson);
                WriteCellForEdit(59,5,PrnInfoFrm.StatPerson);
                WriteCellForEdit(59,8,DateToStr(PrnInfoFrm.StatDate));

                WriteCellForEdit(59,9,'统计负责人:'+PrnInfoFrm.StatMainPerson);
                WriteCellForEdit(59,13,PrnInfoFrm.StatPerson);
                WriteCellForEdit(59,16,DateToStr(PrnInfoFrm.StatDate));

                WriteCellForEdit(3,4,'报告期:'+ComboBox1.Text+'年'+ComboBox2.Text+'月至'+ComboBox5.Text+'月  基期:'+ComboBox4.Text+'年'+ComboBox3.Text+'月至'+ComboBox6.Text+'月');
                WriteCellForEdit(3,12,'报告期:'+ComboBox1.Text+'年'+ComboBox2.Text+'月至'+ComboBox5.Text+'月  基期:'+ComboBox4.Text+'年'+ComboBox3.Text+'月至'+ComboBox6.Text+'月');
                WriteCellForEdit(33,4,'报告期:'+ComboBox1.Text+'年'+ComboBox2.Text+'月至'+ComboBox5.Text+'月  基期:'+ComboBox4.Text+'年'+ComboBox3.Text+'月至'+ComboBox6.Text+'月');
                WriteCellForEdit(33,12,'报告期:'+ComboBox1.Text+'年'+ComboBox2.Text+'月至'+ComboBox5.Text+'月  基期:'+ComboBox4.Text+'年'+ComboBox3.Text+'月至'+ComboBox6.Text+'月');

                PrintExcelEdit;
        end;
end;
procedure THYMonthCompareFrm.BitBtn3Click(Sender: TObject);
var
        iBaseYear:String;
        iComYear:String;
        iBaseMonth1,iBaseMonth2,BaseMonth:String;
        iComMonth1,iComMonth2,ComMonth:String;
        sqlString:String;
        Result:single;
        IDiv,IDivD:single;
        j:integer;
        scmode:String;
        temp:String;
begin
        ClearLView(ListView1,0,19,2,5);
        ClearLView(ListView2,0,19,2,5);
        ClearLView(ListView3,0,20,2,5);
        ClearLView(ListView4,0,19,2,5);
        BBPrint2.Enabled:=false;

        temp:='';
        iBaseYear:=ComboBox4.Text;
        iBaseMonth1:=ComboBox3.Text;
        iBaseMonth2:=ComboBox6.Text;
        iComYear:=ComboBox1.Text;
        iComMonth1:=ComboBox2.Text;
        iComMonth2:=ComboBox5.Text;
        scmode:=ComboBox7.Text;

        if (ComboBox1.Text='') or (ComboBox4.Text='') or (ComboBox2.Text='') or(ComboBox3.Text='') or (ComboBox5.Text='') or (ComboBox5.Text='') then
        begin
            showmessage('请输入需要比较的年、月!');
            exit;
        end;
        if (StrToInt(ComboBox2.Text)>StrToInt(ComboBox5.Text)) then
        begin
                showmessage('对不起!报告期的起始月份不能大于终止月份!请重新选择!');
                exit;
        end;
        if (StrToInt(ComboBox3.Text)>StrToInt(ComboBox6.Text)) then
        begin
                showmessage('对不起!基期的起始月份不能大于终止月份!请重新选择!');
                exit;
        end;
        if scmode='' then
        begin
                showmessage('请选择比较生成数据,还是比较测算数据!');
                exit;
        end;
        if (length(ComboBox1.Text)<>4) or (ComboBox1.Text>'3000') or (ComboBox1.Text<'1900') then
        begin
                showmessage('对不起!报告期年份非法!请重新选择!');
                exit;
        end;
        if (length(ComboBox4.Text)<>4) or (ComboBox4.Text>'3000') or (ComboBox4.Text<'1900') then
        begin
                showmessage('对不起!基期年份非法!请重新选择!');
                exit;
        end;
//判断报告期
        ADOQuery6.Close;
        ADOQuery6.SQL.Clear;
        ADOQuery6.SQL.Add('select * from 公交行业统计月报_z where 统计年份='+ComboBox1.Text+
                           ' and 统计月份='+ComboBox5.Text+' and 城市代码='+''''+'022'+'''');
        ADOQuery6.Open;
        if (ADOQuery6.RecordCount=0) then
        begin
                showmessage('对不起!公交行业在'+ComboBox1.Text+'年'+ComboBox5.Text+'月没有数据!请重新选择报告期!');
                exit;
        end;
        ADOQuery6.Close;
        ADOQuery6.SQL.Clear;
        ADOQuery6.SQL.Add('select * from 公交行业统计月报_z where 统计年份='+ComboBox1.Text+
                           ' and 统计月份>='+ComboBox2.Text+' and 统计月份<='+ComboBox5.Text
                          +' and 城市代码='+''''+'022'+'''');
        ADOQuery6.Open;
        if ADOQuery6.RecordCount=0 then
        begin
            showmessage('公交行业在'+ComboBox1.Text+'年'+ComboBox2.Text+'月至'+ComboBox5.Text+'月的数据为空!请重新选择报告期时间!');
            exit;
        end;
        ADOQuery6.Close;
        ADOQuery6.SQL.Clear;

⌨️ 快捷键说明

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