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

📄 datacompare.pas

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

interface

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

type
  TCompareForm = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Panel3: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Code1: TEdit;
    Year1: TEdit;
    ListView1: TListView;
    TabSheet2: TTabSheet;
    Panel4: TPanel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Edit1: TEdit;
    Year2: TEdit;
    TabSheet3: TTabSheet;
    Panel5: TPanel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Code3: TEdit;
    Year3: TEdit;
    Label1: TLabel;
    Label20: TLabel;
    ListView2: TListView;
    ListView3: TListView;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function Check():boolean;
  end;

var
  CompareForm: TCompareForm;

implementation

uses DataBaseConnection;

{$R *.dfm}
function TCompareForm.Check():boolean;
begin
        if (ComboBox1.ItemIndex > ComboBox2.ItemIndex)
        then    Check := true
        else    Check := false;        
end;

procedure TCompareForm.BitBtn2Click(Sender: TObject);
begin
        CompareForm.Close;
end;

procedure TCompareForm.BitBtn1Click(Sender: TObject);
var
        itemindex : integer;
        sqlstr1,sqlstr2,ss ,ss2: string;
        num1,num2 : integer;
        ch : single;
begin
        if (Messagebox(self.Handle,'生成分析表时间可能较长,请等候!', '提示', mb_OKCancel ) = IDCancel)
        then    exit;

        ComboBox1.Enabled := false;
        ComboBox2.Enabled := false;
        BitBtn1.Enabled := false;
        BitBtn2.Enabled := false;
        //ShowMessage(ComboBox1.Text);   报告期
        //ShowMessage(ComboBox2.Text);   基期
        sqlstr1 := 'select * from 公交行业名录统计年报表 where 统计年份='+ComboBox1.Text+ ' and 记录类型='+''''+'合计'+'''';
        sqlstr2 := 'select * from 公交行业名录统计年报表 where 统计年份='+ComboBox2.Text+ ' and 记录类型='+''''+'合计'+'''';
        AdoQuery1.Close;
        AdoQuery1.SQL.Clear;
        AdoQuery1.SQL.Add(sqlstr1);
        AdoQuery1.Open;
        AdoQuery2.Close;
        AdoQuery2.SQL.Clear;
        AdoQuery2.SQL.Add(sqlstr2);
        AdoQuery2.Open;

        for itemindex := 0 to 18 do
        begin
                ss := listview1.Items.Item[itemindex].SubItems[0];
                num1 := AdoQuery1.fieldbyname(ss).AsInteger;
                num2 := AdoQuery2.fieldbyname(ss).AsInteger;
                ListView1.Items.Item[itemindex].SubItems[1] := IntToStr(num1);
                ListView1.Items.Item[itemindex].SubItems[2] := IntToStr(num2);
                ListView1.Items.Item[itemindex].SubItems[3] := IntToStr(num1-num2);
                if ((num1<>0) and (num2<>0))
                then
                begin
                        ss2 := FloatToStr((num1-num2)/num2);
                        ListView1.Items.Item[itemindex].SubItems[4] := copy(ss2,0,5);
                end;
                if ((num1<>0) and (num2 = 0))
                then
                        ListView1.Items.Item[itemindex].SubItems[4] := '1';
                if ((num1 = 0) and (num2<>0))
                then
                        ListView1.Items.Item[itemindex].SubItems[4] := '-1';
                if ((num1 = 0) and (num2 = 0))
                then
                        ListView1.Items.Item[itemindex].SubItems[4] := '0';
        end;
        for itemindex := 0 to 20 do
        begin
                ss := listview2.Items.Item[itemindex].SubItems[0];
                num1 := AdoQuery1.fieldbyname(ss).AsInteger;
                num2 := AdoQuery2.fieldbyname(ss).AsInteger;
                ListView2.Items.Item[itemindex].SubItems[1] := IntToStr(num1);
                ListView2.Items.Item[itemindex].SubItems[2] := IntToStr(num2);
                ListView2.Items.Item[itemindex].SubItems[3] := IntToStr(num1-num2);
                if ((num1<>0) and (num2<>0))
                then
                begin
                        ss2 := FloatToStr((num1-num2)/num2);
                        ListView2.Items.Item[itemindex].SubItems[4] := copy(ss2,0,5);
                end;
                if ((num1<>0) and (num2 = 0))
                then
                        ListView2.Items.Item[itemindex].SubItems[4] := '1';
                if ((num1 = 0) and (num2<>0))
                then
                        ListView2.Items.Item[itemindex].SubItems[4] := '-1';
                if ((num1 = 0) and (num2 = 0))
                then
                        ListView2.Items.Item[itemindex].SubItems[4] := '0';
        end;
        for itemindex := 0 to 11 do
        begin
                ss := listview3.Items.Item[itemindex].SubItems[0];
                num1 := AdoQuery1.fieldbyname(ss).AsInteger;
                num2 := AdoQuery2.fieldbyname(ss).AsInteger;
                ListView3.Items.Item[itemindex].SubItems[1] := IntToStr(num1);
                ListView3.Items.Item[itemindex].SubItems[2] := IntToStr(num2);
                ListView3.Items.Item[itemindex].SubItems[3] := IntToStr(num1-num2);
                if ((num1<>0) and (num2<>0))
                then
                begin
                        ss2 := FloatToStr((num1-num2)/num2);
                        ListView3.Items.Item[itemindex].SubItems[4] := copy(ss2,0,5);
                end;
                if ((num1<>0) and (num2 = 0))
                then
                        ListView3.Items.Item[itemindex].SubItems[4] := '1';
                if ((num1 = 0) and (num2<>0))
                then
                        ListView3.Items.Item[itemindex].SubItems[4] := '-1';
                if ((num1 = 0) and (num2 = 0))
                then
                        ListView3.Items.Item[itemindex].SubItems[4] := '0';
        end;

        sqlstr1 := 'select MNS03 as MNS54,MNS04 as MNS55,MNS05 as MNS56,MNS06 as MNS57,MNS03+MNS04+MNS05+MNS06 as MNS53 from 公交行业名录统计年报表 where 统计年份='+ComboBox1.Text+ ' and 记录类型='+''''+'企业注册资本金'+'''';
        sqlstr2 := 'select MNS03 as MNS54,MNS04 as MNS55,MNS05 as MNS56,MNS06 as MNS57,MNS03+MNS04+MNS05+MNS06 as MNS53 from 公交行业名录统计年报表 where 统计年份='+ComboBox2.Text+ ' and 记录类型='+''''+'企业注册资本金'+'''';
        AdoQuery1.Close;
        AdoQuery1.SQL.Clear;
        AdoQuery1.SQL.Add(sqlstr1);
        AdoQuery1.Open;
        AdoQuery2.Close;
        AdoQuery2.SQL.Clear;
        AdoQuery2.SQL.Add(sqlstr2);
        AdoQuery2.Open;
        for itemindex := 12 to 16 do
        begin
                ss := listview3.Items.Item[itemindex].SubItems[0];
                num1 := AdoQuery1.fieldbyname(ss).AsInteger;
                num2 := AdoQuery2.fieldbyname(ss).AsInteger;
                ListView3.Items.Item[itemindex].SubItems[1] := IntToStr(num1);
                ListView3.Items.Item[itemindex].SubItems[2] := IntToStr(num2);
                ListView3.Items.Item[itemindex].SubItems[3] := IntToStr(num1-num2);
                if ((num1<>0) and (num2<>0))
                then
                begin
                        ss2 := FloatToStr((num1-num2)/num2);
                        ListView3.Items.Item[itemindex].SubItems[4] := copy(ss2,0,5);
                end;
                if ((num1<>0) and (num2 = 0))
                then
                        ListView3.Items.Item[itemindex].SubItems[4] := '1';
                if ((num1 = 0) and (num2<>0))
                then
                        ListView3.Items.Item[itemindex].SubItems[4] := '-1';
                if ((num1 = 0) and (num2 = 0))
                then
                        ListView3.Items.Item[itemindex].SubItems[4] := '0';
        end;

        ComboBox1.Enabled := true;
        ComboBox2.Enabled := true;
        BitBtn1.Enabled := true;
        BitBtn2.Enabled := true;
end;

end.

⌨️ 快捷键说明

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