Example #1
0
        private void Button_ClickUpdate(object sender, RoutedEventArgs e)
        {
            int           num           = (GridAcademic.SelectedItem as AcademicLeave).AcademicLeaveId;
            var           queryUpdate   = db.AcademicLeave.Where(u => u.AcademicLeaveId == num).FirstOrDefault();
            AcademicLeave academicLeave = new AcademicLeave();

            queryUpdate.IdStudent         = Convert.ToInt32(StudentTb.Text);
            queryUpdate.DateAcademicLeave = Convert.ToDateTime(DateAcademicLeaveDP.SelectedDate);
            queryUpdate.OrderNumber       = Convert.ToInt32(OrderNumberTB.Text);
            queryUpdate.DateExpiration    = Convert.ToDateTime(DateExpirationDP.SelectedDate);
            queryUpdate.IdNumberGroup     = Convert.ToInt32(NumberGroupCB.SelectedValue);
            db.SaveChanges();
            GridAcademic.ItemsSource = db.AcademicLeave.ToList();
        }
Example #2
0
        private void Button_ClickAdd(object sender, RoutedEventArgs e)
        {
            AcademicLeave academicLeave = new AcademicLeave()
            {
                IdStudent         = Convert.ToInt32(StudentTb.Text),
                DateAcademicLeave = Convert.ToDateTime(DateAcademicLeaveDP.SelectedDate),
                OrderNumber       = Convert.ToInt32(OrderNumberTB.Text),
                DateExpiration    = Convert.ToDateTime(DateExpirationDP.SelectedDate),
                IdNumberGroup     = Convert.ToInt32(NumberGroupCB.SelectedValue)
            };

            db.AcademicLeave.Add(academicLeave);
            db.SaveChanges();
            GridAcademic.ItemsSource = db.AcademicLeave.ToList();
        }