private void ColorizeMenu(DataGridView source) { 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; } } }
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; } }
public void LoadDishWish(int dishId) { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { CurrentDish = context.GetWishedDish(CurrentClient.Id, null).Where(dish => dish.DishId == dishId).First(); } }