Exemplo n.º 1
0
        /// <summary>
        /// 执行添加操作
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public int Insert(Brand_Information brand)
        {
            var parameters = new List<SqlParameter>
            {

                this.SqlServer.CreateSqlParameter(
                    "BrandID",
                    SqlDbType.Int,
                    brand.BrandID,
                    ParameterDirection.Input
                    ),
                this.SqlServer.CreateSqlParameter(
                    "Title",
                    SqlDbType.Text,
                    brand.Title,
                    ParameterDirection.Input
                    ),
                this.SqlServer.CreateSqlParameter(
                    "Introduce",
                    SqlDbType.Text,
                    brand.Introduce,
                    ParameterDirection.Input
                    ),
                this.SqlServer.CreateSqlParameter(
                    "Logo",
                    SqlDbType.VarChar,
                    brand.Logo,
                    ParameterDirection.Input
                    ),
                this.SqlServer.CreateSqlParameter(
                    "ProductID",
                    SqlDbType.VarChar,
                    brand.ProductID,
                    ParameterDirection.Input
                    ),
                this.SqlServer.CreateSqlParameter(
                    "ReferenceID",
                    SqlDbType.Int,
                    null,
                    ParameterDirection.Output
                    )
            };

            this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_BrandInformation_Insert", parameters, null);
            return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
        }
 /// <summary>
 /// 根据品牌ID执行修改操作 
 /// </summary>
 /// <param name="brand"></param>
 /// <returns></returns>
 public int UpdateByBrandID(Brand_Information brand)
 {
     return this.brandInformationDA.UpdateByBrandID(brand);
 }
 /// <summary>
 /// 添加操作
 /// </summary>
 /// <param name="brand"></param>
 /// <returns></returns>
 public int Insert(Brand_Information brand)
 {
     return this.brandInformationDA.Insert(brand);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 根据品牌ID执行修改操作 
 /// </summary>
 /// <param name="brand"></param>
 /// <returns></returns>
 public int UpdateByBrandID(Brand_Information brand)
 {
     var parameters = new List<SqlParameter>
     {
     this.SqlServer.CreateSqlParameter(
     "BrandID",
     SqlDbType.Int,
     brand.BrandID,
     ParameterDirection.Input
     ),
     this.SqlServer.CreateSqlParameter(
     "Title",
     SqlDbType.Text,
     brand.Title,
     ParameterDirection.Input
     ),
     this.SqlServer.CreateSqlParameter(
     "Introduce",
     SqlDbType.Text,
     brand.Introduce,
     ParameterDirection.Input
     ),
     this.SqlServer.CreateSqlParameter(
     "ProductID",
     SqlDbType.VarChar,
     brand.ProductID,
     ParameterDirection.Input
     ),
     this.SqlServer.CreateSqlParameter(
     "logo",
     SqlDbType.VarChar,
     brand.Logo,
     ParameterDirection.Input
     )
     };
     return this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_BrandInformation_UpdateByBrandID",
          parameters, null);
 }
 public ActionResult ModifyProduct(int brandId, string product)
 {
     this.brandInformationService = new BrandInformationService();
     var returnValue = this.brandInformationService.QueryByBrandID(brandId);
     if (returnValue != null)
     {
         if (brandInformationService.UpdateProductString(brandId, product) > 0)
         {
             return Json(new AjaxResponse { Data = 1, Message = "保存成功", State = 1 });
         }
     }
     else
     {
         var model = new Brand_Information
         {
             BrandID = brandId,
             Logo = "",
             Introduce = "NULL",
             ProductID = product,
             Title = "NULL"
         };
         if (brandInformationService.Insert(model) > 0)
         {
             return Json(new AjaxResponse { Data = 1, Message = "保存成功", State = 1 });
         }
     }
     return Json(new AjaxResponse { Data = 0, Message = "保存失败", State = 0 });
 }
        public ActionResult ModifyAndInsert(string title, string Introduce, int brandId, string logo, string product)
        {
            try
            {
                this.brandInformationService = new BrandInformationService();
                var brand = this.brandInformationService.QueryByBrandID(brandId);

                Brand_Information model;
                if (brand != null)
                {
                    model = new Brand_Information
                     {
                         BrandID = brandId,
                         Introduce = Introduce,
                         Title = title,
                         Logo = !string.IsNullOrEmpty(logo) ? logo : brand.Logo,
                         ProductID = product
                     };
                    if (brandInformationService.UpdateByBrandID(model) > 0)
                    {
                        return Json(new AjaxResponse { Data = 1, Message = "修改成功", State = 1 });
                    }
                }
                else
                {
                    model = new Brand_Information
                    {
                        BrandID = brandId,
                        Introduce = Introduce,
                        Title = title,
                        Logo = logo,
                        ProductID = product,
                    };
                    if (brandInformationService.Insert(model) > 0)
                    {
                        return Json(new AjaxResponse { Data = 1, Message = "添加成功", State = 1 });
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
            return Json(new AjaxResponse { Data = 0, Message = "出错了", State = 0 });
        }