Пример #1
0
 public MaterialReturn GetMaterialReturn(string key)
 {
     using (MaterialReturnServiceClient client = new MaterialReturnServiceClient())
     {
         MethodReturnResult <MaterialReturn> rst = client.Get(key);
         if (rst.Code <= 0)
         {
             return(rst.Data);
         }
     }
     return(null);
 }
Пример #2
0
        public ActionResult GetReturnNo()
        {
            string prefix = string.Format("TMK{0:yyMM}", DateTime.Now);
            int    itemNo = 0;

            using (MaterialReturnServiceClient client = new MaterialReturnServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("Key LIKE '{0}%'", prefix),
                    OrderBy  = "Key Desc"
                };
                MethodReturnResult <IList <MaterialReturn> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null && result.Data.Count > 0)
                {
                    string sItemNo = result.Data[0].Key.Replace(prefix, "");
                    int.TryParse(sItemNo, out itemNo);
                }
            }
            return(Json(prefix + (itemNo + 1).ToString("0000"), JsonRequestBehavior.AllowGet));
        }
Пример #3
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 (MaterialReturnServiceClient client = new MaterialReturnServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <MaterialReturn> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Пример #4
0
        public async Task <ActionResult> Query(MaterialReturnQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (MaterialReturnServiceClient client = new MaterialReturnServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.ReturnNo))
                            {
                                where.AppendFormat(" {0} Key = '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.ReturnNo);
                            }
                            if (!string.IsNullOrEmpty(model.OrderNumber))
                            {
                                where.AppendFormat(" {0} OrderNumber = '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.OrderNumber);
                            }

                            if (model.StartReturnDate != null)
                            {
                                where.AppendFormat(" {0} ReturnDate >= '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.StartReturnDate);
                            }

                            if (model.EndReturnDate != null)
                            {
                                where.AppendFormat(" {0} ReturnDate <= '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.EndReturnDate);
                            }
                        }

                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "CreateTime Desc",
                            Where   = where.ToString()
                        };

                        MethodReturnResult <IList <MaterialReturn> > result = client.Get(ref cfg);

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