Example #1
0
        public 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 (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        PageNo   = pageNo,
                        PageSize = pageSize,
                        Where    = where ?? string.Empty,
                        OrderBy  = orderBy ?? string.Empty
                    };
                    MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);
                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                }
            }
            return(PartialView("_ListPartial"));
        }
Example #2
0
        public IEnumerable <SelectListItem> GetReasonCodeCategoryNameList()
        {
            IList <ReasonCodeCategory> lst = new List <ReasonCodeCategory>();

            //获取原因代码分组信息。
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Type='{0}'", Convert.ToInt32(EnumReasonCodeType.Hold))
                };
                MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null && result.Data.Count > 0)
                {
                    lst = result.Data;
                }
            }
            return(from item in lst
                   select new SelectListItem
            {
                Text = item.Key,
                Value = item.Key
            });
        }
Example #3
0
        public IEnumerable <SelectListItem> GetReasonCodeCategoryName(EnumReasonCodeType type)
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Type='{0}'", Convert.ToInt32(type))
                };

                MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }

            return(new List <SelectListItem>());
        }
Example #4
0
        //
        // GET: /FMM/ReasonCodeCategory/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                MethodReturnResult <ReasonCodeCategory> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    ReasonCodeCategoryViewModel viewModel = new ReasonCodeCategoryViewModel()
                    {
                        Name        = result.Data.Key,
                        Type        = result.Data.Type,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Example #5
0
        public async Task <ActionResult> Delete(string key)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                result = await client.DeleteAsync(key);

                if (result.Code == 0)
                {
                    result.Message = string.Format(FMMResources.StringResource.ReasonCodeCategory_Delete_Success
                                                   , key);
                }
                return(Json(result));
            }
        }
Example #6
0
        //
        // GET: /FMM/ReasonCodeCategory/
        public ActionResult Index()
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "Key"
                };
                MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);

                if (result.Code == 0)
                {
                    ViewBag.PagingConfig = cfg;
                    ViewBag.List         = result.Data;
                }
            }
            return(View(new ReasonCodeCategoryQueryViewModel()));
        }
Example #7
0
        public ActionResult Query(ReasonCodeCategoryQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
                {
                    StringBuilder where = new StringBuilder();
                    if (model != null)
                    {
                        if (!string.IsNullOrEmpty(model.Name))
                        {
                            where.AppendFormat(" {0} Key LIKE '{1}%'"
                                               , where.Length > 0 ? "AND" : string.Empty
                                               , model.Name);
                        }
                        if (model.Type != null)
                        {
                            where.AppendFormat(" {0} Type = '{1}'"
                                               , where.Length > 0 ? "AND" : string.Empty
                                               , Convert.ToInt32(model.Type));
                        }
                    }
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key",
                        Where   = where.ToString()
                    };
                    MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                }
            }
            return(PartialView("_ListPartial"));
        }
Example #8
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
            }));
        }
Example #9
0
        public async Task <ActionResult> SaveModify(ReasonCodeCategoryViewModel model)
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                MethodReturnResult <ReasonCodeCategory> result = await client.GetAsync(model.Name);

                if (result.Code == 0)
                {
                    result.Data.Type        = model.Type;
                    result.Data.Description = model.Description;
                    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.ReasonCodeCategory_SaveModify_Success
                                                    , model.Name);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Example #10
0
        public async Task <ActionResult> Save(ReasonCodeCategoryViewModel model)
        {
            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                ReasonCodeCategory obj = new ReasonCodeCategory()
                {
                    Key         = model.Name,
                    Type        = model.Type,
                    Description = model.Description,
                    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.ReasonCodeCategory_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
Example #11
0
        public IEnumerable <SelectListItem> GetReasonCodeCategoryName()
        {
            IList <ReasonCodeCategory> lst = null;

            using (ReasonCodeCategoryServiceClient client = new ReasonCodeCategoryServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = "Key.Type='0'"
                };
                MethodReturnResult <IList <ReasonCodeCategory> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lst = result.Data;
                }
            }
            return(from item in lst
                   select new SelectListItem
            {
                Text = item.Key,
                Value = item.Key
            });
        }