示例#1
0
        public MaterialLoading GetMaterialLoading(string loadingNo)
        {
            MaterialLoading obj = new MaterialLoading();

            using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
            {
                MethodReturnResult <MaterialLoading> result = client.Get(loadingNo);
                if (result.Code <= 0 && result.Data != null)
                {
                    obj = result.Data;
                }
            }
            return(obj);
        }
示例#2
0
        public ActionResult GetLoadingNo()
        {
            string prefix = string.Format("MLM{0:yyMM}", DateTime.Now);
            int    itemNo = 0;

            using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("Key LIKE '{0}%'", prefix),
                    OrderBy  = "Key Desc"
                };
                MethodReturnResult <IList <MaterialLoading> > 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("000000"), 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 (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <MaterialLoading> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial", new MaterialLoadingViewModel()));
        }
示例#4
0
        public async Task <ActionResult> Query(MaterialLoadingQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (MaterialLoadingServiceClient client = new MaterialLoadingServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.LoadingNo))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.LoadingNo);
                            }
                            if (!string.IsNullOrEmpty(model.RouteOperationName))
                            {
                                where.AppendFormat(" {0} RouteOperationName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.RouteOperationName);
                            }

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

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

                            if (model.StartLoadingTime != null)
                            {
                                where.AppendFormat(" {0} LoadingTime >= '{1:yyyy-MM-dd HH:mm:ss}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.StartLoadingTime);
                            }

                            if (model.EndLoadingTime != null)
                            {
                                where.AppendFormat(" {0} LoadingTime <= '{1:yyyy-MM-dd HH:mm:ss}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.EndLoadingTime);
                            }
                        }

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

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

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