Exemplo n.º 1
0
        /// <summary>
        /// 从IDataReader创建BrandInfo
        /// </summary>
        public static BrandInfo BuildBrandFromReader(IDataReader reader)
        {
            BrandInfo brandInfo = new BrandInfo();

            brandInfo.BrandId = TypeHelper.ObjectToInt(reader["brandid"]);
            brandInfo.DisplayOrder = TypeHelper.ObjectToInt(reader["displayorder"]);
            brandInfo.Name = reader["name"].ToString();
            brandInfo.Logo = reader["logo"].ToString();

            return brandInfo;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 创建品牌
 /// </summary>
 /// <param name="brandInfo"></param>
 public void CreateBrand(BrandInfo brandInfo)
 {
     DbParameter[] parms = {
                                 GenerateInParam("@displayorder", SqlDbType.Int,4,brandInfo.DisplayOrder),
                                 GenerateInParam("@name", SqlDbType.NChar, 20, brandInfo.Name),
                                 GenerateInParam("@logo", SqlDbType.NChar,100,brandInfo.Logo)
                             };
     string commandText = string.Format("INSERT INTO [{0}brands]([displayorder],[name],[logo]) VALUES(@displayorder,@name,@logo)",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新品牌
        /// </summary>
        /// <param name="brandInfo"></param>
        public void UpdateBrand(BrandInfo brandInfo)
        {
            DbParameter[] parms = {
                                        GenerateInParam("@displayorder", SqlDbType.Int,4,brandInfo.DisplayOrder),
                                        GenerateInParam("@name", SqlDbType.NChar, 20, brandInfo.Name),
                                        GenerateInParam("@logo", SqlDbType.NChar,100,brandInfo.Logo),
                                        GenerateInParam("@brandid", SqlDbType.Int, 4, brandInfo.BrandId)    
                                    };

            string commandText = string.Format("UPDATE [{0}brands] SET [displayorder]=@displayorder,[name]=@name,[logo]=@logo WHERE [brandid]=@brandid",
                                                RDBSHelper.RDBSTablePre);
            RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 创建品牌
 /// </summary>
 /// <param name="brandInfo"></param>
 public static void CreateBrand(BrandInfo brandInfo)
 {
     BrnMall.Core.BMAData.RDBS.CreateBrand(brandInfo);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 创建品牌
 /// </summary>
 /// <param name="brandInfo"></param>
 public static void CreateBrand(BrandInfo brandInfo)
 {
     BrnMall.Data.Brands.CreateBrand(brandInfo);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新品牌
 /// </summary>
 /// <param name="brandInfo"></param>
 public static void UpdateBrand(BrandInfo brandInfo)
 {
     BrnMall.Data.Brands.UpdateBrand(brandInfo);
     BrnMall.Core.BMACache.Remove(CacheKeys.MALL_BRAND_INFO + brandInfo.BrandId);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 获得分类品牌列表
        /// </summary>
        /// <param name="cateId">分类id</param>
        /// <param name="keyword">关键词</param>
        /// <returns></returns>
        public List<BrandInfo> GetCategoryBrandListByKeyword(int cateId, string keyword)
        {
            DbParameter[] parms = {
                                    GenerateInParam("@cateid", SqlDbType.Int,4,cateId),
                                    GenerateInParam("@keyword", SqlDbType.NChar,40,keyword)
                                   };

            List<BrandInfo> brandList = new List<BrandInfo>();
            IDataReader reader = RDBSHelper.ExecuteReader(CommandType.StoredProcedure,
                                                          string.Format("{0}getcategorybrandlistbykeyword", RDBSHelper.RDBSTablePre),
                                                          parms);
            while (reader.Read())
            {
                BrandInfo brandInfo = new BrandInfo();

                brandInfo.BrandId = TypeHelper.ObjectToInt(reader["brandid"]);
                brandInfo.DisplayOrder = TypeHelper.ObjectToInt(reader["displayorder"]);
                brandInfo.Name = reader["name"].ToString();
                brandInfo.Logo = reader["logo"].ToString();

                brandList.Add(brandInfo);
            }
            reader.Close();
            return brandList;
        }
Exemplo n.º 8
0
        public ActionResult Add(BrandModel model)
        {
            if (AdminBrands.GetBrandIdByName(model.BrandName) > 0)
                ModelState.AddModelError("BrandName", "名称已经存在");

            if (ModelState.IsValid)
            {
                BrandInfo brandInfo = new BrandInfo()
                {
                    DisplayOrder = model.DisplayOrder,
                    Name = model.BrandName,
                    Logo = model.Logo
                };

                AdminBrands.CreateBrand(brandInfo);
                AddMallAdminLog("添加品牌", "添加品牌,品牌为:" + model.BrandName);
                return PromptView("品牌添加成功");
            }
            Load();
            return View(model);
        }