Exemplo n.º 1
0
        //
        // GET: /ZPVM/MaterialReplace/
        public async Task <ActionResult> Index()
        {
            using (MaterialReplaceServiceClient client = new MaterialReplaceServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <MaterialReplace> > result = client.Gets(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new MaterialQueryReplaceViewModel()));
        }
Exemplo n.º 2
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 (MaterialReplaceServiceClient client = new MaterialReplaceServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <MaterialReplace> > result = client.Gets(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Query(MaterialQueryReplaceViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (MaterialReplaceServiceClient client = new MaterialReplaceServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.ProductCode))
                            {
                                where.AppendFormat(" {0} Key.ProductCode LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.ProductCode.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.OrderNumber))
                            {
                                where.AppendFormat(" {0} Key.OrderNumber LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.OrderNumber.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.OldMaterialCode))
                            {
                                where.AppendFormat(" {0} Key.OldMaterialCode LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.OldMaterialCode.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.OldMaterialSupplier))
                            {
                                where.AppendFormat(" {0} Key.OldMaterialSupplier LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.OldMaterialSupplier.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.NewMaterialCode))
                            {
                                where.AppendFormat(" {0} NewMaterialCode LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.NewMaterialCode.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.NewMaterialSupplier))
                            {
                                where.AppendFormat(" {0} NewMaterialSupplier LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.NewMaterialSupplier.ToString().Trim().ToUpper());
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key.ProductCode desc,EditTime desc ",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <MaterialReplace> > result = client.Gets(ref cfg);

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