public DiscountDetail CreateDiscountDetail(DiscountDetailBean bean)
        {
            DiscountDetail beanBack = new DiscountDetail();
            beanBack.Id = bean.Id;
            beanBack.DishId = bean.DishId;
            beanBack.DiscountId = bean.DiscountId;
            beanBack.DiscountValue = bean.DiscountValue;
            beanBack.CreateDatetime = bean.CreateDatetime;
            beanBack.CreateBy = bean.CreateBy;
            beanBack.Deleted = bean.Deleted;
            beanBack.Status = bean.Status;
            beanBack.UpdateDatetime = bean.UpdateDatetime;
            beanBack.UpdateBy = bean.UpdateBy;
            return beanBack;

        }
         //0修改失败,-1修改重复
         public int UpdateDetail(DiscountDetail Detail)
         {
             int flag = 0;
             using (ChooseDishesEntities entities = new ChooseDishesEntities())
             {
                 //查询折扣方案是否存在
                 var type = entities.DiscountDetail.SingleOrDefault(bt => bt.Id == Detail.Id && bt.Deleted == 0);
                 if (type != null)
                 {
                     //设置属性是否参与修改 ,设置为false则无法更新数据
                     type.DiscountValue = Detail.DiscountValue;
                     type.UpdateDatetime = Detail.UpdateDatetime;
                     type.UpdateBy = Detail.UpdateBy;
                     try
                     {
                         //关闭实体验证,不关闭验证需要整个对象全部传值
                         entities.Configuration.ValidateOnSaveEnabled = false;
                         //操作数据库
                         flag = entities.SaveChanges();
                         entities.Configuration.ValidateOnSaveEnabled = true;
                     }
                     catch (Exception ex)
                     {
                         ex.ToString();
                     }
                 }

             }
             return flag;
         }
        public DiscountDetailBean CreateDiscountDetailBean(DiscountDetail bean)
        {
            this.Id = bean.Id;
            this.DishId = bean.DishId;
            this.DiscountId = bean.DiscountId;
            this.DiscountValue = bean.DiscountValue;
            this.CreateDatetime = bean.CreateDatetime;
            this.CreateBy = bean.CreateBy;
            this.Deleted = bean.Deleted;
            this.Status = bean.Status;
            this.UpdateDatetime = bean.UpdateDatetime;
            this.UpdateBy = bean.UpdateBy;
            return this;

        }
         //添加折扣方案明细 0 添加失败
         public int AddDetail(DiscountDetail Detail)
         {
             int flag = 0;
             using (ChooseDishesEntities entities = new ChooseDishesEntities())
             {
                 entities.DiscountDetail.Add(Detail);
                 try
                 {
                     flag = entities.SaveChanges();
                 }
                 catch (Exception ex)
                 {
                     ex.ToString();
                 }

             }
             return flag;
         }