Exemple #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int    crsID  = Convert.ToInt32(txtCrsID.Text);
            Course course = (from obj in db.Courses
                             where obj.crsID == crsID
                             select obj).Distinct().FirstOrDefault();

            db.SP_DeleteCrsById(course.crsID);
            db.SaveChanges();
            txtCrsName.Text = txtCrsDuration.Text = txtCrsID.Text = string.Empty;
            MessageBox.Show("Course Deleted !!!");
            fillDataGridView();
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //if ((int)comboBox1.SelectedValue != -1)
            //{
            // int courseID = (int)comboBox1.SelectedValue;
            string crsName = comboBox1.SelectedItem.ToString();
            Course course  = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();

            db.SP_DeleteCrsById(course.crsID);
            db.SaveChanges();
            comboBox1.SelectedIndex = 0;
            txtCourseDuration.Text  = txtCourseName.Text = string.Empty;
            MessageBox.Show("Course Deleted !!!");
            // this.ParentForm.Refresh();

            //}
        }