private void LoadCourses()
        {
            CetDb         db      = new CetDb();
            List <Course> courses = db.Courses.ToList();

            dgCourse.ItemsSource = courses;
        }
Пример #2
0
        private void LoadStudents()
        {
            CetDb          db       = new CetDb();
            List <Student> students = db.Students.ToList();

            dgStudents.ItemsSource = students;
        }
        private void btndelete_Click(object sender, RoutedEventArgs e)
        {
            Course course = dgCourse.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 dersi seçmelisin!");
            }
        }
Пример #4
0
        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 btnsave_Click(object sender, RoutedEventArgs e)
        {
            Course course = new Course();

            course.CourseCode   = txtCourseCode.Text;
            course.CourseQuota  = Int32.Parse(txtCourseQuota.Text);
            course.CourseCredit = Int32.Parse(txtCourseCredit.Text);

            CetDb db = new CetDb();

            db.Courses.Add(course);

            db.SaveChanges();
            MessageBox.Show("Ders eklendi.");

            txtCourseCode.Text   = "";
            txtCourseQuota.Text  = "";
            txtCourseCredit.Text = "";
            LoadCourses();
        }
Пример #6
0
        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!");
            }
        }
Пример #7
0
        private void Button_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.");

            txtStudentName.Text       = "";
            txtStudentSurname.Text    = "";
            dtpBirthDate.SelectedDate = DateTime.Now;
            LoadStudents();
        }
        private void btnupdate_Click(object sender, RoutedEventArgs e)
        {
            Course course = dgCourse.SelectedItem as Course;

            if (course != null)
            {
                CetDb db        = new CetDb();
                var   coursenew = db.Courses.Find(course.Id);

                coursenew.CourseCode   = txtCourseCode.Text;
                coursenew.CourseQuota  = Int32.Parse(txtCourseQuota.Text);
                coursenew.CourseCredit = Int32.Parse(txtCourseCredit.Text);

                db.SaveChanges();
                LoadCourses();
                MessageBox.Show("Güncellendi.");
            }
            else
            {
                MessageBox.Show("güncellemek için ders seçmelisin!");
            }
        }