public ActionResult Query(ChestMonitorQueryViewModel model) { if (ModelState.IsValid) { StringBuilder where = new StringBuilder(); where.AppendFormat(string.Format(@" (ChestState = 0 OR ChestState = 6)")); if (model.OrderNumber != null && model.OrderNumber != "") { where.AppendFormat(" {0} OrderNumber = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.OrderNumber.Trim().ToUpper()); } if (model.MaterialCode != null && model.MaterialCode != "") { where.AppendFormat(" {0} MaterialCode = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.MaterialCode.Trim().ToUpper()); } if (model.PowerName != null && model.PowerName != "") { where.AppendFormat(" {0} PowerName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.PowerName.Trim().ToUpper()); } if (model.Grade != null && model.Grade != "") { where.AppendFormat(" {0} Grade LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Grade.Trim().ToUpper()); } if (model.Color != null && model.Color != "") { where.AppendFormat(" {0} Color LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Color.Trim().ToUpper()); } if (model.PowerSubCode != null && model.PowerSubCode != "") { where.AppendFormat(" {0} PowerSubCode = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.PowerSubCode.Trim().ToUpper()); } using (PackageInChestServiceClient client = new PackageInChestServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, OrderBy = "EditTime", Where = where.ToString() }; MethodReturnResult <IList <Chest> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.List = result.Data; } } } if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", model)); } else { return(View(model)); } }
public ActionResult Query() { ChestMonitorQueryViewModel model = new ChestMonitorQueryViewModel(); return(Query(model)); }