Пример #1
0
        //public ActionResult GetSupplierName(string q)
        //{
        //    IList<Supplier> lstSupplier = new List<Supplier>();

        //    using (SupplierServiceClient client = new SupplierServiceClient())
        //    {
        //        PagingConfig cfg = new PagingConfig()
        //        {
        //            IsPaging = false,
        //            Where = string.Format(@"Key LIKE '{0}%'"
        //                                    , q),
        //            OrderBy = "Key"
        //        };
        //        MethodReturnResult<IList<Supplier>> result = client.Get(ref cfg);
        //        if (result.Code <= 0 && result.Data != null)
        //        {
        //            lstSupplier = result.Data;
        //        }
        //    }

        //    return Json(from item in lstSupplier
        //                select new
        //                {
        //                    @label = item.Key + "-" + item.Name,
        //                    @value = item.Key,
        //                    @SupplierName = item.Name
        //                }, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult GetEfficiency(string q)
        {
            IList <Efficiency> lst = new List <Efficiency>();

            using (EfficiencyServiceClient client = new EfficiencyServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Name LIKE '{0}%' and IsUsed = 1"
                                             , q),
                    OrderBy = "Name"
                };
                MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }

            var lnq = from item in lst
                      select item.Name;

            return(Json(from item in lnq.Distinct <string>()
                        select new
            {
                @label = item,
                @value = item
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public async Task <ActionResult> Query(EfficiencyQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (EfficiencyServiceClient client = new EfficiencyServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Group))
                            {
                                where.AppendFormat(" {0} Key.Group LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Group);
                            }
                            if (!string.IsNullOrEmpty(model.Code))
                            {
                                where.AppendFormat(" {0} Key.Code LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Code);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Пример #3
0
        //
        // GET: /ZPVM/Efficiency/
        public async Task <ActionResult> Index()
        {
            using (EfficiencyServiceClient client = new EfficiencyServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new EfficiencyQueryViewModel()));
        }
Пример #4
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 (EfficiencyServiceClient client = new EfficiencyServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <Efficiency> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }