string beginTime = txtFormDate.Text.Trim();//开始时间(用户选择)--查询条件
string endTime = txtToDate.Text.Trim();//结束时间(用户选择)--查询条件
string prodNum = txtProdNum.Text.Trim();//商品编码(用户填写)--查询条件
string shopName = txtShopName.Text.Trim();//门店名称(用户填写)--查询条件
string queryStr = string.Empty;
query = new SPQuery();
if (beginTime.Length > 0 && endTime.Length > 0)
{
queryStr += string.Format(@"<And><Geq><FieldRef Name='SubmitDate'/><Value Type='DateTime'>{0}</Value></Geq>
<Leq><FieldRef Name='SubmitDate'/><Value Type='DateTime' >{1}</Value></Leq></And>", beginTime, endTime);
}
if (beginTime.Length > 0 && endTime.Length <= 0)
{
queryStr += string.Format("<Geq><FieldRef Name='SubmitDate'/><Value Type='DateTime' >{0}</Value></Geq>", beginTime);
}
if (beginTime.Length <= 0 && endTime.Length > 0)
{
queryStr += string.Format("<Leq><FieldRef Name='SubmitDate'/><Value Type='DateTime' >{0}</Value></Leq>",endTime);
}
if (prodNum.Length > 0)
{
queryStr += string.Format("<Eq><FieldRef Name='ProdNum'/><Value Type='Text'>{0}</Value></Eq>", prodNum);
}
if (shopName.Length > 0)
{
queryStr += string.Format("<Eq><FieldRef Name='ShopName'/><Value Type='Text'>{0}</Value></Eq>", shopName);
}
query.Query = string.Format("<Where>{0}</Where>", queryStr);
现在的业务是多条件查询,但不知道如何拼接spquery,以上是我拼接的Query,但是存在很多问题导致功能无法实现,请高手帮忙解决,不甚感激!