コード例 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Student student = new Student();

            student.ID        = Int32.Parse(txtStudentID.Text);
            student.Name      = txtStudentName.Text;
            student.Surname   = txtStudentSurname.Text;
            student.BirthDate = dtpBirthDate.SelectedDate.Value;


            CetDB db = new CetDB();

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


            MessageBox.Show("Öğrenci Kaydedildi.");
            lblStudentId.Content      = "";
            txtStudentName.Text       = "";
            txtStudentSurname.Text    = "";
            dtpBirthDate.SelectedDate = DateTime.Now;
            LoadStudents();
        }
コード例 #2
0
        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çmelisiniz!");
            }
        }
コード例 #3
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!");
            }
        }
コード例 #4
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çmelisiniz!");
            }
        }
コード例 #5
0
        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.Quota  = Int32.Parse(txtCourseQuota.Text);
                coursenew.Credit = Int32.Parse(txtCourseCredit.Text);
                db.SaveChanges();
                LoadCourses();
                MessageBox.Show("Ders güncellendi!");
            }
            else
            {
                MessageBox.Show("Güncellemek için ders seçmelisiniz!");
            }
        }
コード例 #6
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            Course course = new Course();

            course.CName  = txtCourseName.Text;
            course.Code   = Int32.Parse(txtCourseCode.Text);
            course.Credit = Int32.Parse(txtCourseCredit.Text);
            course.Quota  = Int32.Parse(txtCourseQuota.Text);



            CetDB db = new CetDB();

            db.Courses.Add(course);

            db.SaveChanges();
            MessageBox.Show("Ders kaydedildi!");
            txtCourseName.Text   = "";
            txtCourseCode.Text   = "";
            txtCourseQuota.Text  = "";
            txtCourseCredit.Text = "";
            LoadCourses();
        }