private void QueryBut_Click(object sender, EventArgs e) { IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); string text = ""; int count = this.DXArray.Count; int num = 1; foreach (string current in this.DXArray) { text += this.strDX; text += " = '"; text += current; text += "'"; if (num < count) { text += " OR "; } num++; } spatialFilter.WhereClause = text; if (this.GeometrySet.Checked) { if (this.m_ipGeo != null) { spatialFilter.Geometry = (this.m_ipGeo); } spatialFilter.SpatialRel = (esriSpatialRelEnum)(1); } IFeatureCursor pCursor = featureClass.Search(spatialFilter, false); //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); }
private void btnPipeLineQuery_Click(object sender, EventArgs e) { if (this.cmbPipeLineFields.Text == "") { MessageBox.Show(@"请选择管线层查询字段!"); } else if (this.lstBoxPipeLineValues.Text == "") { MessageBox.Show(@"请指定管线层查询值!"); } else if (this.lstBoxPipeLineValues.Text == "") { MessageBox.Show(@"请指定管点层查询值!"); } else { Splash.Show(); Splash.Status = "状态:关联查询中,请稍候..."; this.Walk(); RelateQueryUI.LayerboxItem layerboxItem = this.cmbPipeLine.SelectedItem as RelateQueryUI.LayerboxItem; IFeatureLayer pPipeLayer = layerboxItem.m_pPipeLayer; IFeatureSelection featureSelection = (IFeatureSelection)pPipeLayer; featureSelection.Clear(); ISelectionSet selectionSet = featureSelection.SelectionSet; selectionSet.IDs.Reset(); int count = this.m_alPipeLine.Count; for (int i = 0; i < count; i++) { IFeature feature = this.m_alPipeLine[i] as IFeature; selectionSet.Add(feature.OID); } IQueryFilter queryFilter = new QueryFilter(); ICursor cursor; selectionSet.Search(queryFilter, false, out cursor); IFeatureCursor pFeatureCursor = cursor as IFeatureCursor; Splash.Close(); _plugin.FireQueryResultChanged(new QueryResultArgs(pFeatureCursor, featureSelection, queryFilter as ISpatialFilter)); } }
private void QueryButton_Click(object sender, EventArgs e) { ISpatialFilter spatialFilter = new SpatialFilter(); IFeatureCursor featureCursor = null; if (this.SqlBox.Text != "" || MessageBox.Show(@"末指定属性条件,是否查询?", @"提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { spatialFilter.WhereClause = this.SqlBox.Text; if (this.bGeo.Checked && this.m_ipGeo != null) { if (this.GlacisUpDown.Value > 0m) { ITopologicalOperator topologicalOperator = (ITopologicalOperator)this.m_OriginGeo; IGeometry ipGeo = topologicalOperator.Buffer((double)this.GlacisUpDown.Value); this.m_ipGeo = ipGeo; spatialFilter.Geometry = (this.m_ipGeo); } else { spatialFilter.Geometry = (this.m_OriginGeo); } } if (this.SelectType == 0) { spatialFilter.SpatialRel = (esriSpatialRelEnum)(1); } if (this.SelectType == 1) { spatialFilter.SpatialRel = (esriSpatialRelEnum)(7); } try { this.MakeSelectionSetForSearch(this.SelectLayer); ICursor cursor = null; this.m_pSelectionSetForSearch.Search(spatialFilter, false, out cursor); if (cursor is IFeatureCursor) { featureCursor = (cursor as IFeatureCursor); } } catch (Exception) { MessageBox.Show(@"查询值有误,请检查!"); return; } _plugin.FireQueryResultChanged(new QueryResultArgs(featureCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); } }
private void button1_Click(object sender, EventArgs e) { if (this.SelectLayer == null) { MessageBox.Show(@"项目地界层不存在!"); } else { IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); string text = this.comboBox1.Text; string text2; if (!this.checkBox1.Checked) { text2 = "名称 = "; text2 += " '"; text2 += text; text2 += "'"; } else { text2 = "名称 LIKE "; IDataset dataset = this.SelectLayer.FeatureClass as IDataset; if (dataset.Workspace.Type == (esriWorkspaceType)2) { text2 += " '%"; text2 += text; text2 += "%'"; } else { text2 += " '*"; text2 += text; text2 += "*'"; } } if (this.comboBox1.Text == "") { text2 = "名称 IS NULL "; } spatialFilter.WhereClause = text2; IFeatureCursor pCursor = featureClass.Search(spatialFilter, false); //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); } }
private void QueryBut_Click(object sender, EventArgs e) { IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); string text = ""; if (!this.BlurCheck.Checked) { int count = this.ADArray.Count; int num = 1; using (List <string> .Enumerator enumerator = this.ADArray.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; text += this.FieldBox.Text; text += " = \""; text += current; text += "\""; if (num < count) { text += " OR "; } num++; } goto IL_101; } } text = this.FieldBox.Text; text += " LIKE \"*"; text += this.SqlBox.Text; text += "*\""; IL_101: spatialFilter.WhereClause = text; IFeatureCursor pFeatureCursor = featureClass.Search(spatialFilter, false); _plugin.FireQueryResultChanged(new QueryResultArgs(pFeatureCursor, this.SelectLayer as IFeatureSelection)); }
private void button1_Click(object sender, EventArgs e) { if (this.SelectLayer == null) { MessageBox.Show(@"项目地界层不存在!"); } else { IFeatureClass featureClass = this.SelectLayer.FeatureClass; IFunctionLayer layerInfo = pPipeCfg.GetFunctionLayer(featureClass); ISpatialFilter spatialFilter = new SpatialFilter(); string text = this.comboBox1.Text; string text2; if (!this.checkBox1.Checked) { if (this.radioButton1.Checked) { text2 = $"{layerInfo.GetFieldName(PipeConfigWordHelper.FunctionLayerWorkds.XMMC)} = "; } else { text2 = $"{layerInfo.GetFieldName(PipeConfigWordHelper.FunctionLayerWorkds.XMDW)} = "; } text2 += " '"; text2 += text; text2 += "'"; } else { if (this.radioButton1.Checked) { text2 = $"{layerInfo.GetFieldName(PipeConfigWordHelper.FunctionLayerWorkds.XMMC)} LIKE "; } else { text2 = $"{layerInfo.GetFieldName(PipeConfigWordHelper.FunctionLayerWorkds.XMDW)} LIKE "; } IDataset dataset = this.SelectLayer.FeatureClass as IDataset; if (dataset.Workspace.Type == (esriWorkspaceType)2) { text2 += " '%"; text2 += text; text2 += "%'"; } else { text2 += " '*"; text2 += text; text2 += "*'"; } } if (this.comboBox1.Text == "") { text2 = ""; } spatialFilter.WhereClause = text2; IFeatureCursor pCursor = featureClass.Search(spatialFilter, false); //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer)); } }
private void QueryBut_Click(object sender, EventArgs e) { IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); IFeatureCursor pCursor = null; string text = ""; if (this.FieldValueBox.Text == string.Empty) { MessageBox.Show(@"请确定所在位置!"); } else { if (!this.BlurCheck.Checked) { text = this.FieldBox.Text; text += "='"; text += this.FieldValueBox.Text; text += "'"; } else { IDataset dataset = this.SelectLayer.FeatureClass as IDataset; if (dataset != null && dataset.Workspace.Type == (esriWorkspaceType)2) { text = this.FieldBox.Text; text += " LIKE '%"; text += this.FieldValueBox.Text; text += "%'"; } else { text = this.FieldBox.Text; text += " LIKE '*"; text += this.FieldValueBox.Text; text += "*'"; } } List <string> list = new List <string>(); list.Clear(); for (int i = 0; i < this.ValueBox.Items.Count; i++) { if (this.ValueBox.GetItemChecked(i)) { string item = this.ValueBox.Items[i].ToString(); list.Add(item); } } if (this.radioButton1.Checked) { if (list.Count > 0) { text += " and ( "; int num = 1; int count = list.Count; foreach (string current in list) { text += this.FindField; text += " = '"; text += current; text += "'"; if (num < count) { text += " OR "; } num++; } text += ")"; } } else if (list.Count > 0) { text += " and ( "; int num2 = 1; int count2 = list.Count; foreach (string current2 in list) { if (current2.Contains("x") || current2.Contains("X") || current2.Contains("*")) { text += this.FindField1; text += " = '"; text += current2; text += "'"; } else { text += this.FindField; text += " = "; text += current2; } if (num2 < count2) { text += " OR "; } num2++; } text += ")"; } spatialFilter.WhereClause = text; try { pCursor = featureClass.Search(spatialFilter, false); } catch (Exception ex) { MessageBox.Show(@"查询条件过于复杂,请减少条件项。" + ex.Message); } //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); } }
private void QueryBut_Click(object sender, EventArgs e) { if (!this.radioButton1.Checked && !this.radioButton2.Checked) { MessageBox.Show(@"系统设置有误/当前层不含有管径信息,请检查配置文件/数据!"); } else if (!this.radioButton1.Enabled && !this.radioButton2.Enabled) { MessageBox.Show(@"系统设置有误/当前层不含有管径信息,请检查配置文件/数据!"); } else { IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); IFeatureCursor pCursor = null; string text = ""; if (this.radioButton1.Checked) { if (this.OperateBox.SelectedItem.ToString() == "介于") { double num = Convert.ToDouble(this.ValueBox1.Text); double num2 = Convert.ToDouble(this.ValueBox2.Text); string text2; string text3; if (num > num2) { text2 = this.ValueBox1.Text; text3 = this.ValueBox2.Text; } else { text3 = this.ValueBox1.Text; text2 = this.ValueBox2.Text; } if (text3 == text2) { if (this.myfieldGJ.Type == esriFieldType.esriFieldTypeString) { text = this.strGJ; text += " = '"; text += text3; text += "'"; } else { text = this.strGJ; text += text3; } } else if (this.myfieldGJ.Type == esriFieldType.esriFieldTypeString) { text = this.strGJ; text += ">= '"; text += text3; text += "' and "; text += this.strGJ; text += "<= '"; text += text2; text += "'"; } else { text = this.strGJ; text += ">="; text += text3; text += " and "; text += this.strGJ; text += "<="; text += text2; } } else { text += this.strGJ; switch (this.OperateBox.SelectedIndex) { case 0: text += ">"; break; case 1: text += ">="; break; case 2: text += "="; break; case 3: text += "<>"; break; case 4: text += "<"; break; case 5: text += "<="; break; } if (this.myfieldGJ.Type == esriFieldType.esriFieldTypeString) { text += "'"; text += this.ValueBox1.Text; text += "'"; } else { text += this.ValueBox1.Text; } } } else if (this.radioButton2.Checked) { text = this.strKG; switch (this.OperateBox2.SelectedIndex) { case 0: text += "="; break; case 1: text += "<>"; break; } if (this.ValueBox3.Text == @"空字段值") { text += "''"; } else { text += "'"; text += this.ValueBox3.Text; text += "'"; } } spatialFilter.WhereClause = text; try { if (this.GeometrySet.Checked && this.m_ipGeo != null) { spatialFilter.Geometry = (this.m_ipGeo); } if (this.SelectType == 0) { spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; } else if (this.SelectType == 1) { spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin; } pCursor = featureClass.Search(spatialFilter, false); } catch (Exception) { MessageBox.Show(@"查询值有误,请检查!"); return; } //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); } }
private void QueryButton_Click(object sender, EventArgs e) { IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); IFeatureCursor pCursor = null; string text = this.ValueEdit.Text; if (text != "") { if (this.myfields == null) { return; } int num = this.myfields.FindField(this.FieldsBox.SelectedItem.ToString()); IField field = this.myfields.Field[num]; string text2 = this.FieldsBox.SelectedItem.ToString(); if (text == "NULL") { if (this.Equalradio.Checked) { text2 += " IS NULL"; } if (this.NoEqualRadio.Checked) { text2 = "NOT(" + text2 + " IS NULL)"; } if (this.LikeRadio.Checked) { text2 += " LIKE NULL"; } } else { if (this.Equalradio.Checked) { text2 += "="; } if (this.NoEqualRadio.Checked) { text2 += "<>"; } if (this.SmallRadio.Checked) { text2 += "<"; } if (this.SmalelRadio.Checked) { text2 += "<="; } if (this.Bigradio.Checked) { text2 += ">"; } if (this.BigeRaido.Checked) { text2 += ">="; } if (this.LikeRadio.Checked) { text2 += " like "; } if (text == "空字段值") { text = ""; } if (field.Type == (esriFieldType)4) { if (this.LikeRadio.Checked) { IDataset dataset = this.SelectLayer.FeatureClass as IDataset; if (dataset.Workspace.Type == (esriWorkspaceType)2) { text2 += "'%"; text2 += text; text2 += "%'"; } else { text2 += "'*"; text2 += text; text2 += "*'"; } } else { text2 += "'"; text2 += text; text2 += "'"; } } else if (field.Type == esriFieldType.esriFieldTypeDate) { if (this.SelectLayer.DataSourceType == "SDE Feature Class") { text2 += "TO_DATE('"; text2 += text; text2 += "','YYYY-MM-DD')"; } if (this.SelectLayer.DataSourceType == "Personal Geodatabase Feature Class") { text2 += "#"; text2 += text; text2 += "#"; } } else { text2 += text; } } spatialFilter.WhereClause = (text2); } else if (MessageBox.Show(@"末指定属性条件,是否查询?", @"提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } if (this.GeometrySet.Checked && this.m_ipGeo != null) { spatialFilter.Geometry = (this.m_ipGeo); } if (this.SelectType == 0) { spatialFilter.SpatialRel = (esriSpatialRelEnum)(1); } if (this.SelectType == 1) { spatialFilter.SpatialRel = (esriSpatialRelEnum)(7); } try { pCursor = featureClass.Search(spatialFilter, false); } catch (Exception) { MessageBox.Show(@"查询值有误,请检查!"); return; } //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); }
private void QueryBut_Click(object sender, EventArgs e) { string text = ""; int selectedIndex = this.LayerBox.SelectedIndex; if (selectedIndex >= 0) { this.SelectLayer = null; if (this.MapControl != null) { this.SelectLayer = ((SimpleQueryByDataUI.LayerboxItem) this.LayerBox.SelectedItem).m_pPipeLayer; if (this.SelectLayer != null) { this.myfields = this.SelectLayer.FeatureClass.Fields; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(this.SelectLayer.FeatureClass); string text2; if (this.radioButton1.Checked) { text2 = layerInfo.GetFieldName(PipeConfigWordHelper.PointWords.MSRQ); ; // this.pPipeCfg.GetPointTableFieldName("建设年代"); } else { text2 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.MSRQ); // this.pPipeCfg.GetLineTableFieldName("建设年代"); } int num = this.myfields.FindField(text2); if (num < 0) { MessageBox.Show(@"图层中日期字段没有找到!请检查配置文件!"); } else { IField field = this.myfields.Field[num]; if (field.Type == (esriFieldType)4) { switch (this.OperateBox.SelectedIndex) { case 0: text = text2; text += "<= '"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "'"; break; case 1: text = text2; text += ">= '"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "'"; break; case 2: text = text2; text += "= '"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "'"; break; case 3: text = text2; text += ">= '"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "'and "; text += text2; text += "<= '"; text += this.dateTimePicker2.Value.ToShortDateString(); text += "'"; break; } } else if (field.Type == (esriFieldType)5) { if (this.SelectLayer.DataSourceType == "Personal Geodatabase Feature Class") { switch (this.OperateBox.SelectedIndex) { case 0: text = text2; text += "<= #"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "#"; break; case 1: text = text2; text += ">= #"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "#"; break; case 2: text = text2; text += "= #"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "#"; break; case 3: text = text2; text += ">= #"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "# and "; text += text2; text += "<= #"; text += this.dateTimePicker2.Value.ToShortDateString(); text += "#"; break; } } if (this.SelectLayer.DataSourceType == "SDE Feature Class") { switch (this.OperateBox.SelectedIndex) { case 0: text = text2; text += "<= TO_DATE('"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "','YYYY-MM-DD')"; break; case 1: text = text2; text += ">= TO_DATE('"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "','YYYY-MM-DD')"; break; case 2: text = text2; text += "= TO_DATE('"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "','YYYY-MM-DD')"; break; case 3: text = text2; text += ">= TO_DATE('"; text += this.dateTimePicker1.Value.ToShortDateString(); text += "','YYYY-MM-DD') and "; text += text2; text += "<= TO_DATE('"; text += this.dateTimePicker2.Value.ToShortDateString(); text += "','YYYY-MM-DD')"; break; } } } IFeatureClass featureClass = this.SelectLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.WhereClause = text; if (this.GeometrySet.Checked) { if (this.m_ipGeo != null) { spatialFilter.Geometry = (this.m_ipGeo); } spatialFilter.SpatialRel = (esriSpatialRelEnum)(1); } IFeatureCursor pCursor = featureClass.Search(spatialFilter, false); //修改为插件事件,因为结果显示窗体为插件拥有。 _plugin.FireQueryResultChanged(new QueryResultArgs(pCursor, (IFeatureSelection)this.SelectLayer, spatialFilter)); } } } } }