// Category列表
        public ActionResult Index(int?p, int id, string CategoryParentName)
        {
            Pager pager = new Pager();

            pager.table      = "CMSCategory";
            pager.strwhere   = "CategoryParentId=" + id;
            pager.PageSize   = 10;
            pager.PageNo     = p ?? 1;
            pager.FieldKey   = "CategoryId";
            pager.FiledOrder = "CategoryId Desc";
            pager            = CMSService.SelectAll("Category", pager);

            List <CategoryDto> list = new List <CategoryDto>();

            foreach (DataRow dr in pager.EntityDataTable.Rows)
            {
                CategoryDto dto = CategoryMapping.getDTO(dr);
                list.Add(dto);
            }
            pager.Entity = list.AsQueryable();

            ViewBag.PageNo             = p ?? 1;
            ViewBag.PageCount          = pager.PageCount;
            ViewBag.RecordCount        = pager.Amount;
            ViewBag.Message            = pager.Amount;
            ViewBag.CategoryParentName = CategoryParentName;
            ViewBag.CategoryParentId   = id;
            return(View(pager.Entity));
        }
        // 删除Category

        public ActionResult Delete(int id, string CategoryName)
        {
            try
            {
                CategoryDto dto = new CategoryDto();
                DataTable   dt  = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + id);
                foreach (DataRow dr in dt.Rows)
                {
                    dto = CategoryMapping.getDTO(dr);
                }
                string    strwhere   = "CategoryParentId=" + id;
                DataTable categorydt = CMSService.SelectSome("Category", "CMSCategory", strwhere);

                Message msg = new Message();
                if (categorydt.Rows.Count > 0)
                {
                    msg.MessageInfo = "此角色还有" + categorydt.Rows.Count + "条相关数据,不允许删除";
                    return(RedirectTo("/Category/Index/" + dto.CategoryParentId + "?CategoryName=" + CategoryName, msg.MessageInfo));
                }
                else
                {
                    msg             = CMSService.Delete("Category", "CMSCategory", "CategoryId=" + id);
                    msg.MessageInfo = "数据删除操作成功";
                    return(RedirectTo("/Category/Index/" + dto.CategoryParentId + "?CategoryName=" + CategoryName, msg.MessageInfo));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemple #3
0
        public static string CategoryIdToName(string strWhere)
        {
            CategoryDto dto = new CategoryDto();
            DataTable   dt  = CMSService.SelectOne("Category", "CMSCategory", strWhere);

            foreach (DataRow dr in dt.Rows)
            {
                dto = CategoryMapping.getDTO(dr);
            }
            return(dto.CategoryName);
        }
Exemple #4
0
        //分类列表
        public static List <CategoryDto> GetCategoryList(string strwhere)
        {
            List <CategoryDto> CategoryList = new List <CategoryDto>();
            DataTable          dt           = CMSService.SelectSome("Category", "CMSCategory", strwhere);

            foreach (DataRow dr in dt.Rows)
            {
                CategoryDto dto = CategoryMapping.getDTO(dr);
                CategoryList.Add(dto);
            }

            return(CategoryList);
        }
Exemple #5
0
        //分类的下拉列表显示
        public static List <SelectListItem> GetCategorySelectList(string strwhere)
        {
            DataTable             dt    = CMSService.SelectSome("Category", "CMSCategory", strwhere);
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (DataRow dr in dt.Rows)
            {
                CategoryDto dto = CategoryMapping.getDTO(dr);
                items.Add(new SelectListItem {
                    Text = dto.CategoryName, Value = dto.CategoryId.ToString()
                });
            }
            return(items);
        }
        // 编辑Category视图
        public ActionResult Edit(int id, string CategoryParentName)
        {
            CategoryModel model = new CategoryModel();
            DataTable     dt    = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + id);

            foreach (DataRow dr in dt.Rows)
            {
                CategoryDto dto = new CategoryDto();
                dto = CategoryMapping.getDTO(dr);
                model.CategoryId          = dto.CategoryId;
                model.CategoryName        = dto.CategoryName;
                model.CategoryDescription = dto.CategoryDescription;
                model.CategoryParentId    = dto.CategoryParentId;
                model.CategoryParentName  = CategoryParentName;
            }

            return(View(model));
        }
        public ActionResult Edit(CategoryModel model)
        {
            CategoryDto dto = new CategoryDto();
            DataTable   dt  = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + model.CategoryId);

            foreach (DataRow dr in dt.Rows)
            {
                dto                     = CategoryMapping.getDTO(dr);
                dto.CategoryId          = model.CategoryId;
                dto.CategoryName        = model.CategoryName;
                dto.CategoryDescription = model.CategoryDescription;
                dto.CategoryParentId    = model.CategoryParentId;
            }
            string  JsonString = JsonHelper.JsonSerializerBySingleData(dto);
            Message msg        = CMSService.Update("Category", JsonString);

            // TODO: Add update logic here

            return(RedirectTo("/Category/Index/" + model.CategoryParentId + "?CategoryParentName=" + model.CategoryParentName, msg.MessageInfo));
        }
Exemple #8
0
        public static double GetFenshuByCategory(int categoryId)
        {
            double      fenshu = 0;
            CategoryDto dto    = new CategoryDto();
            DataTable   dt     = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + categoryId);

            foreach (DataRow dr in dt.Rows)
            {
                dto = CategoryMapping.getDTO(dr);
            }
            try
            {
                fenshu = double.Parse(dto.CategoryDescription);
            }
            catch
            {
                fenshu = 0;
            }
            return(fenshu);
        }
        public ActionResult Create(ImageModel model)
        {
            ImageDto dto = new ImageDto();

            dto.ImageTitle = model.ImageTitle;
            if (String.IsNullOrEmpty(model.ImageUrl))
            {
                ViewBag.status = "Error";
                ViewBag.msg    = "图片不能为空";
                DataTable             dt    = CMSService.SelectSome("Category", "CMSCategory", "CategoryParentId=6");
                List <SelectListItem> items = new List <SelectListItem>();
                //List<CategoryDto> list = new List<CategoryDto>();
                foreach (DataRow dr in dt.Rows)
                {
                    CategoryDto categoryDto = CategoryMapping.getDTO(dr);
                    items.Add(new SelectListItem {
                        Text = categoryDto.CategoryName, Value = categoryDto.CategoryId.ToString()
                    });

                    // list.Add(dto);
                }
                ViewData["Category"] = items;
                return(View());
            }
            else
            {
                dto.ImageUrl = model.ImageUrl;
            }
            dto.ImageHref        = model.ImageHref;
            dto.ImageDescription = model.ImageDescription;
            dto.ImageCategory    = model.ImageCategory;
            dto.ImageStatus      = false;


            string  JsonString = JsonHelper.JsonSerializerBySingleData(dto);
            Message msg        = CMSService.Insert("Image", JsonString);

            return(RedirectTo("/Image/Index", msg.MessageInfo));
        }