private void FormReservationDetails_Load(object sender, EventArgs e) { if ((CurrentClient != null) && (CurrentReception != null)) { textBoxDate.Text = CurrentReception.ReceptionDate.ToString("dd MMMM yyyy"); textBoxName.Text = CurrentReception.ReceptionName; try { using (ProjetSGBDEntities context = new ProjetSGBDEntities()) { IQueryable <GetReservedDish_Result> _reservedDishes = context.GetReservedDish(CurrentReception.ReceptionId, CurrentClient.Id); if (_reservedDishes.Where(dish => dish.DishTypeId == DishTypeStarter).Count() == 1) { _starter_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeStarter).First(); _starter = context.Dish.Where(dish => dish.DishId == _starter_old.DishId).First(); textBoxStarter.Text = _starter.Name; } if (_reservedDishes.Where(dish => dish.DishTypeId == DishTypeMainDish).Count() == 1) { _mainCourse_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeMainDish).First(); _mainCourse = context.Dish.Where(dish => dish.DishId == _mainCourse_old.DishId).First(); textBoxMainCourse.Text = _mainCourse.Name; } if (_reservedDishes.Where(dish => dish.DishTypeId == DishTypeDessert).Count() == 1) { _dessert_old = _reservedDishes.Where(dish => dish.DishTypeId == DishTypeDessert).First(); _dessert = context.Dish.Where(dish => dish.DishId == _dessert_old.DishId).First(); textBoxDessert.Text = _dessert.Name; } } } catch (Exception ex) { ModelError modelError = new ModelError(ex); MessageBox.Show(modelError.Message, "Erreur fatale!", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Abort; Close(); } } }