private void btnDelete_Click(object sender, EventArgs e)
        {
            int Id = Convert.ToInt32(txtID.Text);
            //string FullName = "";
            //string fName = "";
            //if (cmboxInstructor.SelectedItem != null)
            //{
            //    FullName = cmboxInstructor.SelectedItem.ToString();
            //    int pos = FullName.IndexOf(" ");
            //    fName = FullName.Substring(0, pos);
            //}
            //Instructor instructor = (from obj in db.Instructors
            //                         where obj.fName == fName
            //                         select obj).Distinct().FirstOrDefault();
            //string crsName = cmboxCourse.SelectedItem.ToString();
            //Course crs = (from obj in db.Courses
            //              where obj.crsName == crsName
            //              select obj).Distinct().FirstOrDefault();
            instCourse instCourse = (from obj in db.instCourses
                                     where obj.ID == Id
                                     select obj).FirstOrDefault();

            db.instCourses.Remove(instCourse);
            db.SaveChanges();
            txtID.Text = cmboxCourse.Text = cmboxInstructor.Text = string.Empty;
            cmboxInstructor.Items.Clear();
            cmboxCourse.Items.Clear();
            cmboxCourseSearch.Items.Clear();
            fillDataGridView();
            fillComboboxCrs();
            fillComboboxInst();
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string FullName = "";
            string fName    = "";
            string lName    = "";

            if (cmboxInstructor.SelectedItem != null)
            {
                FullName = cmboxInstructor.SelectedItem.ToString();
                int pos = FullName.IndexOf(" ");
                fName = FullName.Substring(0, pos);
                lName = FullName.Substring(pos + 1);
            }
            var instructor = (from obj in db.Instructors
                              where obj.fName == fName && obj.lName == lName
                              select new {
                obj.instID
            }).FirstOrDefault();
            string crsName = cmboxCourse.SelectedItem.ToString();
            Course crs     = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();
            instCourse instCourse = new instCourse();

            instCourse.crsID      = crs.crsID;
            instCourse.instID     = instructor.instID;
            instCourse.insCrsCode = 1000;
            db.instCourses.Add(instCourse);
            db.SaveChanges();
            cmboxCourse.Text = cmboxInstructor.Text = string.Empty;
            cmboxInstructor.Items.Clear();
            cmboxCourse.Items.Clear();
            cmboxCourseSearch.Items.Clear();
            fillComboboxCrs();
            fillComboboxInst();
            fillDataGridView();
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int    Id       = Convert.ToInt32(txtID.Text);
            string FullName = "";
            string fName    = "";
            string lName    = "";

            if (cmboxInstructor.SelectedItem != null)
            {
                FullName = cmboxInstructor.SelectedItem.ToString();
                int pos = FullName.IndexOf(" ");
                fName = FullName.Substring(0, pos);
                lName = FullName.Substring(pos + 1);
            }
            Instructor instructor = (from obj in db.Instructors
                                     where obj.fName == fName && obj.lName == lName
                                     select obj).Distinct().FirstOrDefault();
            string crsName = cmboxCourse.SelectedItem.ToString();
            Course crs     = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();
            instCourse instCourse = (from obj in db.instCourses
                                     where obj.ID == Id
                                     select obj).FirstOrDefault();

            instCourse.crsID      = Convert.ToInt32(crs.crsID);
            instCourse.instID     = Convert.ToInt32(instructor.instID);
            instCourse.insCrsCode = 1000;
            db.SaveChanges();
            txtID.Text = cmboxCourse.Text = cmboxInstructor.Text = string.Empty;
            cmboxInstructor.Items.Clear();
            cmboxCourse.Items.Clear();
            cmboxCourseSearch.Items.Clear();
            fillDataGridView();
            fillComboboxCrs();
            fillComboboxInst();
        }