コード例 #1
0
        public override void OnClick()
        {
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }
            IMap pMap = _AppHk.MapControl.Map;

            if (frmSQL != null)
            {
                frmSQL.Close();
            }
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("河流查询");//xisheng 日志记录;
            }
            string        strLayerName   = "";
            string        strFieldName   = ""; //名称字段
            string        strFieldCode   = ""; //编码字段
            IFeatureClass pRiverFeaClass = null;

            try
            {//查找河流地物类
                ModQuery.GetQueryConfig("河流查询", out pRiverFeaClass, out strLayerName, out strFieldName, out strFieldCode);
                if (pRiverFeaClass == null)
                {
                    MessageBox.Show("找不到河流数据,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                //检查河流名称字段
                if (pRiverFeaClass.FindField(strFieldName) < 0)
                {
                    MessageBox.Show("找不到河流名称属性,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    pRiverFeaClass = null;
                    return;
                }
                //检查河流编码字段
                if (pRiverFeaClass.FindField(strFieldCode) < 0)
                {
                    MessageBox.Show("找不到河流编码属性,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    pRiverFeaClass = null;
                    return;
                }
                frmQueryRoad fmQD = new frmQueryRoad((_AppHk as Plugin.Application.IAppFormRef).MainForm, _AppHk.MapControl, pRiverFeaClass, strLayerName, strFieldName, strFieldCode, "河 流 名:", "河流编码:", "河流查询");
                fmQD.WriteLog = this.WriteLog;
                fmQD.Show((_AppHk as Plugin.Application.IAppFormRef).MainForm);
            }
            catch (Exception ex)
            {
                ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
            }
        }
コード例 #2
0
        public override void OnClick()
        {
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }
            IMap pMap = _AppHk.MapControl.Map;

            string        strFieldName  = ""; //名称字段
            string        strFieldCode  = ""; //编码字段
            string        strRoadName   = "铁路查询";
            string        strLayerName  = "";
            IFeatureClass pRoadFeaClass = null;

            try
            {//获取道路地物类
                ModQuery.GetQueryConfig(strRoadName, out pRoadFeaClass, out strLayerName, out strFieldName, out strFieldCode);
                if (pRoadFeaClass == null)
                {
                    MessageBox.Show("找不到铁路数据,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                //检查河流名称字段
                if (pRoadFeaClass.FindField(strFieldName) < 0)
                {
                    MessageBox.Show("找不到铁路名称属性,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    pRoadFeaClass = null;
                    return;
                }
                //检查河流编码字段
                if (pRoadFeaClass.FindField(strFieldCode) < 0)
                {
                    MessageBox.Show("找不到铁路编码属性,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    pRoadFeaClass = null;
                    return;
                }
                frmQueryRoad fmQD = new frmQueryRoad(_pAppForm.MainForm, _AppHk.MapControl, pRoadFeaClass, strLayerName, strFieldName, strFieldCode, "铁 路 名:", "铁路编码:", "铁路查询");
                fmQD.WriteLog = this.WriteLog;
                fmQD.Show(_pAppForm.MainForm);
            }
            catch (Exception ex)
            {
                ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
            }
        }
コード例 #3
0
        private void txtLayer_Click(object sender, EventArgs e)
        {
            Plugin.SelectLayerByTree frm = new Plugin.SelectLayerByTree(1);
            SysCommon.ModSysSetting.CopyLayerTreeXmlFromDataBase(Plugin.ModuleCommon.TmpWorkSpace, frm._LayerTreePath);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.m_NodeKey.Trim() != "")
                {
                    _ListLayers.Clear();
                    _ListFeatureClasses.Clear();
                    _ListLayerNames.Clear();
                    IMap        pMap    = _MapControl.Map;
                    XmlDocument pXmldoc = new XmlDocument();
                    pXmldoc.Load(frm._LayerTreePath);
                    ILayer pLayer = SysCommon.ModuleMap.GetLayerByNodeKey(Plugin.ModuleCommon.TmpWorkSpace, pMap, frm.m_NodeKey, pXmldoc);
                    pXmldoc = null;
                    IFeatureClass pFeatureClass = null;
                    string        strLayerName  = "";
                    if (pLayer != null)
                    {
                        strLayerName = pLayer.Name;
                        try
                        {
                            pFeatureClass = (pLayer as IFeatureLayer).FeatureClass;
                        }
                        catch
                        { }
                    }
                    else
                    {
                        pFeatureClass = ModQuery.GetFeatureClassByNodeKey(frm._LayerTreePath, frm.m_NodeKey, out strLayerName);
                    }
                    _ListLayers.Add(pLayer);
                    _ListLayerNames.Add(strLayerName);
                    _ListFeatureClasses.Add(pFeatureClass);
                    txtLayer.Text = strLayerName;
                }

                if (_ListFeatureClasses != null)
                {
                    if (_ListFeatureClasses.Count > 0)
                    {
                        IntialComBox(_ListFeatureClasses[0]);
                    }
                }
            }
        }
コード例 #4
0
ファイル: frmQueryRoad.cs プロジェクト: siszoey/geosufan
        private void btnQuery_Click(object sender, EventArgs e)
        {
            if (_QueryFeaClass == null)
            {
                return;
            }
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(this.Text);//xisheng 日志记录 0928;
            }
            //获得数据库类型,根据数据库类型书写where条件
            string strWKSdescrip = ModQuery.GetDescriptionOfWorkspace((_QueryFeaClass as IDataset).Workspace);

            int indexName = _QueryFeaClass.Fields.FindField(_strFieldName);
            int indexCode = _QueryFeaClass.Fields.FindField(_strFieldCode);

            if (indexName < 0)
            {
                MessageBox.Show("找不到名称字段,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (indexCode < 0)
            {
                MessageBox.Show("找不到编码字段,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            esriFieldType typeName = _QueryFeaClass.Fields.get_Field(indexName).Type;
            esriFieldType typeCode = _QueryFeaClass.Fields.get_Field(indexCode).Type;
            string        strLike  = "";

            switch (strWKSdescrip)
            {
            case "Personal Geodatabase":    //mdb数据库 使用*作匹配符
                strLike = "*";
                break;

            case "File Geodatabase":    //gdb数据库 使用%作匹配符
                strLike = "%";
                break;

            case "Spatial Database Connection":    //sde(oracle数据库) 使用%作匹配符(sql server数据库,现在暂未考虑)
                strLike = "%";
                break;

            default:
                strLike = "%";
                break;
            }
            //构造where条件语句
            string strSqlWhere2 = "";
            string strSqlWhere3 = "";

            if (txtName.Text == "" && this.textCode.Text == "")
            {
                strSqlWhere  = "";    //全部结果的查询条件
                strSqlWhere2 = "";    //查询结果中排序在前
                strSqlWhere3 = "1=0"; //查询结果中排序在后
            }
            else if (this.textCode.Text == "")
            {
                switch (strWKSdescrip)
                {
                case "Personal Geodatabase":    //mdb数据库 使用*作匹配符
                    strLike     = "*";
                    strSqlWhere = _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;

                case "File Geodatabase":    //gdb数据库 使用%作匹配符
                    strLike     = "%";
                    strSqlWhere = _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;

                case "Spatial Database Connection":    //sde(oracle数据库) 使用%作匹配符(sql server数据库,现在暂未考虑)
                    strLike     = "%";
                    strSqlWhere = "contains(" + _strFieldName + ",'" + txtName.Text.Trim() + "')>0";
                    break;

                default:
                    strLike     = "%";
                    strSqlWhere = _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;
                }

                if (typeName.Equals(esriFieldType.esriFieldTypeString))
                {
                    strSqlWhere2 = _strFieldName + " = '" + txtName.Text.Trim() + "'";
                    strSqlWhere3 = _strFieldName + "<>'" + txtName.Text.Trim() + "'";
                }
                else
                {
                    strSqlWhere2 = _strFieldName + " = " + txtName.Text.Trim();
                    strSqlWhere3 = _strFieldName + " <> " + txtName.Text.Trim();
                }
            }
            else if (this.txtName.Text == "")
            {
                switch (strWKSdescrip)
                {
                case "Personal Geodatabase":    //mdb数据库 使用*作匹配符
                    strLike     = "*";
                    strSqlWhere = _strFieldCode + " LIKE '" + strLike + textCode.Text.Trim() + strLike + "'";
                    break;

                case "File Geodatabase":    //gdb数据库 使用%作匹配符
                    strLike     = "%";
                    strSqlWhere = _strFieldCode + " LIKE '" + strLike + textCode.Text.Trim() + strLike + "'";
                    break;

                case "Spatial Database Connection":    //sde(oracle数据库) 使用%作匹配符(sql server数据库,现在暂未考虑)
                    strLike     = "%";
                    strSqlWhere = "contains(" + _strFieldCode + ",'" + textCode.Text.Trim() + "')>0";
                    break;

                default:
                    strLike     = "%";
                    strSqlWhere = _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;
                }

                if (typeCode.Equals(esriFieldType.esriFieldTypeString))
                {
                    strSqlWhere2 = _strFieldCode + " = '" + textCode.Text.Trim() + "'";
                    strSqlWhere3 = _strFieldCode + "<>'" + textCode.Text.Trim() + "'";
                }
                else
                {
                    strSqlWhere2 = _strFieldCode + " = " + textCode.Text.Trim();
                    strSqlWhere3 = _strFieldCode + "<>" + textCode.Text.Trim();
                }
            }
            else
            {
                switch (strWKSdescrip)
                {
                case "Personal Geodatabase":    //mdb数据库 使用*作匹配符
                    strLike     = "*";
                    strSqlWhere = _strFieldCode + " LIKE '" + strLike + textCode.Text.Trim() + strLike + "' and " + _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;

                case "File Geodatabase":    //gdb数据库 使用%作匹配符
                    strLike     = "%";
                    strSqlWhere = _strFieldCode + " LIKE '" + strLike + textCode.Text.Trim() + strLike + "' and " + _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;

                case "Spatial Database Connection":    //sde(oracle数据库) 使用%作匹配符(sql server数据库,现在暂未考虑)
                    strLike     = "%";
                    strSqlWhere = "contains(" + _strFieldCode + ",'" + textCode.Text.Trim() + "') and contains(" + _strFieldName + ",'" + txtName.Text.Trim() + "')>0";
                    break;

                default:
                    strLike     = "%";
                    strSqlWhere = _strFieldName + " LIKE '" + strLike + txtName.Text.Trim() + strLike + "'";
                    break;
                }
                if (typeName.Equals(esriFieldType.esriFieldTypeString))
                {
                    strSqlWhere2 = _strFieldName + " = '" + txtName.Text.Trim() + "'";
                    strSqlWhere3 = _strFieldName + "<>'" + txtName.Text.Trim() + "'";
                }
                else
                {
                    strSqlWhere2 = _strFieldName + " = " + txtName.Text.Trim();
                    strSqlWhere3 = _strFieldName + " <> " + txtName.Text.Trim();
                }
            }
            this.Hide();
            if (_QueryFilterAll == null)
            {
                _QueryFilterAll = new QueryFilterClass();
            }
            if (_QueryFilterPart1 == null)
            {
                _QueryFilterPart1 = new QueryFilterClass();
            }
            if (_QueryFilterPart2 == null)
            {
                _QueryFilterPart2 = new QueryFilterClass();
            }
            //deleted by chulili 20110802 查询道路地物类,不再查询自然地名注记,就不必增加查询条件
            ////added by chulili 20110801
            //if (RoadWhere.Equals(""))
            //{
            //    RoadWhere = "CLASS ='DI' OR CLASS='DG'";
            //}
            //else
            //{
            //    RoadWhere = RoadWhere + " AND (CLASS ='DI' OR CLASS='DG')";
            //}

            ////end added by chulili
            _QueryFilterAll.WhereClause   = strSqlWhere;
            _QueryFilterPart1.WhereClause = strSqlWhere2;
            _QueryFilterPart2.WhereClause = strSqlWhere3;

            if (m_frmQuery == null)
            {
                m_frmQuery = new frmQuerytoTable(_MapControl);
            }
            //用查询地物类,查询条件填充查询窗体

            m_frmQuery.FillData(_QueryFeaClass, _strLayerName, _QueryFilterAll, _QueryFilterPart1, _QueryFilterPart2, true);
            m_frmQuery.Show(_OwnerFrm);
            m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
        }
コード例 #5
0
        public override void OnClick()
        {
            Plugin.Application.IAppGisUpdateRef phook = _AppHk as Plugin.Application.IAppGisUpdateRef;
            SysCommon.BottomQueryBar            pBar  = phook.QueryBar;
            if (pBar.m_WorkSpace == null)
            {
                pBar.m_WorkSpace = Plugin.ModuleCommon.TmpWorkSpace;
            }
            if (pBar.ListDataNodeKeys == null)
            {
                pBar.ListDataNodeKeys = Plugin.ModuleCommon.ListUserdataPriID;
            }
            if (_AppHk == null)
            {
                return;
            }
            if (_AppHk.MapControl == null)
            {
                return;
            }
            IMap pMap = _AppHk.MapControl.Map;

            string strDMFL = "", strDM = "";

            List <ILayer>        pListLayers = null;
            List <IFeatureClass> pListFeatureClasses = null;
            List <string>        pListLayerNames = null;
            List <string>        pListNodeKeys = null;

            SysCommon.ModSysSetting.CopyConfigXml(Plugin.ModuleCommon.TmpWorkSpace, "查询配置", ModQuery.m_QueryPath); //added by chulili 20111110先从业务库拷贝配置文件
            try
            {                                                                                                      //获取地名地物类
                ModQuery.GetPlaceNameQueryConfig(pMap, out pListNodeKeys, out pListLayers, out pListFeatureClasses, out pListLayerNames, out strDM);
                //检查地名字段
                if (pListFeatureClasses == null)
                {
                    MessageBox.Show("找不到地名数据,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (pListFeatureClasses.Count == 0)
                {
                    MessageBox.Show("找不到地名数据,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                for (int i = 0; i < pListFeatureClasses.Count; i++)
                {
                    IFeatureClass pTmpFeaCls = pListFeatureClasses[i];
                    if (pTmpFeaCls.FindField(strDM) < 0)
                    {
                        MessageBox.Show("找不到地名数据名称属性,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                frmQueryDomain fmQD = new frmQueryDomain(Plugin.ModuleCommon.TmpWorkSpace, _pAppForm.MainForm, _AppHk.MapControl, pListNodeKeys, pListLayers, pListFeatureClasses, pListLayerNames, strDM);
                fmQD.WriteLog = this.WriteLog;
                fmQD.QueryBar = pBar;
                fmQD.Show(_pAppForm.MainForm);
                //IQueryFilter pQF = new QueryFilterClass();
                //pQF.WhereClause = fmQD.SqlWhere;
                //frmQuery fmQ = new frmQuery(_AppHk.MapControl);
                ////用查询地物类,查询条件 填充查询窗体
                //if (fmQD._QueryTag.Equals("XZ"))
                //{
                //    fmQ.FillData(pXZFeaClass, pQF,false);
                //}
                //else
                //{
                //    fmQ.FillData(pZRFeaClass, pQF,false);
                //}
                //fmQ.Show((_AppHk as Plugin.Application.IAppFormRef).MainForm);
            }
            catch (Exception ex)
            {
                ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
            }
        }
コード例 #6
0
        //private void radioXZDM_CheckedChanged(object sender, EventArgs e)
        //{
        //    if (radioXZDM.Checked)
        //    {
        //        _QueryTag = "XZ";
        //        //cmbClass1.Items.Clear();
        //        //cmbClass2.Items.Clear();
        //        //cmbClass2.Text = "";
        //        //cmbClass1.Items.Add("省、直辖市、自治区");//AB
        //        //cmbClass1.Items.Add("地级市、自治州、地区");//AC  AD
        //        //cmbClass1.Items.Add("县、县级市");// AE  AF  AG
        //        //cmbClass1.Items.Add("乡镇、街道办"); //AH  AI AJ
        //        //cmbClass1.Items.Add("行政村");// AK
        //        //cmbClass1.Items.Add("自然村");//BA、BB、BC、BD
        //        //cmbClass1.Items.Add("企事业单位");//CA-CH

        //        //cmbClass2.Enabled = false;
        //        //cmbClass1.SelectedIndex = 0;
        //    }
        //}

        //private void radioZRDM_CheckedChanged(object sender, EventArgs e)
        //{
        //    if (radioZRDM.Checked)
        //    {
        //        _QueryTag = "ZR";
        //        //cmbClass2.Enabled = true;
        //        //cmbClass1.Items.Clear();
        //        //cmbClass2.Items.Clear();
        //        //cmbClass1.Items.Add("交通要素");
        //        //cmbClass1.Items.Add("纪念地和古迹名");
        //        //cmbClass1.Items.Add("山名");
        //        //cmbClass1.Items.Add("陆地水域");
        //        //cmbClass1.Items.Add("海洋水域");
        //        //cmbClass1.Items.Add("自然地域");
        //        //cmbClass1.Items.Add("境界标志");
        //        //cmbClass1.SelectedIndex = 0;
        //    }
        //}

        //private void cmbClass1_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    #region radioZRDM.Checked
        //    if (radioZRDM.Checked)
        //    {
        //        switch (cmbClass1.Text)
        //        {
        //            case "交通要素":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("空运站、机场名", "DA");
        //                    zrdm1.Add("海运航线名", "DB");
        //                    zrdm1.Add("海港名", "DC");
        //                    zrdm1.Add("内河航线名", "DD");
        //                    zrdm1.Add("内河港口名", "DE");
        //                    zrdm1.Add("渡口名", "DF");
        //                    zrdm1.Add("铁路线路名", "DG");
        //                    zrdm1.Add("铁路车站名", "DH");
        //                    zrdm1.Add("公路及乡村路名", "DI");
        //                    zrdm1.Add("公路站名", "DJ");
        //                    zrdm1.Add("桥梁、涵洞、隧道名", "DK");
        //                    zrdm1.Add("城市路、街、巷等名", "DL");
        //                    zrdm1.Add("管线、索道名", "DM");
        //                    zrdm1.Add("地铁线路名", "DN");
        //                    zrdm1.Add("地铁站名", "DO");
        //                    zrdm1.Add("其它", "DP");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //            case "纪念地和古迹名":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("具有历史意义的纪念地", "EA");
        //                    zrdm1.Add("公园、风景名胜名", "EB");
        //                    zrdm1.Add("古建筑名(包括钟楼、鼓楼、城楼、关塞、庙宇、塔、宫殿、官邸、府衙、牌坊、碑、寺、石窟、祠、古桥等)", "EC");
        //                    zrdm1.Add("古长城名", "ED");
        //                    zrdm1.Add("古石刻名、摩岩名", "EE");
        //                    zrdm1.Add("古遗址名", "EF");
        //                    zrdm1.Add("古墓葬名", "EG");
        //                    zrdm1.Add("古战场名", "EH");
        //                    zrdm1.Add("其它", "EI");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //            case "山名":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("山体名(包括山脉、山岭、火山、冰山、雪山等)", "HA");
        //                    zrdm1.Add("山峰名(山丘、崮等)", "HB");
        //                    zrdm1.Add("山坡名", "HC");
        //                    zrdm1.Add("谷地名", "HD");
        //                    zrdm1.Add("山崖名", "HE");
        //                    zrdm1.Add("洞穴名", "HF");
        //                    zrdm1.Add("山口名(包括垭口、关口、隘口等)", "HG");
        //                    zrdm1.Add("台地名(塬、坝子名)", "HH");
        //                    zrdm1.Add("其它", "HI");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //            case "陆地水域":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("常年河流名", "IA");
        //                    zrdm1.Add("季节性河流名", "IB");
        //                    zrdm1.Add("消失河名", "IC");
        //                    zrdm1.Add("伏流河名", "ID");
        //                    zrdm1.Add("运河名", "IE");
        //                    zrdm1.Add("渠道名", "IF");
        //                    zrdm1.Add("湖泊名", "IG");
        //                    zrdm1.Add("水库名", "IH");
        //                    zrdm1.Add("蓄洪区名", "II");
        //                    zrdm1.Add("瀑布名", "IJ");
        //                    zrdm1.Add("泉名", "IK");
        //                    zrdm1.Add("井名", "IL");
        //                    zrdm1.Add("干涸河名", "IM");
        //                    zrdm1.Add("干涸湖名", "IN");
        //                    zrdm1.Add("冰川名", "IO");
        //                    zrdm1.Add("河口名", "IP");
        //                    zrdm1.Add("河滩名", "IQ");
        //                    zrdm1.Add("河曲、河湾、峡名", "IR");
        //                    zrdm1.Add("洲岛名", "IS");
        //                    zrdm1.Add("沼泽、湿地名", "IT");
        //                    zrdm1.Add("水利设施名(包括堤坝、水闸、输水隧道等)", "IU");
        //                    zrdm1.Add("其它", "IV");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //            case "海洋水域":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("海洋名", "JA");
        //                    zrdm1.Add("海湾、港湾名", "JB");
        //                    zrdm1.Add("海峡名", "JC");
        //                    zrdm1.Add("水道名", "JD");
        //                    zrdm1.Add("岛、礁名", "JE");
        //                    zrdm1.Add("群岛、列岛名", "JF");
        //                    zrdm1.Add("半岛、岬角名", "JG");
        //                    zrdm1.Add("滩涂名", "JH");
        //                    zrdm1.Add("海盆名", "JI");
        //                    zrdm1.Add("海沟名", "JJ");
        //                    zrdm1.Add("海底山脉名", "JK");
        //                    zrdm1.Add("海岸名", "JL");
        //                    zrdm1.Add("海槽名", "JM");
        //                    zrdm1.Add("海底断裂带名", "JN");
        //                    zrdm1.Add("海底峡谷名", "JO");
        //                    zrdm1.Add("海底高原名", "JP");
        //                    zrdm1.Add("海底平原名", "JQ");
        //                    zrdm1.Add("大陆架、大陆坡名", "JR");
        //                    zrdm1.Add("其它", "JS");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //            case "自然地域":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("平原名", "KA");
        //                    zrdm1.Add("凹地、盆地名", "KB");
        //                    zrdm1.Add("山地、丘陵名", "KC");
        //                    zrdm1.Add("高原名", "KD");
        //                    zrdm1.Add("草原名", "KE");
        //                    zrdm1.Add("绿洲名", "KF");
        //                    zrdm1.Add("荒漠、沙漠名", "KH");
        //                    zrdm1.Add("森林名", "KI");
        //                    zrdm1.Add("三角洲名", "KJ");
        //                    zrdm1.Add("盐田名", "KK");
        //                    zrdm1.Add("自然保护区名", "KL");
        //                    zrdm1.Add("其它", "KM");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //            case "境界标志":
        //                {
        //                    zrdm1 = new Dictionary<string, string>();
        //                    zrdm1.Clear();
        //                    zrdm1.Add("界碑名", "LA");
        //                    zrdm1.Add("界桩名", "LB");
        //                    zrdm1.Add("其它", "LC");
        //                    cmbClass2.Items.Clear();
        //                    foreach (KeyValuePair<string, string> kvp in zrdm1)
        //                    {
        //                        cmbClass2.Items.Add(kvp.Key);
        //                    }
        //                    cmbClass2.SelectedIndex = 0;
        //                    break;
        //                }
        //        }
        //    }
        //    #endregion radioZRDM.Checked
        //    #region else
        //    else
        //    {
        //        switch (cmbClass1.Text)
        //        {
        //            case "省、直辖市、自治区":
        //                {
        //                    xzdmBH = "'AB'";
        //                    break;
        //                }
        //            case "地级市、自治州、地区":
        //                {
        //                    xzdmBH = "'AC','AD'";
        //                    break;
        //                }
        //            case "县、县级市":
        //                {
        //                    xzdmBH = "'AE','AF','AG'";
        //                    break;
        //                }
        //            case "乡镇、街道办":
        //                {
        //                    xzdmBH = "'AH','AI','AJ'";
        //                    break;
        //                }
        //            case "行政村":
        //                {
        //                    xzdmBH = "'AK'";
        //                    break;
        //                }
        //            case "自然村":
        //                {
        //                    xzdmBH = "'BA','BB','BC','BD'";
        //                    break;
        //                }
        //            case "企事业单位":
        //                {
        //                    xzdmBH = "'CA','CB','CC','CD','CE','CF','CG','CH'";
        //                    break;
        //                }
        //        }
        //        #endregion
        //    }
        //}
        #endregion
        private void btnQuery_Click(object sender, EventArgs e)
        {
            //if (radioZRDM.Checked)
            //{
            //    _QueryTag = "ZR";
            //    //strSqlWhere = fdDMFL + " =  '" + zrdm1[cmbClass2.Text] + "' AND " + fdDM + " LIKE '%" + txtName.Text.Trim() + "%'";
            //}
            //else
            //{
            //    _QueryTag = "XZ";
            //    //strSqlWhere = fdDMFL + " IN(" + xzdmBH + ") AND " + fdDM + " LIKE '%" + txtName.Text.Trim() + "%'";
            //}
            int Index = ComField.SelectedIndex;

            if (Index > 0)
            {
                fdDM = m_ListField[Index];
            }
            if (_ListFeatureClasses == null)
            {
                return;
            }
            if (_ListFeatureClasses.Count == 0)
            {
                return;
            }
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("林班查询");//xisheng 日志记录 0928;
            }
            string strWKSdescrip = ModQuery.GetDescriptionOfWorkspace((_ListFeatureClasses[0] as IDataset).Workspace);

            int indexName = _ListFeatureClasses[0].Fields.FindField(fdDM);

            if (indexName < 0)
            {
                MessageBox.Show("找不到名称字段,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            esriFieldType typeName = _ListFeatureClasses[0].Fields.get_Field(indexName).Type;

            string strLike = "";

            switch (strWKSdescrip)
            {
            case "Personal Geodatabase":    //mdb数据库 使用*作匹配符
                strLike = "*";
                break;

            case "File Geodatabase":    //gdb数据库 使用%作匹配符
                strLike = "%";
                break;

            case "Spatial Database Connection":    //sde(oracle数据库) 使用%作匹配符(sql server数据库,现在暂未考虑)
                strLike = "%";
                break;

            default:
                strLike = "%";
                break;
            }
            string strSqlWhere2 = "", strSqlWhere3 = "";

            if (txtBoxName.Text.Trim().Equals(""))
            {
                if (this.rdbAccurate.Checked)
                {
                    MessageBox.Show("精确查询,需输入小班号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (MessageBox.Show("该操作将会查询全库数据,查询速度较慢,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) != DialogResult.Yes)
                {
                    return;
                }
                strSqlWhere  = "";
                strSqlWhere2 = "";
                strSqlWhere3 = "1=0";
            }
            else
            {
                if (this.rdbAccurate.Checked)
                {
                    if (m_SelectXZQ != "")
                    {
                        string tempString = GetWhereCase(m_SelectXZQ);
                        strSqlWhere = fdDM + " = '" + txtBoxName.Text.Trim() + "' and " + tempString;
                    }
                    else
                    {
                        strSqlWhere = fdDM + " = '" + txtBoxName.Text.Trim() + "'";
                    }
                    if (typeName.Equals(esriFieldType.esriFieldTypeString))
                    {
                        strSqlWhere2 = fdDM + " = '" + txtBoxName.Text.Trim() + "'";
                    }
                    else
                    {
                        strSqlWhere2 = fdDM + " = " + txtBoxName.Text.Trim();
                    }

                    strSqlWhere3 = "1=0";
                }
                else
                {
                    if (m_SelectXZQ != "")
                    {
                        string temp = GetWhereCase(m_SelectXZQ);
                        strSqlWhere = fdDM + " LIKE '" + strLike + txtBoxName.Text.Trim() + strLike + "' and " + temp;
                    }
                    else
                    {
                        strSqlWhere = fdDM + " LIKE '" + strLike + txtBoxName.Text.Trim() + strLike + "'";
                    }
                    //strSqlWhere = " contains(" + fdDM + ",'" + txtBoxName.Text.Trim() + "')>0";
                    if (typeName.Equals(esriFieldType.esriFieldTypeString))
                    {
                        strSqlWhere2 = fdDM + " = '" + txtBoxName.Text.Trim() + "'";
                        strSqlWhere3 = fdDM + "<> '" + txtBoxName.Text.Trim() + "'";
                    }
                    else
                    {
                        strSqlWhere2 = fdDM + " = " + txtBoxName.Text.Trim();
                        strSqlWhere3 = fdDM + "<> " + txtBoxName.Text.Trim();
                    }
                }
            }
            this.Hide();

            if (_QueryFilterAll == null)
            {
                _QueryFilterAll = new QueryFilterClass();
            }
            if (_QueryFilterPart1 == null)
            {
                _QueryFilterPart1 = new QueryFilterClass();
            }
            if (_QueryFilterPart2 == null)
            {
                _QueryFilterPart2 = new QueryFilterClass();
            }
            //deleted by chulili 20110802 查询道路地物类,不再查询自然地名注记,就不必增加查询条件
            ////added by chulili 20110801
            //if (RoadWhere.Equals(""))
            //{
            //    RoadWhere = "CLASS ='DI' OR CLASS='DG'";
            //}
            //else
            //{
            //    RoadWhere = RoadWhere + " AND (CLASS ='DI' OR CLASS='DG')";
            //}

            ////end added by chulili
            _QueryFilterAll.WhereClause   = strSqlWhere;
            _QueryFilterPart1.WhereClause = strSqlWhere2;
            _QueryFilterPart2.WhereClause = strSqlWhere3;
            if (m_frmQuery == null)
            {
                m_frmQuery = new frmQuerytoTable(_MapControl);
            }
            //用查询地物类,查询条件填充查询窗体
            //if (this.rdbAccurate.Checked)
            //{
            //    m_frmQuery.FillData(_QueryFeaClass_XZ, _QueryFilterPart1, true);
            //}
            //else
            //{
            //    m_frmQuery.FillData(_QueryFeaClass_XZ, _QueryFilterAll, _QueryFilterPart1, _QueryFilterPart2, true);
            //    //m_frmQuery.FillData(_QueryFeaClass_ZR, pQF, pQF2, pQF3, true);
            //}

            SysCommon.CProgress vProgress = new SysCommon.CProgress("林班查询");
            vProgress.EnableCancel    = false;
            vProgress.ShowDescription = true;
            vProgress.FakeProgress    = true;
            vProgress.TopMost         = true;
            vProgress.ShowProgress();
            vProgress.SetProgress("进行查询");
            try
            {
                // m_frmQuery.FillData(ListLayerName, ListFeatureClass, _QueryFilterAll, _QueryFilterPart1, _QueryFilterPart2, true);
                // QueryBar.EmergeQueryData(_ListNodeKeys, _ListLayers, _ListLayerNames, _ListFeatureClasses, _QueryFilterAll, _QueryFilterPart1, _QueryFilterPart2, true);
                QueryBar.EmergeQueryData(_ListLayers[0] as IFeatureLayer, _QueryFilterAll, vProgress);
                QueryBar.m_pMapControl = _MapControl;
                try
                {
                    DevComponents.DotNetBar.Bar pBar = QueryBar.Parent.Parent as DevComponents.DotNetBar.Bar;
                    if (pBar != null)
                    {
                        pBar.AutoHide = false;
                        //pBar.SelectedDockTab = 1;
                        int tmpindex = pBar.Items.IndexOf("dockItemDataCheck");
                        pBar.SelectedDockTab = tmpindex;
                    }
                }
                catch
                { }
            }
            catch (Exception err2)
            {
                vProgress.Close();
            }
            vProgress.Close();
            //m_frmQuery.Show(_OwnerFrm);
            // m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
        }
コード例 #7
0
        public override void OnClick()
        {//XZQLocation
            if (_hook == null)
            {
                return;
            }
            if (_hook.MainUserControl == null)
            {
                return;
            }

            IGeometry xzqGeo = ModGetData.getExtentByXZQ(m_xzqTree.SelectedNode);

            if (xzqGeo == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未找到相应的行政区范围!");
                return;
            }
            ///ZQ  20111027 add  判断数据字典是否初始化
            if (SysCommon.ModField._DicFieldName.Count == 0)
            {
                SysCommon.ModField.InitNameDic(Plugin.ModuleCommon.TmpWorkSpace, SysCommon.ModField._DicFieldName, "属性对照表");
            }
            IList <string> listMapNo = new List <string>();
            IEnvelope      pExtent   = xzqGeo.Envelope;

            pExtent.Expand(1.5, 1.5, true);//跟地位效果一样 xisheng 20111104
            (_AppHk.ArcGisMapControl.Map as IActiveView).Extent = pExtent;
            //ZQ    20110914    modify   改变显示方式
            //drawPolygonElement(pGeometry as IPolygon, psGra);
            _AppHk.ArcGisMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            //end
            //ZQ   20110809   modify   先刷新后闪烁问题
            _AppHk.ArcGisMapControl.ActiveView.ScreenDisplay.UpdateWindow();
            //end
            _AppHk.ArcGisMapControl.FlashShape(xzqGeo, 3, 200, null);
            //这里需要修改NodeKey 的值      ZQ  20110801     Add
            try
            {
                string        strMapNoField = "";
                string        NodeKey       = GetNodeKey("1:50000", out strMapNoField).ToString();//不同比例尺的接图表的ID号
                IFeatureClass pFeatureClass = ModQuery.GetFeatureClassByNodeKey(NodeKey);
                if (strMapNoField == "")
                {
                    return;
                }
                if (pFeatureClass == null)
                {
                    return;
                }
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry   = xzqGeo;
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor pFeaCursor = pFeatureClass.Search(pSpatialFilter, false);
                IFeature       pFeature   = pFeaCursor.NextFeature();
                while (pFeature != null)
                {
                    //ZQ   20110807  modify
                    listMapNo.Add((pFeature.get_Value(pFeature.Table.FindField(strMapNoField))).ToString());
                    //end
                    pFeature = pFeaCursor.NextFeature();
                }

                pFeaCursor = null;
                GeoUtilities.Gis.Form.frmExportDataByMapNO pfrmExportDataByMapNO = new GeoUtilities.Gis.Form.frmExportDataByMapNO(listMapNo, true, false, false, false, _AppHk.ArcGisMapControl as IMapControlDefault, _hook.CurWksInfo.Wks);
                pfrmExportDataByMapNO.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }