/// <summary>
        /// 添加多瓶装促销活动.
        /// </summary>
        /// <param name="promoteMuchBottled">
        /// Promote_MuchBottled的对象实例.
        /// </param>
        /// <returns>
        /// 多瓶装编号.
        /// </returns>
        public int Insert(Promote_MuchBottled promoteMuchBottled)
        {
            if (promoteMuchBottled == null)
            {
                throw new ArgumentNullException("promoteMuchBottled");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "EmployeeID",
                                         SqlDbType.Int,
                                         promoteMuchBottled.EmployeeID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         promoteMuchBottled.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ProductID",
                                         SqlDbType.Int,
                                         promoteMuchBottled.ProductID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsOnlinePayment",
                                         SqlDbType.Bit,
                                         promoteMuchBottled.IsOnlinePayment,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "StartTime",
                                         SqlDbType.DateTime,
                                         promoteMuchBottled.StartTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "EndTime",
                                         SqlDbType.DateTime,
                                         promoteMuchBottled.EndTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsDisplayTime",
                                         SqlDbType.Bit,
                                         promoteMuchBottled.IsDisplayTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "CreateTime",
                                         SqlDbType.DateTime,
                                         promoteMuchBottled.CreateTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         null,
                                         ParameterDirection.Output)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_MuchBottled_Insert",
                parameters,
                null);
            return (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
        }
        /// <summary>
        /// 更新多瓶装促销.
        /// </summary>
        /// <param name="promoteMuchBottled">
        /// Promote_MuchBottled的对象实例.
        /// </param>
        public void Update(Promote_MuchBottled promoteMuchBottled)
        {
            if (promoteMuchBottled == null)
            {
                throw new ArgumentNullException("promoteMuchBottled");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         promoteMuchBottled.ID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "EmployeeID",
                                         SqlDbType.Int,
                                         promoteMuchBottled.EmployeeID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsOnlinePayment",
                                         SqlDbType.Bit,
                                         promoteMuchBottled.IsOnlinePayment,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "EndTime",
                                         SqlDbType.DateTime,
                                         promoteMuchBottled.EndTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsDisplayTime",
                                         SqlDbType.Bit,
                                         promoteMuchBottled.IsDisplayTime,
                                         ParameterDirection.Input)
                                 };

            this.SqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_MuchBottled_Update",
                parameters,
                null);
        }
        public void AddMuchBottled(
            string productID,
            string gjwPrice,
            string promoteName,
            bool isOnlinePayment,
            string startTime,
            string endTime,
            bool isDisplayTime,
            string property,
            string number,
            string price,
            string imgstr,
            string isDefault)
        {
            try
            {
                this.promoteMuchBottledService = new PromoteMuchBottledService();
                var isExists = this.promoteMuchBottledService.QueryByProductID(int.Parse(productID));
                if (isExists)
                {
                    Response.Write("该商品已参加多瓶装促销!");
                    return;
                }

                var promoteMuchBottled = new Promote_MuchBottled
                                             {
                                                 EmployeeID = this.SystemUserSession.EmployeeID,
                                                 ProductID = int.Parse(productID),
                                                 Name = promoteName,
                                                 IsOnlinePayment = isOnlinePayment,
                                                 StartTime = DateTime.Parse(startTime),
                                                 EndTime = DateTime.Parse(endTime),
                                                 IsDisplayTime = isDisplayTime,
                                                 CreateTime = DateTime.Now
                                             };

                promoteMuchBottled.ID = this.promoteMuchBottledService.Add(promoteMuchBottled);

                this.AddMuchBottledRule(
                    promoteMuchBottled.ID,
                    double.Parse(gjwPrice),
                    property,
                    number,
                    price,
                    imgstr,
                    isDefault);

                Response.Write("设置成功!");
            }
            catch (Exception exception)
            {
                Response.Write("设置失败!");
                throw new Exception(exception.Message, exception);
            }
        }
        public void ModifyMuchBottled(
            string muchBottledID,
            bool isOnlinePayment,
            string endTime,
            bool isDisplayTime,
            double goujiuPrice,
            string property,
            string number,
            string price,
            string imgstr,
            string isDefault)
        {
            try
            {
                var promoteMuchbottled = new Promote_MuchBottled
                {
                    ID = int.Parse(muchBottledID),
                    EmployeeID = this.SystemUserSession.EmployeeID,
                    IsOnlinePayment = isOnlinePayment,
                    EndTime = DateTime.Parse(endTime),
                    IsDisplayTime = isDisplayTime
                };
                this.promoteMuchBottledService = new PromoteMuchBottledService();
                this.promoteMuchBottledService.Update(promoteMuchbottled);

                var ruleName = property.Split(',');
                var ruleNum = number.Split(',');
                var rulePrice = price.Split(',');
                var ruleisDefault = isDefault.Split(',');
                var ruleImg = imgstr.Split(',');

                this.promoteMuchBottledRuleService = new PromoteMuchBottledRuleService();
                var promoteMuchBottledRuleList =
                    this.promoteMuchBottledRuleService.QueryByMuchBottledID(int.Parse(muchBottledID));

                var promoteMuchBottledRule = new Promote_MuchBottled_Rule();
                for (int i = 0; i < promoteMuchBottledRuleList.Count; i++)
                {
                    if (ruleName[i].Trim() != string.Empty)
                    {
                        promoteMuchBottledRule.ID = promoteMuchBottledRuleList[i].ID;
                        promoteMuchBottledRule.Name = ruleName[i].Trim();
                        promoteMuchBottledRule.Quantity = int.Parse(ruleNum[i].Trim());
                        promoteMuchBottledRule.UnitPrice = double.Parse(rulePrice[i].Trim());
                        promoteMuchBottledRule.TotalMoney = promoteMuchBottledRule.UnitPrice
                                                            * promoteMuchBottledRule.Quantity;
                        promoteMuchBottledRule.DiscountAmount = (goujiuPrice - int.Parse(rulePrice[i].Trim()))
                                                                * int.Parse(ruleNum[i].Trim());
                        promoteMuchBottledRule.IsDefault = ruleisDefault[i] == "1";
                        promoteMuchBottledRule.ImageUrl = ruleImg[i];

                        this.promoteMuchBottledRuleService.Modify(promoteMuchBottledRule);
                    }
                }

                if (promoteMuchBottledRuleList.Count < ruleName.Length)
                {
                    for (int i = promoteMuchBottledRuleList.Count; i < ruleName.Length; i++)
                    {
                        if (ruleName[i].Trim() != string.Empty)
                        {
                            promoteMuchBottledRule.Name = ruleName[i].Trim();
                            promoteMuchBottledRule.Quantity = int.Parse(ruleNum[i].Trim());
                            promoteMuchBottledRule.UnitPrice = double.Parse(rulePrice[i].Trim());
                            promoteMuchBottledRule.TotalMoney = promoteMuchBottledRule.UnitPrice
                                                                * promoteMuchBottledRule.Quantity;
                            promoteMuchBottledRule.DiscountAmount = (goujiuPrice - int.Parse(rulePrice[i].Trim()))
                                                                    * int.Parse(ruleNum[i].Trim());
                            promoteMuchBottledRule.IsDefault = ruleisDefault[i] == "1";
                            promoteMuchBottledRule.ImageUrl = ruleImg[i];

                            promoteMuchBottledRule.ID = this.promoteMuchBottledRuleService.Add(promoteMuchBottledRule);
                        }
                    }
                } // 如果修改的数量大于已存在的数量则添加新的规则
            }
            catch (Exception exception)
            {
                Response.Write("修改失败!");
                throw new Exception(exception.Message, exception);
            }

            Response.Write("修改成功!");
        }
 /// <summary>
 /// 添加多瓶装促销活动.
 /// </summary>
 /// <param name="promoteMuchBottled">
 /// Promote_MuchBottled的对象实例.
 /// </param>
 /// <returns>
 /// 多瓶装编号.
 /// </returns>
 public int Add(Promote_MuchBottled promoteMuchBottled)
 {
     return this.promoteMuchBottledDA.Insert(promoteMuchBottled);
 }
 /// <summary>
 /// 更新多瓶装促销.
 /// </summary>
 /// <param name="promoteMuchBottled">
 /// Promote_MuchBottled的对象实例.
 /// </param>
 public void Update(Promote_MuchBottled promoteMuchBottled)
 {
     this.promoteMuchBottledDA.Update(promoteMuchBottled);
 }