コード例 #1
0
 public int Insert(ProductCategoryInfo model,int parentId)
 {
     model.Id = KeyGenerator.Instance.GetNextValue("ProductCategory");
     return _dataAccess.Insert(model, parentId);
 }
コード例 #2
0
 public int Update(ProductCategoryInfo model)
 {
     return _dataAccess.Update(model);
 }
コード例 #3
0
 public bool InsertProductCategory()
 {
     //var option = int.Parse(HttpContext.Current.Request.Form["parentSelect"]);
     var model = new ProductCategoryInfo();
     model.Name=HttpContext.Current.Request.Form["CategoryName"];
     model.Desc = HttpContext.Current.Request.Form["desc"];
     model.MediumPicture = HttpContext.Current.Request.Form["mediumpicture"];
     model.ParentId = int.Parse(HttpContext.Current.Request.Form["parentSelect"]);
     var display = 0;
     if(int.TryParse(HttpContext.Current.Request.Form["DisplayOrder"],out display))
     {
         model.DisplayOrder = display;
     }
     else
     {
         model.DisplayOrder = display;
     }
     IProductCategoryService productCategoryService=new ProductCategoryService();
     return productCategoryService.Insert(model, 1) > 0;
 }
コード例 #4
0
 public object UpdateProductCategoryByCategoryId()
 {
     var model = new ProductCategoryInfo();
     model.Id =  Convert.ToInt32(HttpContext.Current.Request.Params["CategoryId"]);
     model.Name = HttpContext.Current.Request.Params["CategoryName"];
     model.Desc = (string)HttpContext.Current.Request.Params["desc"];
     model.BigPicture = HttpContext.Current.Request.Params["BigPicture"];
     model.SmallPicture = HttpContext.Current.Request.Params["SmallPicture"];
     model.MediumPicture = HttpContext.Current.Request.Params["mediumpicture"];
     model.Content = HttpContext.Current.Request.Params["desc"];
     var display = 0;
     if (int.TryParse(HttpContext.Current.Request.Form["DisplayOrder"], out display))
     {
         model.DisplayOrder = display;
     }
     else
     {
         model.DisplayOrder = display;
     }
     //model.ParentId = int.Parse(HttpContext.Current.Request.Form["parentSelect"]);
     IProductCategoryService productCategoryService = new ProductCategoryService();
     return productCategoryService.Update(model);
 }
コード例 #5
0
        public List<ComboTree> GetComboTreeChildren(ComboTree comboTree,ProductCategoryInfo category,List<ProductCategoryInfo> data)
        {
            var childrens =
                data.Where(s => s.Depth == category.Depth + 1 && s.Lft > category.Lft && s.Rgt < category.Rgt);
            var childs = new List<ComboTree>();
            foreach (var productCategoryInfo in childrens)
            {
                var child = new ComboTree();
                child.Id = productCategoryInfo.Id;
                child.Text = productCategoryInfo.Name;
                childs.Add(child);
            }

            comboTree.Children = childs;

            foreach (var child in comboTree.Children)
            {
                var temp = data.FirstOrDefault(s => s.Id == child.Id);
                if(temp!=null)
                {
                    this.GetComboTreeChildren(child, temp, data);
                }
            }
            return comboTree.Children;
        }
コード例 #6
0
 public List<ProductCategoryInfo> GetProductCategory()
 {
     var data = new List<ProductCategoryInfo>();
     using(DataCommand cmd=DataCommandManager.GetDataCommand("GetProductCategory"))
     {
         using (IDataReader dr = cmd.ExecuteDataReader())
         {
             while (dr.Read())
             {
                 var model = new ProductCategoryInfo();
                 if (!Convert.IsDBNull(dr["Id"]))
                 {
                     model.Id = (int)dr["Id"];
                     model.CategoryId = model.Id;
                 }
                 if (!Convert.IsDBNull(dr["Name"]))
                 {
                     model.Name = (string)dr["Name"];
                 }
                 if (!Convert.IsDBNull(dr["Depth"]))
                 {
                     model.Depth = Convert.ToInt32(dr["Depth"]);
                 }
                 if (!Convert.IsDBNull(dr["Lft"]))
                 {
                     model.Lft = Convert.ToInt32(dr["Lft"]);
                 }
                 if (!Convert.IsDBNull(dr["Rgt"]))
                 {
                     model.Rgt = Convert.ToInt32(dr["Rgt"]);
                 }
                 if (model.Lft + 1 == model.Rgt)
                 {
                     model.IsLeaf = true;
                 }
                 if(!Convert.IsDBNull(dr["Content"]))
                 {
                     model.Content = Convert.ToString(dr["Content"]);
                 }
                 if (!Convert.IsDBNull(dr["Description"]))
                 {
                     model.Desc = Convert.ToString(dr["Description"]);
                 }
                 if (!Convert.IsDBNull(dr["MediumPicture"]))
                 {
                     model.MediumPicture = Convert.ToString(dr["MediumPicture"]);
                 }
                 if(!Convert.IsDBNull(dr["ParentId"]))
                 {
                     model.ParentId = Convert.ToInt32(dr["ParentId"]);
                 }
                 if(!Convert.IsDBNull(dr["DataStatus"]))
                 {
                     model.DataStatus = Convert.ToInt32(dr["DataStatus"]);
                 }
                 data.Add(model);
             }
         }
     }
     return data;
 }
コード例 #7
0
 public int Update(ProductCategoryInfo model)
 {
     using(DataCommand cmd=DataCommandManager.GetDataCommand("UpdateProductCategoryByCategoryId"))
     {
         cmd.SetParameterValue("@CategoryId", model.Id);
         cmd.SetParameterValue("@Title", model.Name);
         cmd.SetParameterValue("@Name", model.Name);
         cmd.SetParameterValue("@Content", model.Content);
         cmd.SetParameterValue("@Desc", model.Desc);
         cmd.SetParameterValue("@SmallPicture", model.SmallPicture);
         cmd.SetParameterValue("@MediumPicture", model.MediumPicture);
         cmd.SetParameterValue("@BigPicture", model.BigPicture);
         cmd.SetParameterValue("@DisplayOrder", model.DisplayOrder);
         return cmd.ExecuteNonQuery();
     }
 }
コード例 #8
0
 public int Insert(ProductCategoryInfo model,int parentId)
 {
     var parent = this.GetProductCategoryById(model.ParentId);
     using (DataCommand cmd = DataCommandManager.GetDataCommand("InsertProductCategory"))
     {
         cmd.SetParameterValue("@Id", model.Id);
         cmd.SetParameterValue("@Title", model.Name);
         cmd.SetParameterValue("@Name", model.Name);
         cmd.SetParameterValue("@MyLeft", parent.Lft);
         cmd.SetParameterValue("@Content", model.Content);
         cmd.SetParameterValue("@Desc", model.Desc);
         cmd.SetParameterValue("@SmallPicture", model.SmallPicture);
         cmd.SetParameterValue("@MediumPicture", model.MediumPicture);
         cmd.SetParameterValue("@BigPicture", model.BigPicture);
         cmd.SetParameterValue("@ParentId", model.ParentId);
         cmd.SetParameterValue("@DataStatus", model.DataStatus);
         cmd.SetParameterValue("@DisplayOrder", model.DisplayOrder);
         return cmd.ExecuteNonQuery();
     }
 }
コード例 #9
0
 public ProductCategoryInfo GetProductCategoryById(int id)
 {
     var model = new ProductCategoryInfo();
     using(DataCommand cmd=DataCommandManager.GetDataCommand("GetProductCategoryById"))
     {
         cmd.SetParameterValue("@Id", id);
         using (IDataReader dr = cmd.ExecuteDataReader())
         {
             while (dr.Read())
             {
                 if (!Convert.IsDBNull(dr["Id"]))
                 {
                     model.Id = (int)dr["Id"];
                 }
                 if (!Convert.IsDBNull(dr["Name"]))
                 {
                     model.Name = (string)dr["Name"];
                 }
                 if (!Convert.IsDBNull(dr["Lft"]))
                 {
                     model.Lft = Convert.ToInt32(dr["Lft"]);
                 }
                 if (!Convert.IsDBNull(dr["Rgt"]))
                 {
                     model.Rgt = Convert.ToInt32(dr["Rgt"]);
                 }
                 if (!Convert.IsDBNull(dr["ParentId"]))
                 {
                     model.ParentId = Convert.ToInt32(dr["ParentId"]);
                 }
                 if (!Convert.IsDBNull(dr["Content"]))
                 {
                     model.Content = Convert.ToString(dr["Content"]);
                 }
                 if (!Convert.IsDBNull(dr["Description"]))
                 {
                     model.Desc = Convert.ToString(dr["Description"]);
                 }
                 if (!Convert.IsDBNull(dr["MediumPicture"]))
                 {
                     model.MediumPicture = Convert.ToString(dr["MediumPicture"]);
                 }
                 if (!Convert.IsDBNull(dr["DataStatus"]))
                 {
                     model.DataStatus = Convert.ToInt32(dr["DataStatus"]);
                 }
                 return model;
             }
         }
     }
     return model;
 }