示例#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);
            
        }
示例#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);
            
        }
示例#3
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);
            
        }