I modified my stored procedure to receive a where clause as an nvarchar(4000) data type in addition to two other parameters. The browse dialog's searching method does the following with the filter generated from the user (I previously defined _filter as a private variable of type string):
private void browseDialog1_Searching(object sender, MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogSearchingEventArgs e)
{
_filter = "";
int _count = 1;
foreach (WhereStatement mStmt in e.RawWhereStatementsCollection)
{
if (_count == 1)
{
_filter = mStmt.Fields[0];
}
else
{
_filter += " AND ";
_filter += mStmt.Fields[0];
}
switch (mStmt.StatementType)
{
case WhereStatementTypeOptions.BeginsWith:
_filter += " LIKE '" + mStmt.Values[0].ToString() + "%'";
break;
case WhereStatementTypeOptions.CompoundPrimaryKey:
// not sure how to handle this option
break;
case WhereStatementTypeOptions.Contains:
_filter += " LIKE '%" + mStmt.Values[0].ToString() + "%'";
break;
case WhereStatementTypeOptions.EndsWith:
_filter += " LIKE '%" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.Equals:
_filter += " = '" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.GreaterThan:
_filter += " > '" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.GreaterThanOrEqual:
_filter += " >= '" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.In:
// not fully implemented since this may involve multiple values
_filter += " IN '" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.LessThan:
_filter += " < '" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.LessThanOrEqual:
_filter += " <= '" + mStmt.Values[0].ToString() + "'";
break;
case WhereStatementTypeOptions.Like:
_filter += " LIKE '%" + mStmt.Values[0].ToString() + "%'";
break;
}
_count += 1;
}
}
Once I have the where statement, now I have the necessary ammunition to volley into my stored procedure. I do this within the button that starts the whole thing, like this:
private void cmdSearch_Click(object sender, EventArgs e)
{
Aspire.Model.ADUserBO mADUser = new Aspire.Model.ADUserBO();
browseDialog1.SearchFields["divisionindex"].InitialValue = mADUser.LocationIndex.ToString();
if (browseDialog1.ShowDialog(false) == DialogResult.OK)
{
waitWindow1.ShowWaitWindow();
partsBO1.FillForRequirements(_filter);
GetRequirements();
waitWindow1.HideWaitWindow();
}
}
The GetRequirements method takes a couple of BOs on the form, creates a complex dataset which is fed to a DevEx grid. The grid takes it from there.
If there is an easier way to get the where clause out of the browse dialog, I am open to suggestions. This is working, and fulfills the need of the moment. Thanks for the framework (without which the above would have taken many days to do...only several hours were involved, and that was mostly in the stored procedure) and thanks for the help!
Bill