Exemple #1
0
        public ActionResult GetReasonCode(string categoryName)
        {
            //根据暂停代码组获取暂停代码。
            IList <ReasonCodeCategoryDetail> lst = new List <ReasonCodeCategoryDetail>();

            using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key.ReasonCodeCategoryName ='{0}'"
                                             , categoryName),
                    OrderBy = "ItemNo"
                };
                MethodReturnResult <IList <ReasonCodeCategoryDetail> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }
            return(Json(from item in lst
                        select new
            {
                Text = item.Key.ReasonCodeName,
                Value = item.Key.ReasonCodeName
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        //
        // GET: /FMM/ReasonCodeCategoryDetail/Detail
        public async Task <ActionResult> Detail(string categoryName, string reasonCodeName)
        {
            using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
            {
                MethodReturnResult <ReasonCodeCategoryDetail> result = await client.GetAsync(new ReasonCodeCategoryDetailKey()
                {
                    ReasonCodeCategoryName = categoryName,
                    ReasonCodeName         = reasonCodeName
                });

                if (result.Code == 0)
                {
                    ReasonCodeCategoryDetailViewModel viewModel = new ReasonCodeCategoryDetailViewModel()
                    {
                        ReasonCodeCategoryName = result.Data.Key.ReasonCodeCategoryName,
                        ReasonCodeName         = result.Data.Key.ReasonCodeName,
                        ItemNo     = result.Data.ItemNo,
                        Editor     = result.Data.Editor,
                        EditTime   = result.Data.EditTime,
                        CreateTime = result.Data.CreateTime,
                        Creator    = result.Data.Creator
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Exemple #3
0
        public async Task <ActionResult> SaveModify(ReasonCodeCategoryDetailViewModel model)
        {
            using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
            {
                MethodReturnResult <ReasonCodeCategoryDetail> result = await client.GetAsync(new ReasonCodeCategoryDetailKey()
                {
                    ReasonCodeCategoryName = model.ReasonCodeCategoryName,
                    ReasonCodeName         = model.ReasonCodeName
                });

                if (result.Code == 0)
                {
                    result.Data.ItemNo   = model.ItemNo;
                    result.Data.Editor   = User.Identity.Name;
                    result.Data.EditTime = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(FMMResources.StringResource.ReasonCodeCategoryDetail_SaveModify_Success
                                                    , result.Data.Key);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Exemple #4
0
        public async Task <ActionResult> Save(ReasonCodeCategoryDetailViewModel model)
        {
            using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
            {
                ReasonCodeCategoryDetail obj = new ReasonCodeCategoryDetail()
                {
                    Key = new ReasonCodeCategoryDetailKey()
                    {
                        ReasonCodeCategoryName = model.ReasonCodeCategoryName,
                        ReasonCodeName         = model.ReasonCodeName
                    },
                    ItemNo     = model.ItemNo,
                    Editor     = User.Identity.Name,
                    EditTime   = DateTime.Now,
                    CreateTime = DateTime.Now,
                    Creator    = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.ReasonCodeCategoryDetail_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
Exemple #5
0
        public ActionResult GetReasonCodeName(string reasonCodeCategoryName)
        {
            MethodReturnResult <IList <ReasonCodeCategoryDetail> > result = new MethodReturnResult <IList <ReasonCodeCategoryDetail> >();

            try
            {
                using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format("REASON_CODE_CATEGORY_NAME='{0}'", reasonCodeCategoryName)
                    };

                    result = client.Get(ref cfg);
                    if (result.Code <= 0)
                    {
                        List <SelectListItem> lst = new List <SelectListItem>();

                        foreach (ReasonCodeCategoryDetail item in result.Data)
                        {
                            lst.Add(new SelectListItem()
                            {
                                Text = item.Key.ReasonCodeName, Value = item.Key.ReasonCodeName
                            });
                        }

                        return(Json(lst, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(result));
                    }
                }
            }
            catch (Exception e)
            {
                result.Code    = 1002;
                result.Message = e.Message;
                result.Detail  = e.ToString();

                return(Json(result));
            }
        }
Exemple #6
0
        private IList <ReasonCodeCategoryDetail> GetScrapReasonCodes(string routeName, string routeStepName)
        {
            //如果本次请求有获取过参数清单,则直接返回。
            if (ViewBag.ScrapReasonCodeList != null)
            {
                return(ViewBag.ScrapReasonCodeList);
            }

            string categoryName = string.Empty;

            using (RouteStepServiceClient client = new RouteStepServiceClient())
            {
                MethodReturnResult <RouteStep> result = client.Get(new RouteStepKey()
                {
                    RouteName     = routeName,
                    RouteStepName = routeStepName
                });
                if (result.Code <= 0 && result.Data != null)
                {
                    categoryName = result.Data.ScrapReasonCodeCategoryName;
                }
            }
            //获取原因代码明细。
            if (!string.IsNullOrEmpty(categoryName))
            {
                using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(@"Key.ReasonCodeCategoryName='{0}'"
                                                 , categoryName)
                    };
                    MethodReturnResult <IList <ReasonCodeCategoryDetail> > result = client.Get(ref cfg);
                    if (result.Code <= 0 && result.Data != null)
                    {
                        ViewBag.ScrapReasonCodeList = result.Data;
                        return(result.Data);
                    }
                }
            }
            return(null);
        }
Exemple #7
0
        public async Task <ActionResult> Delete(string categoryName, string reasonCodeName)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
            {
                result = await client.DeleteAsync(new ReasonCodeCategoryDetailKey()
                {
                    ReasonCodeCategoryName = categoryName,
                    ReasonCodeName         = reasonCodeName
                });

                if (result.Code == 0)
                {
                    result.Message = string.Format(FMMResources.StringResource.ReasonCodeCategoryDetail_Delete_Success
                                                   , reasonCodeName);
                }
                return(Json(result));
            }
        }
Exemple #8
0
        public async Task <ActionResult> Query(ReasonCodeCategoryDetailQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            where.AppendFormat(" {0} Key.ReasonCodeCategoryName = '{1}'"
                                               , where.Length > 0 ? "AND" : string.Empty
                                               , model.ReasonCodeCategoryName);

                            if (!string.IsNullOrEmpty(model.ReasonCodeName))
                            {
                                where.AppendFormat(" {0} Key.ReasonCodeName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.ReasonCodeName);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "ItemNo",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <ReasonCodeCategoryDetail> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemple #9
0
        //
        // GET: /FMM/ReasonCodeCategoryDetail/
        public async Task <ActionResult> Index(string categoryName)
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                MethodReturnResult <ReasonCodeCategory> result = await client.GetAsync(categoryName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "ReasonCodeCategory"));
                }
                ViewBag.ReasonCodeCategory = result.Data;
            }

            using (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "ItemNo",
                        Where   = string.Format(" Key.ReasonCodeCategoryName = '{0}'"
                                                , categoryName)
                    };
                    MethodReturnResult <IList <ReasonCodeCategoryDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new ReasonCodeCategoryDetailQueryViewModel()
            {
                ReasonCodeCategoryName = categoryName
            }));
        }
Exemple #10
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 (ReasonCodeCategoryDetailServiceClient client = new ReasonCodeCategoryDetailServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <ReasonCodeCategoryDetail> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }