Пример #1
0
 //Oefening 3.7
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     using (var ctx = new NotitieContext())
     {
         ctx.Notities.Add(new Notitie {
             Title = txttitle.Text, Description = txtDEscription.Text, Todo = dpTodo.SelectedDate.Value.ToUniversalTime()
         });
         ctx.SaveChanges();
     }
 }
Пример #2
0
        private void btnSetDone_Click(object sender, RoutedEventArgs e)
        {
            var item  = (sender as Button).DataContext;
            int index = lvNotities.Items.IndexOf(item);

            using (var ctx = new NotitieContext())
            {
                ctx.Notities.FirstOrDefault(n => n == (Notitie)lvNotities.Items[index]).Done = DateTime.Now;
                ctx.SaveChanges();
            }
        }
Пример #3
0
        private void btnEditTitle_Click(object sender, RoutedEventArgs e)
        {
            var item  = (sender as Button).DataContext;
            int index = lvNotities.Items.IndexOf(item);

            if ((sender as Button).Content.ToString() == "Edit")
            {
            }
            else if ((sender as Button).Content.ToString() == "Save")
            {
                using (var ctx = new NotitieContext())
                {
                    ctx.Notities.FirstOrDefault(n => n == (Notitie)lvNotities.Items[index]).Title = (this.FindName("txtTitle") as TextBox).Text;
                    ctx.SaveChanges();
                    (this.FindName("txtTitle") as TextBox).IsEnabled = false;
                    (sender as Button).Content = "Edit";
                }
            }
        }