Beispiel #1
0
        /**
         *
         * 增加品牌
         *
         * */
        public bool addCategory(Category category)
        {
            try
            {
               // int brandId = this.findIdByColomn("brand","brand_name",category.getBrandName());

                string sql = "insert into category (category_name,net_rate,brand) values(@categoryName,@netRate,@brandId)";

                Dictionary<string, Object> parameters = new Dictionary<string, Object>();

                parameters.Add("@categoryName", category.getCategoryName());
                parameters.Add("@netRate", category.getNetRate());
                parameters.Add("@brandId", category.getBrandId());

                dbAccess.excute(sql, parameters);
                return true;
            }
            catch (Exception e)
            {
                throw new MyException(e.Message);
            }
        }
Beispiel #2
0
        /**
         *
         * 更新品牌
         *
         * */
        public bool updateCategory(Category Category)
        {
            try
            {
                string sql = "update category set category_name = @categoryName, net_rate = @netRate, brand = @brandId where id = @id";

                Dictionary<string, Object> parameters = new Dictionary<string, Object>();

                parameters.Add("@categoryName", Category.getCategoryName());
                parameters.Add("@netRate", Category.getNetRate());
                parameters.Add("@brandId", Category.getBrandId());
                parameters.Add("@id", Category.Id);

                dbAccess.excute(sql, parameters);
                return true;
            }
            catch (Exception e)
            {
                throw new MyException(e.Message);
            }
        }