public async Task <ActionResult> Query(CheckSettingPointQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (CheckSettingPointServiceClient client = new CheckSettingPointServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            where.AppendFormat(" {0} Key.CheckSettingKey = '{1}'"
                                               , where.Length > 0 ? "AND" : string.Empty
                                               , model.CheckSettingKey);

                            if (!string.IsNullOrEmpty(model.CategoryName))
                            {
                                where.AppendFormat(" {0} CategoryName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.CategoryName);
                            }
                            if (!string.IsNullOrEmpty(model.CheckPlanName))
                            {
                                where.AppendFormat(" {0} CheckPlanName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.CheckPlanName);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key.ItemNo",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <CheckSettingPoint> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
 public ActionResult GetMaxItemNo(string checksettingKey)
 {
     using (CheckSettingPointServiceClient client = new CheckSettingPointServiceClient())
     {
         PagingConfig cfg = new PagingConfig()
         {
             PageNo   = 0,
             PageSize = 1,
             Where    = string.Format("Key.CheckSettingKey='{0}'", checksettingKey),
             OrderBy  = "Key.ItemNo Desc"
         };
         MethodReturnResult <IList <CheckSettingPoint> > result = client.Get(ref cfg);
         if (result.Code <= 0 && result.Data != null && result.Data.Count > 0)
         {
             return(Json(result.Data[0].Key.ItemNo + 1, JsonRequestBehavior.AllowGet));
         }
     }
     return(Json(1, JsonRequestBehavior.AllowGet));
 }
        //
        // GET: /QAM/CheckSettingPoint/
        public async Task <ActionResult> Index(string checkSettingKey, string groupName)
        {
            using (CheckSettingServiceClient client = new CheckSettingServiceClient())
            {
                MethodReturnResult <CheckSetting> result = await client.GetAsync(checkSettingKey ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "CheckSetting"));
                }
                ViewBag.CheckSetting = result.Data;
            }

            using (CheckSettingPointServiceClient client = new CheckSettingPointServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key.ItemNo",
                        Where   = string.Format(" Key.CheckSettingKey = '{0}'"
                                                , checkSettingKey)
                    };
                    MethodReturnResult <IList <CheckSettingPoint> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new CheckSettingPointQueryViewModel()
            {
                CheckSettingKey = checkSettingKey, GroupName = groupName
            }));
        }
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (CheckSettingPointServiceClient client = new CheckSettingPointServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <CheckSettingPoint> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }