public JsonResult AddLimitedDiscount( string promoteName, string promoteStartTime, string promoteEndTime, string productArry, string discountArry, string discountPriceArry, string limitedBuyNumArry, string totalNumArry, string isOnlinePayArry, string useCouponArry, string newUserArry, string mobileverifyArry) { try { // 验证相同商品是否参与其他促销 var products = this.VerifyPromote(productArry); if (!string.IsNullOrEmpty(products)) { return this.Json(new AjaxResponse(0, "以下商品已参加其他促销活动:" + products)); } var promoteLimitedDiscount = new Promote_Limited_Discount { Name = promoteName, StartTime = DateTime.Parse(promoteStartTime), EndTime = DateTime.Parse(promoteEndTime), CreateTime = DateTime.Now, IsNewUser = false, IsMobileValidate = false, IsUseCoupon = true }; var productIDArry = productArry.Split(','); var discountNumArry = discountArry.Split(','); var discountedArry = discountPriceArry.Split(','); var limitedBuyArry = limitedBuyNumArry.Split(','); var totalArry = totalNumArry.Split(','); var isOnlineArry = isOnlinePayArry.Split(','); for (int i = 0; i < productIDArry.Length; i++) { if (productIDArry[i].Trim() != string.Empty) { promoteLimitedDiscount.ProductID = int.Parse(productIDArry[i]); promoteLimitedDiscount.Discount = double.Parse(discountNumArry[i]); promoteLimitedDiscount.DiscountPrice = double.Parse(discountedArry[i]); promoteLimitedDiscount.LimitedBuyQuantity = int.Parse(limitedBuyArry[i]); promoteLimitedDiscount.TotalQuantity = int.Parse(totalArry[i]); promoteLimitedDiscount.IsOnlinePayment = isOnlineArry[i] == "1"; promoteLimitedDiscount.Status = 1; this.promoteLimitedDiscountService = new PromoteLimitedDiscountService(); promoteLimitedDiscount.ID = this.promoteLimitedDiscountService.Add(promoteLimitedDiscount); } } return this.Json(new AjaxResponse(1, "设置成功!")); } catch (Exception exception) { return this.Json(new AjaxResponse(0, exception.Message)); } }
/// <summary> /// 添加限时打折促销活动. /// </summary> /// <param name="promoteLimitedDiscount"> /// Promote_Limited_Discount的对象实例. /// </param> /// <returns> /// 限时打折促销活动的编号. /// </returns> public int Insert(Promote_Limited_Discount promoteLimitedDiscount) { if (promoteLimitedDiscount == null) { throw new ArgumentNullException("promoteLimitedDiscount"); } var parameters = new List<SqlParameter> { this.sqlServer.CreateSqlParameter( "ProductID", SqlDbType.Int, promoteLimitedDiscount.ProductID, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "Name", SqlDbType.NVarChar, promoteLimitedDiscount.Name, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "Discount", SqlDbType.Float, promoteLimitedDiscount.Discount, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "DiscountPrice", SqlDbType.Float, promoteLimitedDiscount.DiscountPrice, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "TotalQuantity", SqlDbType.Int, promoteLimitedDiscount.TotalQuantity, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "LimitedBuyQuantity", SqlDbType.Int, promoteLimitedDiscount.LimitedBuyQuantity, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "IsOnlinePayment", SqlDbType.Bit, promoteLimitedDiscount.IsOnlinePayment, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsNewUser", SqlDbType.Bit, promoteLimitedDiscount.IsNewUser, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsMobileValidate", SqlDbType.Bit, promoteLimitedDiscount.IsMobileValidate, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsUseCoupon", SqlDbType.Bit, promoteLimitedDiscount.IsUseCoupon, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "StartTime", SqlDbType.DateTime, promoteLimitedDiscount.StartTime, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "EndTime", SqlDbType.DateTime, promoteLimitedDiscount.EndTime, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "CreateTime", SqlDbType.DateTime, promoteLimitedDiscount.CreateTime, ParameterDirection.Input), this.sqlServer.CreateSqlParameter( "Status", SqlDbType.Int, promoteLimitedDiscount.Status, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "ReferenceID", SqlDbType.Int, null, ParameterDirection.Output) }; this.sqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Promote_Limited_Discount_Insert", parameters, null); return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value; }
/// <summary> /// 修改限时抢购促销. /// </summary> /// <param name="promoteLimitedDiscount"> /// Promote_Limited_Discount的对象的实例. /// </param> public void Modify(Promote_Limited_Discount promoteLimitedDiscount) { this.promoteLimitedDiscountDA.Update(promoteLimitedDiscount); }
/// <summary> /// 修改限时抢购促销. /// </summary> /// <param name="promoteLimitedDiscount"> /// Promote_Limited_Discount的对象的实例. /// </param> public void Update(Promote_Limited_Discount promoteLimitedDiscount) { if (promoteLimitedDiscount == null) { throw new ArgumentNullException("promoteLimitedDiscount"); } var parameters = new List<SqlParameter> { this.SqlServer.CreateSqlParameter( "ID", SqlDbType.Int, promoteLimitedDiscount.ID, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Name", SqlDbType.NVarChar, promoteLimitedDiscount.Name, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "Discount", SqlDbType.Float, promoteLimitedDiscount.Discount, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "DiscountPrice", SqlDbType.Float, promoteLimitedDiscount.DiscountPrice, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "LimitedBuyQuantity", SqlDbType.Float, promoteLimitedDiscount.LimitedBuyQuantity, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "TotalQuantity", SqlDbType.Float, promoteLimitedDiscount.TotalQuantity, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsOnlinePayment", SqlDbType.Bit, promoteLimitedDiscount.IsOnlinePayment, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsNewUser", SqlDbType.Bit, promoteLimitedDiscount.IsNewUser, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsMobileValidate", SqlDbType.Bit, promoteLimitedDiscount.IsMobileValidate, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "IsUseCoupon", SqlDbType.Bit, promoteLimitedDiscount.IsUseCoupon, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "StartTime", SqlDbType.DateTime, promoteLimitedDiscount.StartTime, ParameterDirection.Input), this.SqlServer.CreateSqlParameter( "EndTime", SqlDbType.DateTime, promoteLimitedDiscount.EndTime, ParameterDirection.Input) }; this.SqlServer.ExecuteNonQuery( CommandType.StoredProcedure, "sp_Promote_Limited_Discount_Update", parameters, null); }
/// <summary> /// 添加限时打折促销活动. /// </summary> /// <param name="promoteLimitedDiscount"> /// Promote_Limited_Discount的对象实例. /// </param> /// <returns> /// 限时打折促销活动的编号. /// </returns> public int Add(Promote_Limited_Discount promoteLimitedDiscount) { return this.promoteLimitedDiscountDA.Insert(promoteLimitedDiscount); }