在ArcGlobe三维环境中进行数据查询(.net)
2012-07-26 17:16
211 查看
/// <summary> /// 查询功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnOK_Click(object sender, EventArgs e) { try { //图层名称 String LayerName = this.CbxLayer.Text; //查询条件 String SearchText = this.TbxName.Text; if (SearchText == String.Empty) { MessageBox.Show("查询条件不允许为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); TbxName.Focus(); //清空数据列表 this.dg1.DataSource = null; //跳出查询 return; } //当前视图 IScene scene = this.axGlobeControl1.Globe.GlobeDisplay.Scene; //查询器 IQueryFilter pQueryFilter = new QueryFilterClass(); IActiveView pActiveView; pActiveView = (IActiveView)scene; //清空当前视图 scene.ClearSelection(); IFeatureLayer pFeatureLayer; pFeatureLayer = (IFeatureLayer)scene.get_Layer(GetLayerId(LayerName, scene)); //判断要查询的图层 if (LayerName == "堤防") { //查询条件 pQueryFilter.WhereClause = "XMMC like '%" + SearchText + "%'"; } else if (LayerName == "险工险段") { //查询条件 pQueryFilter.WhereClause = "BZ like '%" + SearchText + "%'"; } ...... IFeatureCursor pFeatureCursor; //查询 pFeatureCursor = pFeatureLayer.FeatureClass.Search(pQueryFilter, false); IFeature pFeature; pFeature = pFeatureCursor.NextFeature(); IFields pFields = pFeatureCursor.Fields; int fieldIndex = 0; int fieldIndexName = 0; if (LayerName == "堤防") { fieldIndex = pFields.FindField("NAME"); fieldIndexName = pFields.FindField("XMMC"); } else if (LayerName == "险工险段") { fieldIndex = pFields.FindField("NAME"); fieldIndexName = pFields.FindField("BZ"); } ...... pfeat = pFeature; if (pFeature == null) { MessageBox.Show("您所查询的结果不存在!"); TbxName.Select(); TbxName.Focus(); this.dg1.DataSource = null; return; } //绑定DataTable DataTable dt = new DataTable(); DataColumn dc1 = new DataColumn(); dc1.ColumnName = "工程代码"; DataColumn dc2 = new DataColumn(); dc2.ColumnName = "工程名称"; dt.Columns.Add(dc1); dt.Columns.Add(dc2); string Code = String.Empty; string Name = String.Empty; while (pFeature != null) { //scene.SelectFeature(pFeatureLayer, pFeature); Code = pFeature.get_Value(fieldIndex) as string; Name = pFeature.get_Value(fieldIndexName) as string; DataRow dr = dt.NewRow(); dr[0] = Code; dr[1] = Name; dt.Rows.Add(dr); pFeature = pFeatureCursor.NextFeature(); } //绑定列表 this.dg1.DataSource = dt.DefaultView; } catch { MessageBox.Show("异常!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.dg1.DataSource = null; } }
相关文章推荐
- 在ArcGlobe三维环境中进行数据查询(.net)
- 在ArcGlobe三维环境中进行数据查询2(模型定位显示)
- 在ArcGlobe三维环境中进行数据查询2(模型定位显示)
- ASP.NET MVC 环境下CKeditor 的配置以及用jQuery进行数据存取操作
- 转自:http://m.blog.csdn.net/article/details?id=6554168 在使用order by语句进行查询结果排序时,不同的数据库对于被排序字段数据行为null的情况
- ASP.NET MVC 环境下CKeditor 的配置以及用jQuery进行数据存取操作
- 一步一步教你使用AgileEAS.NET基础类库进行应用开发-基础篇-UDA应用中使用IOC解偶数据连接环境
- ASP.NET MVC 环境下CKeditor 的配置以及用jQuery进行数据存取操作
- 一步一步教你使用AgileEAS.NET基础类库进行应用开发-基础篇-UDA应用中使用IOC解偶数据连接环境
- ASP.NET MVC 环境下CKeditor 的配置以及用jQuery进行数据存取操作
- 安装IIS后进行Asp.net环境的重新配置
- SQL 大数据查询如何进行优化?
- 在ASP.NET下用Microsoft Excel进行数据分析与报表
- Flex调用WebService进行数据查询和显示(调整)
- 解析ASP.NET Mvc开发之查询数据实例 分类: ASP.NET 2014-01-02 01:27 5788人阅读 评论(3) 收藏
- excel内一键进行sql查询(使用方法 1.选择’需要进行sql查询区域 包括字段名 2 输入sql语句 3.选择输出数据的单元格)
- 通过DataTrigger绑定Tag属性值进行判断(.net 3.5的环境)
- 使用Microsoft excel 2007 进行数据分析---环境配置
- 使用PDF.NET数据开发框架的实体操作语言OQL构造复杂查询条件
- 利用Python进行数据分析-环境搭建