// GET: /PPM/PlanMonth/ public async Task <ActionResult> Index() { //using (PlanMonthServiceClient client = new PlanMonthServiceClient()) //{ // await Task.Run(() => // { // PagingConfig cfg = new PagingConfig() // { // OrderBy = "Key" // }; // MethodReturnResult<IList<PlanMonth>> result = client.Get(ref cfg); // if (result.Code == 0) // { // ViewBag.PagingConfig = cfg; // ViewBag.List = result.Data; // } // }); //} PlanMonthQueryViewModel model = new PlanMonthQueryViewModel { //初始化参数 Year = System.DateTime.Now.ToString("yyyy"), Month = System.DateTime.Now.ToString("MM") }; return(View(model)); }
public async Task <ActionResult> Query(PlanMonthQueryViewModel model) { if (ModelState.IsValid) { using (PlanMonthServiceClient client = new PlanMonthServiceClient()) { await Task.Run(() => { StringBuilder where = new StringBuilder(); if (model != null) { if (!string.IsNullOrEmpty(model.Year)) { where.AppendFormat(" {0} Key.Year LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Year); } if (!string.IsNullOrEmpty(model.Month)) { where.AppendFormat(" {0} Key.Month LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.Month); } if (!string.IsNullOrEmpty(model.LocationName)) { where.AppendFormat(" {0} Key.LocationName LIKE '{1}%'" , where.Length > 0 ? "AND" : string.Empty , model.LocationName); } } PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; MethodReturnResult <IList <PlanMonth> > result = client.Get(ref cfg); if (result.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = result.Data; } }); } } return(PartialView("_ListPartial")); }