private void Button_Click(object sender, RoutedEventArgs e)
        {
            Student student = new Student();

            student.Id        = int.Parse(txtStudentId.Text);
            student.Name      = txtStudentName.Text;
            student.Surname   = txtStudentSurname.Text;
            student.BirthDate = dtpBirthDate.SelectedDate.Value;

            DatabaseDB db = new DatabaseDB();

            db.Database.OpenConnection();
            db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Students ON");
            db.Students.Add(student);
            db.SaveChanges();

            MessageBox.Show("Öğrenci Kaydedildi.");


            txtStudentId.Text         = "";
            txtStudentName.Text       = "";
            txtStudentSurname.Text    = "";
            dtpBirthDate.SelectedDate = DateTime.Now;
            LoadStudents();
            txtStudentId.IsEnabled = false;
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Student student = dgStudents.SelectedItem as Student;

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

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

            if (student != null)
            {
                DatabaseDB db         = new DatabaseDB();
                var        studentnew = db.Students.Find(student.Id);
                studentnew.Id        = int.Parse(txtStudentId.Text);
                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!");
            }
        }
示例#5
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            Course course = dgCourses.SelectedItem as Course;

            if (course != null)
            {
                DatabaseDB db        = new DatabaseDB();
                var        coursenew = db.Courses.Find(course.Id);
                coursenew.Code   = txtCourseCode.Text;
                coursenew.Credit = int.Parse(txtCourseCredit.Text);
                coursenew.Quota  = int.Parse(txtCourseQuota.Text);


                db.SaveChanges();
                LoadCourses();
                MessageBox.Show("Güncellendi.");
            }
            else
            {
                MessageBox.Show("güncellemek için ders seçmelisin!");
            }
        }
示例#6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Course course = new Course();

            course.Code   = txtCourseCode.Text;
            course.Credit = int.Parse(txtCourseCredit.Text);
            course.Quota  = int.Parse(txtCourseQuota.Text);


            DatabaseDB db = new DatabaseDB();

            db.Courses.Add(course);
            db.SaveChanges();

            MessageBox.Show("Ders Kaydedildi.");


            txtCourseCode.Text   = "";
            txtCourseCredit.Text = "";
            txtCourseQuota.Text  = "";

            LoadCourses();
        }