private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Student student = dgStudents.SelectedItem as Student;

            if (student != null)
            {
                CetDb db = new CetDb();
                db.Students.Remove(student);
                db.SaveChanges();
                MessageBox.Show("Öğrenci Silindi!");
                LoadStudents();
            }
            else
            {
                MessageBox.Show("Silmek için öğrenci seçmelisin!");
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Course course = dgCourses.SelectedItem as Course;

            if (course != null)
            {
                CetDb db = new CetDb();
                db.Courses.Remove(course);
                db.SaveChanges();
                MessageBox.Show("Ders Silindi!");
                LoadCourses();
            }
            else
            {
                MessageBox.Show("Silmek için ders seçmelisin!");
            }
        }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            Student student = dgStudents.SelectedItem as Student;

            if (student != null)
            {
                CetDb db         = new CetDb();
                var   studentnew = db.Students.Find(student.Id);
                studentnew.Name      = txtStudentName.Text;
                studentnew.Surname   = txtStudentSurname.Text;
                studentnew.BirthDate = dtpBirthDate.SelectedDate.Value;
                db.SaveChanges();
                LoadStudents();
                MessageBox.Show("Güncellendi.");
            }
            else
            {
                MessageBox.Show("güncellemek için öğrenci seçmelisin!");
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Student student = new Student();

            student.Name      = txtStudentName.Text;
            student.Surname   = txtStudentSurname.Text;
            student.BirthDate = dtpBirthDate.SelectedDate.Value;

            CetDb db = new CetDb();

            db.Students.Add(student);

            db.SaveChanges();
            MessageBox.Show("Öğrenci Kaydedildi.");
            lblStudentId.Content      = "";
            txtStudentName.Text       = "";
            txtStudentSurname.Text    = "";
            dtpBirthDate.SelectedDate = DateTime.Now;
            LoadStudents();
        }
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            Course course = dgCourses.SelectedItem as Course;

            if (course != null)
            {
                CetDb db        = new CetDb();
                var   coursenew = db.Courses.Find(course.ID);
                coursenew.Cname    = txtCourseName.Text;
                coursenew.Code     = Int32.Parse(txtCourseCode.Text);
                coursenew.Capacity = Int32.Parse(txtCourseCapacity.Text);
                coursenew.Credit   = Int32.Parse(txtCourseCredit.Text);
                db.SaveChanges();
                LoadCourses();
                MessageBox.Show("Güncellendi.");
            }
            else
            {
                MessageBox.Show("güncellemek için öğrenci seçmelisin!");
            }
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Course course = new Course();

            course.Cname    = txtCourseName.Text;
            course.Code     = Int32.Parse(txtCourseCode.Text);
            course.Capacity = Int32.Parse(txtCourseCapacity.Text);
            course.Credit   = Int32.Parse(txtCourseCredit.Text);



            CetDb db = new CetDb();

            db.Courses.Add(course);

            db.SaveChanges();
            MessageBox.Show("Ders Kaydedildi.");
            //lblStudentId.Content = "";
            txtCourseName.Text     = "";
            txtCourseCode.Text     = "";
            txtCourseCredit.Text   = "";
            txtCourseCapacity.Text = "";
            LoadCourses();
        }