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

📄 busindustry_report.~pas

📁 公交行业的管理系统
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
        AdoQuery2.Close;
        AdoQuery2.SQL.Clear;
        AdoQuery2.SQL.Add(sqlstr2);
        AdoQuery2.Open;
        if (AdoQuery2.fieldbyname('capi').AsString='')
        then   listview1.Items.Item[1].SubItems[4]:= '0'
        else   listview1.Items.Item[1].SubItems[4]:= ConverterPercent(AdoQuery2.fieldbyname('capi').AsString);
end;

function TAnnualReport.GetIndex(tmpname : string): integer;
var
        find : boolean;
        loc : integer;
        i : integer;
begin
        i := 0; find := false;
        while ((not find) and (i<52))
        do
        begin
                if ( iname[i] = tmpname )
                then    find := true;
                i:= i+1;
        end;
        if (find)
        then    GetIndex := i-1
        else    GetIndex := -1;
end;

function TAnnualReport.GetIndex2(tmpname : string; statptn : integer): integer;
var
        find : boolean;
        loc : integer;
        i : integer;
begin
        i := statptn; find := false;
        while ((not find) and (i<itemnumber))
        do
        begin
                if ( iname[i] = tmpname )
                then    find := true;
                i:= i+1;
        end;
        if (find)
        then    GetIndex2 := i-1
        else    GetIndex2 := -1;
end;


procedure TAnnualReport.GetName(rowstr: array of string);
var
        len,i: integer;
        s : string;
begin
        i:= 0;
        while (i<52)
        do
        begin

                len := length(rowstr[i]);
                s := copy(rowstr[i],4,len-3);
                iname[i] := s;
                i:=i+1;
        end;

end;

procedure TAnnualReport.InitListViews();
var
        sqlstr,s : string;
        rownumber: integer;
        tempitem: TlistItem;
        i : integer;
        jname: array [0..51] of string;
begin
        sqlstr := 'select * from 公交行业名录统计年报指标定义表 order by 指标代码';
        AdoQuery1.Close;
        AdoQuery1.SQL.Clear;
        AdoQuery1.SQL.Add(sqlstr);
        AdoQuery1.Open;

        listview1.Items.Clear;
        listview2.Items.Clear;
        listview3.Items.Clear;

        rownumber := 0;
        while (rownumber < 19)        // init listview1,
        do
        begin
                tempitem:= listview1.Items.Add;
                tempitem.Caption:= AdoQuery1.fieldbyname('指标名称').AsString;
                tempitem.SubItems.Add(AdoQuery1.fieldbyname('指标代码').AsString);
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                jname[rownumber]:= tempitem.Caption;
                rownumber:= rowNumber+1;
                AdoQuery1.Next;
        end;

        while (rownumber < 40)        // init listview2
        do
        begin
                tempitem:= listview2.Items.Add;
                tempitem.Caption:= AdoQuery1.fieldbyname('指标名称').AsString;
                tempitem.SubItems.Add(AdoQuery1.fieldbyname('指标代码').AsString);
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                jname[rownumber]:= tempitem.Caption;
                rownumber:= rowNumber+1;
                AdoQuery1.Next;
        end;

        while (rownumber < 52)        // init listview3
        do
        begin
                tempitem:= listview3.Items.Add;
                tempitem.Caption:= AdoQuery1.fieldbyname('指标名称').AsString;
                tempitem.SubItems.Add(AdoQuery1.fieldbyname('指标代码').AsString);
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                tempitem.SubItems.Add('0');
                jname[rownumber]:= tempitem.Caption;
                rownumber:= rowNumber+1;
                AdoQuery1.Next;
        end;

        GetName(jname);
end;

procedure TAnnualReport.FormShow(Sender: TObject);
begin
        //SetBtn();
        InitListViews();
        sumyear := ComboBox1.Text;
        iState := 'Ini';
        //SetBtn();
end;

procedure TAnnualReport.BitBtn1Click(Sender: TObject);
begin
        ComboBox1.Enabled := true;
        iState := 'Nul';
        //SetBtn();
        AnnualReport.Close;
end;

procedure TAnnualReport.BitBtn2Click(Sender: TObject);
var
        sqlstr,sqlstr2 : string;
        //sqlstr2: string;
        rownumber : integer;
        s1 : string;
        itmp1,itmp2 : integer;
begin
        if ComboBox1.Text='' then
        begin
                showmessage('请选择生成年报的时间!');
                exit;
        end;
        if (Length(Combobox1.Text)<>4) or (StrToInt(Combobox1.Text)>3000) or (StrToInt(Combobox1.Text)<1900) then
        begin
                showmessage('对不起!您输入的年份非法!请重新选择!');
                exit;
        end;
        if (Messagebox(self.Handle,'         请等候!', '提示', mb_OKCancel ) = IDCancel)
        then    exit;

        iState := 'Run';
        //SetBtn();
        Bitbtn1.Enabled:= false;
        Bitbtn2.Enabled:= false;
        Bitbtn3.Enabled:= false;
        Bitbtn4.Enabled:= false;
        Screen.Cursor := crHourGlass;
        // ********************  MNS03--------MNS07************************
        sqlstr := 'SELECT sum(企业注册资本金) AS capital, count(*) as amount, 行业类别 FROM 公用事业单位基本情况表 where 统计年份='+sumyear+' group by 行业类别 ';
        AdoQuery1.Close;
        AdoQuery1.SQL.Clear;
        AdoQuery1.SQL.Add(sqlstr);
        AdoQuery1.Open;
        while (not AdoQuery1.Eof)
        do
        begin
                s1 :=AdoQuery1.FieldByName('行业类别').AsString;
                if (s1 = '轨道交通业') then
                begin
                        // rail way 
                        sqlstr2:= 'select count(企业代码) as 合计 from 主要业务活动表 where 统计年份='+sumyear+' and 地铁='+''''+'1'+'''';
                        AdoQuery3.Close;
                        AdoQuery3.SQL.Clear;
                        AdoQuery3.SQL.Add(sqlstr2);
                        AdoQuery3.Open;
                        listview1.Items.Item[3].SubItems[1]:= AdoQuery3.fieldbyname('合计').AsString;
                        sqlstr2:= 'select count(企业代码) as 去年 from 主要业务活动表 where 统计年份='+IntToStr(StrToInt(sumyear)-1)+' and 地铁='+''''+'1'+'''';
                        AdoQuery3.Close;
                        AdoQuery3.SQL.Clear;
                        AdoQuery3.SQL.Add(sqlstr2);
                        AdoQuery3.Open;
                        itmp1 := StrToInt(listview1.Items.Item[3].SubItems[1]);
                        itmp2:= AdoQuery3.fieldbyname('去年').AsInteger;
                        if (itmp1 >= itmp2) then
                                listview1.Items.Item[3].SubItems[2]:= IntToStr(itmp1-itmp2)
                        else    listview1.Items.Item[3].SubItems[3]:= IntToStr(itmp1-itmp2);
                        sqlstr2:= 'SELECT sum(a.企业注册资本金) as capi FROM 公用事业单位基本情况表 as a,主要业务活动表 as b where a.统计年份='+sumyear+' and a.统计年份=b.统计年份 and a.单位代码=b.企业代码 and b.地铁='+''''+'1'+'''';
                        AdoQuery3.Close;
                        AdoQuery3.SQL.Clear;
                        AdoQuery3.SQL.Add(sqlstr2);
                        AdoQuery3.Open;
                        if (AdoQuery3.fieldbyname('capi').AsString<>'') then
                        listview1.Items.Item[3].SubItems[4]:= ConverterPercent(AdoQuery3.fieldbyname('capi').AsString)
                        else
                        listview1.Items.Item[3].SubItems[4]:='0';
                        //light railway
                        sqlstr2:= 'select count(企业代码) as 合计 from 主要业务活动表 where 统计年份='+sumyear+' and 轻轨='+''''+'1'+'''';
                        AdoQuery3.Close;
                        AdoQuery3.SQL.Clear;
                        AdoQuery3.SQL.Add(sqlstr2);
                        AdoQuery3.Open;
                        listview1.Items.Item[4].SubItems[1]:= AdoQuery3.fieldbyname('合计').AsString;
                        sqlstr2:= 'select count(企业代码) as 去年 from 主要业务活动表 where 统计年份='+IntToStr(StrToInt(sumyear)-1)+' and 轻轨='+''''+'1'+'''';
                        AdoQuery3.Close;
                        AdoQuery3.SQL.Clear;
                        AdoQuery3.SQL.Add(sqlstr2);
                        AdoQuery3.Open;
                        itmp1 := StrToInt(listview1.Items.Item[4].SubItems[1]);
                        itmp2:= AdoQuery3.fieldbyname('去年').AsInteger;
                        if (itmp1 >= itmp2) then
                                listview1.Items.Item[4].SubItems[2]:= IntToStr(itmp1-itmp2)
                        else    listview1.Items.Item[4].SubItems[3]:= IntToStr(itmp1-itmp2);
                        sqlstr2:= 'SELECT sum(a.企业注册资本金) as capi FROM 公用事业单位基本情况表 as a,主要业务活动表 as b where a.统计年份='+sumyear+' and a.统计年份=b.统计年份 and a.单位代码=b.企业代码 and b.轻轨='+''''+'1'+'''';
                        AdoQuery3.Close;
                        AdoQuery3.SQL.Clear;
                        AdoQuery3.SQL.Add(sqlstr2);
                        AdoQuery3.Open;
                        if (AdoQuery3.fieldbyname('capi').AsString<>'') then
                        listview1.Items.Item[4].SubItems[4]:= ConverterPercent(AdoQuery3.fieldbyname('capi').AsString)
                        else
                        listview1.Items.Item[4].SubItems[4]:='0';
                end
                else
                begin
                        rownumber := GetIndex(s1);
                        if (rownumber <> -1)
                        then
                        begin
                                listview1.Items.Item[rownumber].SubItems[1]:= AdoQuery1.FieldByName('amount').AsString;
                                listview1.Items.Item[rownumber].SubItems[4]:= ConverterPercent(AdoQuery1.FieldByName('capital').AsString);
                                listview1.Items.Item[rownumber].SubItems[2]:= GetIncrDecr(sumyear,s1,'行业类别').incrnum;
                                listview1.Items.Item[rownumber].SubItems[3]:= GetIncrDecr(sumyear,s1,'行业类别').decrnum;
                        end;
                end;
                AdoQuery1.Next;
        end;
        // ********************  MNS09--------MNS20************************
        sqlstr := 'SELECT sum(企业注册资本金) AS capital, count(*) as amount, [企业(单位)登记注册类型] as type FROM 公用事业单位基本情况表 where 统计年份='+sumyear+' group by [企业(单位)登记注册类型]  ';
        AdoQuery1.Close;
        AdoQuery1.SQL.Clear;
        AdoQuery1.SQL.Add(sqlstr);
        AdoQuery1.Open;
        while (not AdoQuery1.Eof)
        do
        begin
                s1 :=AdoQuery1.FieldByName('type').AsString;
                rownumber := GetIndex(s1);
                if (rownumber <> -1)
                then
                begin
                        listview1.Items.Item[rownumber].SubItems[1]:= AdoQuery1.FieldByName('amount').AsString;
                        listview1.Items.Item[rownumber].SubItems[4]:= ConverterPercent(AdoQuery1.FieldByName('capital').AsString);
                        listview1.Items.Item[rownumber].SubItems[2]:= GetIncrDecr(sumyear,s1,'[企业(单位)登记注册类型]').incrnum;
                        listview1.Items.Item[rownumber].SubItems[3]:= GetIncrDecr(sumyear,s1,'[企业(单位)登记注册类型]').decrnum;
                end;
                AdoQuery1.Next;
        end;

        // ********************  MNS22--------MNS41************************
        sqlstr := 'SELECT sum(企业注册资本金) AS capital, count(*) as amount, 单位坐落区域 as type FROM 公用事业单位基本情况表  where 统计年份='+sumyear+' group by 单位坐落区域';
        AdoQuery1.Close;
        AdoQuery1.SQL.Clear;
        AdoQuery1.SQL.Add(sqlstr);
        AdoQuery1.Open;
        while (not AdoQuery1.Eof)
        do
        begin
                s1 :=AdoQuery1.FieldByName('type').AsString;
                rownumber := GetIndex(s1);
                if (rownumber <> -1)
                then
                begin
                        listview2.Items.Item[rownumber-19].SubItems[1]:= AdoQuery1.FieldByName('amount').AsString;
                        listview2.Items.Item[rownumber-19].SubItems[4]:= ConverterPercent(AdoQuery1.FieldByName('capital').AsString);
                        listview2.Items.Item[rownumber-19].SubItems[2]:= GetIncrDecr(sumyear,s1,'单位坐落区域').incrnum;
                        listview2.Items.Item[rownumber-19].SubItems[3]:= GetIncrDecr(sumyear,s1,'单位坐落区域').decrnum;
                end;
                AdoQuery1.Next;
        end;

⌨️ 快捷键说明

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