//主窗体初始化
     public DishPackagesViewModel(IChooseDishesDataService dataService)
     {
         _DataService = dataService;
         //查询套菜绑定grid
         DishV = new ObservableCollection<DishBean>();
         DishDaoV = new ObservableCollection<DishDaoBean>();
         DishDetailV = new ObservableCollection<DishDetailBean>();
         Dish dish = new Dish();
         List<Dish> loooo = _DataService.queryByDish(dish);
         bool a = loooo != null;
         if (a)
         {
             foreach (var loca in loooo)
             {
                 DishBean bean = new DishBean();
                 bean=bean.CreateDishBean(loca);
                 bean.InjectBeanPrice();
                 DishV.Add(new DishBean
                 {
                     DishId=bean.DishId,
                     Code = bean.Code,
                     DishName = bean.DishName,
                     DishFormatName = bean.DishFormatName,
                     Price1=bean.Price1
                  });
             }
         }
 }
 public BargainDishBean InjectDish(Dish dish) {
     if (dish != null) { 
         this.Code = dish.Code;
         this.DishName = dish.DishName;
         this.DishFormat = dish.DishFormat;
         if (dish.DishUnit != null) {
             this.DishUnitName = dish.DishUnit.Name;
         }
     }
     return this;
 }
 /// <summary>
 /// 加载做法关联的基本数据
 /// </summary>
 /// <param name="dish"></param>
 private void LoadRefData(Dish dish)
 {
     DishesWayRefTableItems.Clear();
     if (dish == null)
     {
         return;
     }
     List<DischesWayRef> dwrs = _DataService.QueryAllByDishesId(dish.DishId);
     if (dwrs != null && dwrs.Count > 0)
         foreach (var dwr in dwrs)
         {
             _DischesWayRefModel = new DischesWayRefModel();
             _DischesWayRefModel.LineNumber = DishesWayRefTableItems.Count + 1;
             _DischesWayRefModel.CreateDischesWayRefModel(dwr);
             DishesWayRefTableItems.Add(DischesWayRefModel);
         }
 }
        //修改收银方式  返回修改成功后的方式
        public bool updateDish(Dish dish)
        {
            if (dish == null)
            {
                return false;
            }
            using (ChooseDishesEntities entities = new ChooseDishesEntities())
            {
                dish.UpdateDatetime = DateTime.Now;
                var type = entities.Dish.SingleOrDefault(bt => bt.DishId == dish.DishId);
                if (type != null)
                {
                    type.AidNumber = dish.AidNumber;
                    type.DischesType = dish.DischesType;
                    type.DiscountConfirm = dish.DiscountConfirm;
                    type.DishFormat = dish.DishFormat;
                    type.DishName = dish.DishName;
                    type.DishUnitId = dish.DishUnitId;
                    type.EnglishName = dish.EnglishName;
                    type.FoodFight = dish.FoodFight;
                    type.IsStop = dish.IsStop;
                    type.KitchenType = dish.KitchenType;
                    type.LineConfirm = dish.LineConfirm;
                    type.LowConsumerConfirm = dish.LowConsumerConfirm;
                    type.PackagesConfirm = dish.PackagesConfirm;
                    type.PingYing = dish.PingYing;
                    type.PosConfirm = dish.PosConfirm;
                    type.PriceTimeConfirm = dish.PriceTimeConfirm;
                    type.PublisherType = dish.PublisherType;
                    type.SanpConfirm = dish.SanpConfirm;
                    type.Status = dish.Status;
                    type.ServerfreeConsumer = dish.ServerfreeConsumer;
                    type.UpdateBy = SubjectUtils.GetAuthenticationId();
                    type.UpdateDatetime = dish.UpdateDatetime;
                    type.WeightConfirm = dish.WeightConfirm;

                    int num = entities.SaveChanges();
                    return num == 0 ? false : true;
                }

                return false;
               
            }
        }
 //新增菜品
 public Dish AddDish(Dish dish)
 {
     //try
     //{
         if (dish == null || dish.Code == null)
         {
             return null;
         }
         using (ChooseDishesEntities entities = new ChooseDishesEntities())
         {
             var type = entities.Dish.SingleOrDefault(bt =>bt.Deleted == 0 && bt.Code == dish.Code);
             if (type != null)
             {
                 return null;
             }
             entities.Dish.Add(dish);
             //关闭实体验证,不关闭验证需要整个对象全部传值
             entities.Configuration.ValidateOnSaveEnabled = false;
             entities.SaveChanges();
         }
         return dish;
     //}
     //catch (Exception e)
     //{
     //    e.ToString();
     //    return null;
     //}
 }
 public List<Dish> queryByDish(Dish dish)
 {
     List<Dish> result;
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         //查询条件
         Expression<Func<Dish, bool>> checkCourse = Dish => Dish.PackagesConfirm == 1 && Dish.Deleted==0;
         result = entities.Dish.Include(t => t.DishPrice).Include(t => t.DishUnit).Where(checkCourse).ToList();
      }
     return result;
 }
Ejemplo n.º 7
0
        public DishPriceBean CreateDishPriceBean(DishPrice bean)
        {
            this.Id = bean.Id;
            this.DishId = bean.DishId;
            this.DishSpecification = bean.DishSpecification;
            this.Price1 = bean.Price1;
            this.Price2 = bean.Price2;
            this.Price3 = bean.Price3;
            this.MemberPrice3 = bean.MemberPrice3;
            this.MemberPrice2 = bean.MemberPrice2;
            this.MemberPrice1 = bean.MemberPrice1;
            this.IsMainPrice = bean.IsMainPrice;
            this.Dish = bean.Dish;
            return this;

        }
 public void ZhuRuDishTypeName(Dish element, DishBean dishBean)
 {
     if(element.DishType!=null){
         for (int j = 0; j < _DishTypeBig.Count; j++)
         {
             if (element.DishType.ParentId == _DishTypeBig[j].DishTypeId)
             {
                 dishBean.DishTypeBigName = _DishTypeBig[j].Name;
                 break;
             }
         }
             
     }        
 }
Ejemplo n.º 9
0
        public Dish CreateDish(DishBean dishBean)
        {
            Dish dish = new Dish();
            dish.AidNumber = dishBean.AidNumber;
            dish.Code = dishBean.Code;
            dish.CreateBy = dishBean.CreateBy;
            dish.CreateDatetime = dishBean.CreateDatetime;
            dish.Deleted = dishBean.Deleted;
            dish.Detail = dishBean.Detail;
            dish.DischesType = dishBean.DischesType;
            dish.DiscountConfirm = dishBean.DiscountConfirm;
            dish.DishFinanceId = dishBean.DishFinanceId;
            dish.DishFormat = dishBean.DishFormat;
            dish.DishId = dishBean.DishId;
            dish.DishName = dishBean.DishName;
            dish.DishTypeId = dishBean.DishTypeId;
            dish.DishUnitId = dishBean.DishUnitId;
            dish.EnglishName = dishBean.EnglishName;
            dish.FoodFight = dishBean.FoodFight;
            dish.Img = dishBean.Img;
            dish.IsStop = dishBean.IsStop;
            dish.KitchenType = dishBean.KitchenType;
            dish.LineConfirm = dishBean.LineConfirm;
            dish.LowConsumerConfirm = dishBean.LowConsumerConfirm;
            dish.PackagesConfirm = dishBean.PackagesConfirm;
            dish.PingYing = dishBean.PingYing;
            dish.PosConfirm = dishBean.PosConfirm;
            dish.PriceTimeConfirm = dishBean.PriceTimeConfirm;
            dish.PublisherType = dishBean.PublisherType;
            dish.SanpConfirm = dishBean.SanpConfirm;
            dish.Status = dishBean.Status;
            dish.ServerfreeConsumer = dishBean.ServerfreeConsumer;
            dish.UpdateBy = dishBean.UpdateBy;
            dish.UpdateDatetime = dishBean.UpdateDatetime;
            dish.WeightConfirm = dishBean.WeihtConfirm;

            return dish;
        }
Ejemplo n.º 10
0
 public DishBean CreateDishBean2DishWay(Dish dish,DishUnit unit)
 {
     this.AidNumber = dish.AidNumber;
     this.Code = dish.Code;
     this.CreateBy = dish.CreateBy;
     this.CreateDatetime = dish.CreateDatetime;
     this.Deleted = dish.Deleted;
     this.Detail = dish.Detail;
     this.DischesType = dish.DischesType;
     this.DiscountConfirm = dish.DiscountConfirm;
     this.DishFinanceId = dish.DishFinanceId;
     this.DishFormat = dish.DishFormat;
     this.DishId = dish.DishId;
     this.DishName = dish.DishName;
     this.DishTypeId = dish.DishTypeId;
     this.DishUnitId = dish.DishUnitId;
     this.EnglishName = dish.EnglishName;
     this.FoodFight = dish.FoodFight;
     this.Img = dish.Img;
     this.IsStop = dish.IsStop;
     this.KitchenType = dish.KitchenType;
     this.LineConfirm = dish.LineConfirm;
     this.LowConsumerConfirm = dish.LowConsumerConfirm;
     this.PackagesConfirm = dish.PackagesConfirm;
     this.PingYing = dish.PingYing;
     this.PosConfirm = dish.PosConfirm;
     this.PriceTimeConfirm = dish.PriceTimeConfirm;
     this.PublisherType = dish.PublisherType;
     this.SanpConfirm = dish.SanpConfirm;
     this.Status = dish.Status;
     this.ServerfreeConsumer = dish.ServerfreeConsumer;
     this.UpdateBy = dish.UpdateBy;
     this.UpdateDatetime = dish.UpdateDatetime;
     this.WeightConfirm = dish.WeightConfirm;
     this.DishUnitName = unit.Name;
     return this;
 }
        public PromotionsDishBean CreatePromotionsDishBean(PromotionsDish bean)
        {
            this.PromotionsDishId = bean.PromotionsDishId;
            this.TradeNo = bean.TradeNo;
            this.DishId = bean.DishId??0;
            this.MarketTypeId = bean.MarketTypeId;
            this.DishFormat = bean.DishFormat;
            this.Price = bean.Price;
            this.StartTime = bean.StartTime;
            this.EndTime = bean.EndTime;
            this.StartDate = bean.StartDate;
            this.EndDate = bean.EndDate;
            this.Week_1 = bean.Week_1;
            this.Week_2 = bean.Week_2;
            this.Week_3 = bean.Week_3;
            this.Week_4 = bean.Week_4;
            this.Week_5 = bean.Week_5;
            this.Week_6 = bean.Week_6;
            this.Week_0 = bean.Week_0;
            this.Status = bean.Status;
            this.Usering = bean.Usering;
            this.CreateDatetime = bean.CreateDatetime;
            this.CreateBy = bean.CreateBy;
            this.Deleted = bean.Deleted;
            this.UpdateDatetime = bean.UpdateDatetime;
            this.UpdateBy = bean.UpdateBy;
            this.Dish = bean.Dish;
            this.PromotionsDishDetail = bean.PromotionsDishDetail;
            return this;

        }