예제 #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";
                }
            }
        }
예제 #4
0
 public MainWindow()
 {
     InitializeComponent();
     //Ofening2.1 & 3.5:
     Persons.Add(new Person("fistname", "lastname", "C:\\Users\\Mohamed\\source\\repos\\Myfirstwpfapp\\Myfirstwpfapp\\images\\person.jpg", "images\\on.png"));
     Persons.Add(new Person("fistname1", "lastname1", "C:\\Users\\Mohamed\\source\\repos\\Myfirstwpfapp\\Myfirstwpfapp\\images\\person1.png", "images\\on.png"));
     Persons.Add(new Person("fistname2", "lastname2", "C:\\Users\\Mohamed\\source\\repos\\Myfirstwpfapp\\Myfirstwpfapp\\images\\person2.png", "images\\off.png"));
     Persons.Add(new Person("fistname3", "lastname3", "C:\\Users\\Mohamed\\source\\repos\\Myfirstwpfapp\\Myfirstwpfapp\\images\\person3.png", "images\\off.png"));
     Persons.Add(new Person("fistname4", "lastname4", "C:\\Users\\Mohamed\\source\\repos\\Myfirstwpfapp\\Myfirstwpfapp\\images\\person4.png", "images\\on.png"));
     //Ofening2.1:
     cmbpersons.ItemsSource = Persons;
     //Ofening3.5:
     lbPersons.ItemsSource = Persons;
     //Ofening3.7:
     using (var ctx = new NotitieContext())
     {
         Notities = ctx.Notities.ToList();
     }
     lvNotities.ItemsSource    = Notities.Where(n => n.Started == null && n.Done == null);
     lvNotitiesStr.ItemsSource = Notities.Where(n => n.Started != null && n.Done == null);
     lvNotitiesDne.ItemsSource = Notities.Where(n => n.Started != null && n.Done != null);
 }