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

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "MuchBottledID",
                                         SqlDbType.Int,
                                         promoteMuchBottledRule.MuchBottledID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         promoteMuchBottledRule.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Quantity",
                                         SqlDbType.Int,
                                         promoteMuchBottledRule.Quantity,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "UnitPrice",
                                         SqlDbType.Float,
                                         promoteMuchBottledRule.UnitPrice,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "DiscountAmount",
                                         SqlDbType.Float,
                                         promoteMuchBottledRule.DiscountAmount,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "TotalMoney",
                                         SqlDbType.Float,
                                         promoteMuchBottledRule.TotalMoney,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ImageUrl",
                                         SqlDbType.NVarChar,
                                         promoteMuchBottledRule.ImageUrl,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsDefault",
                                         SqlDbType.Bit,
                                         promoteMuchBottledRule.IsDefault,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         null,
                                         ParameterDirection.Output)
                                 };

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

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         promoteMuchBottledRule.ID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         promoteMuchBottledRule.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Quantity",
                                         SqlDbType.Int,
                                         promoteMuchBottledRule.Quantity,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "UnitPrice",
                                         SqlDbType.Float,
                                         promoteMuchBottledRule.UnitPrice,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "DiscountAmount",
                                         SqlDbType.Float,
                                         promoteMuchBottledRule.DiscountAmount,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "TotalMoney",
                                         SqlDbType.Float,
                                         promoteMuchBottledRule.TotalMoney,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ImageUrl",
                                         SqlDbType.NVarChar,
                                         promoteMuchBottledRule.ImageUrl,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "IsDefault",
                                         SqlDbType.Bit,
                                         promoteMuchBottledRule.IsDefault,
                                         ParameterDirection.Input)
                                 };
            this.sqlServer.ExecuteNonQuery(
                CommandType.StoredProcedure,
                "sp_Promote_MuchBottled_Rule_Update",
                parameters,
                null);
        }
        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="muchBottledID">
        /// 多瓶装活动的编号.
        /// </param>
        /// <param name="goujiuPrice">
        /// 商品购酒网价格.
        /// </param>
        /// <param name="property">
        /// 活动的规则名称列表.
        /// </param>
        /// <param name="number">
        /// 活动的规则数量列表.
        /// </param>
        /// <param name="price">
        /// 活动规则促销价格列表.
        /// </param>
        /// <param name="imgstr">
        /// 缩略图列表.
        /// </param>
        /// <param name="isDefault">
        /// 是否默认列表
        /// </param>
        public void AddMuchBottledRule(
            int muchBottledID,
            double goujiuPrice,
            string property,
            string number,
            string price,
            string imgstr,
            string isDefault)
        {
            var ruleName = property.Split(',');
            var ruleNum = number.Split(',');
            var rulePrice = price.Split(',');
            var ruleisDefault = isDefault.Split(',');
            var ruleImg = imgstr.Split(',');
            var promoteMuchBottledRule = new Promote_MuchBottled_Rule { MuchBottledID = muchBottledID };
            for (int i = 0; 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 = "Images/pro/" + ruleImg[i];

                    this.promoteMuchBottledRuleService = new PromoteMuchBottledRuleService();
                    promoteMuchBottledRule.ID = this.promoteMuchBottledRuleService.Add(promoteMuchBottledRule);
                }
            }
        }
 /// <summary>
 /// 更新多瓶装促销规则.
 /// </summary>
 /// <param name="promoteMuchBottledRule">
 /// Promote_MuchBottled_Rule的对象实例.
 /// </param>
 public void Modify(Promote_MuchBottled_Rule promoteMuchBottledRule)
 {
     this.promoteMuchBottledRuleDA.Update(promoteMuchBottledRule);
 }
 /// <summary>
 /// 添加多瓶装活动规则.
 /// </summary>
 /// <param name="promoteMuchBottledRule">
 /// Promote_MuchBottled_Rule的对象实例.
 /// </param>
 /// <returns>
 /// 多瓶装活动规则的编号.
 /// </returns>
 public int Add(Promote_MuchBottled_Rule promoteMuchBottledRule)
 {
     return this.promoteMuchBottledRuleDA.Insert(promoteMuchBottledRule);
 }