private void cmdQuery_Click(object sender, System.EventArgs e)
{
//Set mouse cursor as this can take some time with large datasets
Cursor.Current = Cursors.WaitCursor;
//Check value has been entered in field combo
if (cboFields.Text == "")
{
System.Windows.Forms.MessageBox.Show("You have not selected a field.");
Cursor.Current = Cursors.Default;
return;
}
//Check value has been entered in operator combo
if (cboOperator.Text == "")
{
System.Windows.Forms.MessageBox.Show("You have not selected an operator.");
Cursor.Current = Cursors.Default;
return;
}
//Check value has been entered in value textbox
if (txtValue.Text == "")
{
System.Windows.Forms.MessageBox.Show("You have not entered a query value.");
txtValue.Focus();
Cursor.Current = Cursors.Default;
return;
}
//Get layer to query
ARMap arMap = axArcReaderControl1.ARPageLayout.FocusARMap;
ARLayer arLayer = (ARLayer)m_LayersIndex[cboLayers.SelectedIndex];
//Build the ARSearchDef
ArcReaderSearchDef arSearchDef = new ArcReaderSearchDefClass();
//Build WhereClause that meets search criteria
string sWhereClause;
//Remove quotes from WhereClause if search is numeric
if (optNumber.Checked == true)
{
sWhereClause = cboFields.Text + " " + cboOperator.Text + " " + txtValue.Text;
}
else
{
sWhereClause = cboFields.Text + " " + cboOperator.Text + " '" + txtValue.Text + "'";
}
arSearchDef.WhereClause = sWhereClause;
//Get ARFeatureSet that meets the search criteria
m_arFeatureSetMeets = arLayer.QueryARFeatures(arSearchDef);
//Build WhereClause that fails search criteria
//Remove quotes from WhereClause if search is numeric
if (optNumber.Checked == true)
{
sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " " + txtValue.Text;
}
else
{
sWhereClause = cboFields.Text + " " + InverseOperator[cboOperator.SelectedIndex].inverse.ToString() + " '" + txtValue.Text + "'";
}
arSearchDef.WhereClause = sWhereClause;
//Get ARFeatureSet that fails search criteria
m_arFeatureSetFails = arLayer.QueryARFeatures(arSearchDef);
//Reset mouse cursor
Cursor.Current = Cursors.Default;
//Populate the DataGrid Controls with the ARFeatureSets
PopulateFlexGrids(dataGridView1, m_arFeatureSetMeets);
PopulateFlexGrids(dataGridView2, m_arFeatureSetFails);
//Give the user some feedback regarding the number of features that meet criteria
if (m_arFeatureSetMeets.ARFeatureCount > 0)
{
EnableMeetHighlightTools(true);
lblMeets.Text = "Features MEETING the search criteria: " + m_arFeatureSetMeets.ARFeatureCount.ToString();
}
else
{
EnableMeetHighlightTools(false);
dataGridView1.Rows.Clear();
lblMeets.Text = "Features MEETING the search criteria: 0";
}
if (m_arFeatureSetFails.ARFeatureCount > 0)
{
EnableFailHighlightTools(true);
lblFails.Text = "Features FAILING the search criteria: " + m_arFeatureSetFails.ARFeatureCount.ToString();
}
else
{
EnableFailHighlightTools(false);
dataGridView2.Rows.Clear();
lblMeets.Text = "Features FAILING the search criteria: 0";
}
}
private void PopulateFlexGrids(DataGridView pDataGrid, ARFeatureSet arFeatureSet)