public static List getAllplanFine(string startime,string
endtime,string productname,string equipment, string properson)
{
List dqt = new List();
string sql = @"select *from [Plan] p inner join [Week] w on p.planid=w.pid where 1=1";
List items = new List();
if (startime.Length > 0)
{
sql += " and startime = @startime";
items.Add(new SqlParameter("@startime", startime ));
}
if (endtime.Length > 0)
{
sql += " and endtime = @endtime";
items.Add(new SqlParameter("@endtime", endtime ));
}
if (equipment.Length > 0)
{
sql += " and equipment= @equipment";
items.Add(new SqlParameter("@equipment", equipment));
}
if (productname.Length > 0)
{
sql += " and productname = @productname";
items.Add(new SqlParameter("@productname", productname));
}
if (properson.Length > 0)
{
sql += " and properson= @properson";
items.Add(new SqlParameter("@properson", properson));
}
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionString, CommandType.Text, sql, items.ToArray());
//dataset yeyou talbes
//datable DataRow in dt.Rows
if (ds.Tables.Count > 0)
{
DataTable dt = ds.Tables[0];
foreach (DataRow item in dt.Rows)
{
Plan q = new Plan();
q.planid = int.Parse(item["planid"].ToString());
q.productname = item["productname"].ToString();
q.equipment = item["equipment"].ToString();
q.functionalmodule = item["functionalmodule"].ToString();
q.partscode = item["partscode"].ToString();
q.partsimage = item["partsimage"].ToString();
多条件查询 没值 为空