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="request">
        /// The request.
        /// </param>
        /// <param name="promoteName">
        /// 多瓶装促销名称.
        /// </param>
        /// <param name="startStartTime">
        /// 活动开始时间范围起始时间.
        /// </param>
        /// <param name="startEndTime">
        /// 活动开始时间范围结束时间.
        /// </param>
        /// <param name="endStartTime">
        /// 活动结束时间范围起始时间.
        /// </param>
        /// <param name="endEndTime">
        /// 活动结束时间范围结束时间.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public JsonResult QueryMuchBottled(
            [DataSourceRequest] DataSourceRequest request,
            string promoteName,
            string startStartTime,
            string startEndTime,
            string endStartTime,
            string endEndTime)
        {
            this.promoteMuchBottledService = new PromoteMuchBottledService();
            if (request.Page <= 0)
            {
                request.Page = 1;
            }

            if (request.PageSize == 0)
            {
                request.PageSize = 10;
            }

            int totalCount;
            var stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(promoteName))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[Name] like '%" + promoteName + "%'");
            }

            if (!string.IsNullOrEmpty(startStartTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[StartTime] >= '" + startStartTime + "'");
            }

            if (!string.IsNullOrEmpty(startEndTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[StartTime] <= '" + startEndTime + "'");
            }

            if (!string.IsNullOrEmpty(endStartTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[EndTime] >= '" + endStartTime + "'");
            }

            if (!string.IsNullOrEmpty(endEndTime))
            {
                CheckCondition(stringBuilder);
                stringBuilder.Append("[EndTime] <= '" + endEndTime + "'");
            }

            var condition = stringBuilder.ToString();
            List<Promote_MuchBottled> list;
            try
            {
                var paging = new Paging("[view_Promote_MuchBottled]", null, "[ID]", condition, request.Page, request.PageSize);
                int pageCount;
                list = this.promoteMuchBottledService.Query(paging, out pageCount, out totalCount);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            if (list != null)
            {
                var modelList = new List<PromoteMuchBottledModel>();
                foreach (var muchBottled in list)
                {
                    modelList.Add(
                        DataTransfer.Transfer<PromoteMuchBottledModel>(muchBottled, typeof(Promote_MuchBottled)));
                }

                var data = new DataSource { Data = modelList, Total = totalCount };
                return this.Json(data, JsonRequestBehavior.AllowGet);
            }

            return this.Json(string.Empty);
        }
        public JsonResult GetMuchBottledInfoByID(string muchBottledID)
        {
            if (string.IsNullOrEmpty(muchBottledID))
            {
                return this.Json(null);
            }

            try
            {
                this.promoteMuchBottledService = new PromoteMuchBottledService();
                var promoteMuchBottled = this.promoteMuchBottledService.QueryByID(int.Parse(muchBottledID));
                var promoteMuchBottledModel = DataTransfer.Transfer<PromoteMuchBottledModel>(
                    promoteMuchBottled,
                    typeof(Promote_MuchBottled));

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

                if (promoteMuchBottledRuleList != null)
                {
                    var modelList = new List<PromoteMuchBottledRuleModel>();
                    foreach (var muchBottledRule in promoteMuchBottledRuleList)
                    {
                        modelList.Add(
                            DataTransfer.Transfer<PromoteMuchBottledRuleModel>(
                                muchBottledRule,
                                typeof(Promote_MuchBottled_Rule)));
                    }

                    promoteMuchBottledModel.PromoteMuchBottledRuleModels = modelList;
                }

                return this.Json(promoteMuchBottledModel, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }