コード例 #1
0
 //0修改失败,-1修改重复
 public int UpdateProgram(DiscountProgram Program)
 {
     int flag = 0;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         //查询折扣方案是否存在
         var type = entities.DiscountProgram.SingleOrDefault(bt => bt.DiscountId == Program.DiscountId && bt.Deleted == 0);
         if (type != null)
         {
            //设置属性是否参与修改 ,设置为false则无法更新数据
             type.Code = Program.Code;
             type.Name = Program.Name;
             type.ByDish = Program.ByDish;
             type.Rate = Program.Rate;
             type.UpdateDatetime = Program.UpdateDatetime;
             type.UpdateBy = Program.UpdateBy;
             try
             {
                 //关闭实体验证,不关闭验证需要整个对象全部传值
                 entities.Configuration.ValidateOnSaveEnabled = false;
                 //操作数据库
                 flag = entities.SaveChanges();
                 entities.Configuration.ValidateOnSaveEnabled = true;
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
         }
         
     }
     return flag;
 }
コード例 #2
0
        public DiscountProgram CreateDiscountProgram(DiscountProgramBean bean)
        {
            DiscountProgram beanBack = new DiscountProgram();
            beanBack.DiscountId = bean.DiscountId;
            beanBack.Code = bean.Code;
            beanBack.Name = bean.Name;
            beanBack.ByDish = bean.ByDish;
            beanBack.Rate = bean.Rate;
            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;

        }
コード例 #3
0
 //添加折扣方案 0 添加失败
 public int AddProgram(DiscountProgram Program)
 {
     int flag = 0;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
          //实体绑定MODEL
         entities.DiscountProgram.Add(Program);
             try
             {
                 //操作数据库
                 entities.SaveChanges();
                 flag = Program.DiscountId;
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
        
     }
     return flag;
 }
コード例 #4
0
        public DiscountProgramBean CreateDiscountProgramBean(DiscountProgram bean)
        {
            this.DiscountId = bean.DiscountId;
            this.Code = bean.Code;
            this.Name = bean.Name;
            this.ByDish = bean.ByDish;
            this.Rate = bean.Rate;
            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;

        }