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

📄 hymonthcompareunit.pas

📁 公交行业的管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        ADOQuery6.SQL.Add('select distinct 统计月份 from 公交行业统计月报_z where 统计年份='+ComboBox1.Text+
                           ' and 统计月份>='+ComboBox2.Text+' and 统计月份<='+ComboBox5.Text
                          +' and 城市代码='+''''+'022'+'''');
        ADOQuery6.Open;

        ComMonth:=IntToStr(ADOQuery6.RecordCount);
//判断基期
        ADOQuery6.Close;
        ADOQuery6.SQL.Clear;
        ADOQuery6.SQL.Add('select * from 公交行业统计月报_z where 统计年份='+ComboBox4.Text
                          +' and 统计月份='+ComboBox6.Text+' and 城市代码='+''''+'022'+'''');
        ADOQuery6.Open;
        if (ADOQuery6.RecordCount=0) then
        begin
                showmessage('公交行业在'+ComboBox4.Text+'年'+ComboBox6.Text+'月的数据为空!请重新选择基期时间!');
        end;
        ADOQuery6.Close;
        ADOQuery6.SQL.Clear;
        ADOQuery6.SQL.Add('select * from 公交行业统计月报_z where 统计年份='+ComboBox4.Text
                          +' and 统计月份>='+ComboBox3.Text+' and 统计月份<='+ComboBox6.Text
                          +' and 城市代码='+''''+'022'+'''');
        ADOQuery6.Open;
        if ADOQuery6.RecordCount=0 then
        begin
                showmessage('公交行业在'+ComboBox4.Text+'年'+ComboBox3.Text+'月至'+ComboBox6.Text+'月的数据为空!请重新选择基期时间!');
                exit;
        end;

        ADOQuery6.Close;
        ADOQuery6.SQL.Clear;
        ADOQuery6.SQL.Add('select distinct 统计月份 from 公交行业统计月报_z'+' where 统计年份='+ComboBox4.Text
                          +' and 统计月份>='+ComboBox3.Text+' and 统计月份<='+ComboBox6.Text
                          +' and 城市代码='+''''+'022'+'''');
        ADOQuery6.Open;

        BaseMonth:=IntToStr(ADOQuery6.RecordCount);
//生成数值
        if scmode='生成值' then
                sqlString:='SELECT a.指标代码,'
                          + ' sum(a.本月实际)/'+BaseMonth+' AS 报告期实际,'
                          + ' sum(b.本月实际)/'+ComMonth+' AS 基期实际,'
                          +' 报告期实际-基期实际 AS 比较量'
                          + ' FROM 公交行业统计月报_z AS a, 公交行业统计月报_z AS b'
                          + ' WHERE a.统计月份>='+iComMonth1+' and a.统计月份<='+iComMonth2
                          +' And b.统计月份>='+iBaseMonth1+' And b.统计月份<='+iBaseMonth2
                          +' And a.统计年份='+iComYear+ ' And b.统计年份='+iBaseYear
                          +' and a.指标代码=b.指标代码 and a.城市代码='+''''+'022'+''''+' and b.城市代码=a.城市代码'
                          + ' GROUP BY a.指标代码 ORDER BY a.指标代码'
        else
                sqlString:='SELECT a.指标代码,'
                          + ' sum(a.测算值)/'+BaseMonth+' AS 报告期实际,'
                          + ' sum(b.测算值)/'+ComMonth+' AS 基期实际,'
                          +' 报告期实际-基期实际 AS 比较量'
                          + ' FROM 公交行业统计月报_z AS a, 公交行业统计月报_z AS b'
                          + ' WHERE a.统计月份>='+iComMonth1+' and a.统计月份<='+iComMonth2
                          +' And b.统计月份>='+iBaseMonth1+' And b.统计月份<='+iBaseMonth2
                          +' And a.统计年份='+iComYear+ ' And b.统计年份='+iBaseYear
                          +' and a.指标代码=b.指标代码 and a.城市代码='+''''+'022'+''''+' and b.城市代码=a.城市代码'
                          + ' GROUP BY a.指标代码 ORDER BY a.指标代码';
        ADOQuery3.Close;
        ADOQuery3.SQL.Clear;
        ADOQuery3.SQL.Add(sqlString);
        ADOQuery3.Open;

        if ADOQuery3.RecordCount<>0 then
        begin
//                IninLView(ListView1,20);
//                IninLView(ListView2,20);
//                IninLView(ListView3,21);
//                IninLView(ListView4,20);
                WriteListView(ListView1,20,ADOQuery3);
                WriteListView(ListView2,20,ADOQuery3);
                WriteListView(ListView3,21,ADOQuery3);
                WriteListView(ListView4,20,ADOQuery3);
        end;
//前25个时点数
        if scmode='生成值' then
                sqlString:='SELECT a.指标代码,a.本月实际 AS 报告期实际,b.本月实际 AS 基期实际,'
                          +' 报告期实际-基期实际 AS 比较量'
                          + ' FROM 公交行业统计月报_z AS a, 公交行业统计月报_z AS b'
                          + ' WHERE a.统计月份='+iComMonth2+' And b.统计月份='+iBaseMonth2
                          +' And a.统计年份='+iComYear+ ' And b.统计年份='+iBaseYear
                          +' and a.指标代码=b.指标代码 and a.城市代码='+''''+'022'+''''
                          +' and b.城市代码=a.城市代码 ORDER BY a.指标代码'
        else
                sqlString:='SELECT a.指标代码, a.测算值 AS 报告期实际, b.测算值 AS 基期实际,'
                          +' 报告期实际-基期实际 AS 比较量'
                          + ' FROM 公交行业统计月报_z AS a, 公交行业统计月报_z AS b'
                          + ' WHERE a.统计月份='+iComMonth2+' And b.统计月份='+iBaseMonth2
                          +' And a.统计年份='+iComYear+ ' And b.统计年份='+iBaseYear
                          +' and a.指标代码=b.指标代码 and a.城市代码='+''''+'022'+''''
                          +' and b.城市代码=a.城市代码 ORDER BY a.指标代码';
        ADOQuery3.Close;
        ADOQuery3.SQL.Clear;
        ADOQuery3.SQL.Add(sqlString);
        ADOQuery3.Open;
        if (ADOQuery3.RecordCount<>0) then
                WriteListView(ListView1,20,ADOQuery3);
        for j:=0 to 4 do
        begin
                if (ADOQuery3.fieldbyname('报告期实际').AsString<>'') then
                        ListView2.Items[j].SubItems[2]:=Converter(ADOQuery3.fieldbyname('报告期实际').AsFloat)
                else
                        ListView2.Items[j].SubItems[2]:='0';
                if (ADOQuery3.fieldbyname('基期实际').AsString<>'') then
                        ListView2.Items[j].SubItems[3]:=Converter(ADOQuery3.fieldbyname('基期实际').AsFloat)
                else
                        ListView2.Items[j].SubItems[3]:='0';
                if (ADOQuery3.fieldbyname('比较量').AsString<>'') then
                        ListView2.Items[j].SubItems[4]:=Converter(ADOQuery3.fieldbyname('比较量').AsFloat)
                else
                        ListView2.Items[j].SubItems[4]:='0';
                ADOQuery3.Next;
        end;
        //.............................百分比........................//
        WritePercent(ListView1,20);
        WritePercent(ListView2,20);
        WritePercent(ListView3,21);
        WritePercent(ListView4,20);

        for j:=2 to 3 do
        begin
                IDiv:=strtofloat(ListView4.Items[2].SubItems[j]);
                IDivD:=strtofloat(ListView4.Items[3].SubItems[j]);
                if IDivD<>0 then begin
                        Result:=(IDiv/IDivD)*10000;
                        ListView4.Items[1].SubItems[j]:=Converter(Result);
                end else
                        ListView4.Items[1].SubItems[j]:='0';

                IDiv:=strtofloat(ListView4.Items[5].SubItems[j]);
                IDivD:=strtofloat(ListView4.Items[6].SubItems[j]);
                if IDivD<>0 then begin
                        Result:=(IDiv/IDivD)*100;
                        ListView4.Items[4].SubItems[j]:=Converter(Result);
                end else
                        ListView4.Items[4].SubItems[j]:='0';

                IDiv:=strtofloat(ListView4.Items[8].SubItems[j]);
                IDivD:=strtofloat(ListView4.Items[9].SubItems[j]);
                if IDivD<>0 then begin
                        Result:=(IDiv/IDivD)*100;
                        ListView4.Items[7].SubItems[j]:=Converter(Result);
                end else
                        ListView4.Items[7].SubItems[j]:='0';

                IDiv:=strtofloat(ListView4.Items[11].SubItems[j]);
                IDivD:=strtofloat(ListView4.Items[12].SubItems[j]);
                if IDivD<>0 then begin
                        Result:=(IDiv/IDivD)*100;
                        ListView4.Items[10].SubItems[j]:=Converter(Result);
                end else
                        ListView4.Items[10].SubItems[j]:='0';

                IDiv:=strtofloat(ListView3.Items[13].SubItems[j]);
                IDivD:=strtofloat(ListView4.Items[13].SubItems[j]);
                if IDivD<>0 then begin
                        Result:=(IDiv/IDivD);
                        ListView4.Items[14].SubItems[j]:=Converter(Result);
                end else
                        ListView4.Items[14].SubItems[j]:='0';

        end;

        if (StrToFloat(ListView4.Items[1].SubItems[2])-StrToFloat(ListView4.Items[1].SubItems[3])<>0) then
                ListView4.Items[1].SubItems[4]:=Converter(StrToFloat(ListView4.Items[1].SubItems[2])-StrToFloat(ListView4.Items[1].SubItems[3]))
        else
                ListView4.Items[1].SubItems[4]:='0';
        if (StrToFloat(ListView4.Items[4].SubItems[2])-StrToFloat(ListView4.Items[4].SubItems[3])<>0) then
                ListView4.Items[4].SubItems[4]:=Converter(StrToFloat(ListView4.Items[4].SubItems[2])-StrToFloat(ListView4.Items[4].SubItems[3]))
        else
                ListView4.Items[4].SubItems[4]:='0';
        if (StrToFloat(ListView4.Items[7].SubItems[2])-StrToFloat(ListView4.Items[7].SubItems[3])<>0) then
                ListView4.Items[7].SubItems[4]:=Converter(StrToFloat(ListView4.Items[7].SubItems[2])-StrToFloat(ListView4.Items[7].SubItems[3]))
        else
                ListView4.Items[7].SubItems[4]:='0';
        if (StrToFloat(ListView4.Items[10].SubItems[2])-StrToFloat(ListView4.Items[10].SubItems[3])<>0) then
                ListView4.Items[10].SubItems[4]:=Converter(StrToFloat(ListView4.Items[10].SubItems[2])-StrToFloat(ListView4.Items[10].SubItems[3]))
        else
                ListView4.Items[10].SubItems[4]:='0';
        if (StrToFloat(ListView4.Items[14].SubItems[2])-StrToFloat(ListView4.Items[14].SubItems[3])<>0) then
                ListView4.Items[14].SubItems[4]:=Converter(StrToFloat(ListView4.Items[14].SubItems[2])-StrToFloat(ListView4.Items[14].SubItems[3]))
        else
                ListView4.Items[14].SubItems[4]:='0';

        if (StrToFloat(ListView4.Items[1].SubItems[3])<>0) then
                ListView4.Items[1].SubItems[5]:=ConverterPercent(FloatToStr(StrToFloat(ListView4.Items[1].SubItems[4])/StrToFloat(ListView4.Items[1].SubItems[3])*100))
        else
                ListView4.Items[1].SubItems[5]:='0';
        if (StrToFloat(ListView4.Items[4].SubItems[3])<>0) then
                ListView4.Items[4].SubItems[5]:=ConverterPercent(FloatToStr(StrToFloat(ListView4.Items[4].SubItems[4])/StrToFloat(ListView4.Items[4].SubItems[3])*100))
        else
                ListView4.Items[4].SubItems[5]:='0';
        if (StrToFloat(ListView4.Items[7].SubItems[3])<>0) then
                ListView4.Items[7].SubItems[5]:=ConverterPercent(FloatToStr(StrToFloat(ListView4.Items[7].SubItems[4])/StrToFloat(ListView4.Items[7].SubItems[3])*100))
        else
                ListView4.Items[7].SubItems[5]:='0';
        if (StrToFloat(ListView4.Items[10].SubItems[3])<>0) then
                ListView4.Items[10].SubItems[5]:=ConverterPercent(FloatToStr(StrToFloat(ListView4.Items[10].SubItems[4])/StrToFloat(ListView4.Items[10].SubItems[3])*100))
        else
                ListView4.Items[10].SubItems[5]:='0';
        if (StrToFloat(ListView4.Items[14].SubItems[3])<>0) then
                ListView4.Items[14].SubItems[5]:=ConverterPercent(FloatToStr(StrToFloat(ListView4.Items[14].SubItems[4])/StrToFloat(ListView4.Items[14].SubItems[3])*100))
        else
                ListView4.Items[14].SubItems[5]:='0';

        BBPrint2.Enabled:=true;
        BBPrint2.Visible:=true;
end;

procedure THYMonthCompareFrm.BitBtn2Click(Sender: TObject);
var
        iRow,iCol:integer;
begin
     HYMonthCompareFrm.Close;
end;

procedure THYMonthCompareFrm.FormShow(Sender: TObject);
begin
        TabSheet1.TabVisible:=true;
        TabSheet2.TabVisible:=true;
        TabSheet3.TabVisible:=true;
        TabSheet4.TabVisible:=true;
        PageControl1.ActivePage:=TabSheet4;
        PageControl1.ActivePage:=TabSheet3;
        PageControl1.ActivePage:=TabSheet2;
        PageControl1.ActivePage:=TabSheet1;
        IninLView(ListView1,0,19,2,5);
        IninLView(ListView2,0,19,2,5);
        IninLView(ListView3,0,20,2,5);
        IninLView(ListView4,0,19,2,5);
        BBPrint2.Enabled:=false;
end;

procedure THYMonthCompareFrm.ComboBox1Change(Sender: TObject);
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;
end;

procedure THYMonthCompareFrm.ComboBox2Change(Sender: TObject);
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;
end;

procedure THYMonthCompareFrm.ComboBox5Change(Sender: TObject);
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;
end;

procedure THYMonthCompareFrm.ComboBox4Change(Sender: TObject);
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;
end;

procedure THYMonthCompareFrm.ComboBox3Change(Sender: TObject);
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;
end;

procedure THYMonthCompareFrm.ComboBox6Change(Sender: TObject);
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;
end;

procedure THYMonthCompareFrm.ComboBox7Change(Sender: TObject);
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;
end;

end.

⌨️ 快捷键说明

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