コード例 #1
0
 public FormReservationDetails()
 {
     InitializeComponent();
     CurrentClient    = null;
     CurrentReception = null;
     _starter         = null;
     _mainCourse      = null;
     _dessert         = null;
     _starter_old     = null;
     _mainCourse_old  = null;
     _dessert_old     = null;
 }
コード例 #2
0
 private void UpdateDish(GetReservedDish_Result oldDish, Dish newDish)
 {
     using (ProjetSGBDEntities context = new ProjetSGBDEntities()) {
         if (oldDish != null)
         {
             if ((newDish != null) && (oldDish.DishId != newDish.DishId))
             {
                 context.DeleteReservedDish(oldDish.ClientId, oldDish.DishId, CurrentReception.ReceptionId, oldDish.ModifiedAt);
                 context.NewReservedDish(CurrentClient.Id, newDish.DishId, CurrentReception.ReceptionId, CurrentClient.Acronym);
             }
         }
         else
         {
             if (newDish != null)
             {
                 context.NewReservedDish(CurrentClient.Id, newDish.DishId, CurrentReception.ReceptionId, CurrentClient.Acronym);
             }
         }
     }
 }
コード例 #3
0
 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();
         }
     }
 }