Example #1
0
        //批次报批研判
        private static void pcbpJudge(IFeatureLayer pChangeFeaLayer, IFeatureLayer pcbpFeaLayer, IWorkspace pOutWorkSpace, bool useSelection,SysCommon.CProgress vProgress)
        {
            ITable pChangeTable = pChangeFeaLayer as ITable;
            ITable pcbpTable = pcbpFeaLayer as ITable;
            double rol = 0.0001;
            IFeatureClass pcbpFeaClass = pcbpFeaLayer.FeatureClass;
            //创建结果地物类名称
            IFeatureClassName pResFeaClassName = new FeatureClassNameClass();
            String fcName = pcbpFeaClass.AliasName.Trim().Substring(pcbpFeaClass.AliasName.Trim().IndexOf(".") + 1)+"_res";
            IDataset pOutDataset = (IDataset)pOutWorkSpace;
            IDatasetName pOutDatasetName = (IDatasetName)pResFeaClassName;
            pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
            pOutDatasetName.Name = fcName;
            IBasicGeoprocessor pGeoProcessor = new BasicGeoprocessorClass();
            //叠置分析
            pGeoProcessor.Intersect(pChangeTable, useSelection, pcbpTable, false, rol, pResFeaClassName);

            //从叠置结果生成报表
            string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pOutDatasetName.WorkspaceName.PathName;
            OleDbConnection oledbconn = new OleDbConnection(connstr);
            oledbconn.Open();
            ModTableFun.DropTable(oledbconn, "tmprel");
            string sqlstr = "select "+g_XZQHDM+","+g_TBBH+","+g_MJ+" as jctbmj,"+g_PC  +",shape_area as " +g_MJ+",shape_area as zb,"+g_GWYPFWH+" as bpwh,"+g_SGTTPFWH+","+g_SGTJPFWH+" into tmprel from " + fcName;
                            //行政区划代码,编号,监测图斑面积,报批名称,计算面积,占比,批准文号(三个批准文号的备选字段)
            OleDbCommand oledbcomm = oledbconn.CreateCommand();
            oledbcomm.CommandText = sqlstr;
            oledbcomm.ExecuteNonQuery();

            oledbcomm.CommandText = "update tmprel set zb="+g_MJ+"/jctbmj*100";
            oledbcomm.ExecuteNonQuery();
            //报批文号为空,则取省林业厅批复文号
            oledbcomm.CommandText = "update tmprel set bpwh=" + g_SGTTPFWH + " where bpwh is null and " + g_SGTTPFWH + "  is not null";
            oledbcomm.ExecuteNonQuery();
            //报批文号为空,则取省市林业局批复文号
            oledbcomm.CommandText = "update tmprel set bpwh=" + g_SGTJPFWH + " where bpwh is null and " + g_SGTJPFWH + " is not null";
            oledbcomm.ExecuteNonQuery();
            //报表模板路径
            string Templatepath = Application.StartupPath + "\\..\\Template\\批次报批研判模板.cel";
            oledbconn.Close();
            //生成报表对话框
            FormFlexcell frm;
            ModFlexcell.m_SpecialRow = -1;
            ModFlexcell.m_SpecialRow_ex = -1;
            ModFlexcell.m_SpecialRow_ex2 = -1;
            frm = ModFlexcell.SendDataToFlexcell(connstr, "监测图斑报批情况表", "tmprel", g_XZQHDM + "," + g_TBBH + ",jctbmj," + g_PC + "," + g_MJ + "," + g_ZB + ",bpwh", "", Templatepath, 4, 2);

            AxFlexCell.AxGrid pGrid = frm.GetGrid();
            string excelPath = m_WorkPath + "\\监测图斑报批情况表.xls";
            pGrid.ExportToExcel(excelPath);
            
            //frm.SaveFile(m_WorkPath + "\\监测图斑报批情况表.cel");
            //弹出报表
            ModStatReport.OpenExcelFile(excelPath);
            
        }
Example #2
0
        //森林资源/地类图斑研判
        private static void dltbJudge(IFeatureLayer pChangeFeaLayer, IFeatureLayer dltbFeaLayer, IWorkspace pOutWorkSpace, bool useSelection,SysCommon.CProgress vProgress)
        {
            ITable pChangeTable = pChangeFeaLayer as ITable;
            ITable pcbpTable = dltbFeaLayer as ITable;
            IFeatureClass dltbFeaClass = dltbFeaLayer.FeatureClass;
            double rol = 0.0001;
            IFeatureClassName pResFeaClassName = new FeatureClassNameClass();
            //创建结果地物类名称
            String fcName = dltbFeaClass.AliasName.Trim().Substring(dltbFeaClass.AliasName.Trim().IndexOf(".") + 1)+"_res";
            IDataset pOutDataset = (IDataset)pOutWorkSpace;
            IDatasetName pOutDatasetName = (IDatasetName)pResFeaClassName;
            pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
            pOutDatasetName.Name = fcName;
            IBasicGeoprocessor pGeoProcessor = new BasicGeoprocessorClass();
            //叠置分析
            pGeoProcessor.Intersect(pChangeTable, useSelection, pcbpTable, false, rol, pResFeaClassName);

            //从叠置结果生成报表
            string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pOutDatasetName.WorkspaceName.PathName ;
            OleDbConnection oledbconn = new OleDbConnection(connstr);
            oledbconn.Open();
            ModTableFun.DropTable(oledbconn, "tmprel");
            string sqlstr = "select "+g_XZQHDM+","+g_TBBH+","+g_MJ+" as jctbmj,"+g_TBBH+"_1,"+g_DLBM+","+g_TBMJ+","+g_TBDLMJ+",shape_area as jsmj,shape_area as mj,shape_area as zb into tmprel from " + fcName;
                            //行政区划代码,编号,面积,图斑编号,地类编码,图斑面积,图斑地类面积,计算面积,占比
            OleDbCommand oledbcomm = oledbconn.CreateCommand();
            oledbcomm.CommandText = sqlstr;
            oledbcomm.ExecuteNonQuery();
            //叠置结果地类面积计算方法:  面积=叠置结果计算面积*地类图斑地类面积/地类图斑总面积
            oledbcomm.CommandText = "update tmprel set mj=jsmj*"+g_TBDLMJ+"/"+g_TBMJ+"";
            oledbcomm.ExecuteNonQuery();
            //计算占比
            oledbcomm.CommandText = "update tmprel set zb=mj/jctbmj*100";
            oledbcomm.ExecuteNonQuery();
            //报表模板路径
            oledbconn.Close();
            string Templatepath = Application.StartupPath + "\\..\\Template\\森林资源现状研判模板.cel";
            //生成报表对话框
            FormFlexcell frm;
            ModFlexcell.m_SpecialRow = -1;
            ModFlexcell.m_SpecialRow_ex = -1;
            ModFlexcell.m_SpecialRow_ex2 = -1;
            frm = ModFlexcell.SendDataToFlexcell(connstr, "监测图斑地类情况表", "tmprel", g_XZQHDM + "," + g_TBBH + ",jctbmj," + g_TBBH + "_1,"+g_DLBM+"," + g_MJ + "," + g_ZB, "", Templatepath, 4, 2);

            AxFlexCell.AxGrid pGrid = frm.GetGrid();
            string excelPath = m_WorkPath + "\\监测图斑地类情况表.xls";
            pGrid.ExportToExcel(excelPath);
            
            //frm.SaveFile(m_WorkPath + "\\监测图斑地类情况表.cel");
            //弹出报表
            ModStatReport.OpenExcelFile(excelPath);
            
        }
Example #3
0
        public static int m_SpecialRow_ex2; //特殊行(需要单独修改某一行的显示时候用到,通常情况下都是整表输出)
        //added by chulili
        //函数功能:将数据写到表格中(数据存在于数据库的一张表中)
        //输入参数:数据库连接串,报表对话框标题,数据源表名,指定输出的字段,排序字段(仅限于升序排列),报表模板全路径,起始行,起始列,字体,字号
        public static FormFlexcell  SendDataToFlexcell(string connstr, string caption, string TableName, string Fieldstr, string OrderByField, string TemplateFile, int startrow, int startcol, string FontName, int FontSize)
        {
            //根据连接串连接数据库
            OleDbConnection conn = new OleDbConnection(connstr);

            if (conn == null)
            {
                return(null);
            }
            conn.Open();
            //判断数据源表是否存在
            if (ModTableFun.isExist(conn, TableName) == false)
            {
                return(null);
            }
            //设置起始行,起始列
            m_startCol = startcol;
            m_startRow = startrow;
            //初始化报表对话框
            FormFlexcell frm = new FormFlexcell();
            //获取数据源记录数(OleDbDataReader对象的一个缺点是没有recordcount属性或方法,需要单独取记录数)
            int             recordcount = 0;
            OleDbDataReader myreader;
            OleDbCommand    mycomm = conn.CreateCommand();

            mycomm.CommandText = "select count(*) from " + TableName;
            myreader           = mycomm.ExecuteReader();
            if (myreader.Read())
            {
                recordcount = (int)myreader.GetValue(0);
            }
            myreader.Close();
            //判断是否输出全部字段
            if (Fieldstr.Equals(""))
            {
                Fieldstr = "*";
            }
            //判断排序字段是否存在
            if (OrderByField.Equals("") == false)
            {
                if (ModTableFun.isFieldExist(conn, TableName, OrderByField) == false)
                {
                    OrderByField = "";
                }
            }
            string sqlstr;

            //构造获取数据的sql语句
            if (OrderByField.Equals(""))
            {
                sqlstr = "select " + Fieldstr + " from " + TableName;
            }
            else
            {
                sqlstr = "select " + Fieldstr + " from " + TableName + " order by " + OrderByField;
            }
            mycomm.CommandText = sqlstr;
            myreader           = mycomm.ExecuteReader();
            //向报表对话框输入数据
            frm.SetTextFromRS(startrow, startcol, myreader, TemplateFile, recordcount, FontName, FontSize);
            if (caption.Equals(""))
            {
                caption = TableName;
            }
            frm.Text = caption;
            myreader.Close();

            conn.Close();
            return(frm);
        }
Example #4
0
        //森林用途研判
        private static void tdytJudge(IFeatureLayer pChangeFeaLayer, IFeatureLayer tdytFeaLayer, IWorkspace pOutWorkSpace, bool useSelection,SysCommon.CProgress vProgress)
        {
            ITable pChangeTable = pChangeFeaLayer as ITable;
            ITable tdytTable = tdytFeaLayer as ITable;
            double rol = 0.0001;
            IFeatureClass tdytFeaClass = tdytFeaLayer.FeatureClass;
            //创建结果地物类名称
            IFeatureClassName pResFeaClassName = new FeatureClassNameClass();
            String fcName = tdytFeaClass.AliasName.Trim().Substring(tdytFeaClass.AliasName.Trim().IndexOf(".") + 1)+"_res";
            IDataset pOutDataset = (IDataset)pOutWorkSpace;
            IDatasetName pOutDatasetName = (IDatasetName)pResFeaClassName;
            pOutDatasetName.WorkspaceName = (IWorkspaceName)pOutDataset.FullName;
            pOutDatasetName.Name = fcName;
            IBasicGeoprocessor pGeoProcessor = new BasicGeoprocessorClass();
            //叠置分析
            pGeoProcessor.Intersect(pChangeTable, useSelection, tdytTable, false, rol, pResFeaClassName);

            //从叠置结果生成报表
            string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pOutDatasetName.WorkspaceName.PathName;
            OleDbConnection oledbconn = new OleDbConnection(connstr);
            oledbconn.Open();
            ModTableFun.DropTable(oledbconn,"tmprel");
            string sqlstr = "select "+g_XZQHDM+","+g_TBBH+","+g_MJ+" as jctbmj,"+g_TDYTFQBH+","+g_TDYTFQDM+",shape_area as jsmj,shape_area as mj,shape_area as zb into tmprel from " + fcName;
                            //行政区划代码,编号,监测图斑面积,规划图斑编号,规划用地用途代码
            OleDbCommand oledbcomm = oledbconn.CreateCommand();
            oledbcomm.CommandText = sqlstr;
            oledbcomm.ExecuteNonQuery();

            oledbcomm.CommandText = "update tmprel set zb=mj/jctbmj*100";
            oledbcomm.ExecuteNonQuery();

            ModTableFun.DropTable(oledbconn ,"森林用途字典");
            CopyTdytDictionary(oledbconn);//从业务库里面拷贝森林用途字典过来
            
            //根据森林用途字典更新森林用途名称
            oledbcomm.CommandText = "alter table tmprel add tdytmc text(30)";
            oledbcomm.ExecuteNonQuery();
            oledbcomm.CommandText = "update tmprel set tdytmc=" + g_TDYTFQDM;
            oledbcomm.ExecuteNonQuery();
            if (ModTableFun.isExist(oledbconn,"森林用途字典"))
            {               
                oledbcomm.CommandText = "update tmprel a,森林用途字典 b set a.tdytmc=b.森林用途分区类型 where a." + g_TDYTFQDM + "=b.代码";
                oledbcomm.ExecuteNonQuery();
            }
            //报表模板路径
            string Templatepath = Application.StartupPath + "\\..\\Template\\森林资源规划研判模板.cel";
            //生成报表对话框
            oledbconn.Close();
            FormFlexcell frm;
            ModFlexcell.m_SpecialRow = -1;
            ModFlexcell.m_SpecialRow_ex = -1;
            ModFlexcell.m_SpecialRow_ex2 = -1;
            //规划图斑没有图斑编号怎么办??暂时使用森林用途分区编号
            frm = ModFlexcell.SendDataToFlexcell(connstr, "监测图斑规划情况表", "tmprel", g_XZQHDM + "," + g_TBBH + ",jctbmj,TDYTFQBH,tdytmc," + g_MJ + "," + g_ZB, "", Templatepath, 4, 2);
            //弹出报表对话框

            AxFlexCell.AxGrid pGrid = frm.GetGrid();
            string excelPath = m_WorkPath + "\\监测图斑规划情况表.xls";
            pGrid.ExportToExcel(excelPath);

            //frm.SaveFile(m_WorkPath + "\\监测图斑规划情况表.cel");
            ModStatReport.OpenExcelFile(excelPath);
            
        }