Example #1
0
 public FeedingBottleElement(Database.FeedingBottle bottleIn)
 {
     InitializeComponent();
     PopulateComboBox();
     HourPick.MinTime      = new RoyT.TimePicker.DigitalTime(00, 00);
     HourPick.MaxTime      = new RoyT.TimePicker.DigitalTime(23, 45);
     isEditing             = true;
     bottle                = bottleIn;
     DatePick.SelectedDate = new DateTime(bottle.FeedingBottleDT.Year, bottle.FeedingBottleDT.Month, bottle.FeedingBottleDT.Day);
     HourPick.Time         = new RoyT.TimePicker.DigitalTime(bottle.FeedingBottleDT.Hour, bottle.FeedingBottleDT.Minute);
     txtQty.Text           = bottle.FeedingBottleQuantity.ToString();
     Comments.Text         = bottle.FeedingBottleComments;
     cbxType.SelectedItem  = bottle.FeedingBottleType;
 }
Example #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (cbxType.SelectedItem == null || cbxType.SelectedItem.ToString() == "")
     {
         MessageBox.Show("Merci de vouloir sélectionner un type de repas", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         if (isEditing)
         {
             Database.FeedingBottle bottleOut = MainWindow.INSTANCE.ctxBottles.FeedingBottles.Where(fb => fb.FeedingBottleID == bottle.FeedingBottleID).First();
             bottle.FeedingBottleDT       = new DateTime(DatePick.SelectedDate.Value.Year, DatePick.SelectedDate.Value.Month, DatePick.SelectedDate.Value.Day, HourPick.Time.Hour, HourPick.Time.Minute, 0);
             bottle.FeedingBottleComments = Comments.Text;
             bottle.FeedingBottleType     = cbxType.SelectedItem.ToString();
             bottle.FeedingBottleQuantity = (cbxType.SelectedItem.ToString() == "Allaitement maternel" ? 0 : Convert.ToInt32(txtQty.Text));
             bottleOut = bottle;
             MainWindow.INSTANCE.ctxBottles.SaveChanges();
         }
         else
         {
             bottle = new Database.FeedingBottle()
             {
                 FeedingBottleDT       = new DateTime(DatePick.SelectedDate.Value.Year, DatePick.SelectedDate.Value.Month, DatePick.SelectedDate.Value.Day, HourPick.Time.Hour, HourPick.Time.Minute, 0),
                 FeedingBottleComments = Comments.Text,
                 FeedingBottleType     = cbxType.SelectedItem.ToString(),
                 FeedingBottleQuantity = (cbxType.SelectedItem.ToString() == "Allaitement maternel" ? 0 : Convert.ToInt32(txtQty.Text))
             };
             MainWindow.INSTANCE.ctxBottles.FeedingBottles.Add(bottle);
             MainWindow.INSTANCE.ctxBottles.SaveChanges();
         }
         foreach (UserControl ctrl in MainWindow.INSTANCE.FragmentCollection)
         {
             if (ctrl is FeedingBottle)
             {
                 Cursor = Cursors.Wait;
                 ((FeedingBottle)ctrl).LoadBottles();
                 MainWindow.INSTANCE.ChangeMainContent(ctrl);
                 Cursor = Cursors.Arrow;
             }
         }
     }
 }