Ejemplo n.º 1
0
        public ActionResult AddUser(int?id, string isedit)
        {
            ViewBag.TypeList = this.UserEnmTypeRepository.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.Name,
                Value = p.ID.ToString(),
            });
            ViewBag.UserLevelList = this.UserEnmLevelRepository.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.UserLevelName,
                Value = p.ID.ToString(),
            });
            Kf_DepartMentRepository      kf_DepartRepo  = new Kf_DepartMentRepository();
            IEnumerable <SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
                                                          .Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepartMent"] = listDepartMent;
            if (isedit == "1" && id != null)
            {
                var user = userRepository.GetByDatabaseID(id.Value);
                ViewBag.isEdit = "1";

                return(View(user));
            }
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult AddUser(FormCollection collection, int?id, string alertMessage, string isedit)
        {
            ViewBag.TypeList = this.UserEnmTypeRepository.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.Name,
                Value = p.ID.ToString(),
            });
            ViewBag.UserLevelList = this.UserEnmLevelRepository.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.UserLevelName,
                Value = p.ID.ToString(),
            });
            Kf_DepartMentRepository      kf_DepartRepo  = new Kf_DepartMentRepository();
            IEnumerable <SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
                                                          .Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepartMent"] = listDepartMent;
            User user = new User();

            try
            {
                user.RegistrationTime = DateTime.Now;
                if (isedit == "1")
                {
                    var user1 = userRepository.GetByDatabaseID(id.Value);
                    TryUpdateModel(user1, collection);
                    userRepository.Update(user1);
                }
                else
                {
                    TryUpdateModel(user, collection);
                    userRepository.Save(user);
                }


                return(RedirectToAction("UserIndex", new { alertMessage = "操作成功!" }));
            }
            catch (RuleException ex)
            {
                throw new RuleException(ex.Message, ex);
            }
        }
Ejemplo n.º 3
0
        public ActionResult AddShopGroup(int?id)
        {
            Kf_DepartMentRepository      kf_DepartRepo  = new Kf_DepartMentRepository();
            IEnumerable <SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
                                                          .Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepartMent"] = listDepartMent;
            if (id != null)
            {
                ShopGroups shopGroup = this.ShopGroupRepo.GetByDatabaseID(id.Value);
                return(View(shopGroup));
            }
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult AddShop(int?id, string IsEdit)
        {
            if (IsEdit == "1")
            {
                var shop = shopRepository.GetByDatabaseID(id.Value);
                ViewBag.IsEdit = "1";
            }
            ViewBag.TypeList = shopTypeRepositories.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.Name,
                Value = p.ID.ToString(),
            });
            ViewBag.ShopCountLevelList = this.ShopCountLevelRepository.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.CountLevel,
                Value = p.ID.ToString(),
            });
            ViewBag.ShopDifficultLevelList = this.ShopDifficultyLevelRepository.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.ShopDifficultyLevelName,
                Value = p.ID.ToString(),
            });
            UserRepository UserRepo = new UserRepository();
            IEnumerable <SelectListItem> ListSaleUser = UserRepo.GetData(this.Users().DepartMent.ID, Convert.ToInt32(UserEnmType.Sale))
                                                        .Select(p => new SelectListItem
            {
                Text  = p.userName,
                Value = p.ID.ToString().Trim(),
            });

            //IEnumerable<SelectListItem> ListSaleUser = UserRepo.GetAll()
            //    .Where(p=>p.Type.ID==2) //销售
            //    .Select(p => new SelectListItem
            //{
            //    Text = p.userName,
            //    Value = p.ID.ToString().Trim(),
            //});
            ViewData["ListSaleUser"] = ListSaleUser;

            IEnumerable <SelectListItem> listKfUser = UserRepo.GetData(this.Users().DepartMent.ID, Convert.ToInt32(UserEnmType.Person))
                                                      .Select(p => new SelectListItem
            {
                Text  = p.userName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listKfUser"] = listKfUser;


            Kf_DepartMentRepository      kf_DepartRepo  = new Kf_DepartMentRepository();
            IEnumerable <SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
                                                          .Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepartMent"] = listDepartMent;

            PayCircleRepository          PayCircleRepo = new PayCircleRepository();
            IEnumerable <SelectListItem> listPayCircle = PayCircleRepo.GetAll().Select(p => new SelectListItem
            {
                Text  = p.PayCircleName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listPayCircle"] = listPayCircle;


            IEnumerable <SelectListItem> listDepart = this.kf_DepartMentRepo.GetAll().Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepart"] = listDepart;

            if (id != null)
            {
                var shop = shopRepository.GetByDatabaseID(id.Value);
                ViewBag.Edit    = "1";
                shop.TotalScore = 0;
                return(View(shop));
            }
            return(View());
        }
Ejemplo n.º 5
0
        public ActionResult AddShop(FormCollection collection, string alertMessage, string IsEdit, int?id, string _User)
        {
            Shop _shop = new Shop();

            ViewBag.TypeList = shopTypeRepositories.GetAll().ToList().Select(p => new SelectListItem
            {
                Text  = p.Name,
                Value = p.ID.ToString(),
            });
            //ViewBag.ShopCountLevelList = this.ShopCountLevelRepository.GetAll().ToList().Select(p => new SelectListItem
            //{
            //    Text = p.CountLevel,
            //    Value = p.ID.ToString(),
            //});
            //ViewBag.ShopDifficultLevelList = this.ShopDifficultyLevelRepository.GetAll().ToList().Select(p => new SelectListItem
            //{
            //    Text = p.ShopDifficultyLevelName,
            //    Value =p.ID.ToString(),
            //});
            UserRepository UserRepo = new UserRepository();
            IEnumerable <SelectListItem> ListUser = UserRepo.GetAll().Select(p => new SelectListItem
            {
                Text  = p.userName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listUser"] = ListUser;

            PayCircleRepository          PayCircleRepo = new PayCircleRepository();
            IEnumerable <SelectListItem> listPayCircle = PayCircleRepo.GetAll().Select(p => new SelectListItem
            {
                Text  = p.PayCircleName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listPayCircle"] = listPayCircle;

            Kf_DepartMentRepository      kf_DepartRepo  = new Kf_DepartMentRepository();
            IEnumerable <SelectListItem> listDepartMent = kf_DepartRepo.GetData(this.Users().DepartMent.ID)
                                                          .Select(p => new SelectListItem
            {
                Text  = p.DepartMentName,
                Value = p.ID.ToString().Trim(),
            });

            ViewData["listDepartMent"] = listDepartMent;

            try
            {
                if (IsEdit == "1")
                {
                    var shopEdit = shopRepository.GetByDatabaseID(id.Value);

                    TryUpdateModel(shopEdit, collection);
                    shopRepository.Update(shopEdit);
                }
                else
                {
                    TryUpdateModel(_shop, collection);
                    if (shopRepository.ExistShopName(_shop.Name))
                    {
                        alertMessage = "添加失败 店铺已存在!";
                        return(View(_shop));
                    }
                    if (_shop.Name.IsNullOrEmpty())
                    {
                        alertMessage = "店铺名不能为空!";
                        return(View(_shop));
                    }
                    //_shop._User = shopRepository.GetUserByuserName(_User);
                    //_shop.TotalScore = _shop.DifficutyLevel.ID + _shop.ShopCountLevel.ID;

                    //_shop._PayCircle = PayCircleRepo.GetByDatabaseID(Convert.ToInt32(collection["_PayCircle"]));
                    //_shop._Kf_DepartMent = this.kf_DepartMentRepo.GetByDatabaseID(Convert.ToInt32(collection["_Kf_DepartMent"]));
                    //_shop.DemandUser = this.UserRepository.GetByDatabaseID(Convert.ToInt32(collection["DemandUser"]));
                    //_shop.SaleUser = UserRepository.GetByDatabaseID(Convert.ToInt32(collection["SaleUser"]));
                    //_shop.MainKfUser = UserRepository.GetByDatabaseID(Convert.ToInt32(collection["MainKfUser"]));
                    //_shop._Kf_DepartMent = this.kf_DepartMentRepo.GetByDatabaseID(Convert.ToInt32(collection["_Kf_DepartMent"]));
                    shopRepository.Save(_shop);
                }

                alertMessage             = "操作成功!";
                ViewData["alertMessage"] = alertMessage;
                return(RedirectToAction("ShopIndex"));
            }
            catch (RuleException ex)
            {
                throw new RuleException(ex.Message, ex);
            }
        }