Пример #1
0
        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 (PackageOemQueryServiceClient client = new PackageOemQueryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <PackageOemDetail> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial", new LotOemPackageViewModel()));
        }
Пример #2
0
        public ActionResult Query(LotOemPackageQueryViewModel model)
        {
            string keyList = null;

            if (model.Type != null || model.SN != null || model.PNOM != null || model.PackageNo != null)
            {
                using (PackageOemQueryServiceClient client = new PackageOemQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <PackageOemDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0 && result.Data.Count > 0)
                    {
                        StringBuilder strb = new StringBuilder();

                        foreach (var item in result.Data)
                        {
                            strb.Append("'" + item.Key.SN + "',");
                        }
                        keyList = strb.ToString().Substring(0, strb.Length - 1);
                    }
                    else
                    {
                        return(PartialView("_ListPartial", new LotOemPackageViewModel()));
                    }
                }
            }

            if (keyList != null)
            {
                using (PackageOemQueryServiceClient client = new PackageOemQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        //IsPaging = false,
                        Where = string.Format(" Key in ({0})"
                                              , keyList),
                        OrderBy = "PackageNo",
                    };
                    MethodReturnResult <IList <PackageOemDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                }
            }
            else
            {
                using (PackageOemQueryServiceClient client = new PackageOemQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "PackageNo"
                    };
                    MethodReturnResult <IList <PackageOemDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                    ;
                }
            }
            return(PartialView("_ListPartial", new LotOemPackageViewModel()));
        }