예제 #1
0
 private void PopulateDishWishes() {
   using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
     IQueryable<GetWishedDish_Result> DishWishs = context.GetWishedDish(CurrentClient.Id, null);
     dataGridViewDishWish.DataSource = DishWishs.ToList();
     foreach(DataGridViewColumn column in dataGridViewDishWish.Columns) {
       column.Visible = false;
     }
     dataGridViewDishWish.Columns[0].Visible = true;
     dataGridViewDishWish.Columns[1].Visible = true;
     dataGridViewDishWish.Columns[2].Visible = true;
   }
 }
예제 #2
0
 private void ColorizeMenu(DataGridView source) {
   int FeelingTypeLike = Int32.Parse(ConfigurationManager.AppSettings["FeelingTypeLike"]);
   int FeelingTypeDislike = Int32.Parse(ConfigurationManager.AppSettings["FeelingTypeDislike"]);
   GetMenu_Result item;
   IQueryable<GetWishedDish_Result> liked;
   IQueryable<GetWishedDish_Result> disliked;
   Color color;
   using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
     liked = context.GetWishedDish(CurrentClient.Id, FeelingTypeLike);
     disliked = context.GetWishedDish(CurrentClient.Id, FeelingTypeDislike);
     foreach(DataGridViewRow row in source.Rows) {
       item = (GetMenu_Result)row.DataBoundItem;
       if(liked.Where(mainCourse => mainCourse.DishId == item.DishId).Count() > 0) {
         color = Color.Green;
       } else if(disliked.Where(mainCourse => mainCourse.DishId == item.DishId).Count() > 0) {
         color = Color.Red;
       } else {
         color = Color.Black;
       }
       row.DefaultCellStyle.ForeColor = color;
       row.DefaultCellStyle.SelectionBackColor = color;
     }
   }
 }
 public void LoadDishWish(int dishId) {
   using(ProjetSGBDEntities context = new ProjetSGBDEntities()) {
     CurrentDish = context.GetWishedDish(CurrentClient.Id, null).Where(dish => dish.DishId == dishId).First();
   }
 }