Exemplo n.º 1
0
        public MaterialUnloading GetMaterialUnloading(string unloadingNo)
        {
            MaterialUnloading obj = new MaterialUnloading();

            using (MaterialUnloadingServiceClient client = new MaterialUnloadingServiceClient())
            {
                MethodReturnResult <MaterialUnloading> result = client.Get(unloadingNo);
                if (result.Code <= 0 && result.Data != null)
                {
                    obj = result.Data;
                }
            }
            return(obj);
        }
Exemplo n.º 2
0
        public ActionResult GetUnloadingNo()
        {
            string prefix = string.Format("MUM{0:yyMMdd}", DateTime.Now);
            int    itemNo = 0;

            using (MaterialUnloadingServiceClient client = new MaterialUnloadingServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("Key LIKE '{0}%'", prefix),
                    OrderBy  = "Key Desc"
                };
                MethodReturnResult <IList <MaterialUnloading> > 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));
        }
Exemplo n.º 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 (MaterialUnloadingServiceClient client = new MaterialUnloadingServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <MaterialUnloading> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial", new MaterialUnloadingViewModel()));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Query(MaterialUnloadingQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (MaterialUnloadingServiceClient client = new MaterialUnloadingServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.UnloadingNo))
                            {
                                where.AppendFormat(" {0} Key = '{1}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.UnloadingNo);
                            }
                            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.StartUnloadingTime != null)
                            {
                                where.AppendFormat(" {0} UnloadingTime >= '{1:yyyy-MM-dd HH:mm:ss}'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.StartUnloadingTime);
                            }

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

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

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

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