예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     id         = Request["slt"].ToInt32();
     categories = categoriesBLL.QueryList(-1, -1, new { catParentID = 0 }, null, false);
     if (categories == null)
     {
         categories = new List <Categories>();
     }
     if (RequestHelper.IsPostBack(this.Request))
     {
         string choose = Request["choose"];
         if (choose == "添加子分类")
         {
             Categories model = new Categories();
             model.catName = Request["catname"];
             Categories tmp = new Categories();
             tmp = categoriesBLL.QuerySingle(new { catName = model.catName });
             if (tmp != null)
             {
                 msg = "分类名不能重复";
                 return;
             }
             model.catParentID = id;
             model.catDesc     = Request["catdesc"] ?? "";
             categoriesBLL.Insert(model);
         }
         else if (choose == "添加主分类")
         {
             Categories model = new Categories();
             model.catName = Request["catparent"];
             Categories tmp = new Categories();
             tmp = categoriesBLL.QuerySingle(new { catName = model.catName });
             if (tmp != null)
             {
                 msg = "分类名不能重复";
                 return;
             }
             model.catParentID = 0;
             model.catDesc     = Request["parentdesc"] ?? "";
             categoriesBLL.Insert(model);
         }
         msg = "添加成功";
         js  = LayerClose();
     }
 }
예제 #2
0
        public ActionResult Create(Category cat)
        {
            int    le  = Request.Files[0].ContentLength;
            string fn  = Request.Files[0].FileName;
            Stream pic = Request.Files[0].InputStream;

            byte[] photo = null;
            using (var binr = new BinaryReader(pic))
            {
                photo = binr.ReadBytes(le);
            }
            cat.Picture = photo;
            bll.Insert(cat);
            return(View());
        }
예제 #3
0
 public bool Insert(CategoriesBOL obj)
 {
     if (obj != null)
     {
         try
         {
             int retVal = objBll.Insert(obj);
             if (retVal > 0)
             {
                 return(true);
             }
         }
         catch
         {
             return(false);
         }
     }
     return(false);
 }