public ListItemCollection searchProject(ListItemCollection projList)
{
DataSet DSToReturn = new DataSet();
ListItemCollection returnItems = new ListItemCollection();
ListItemCollection ResultItems = new ListItemCollection();
DataTable results = (from d in ((DataSet)_MyDataset).Tables["Records"].AsEnumerable()
orderby d.Field("Name") ascending
select d).CopyToDataTable();
foreach (DataRow row in results.Rows)
{
ListItem item = new ListItem(row["Name"].ToString(), row["Value"].ToString());
ResultItems.Add(item);
}
if (this.myItems[0] != "--")
{
var query = (from q in results.AsEnumerable()
where q["Business"].ToString().Contains(this.myItems[0])
select q);
if (query.Count() > 0)
results = query.CopyToDataTable();
else
results.Rows.Clear();
}
if (this.myItems[1] != "--")
{
var query = (from q in results.AsEnumerable()
where q["Business_group"].ToString().Contains(this.myItems[1])
select q);
if (query.Count() > 0)
results = query.CopyToDataTable();
else
results.Rows.Clear();
}
if (this.myItems[2] != "--")
{
var query = (from q in results.AsEnumerable()
where q["Value_center"].ToString().Contains(this.myItems[2])
select q);
if (query.Count() > 0)
results = query.CopyToDataTable();
else
results.Rows.Clear();
}
if (this.myItems[3] != "--")
{
var query = (from q in results.AsEnumerable()
where q["Client_name"].ToString().Contains(this.myItems[3])
select q);
if (query.Count() > 0)
results = query.CopyToDataTable();
else
results.Rows.Clear();
}
if (this.myItems[4] != "--")
{
var query = (from q in results.AsEnumerable()
where q["Owner_name"].ToString().Contains(this.myItems[4])
select q);
if (query.Count() > 0)
results = query.CopyToDataTable();
else
results.Rows.Clear();
}
if (results.Rows.Count > 0)
{
foreach (ListItem li in ResultItems)
{
if ((from System.Data.DataRow row in results.Rows
where li.Value.Equals(row["value"].ToString(), StringComparison.InvariantCultureIgnoreCase)
select row["value"]).Count() > 0)
returnItems.Add(li);
}
}
else
{
ListItem item = new ListItem("No Results", "0");
returnItems.Add(item);
}
return returnItems;
}
|