Esempio n. 1
0
        //delete instructor to choosen course
        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                int crsId = int.Parse(comboBox1.Text);
                using (Online_Exame ent = new Online_Exame())
                {
                    //--get instractor from combo box
                    string insName = Instructors.SelectedItem.ToString();
                    var    insId   = (int)(ent.Get_insid_by_inname(insName)).First();

                    ent.Delete_course_instractor(crsId, insId);
                    MessageBox.Show("Deleted Successfully");
                    Courses.Items.Clear();
                    Instructors.Items.Clear();
                    label7.Text = comboBox1.Text = comboBox3.Text = textBox1.Text = string.Empty;

                    ent.SaveChanges();
                }
            }
            catch (System.Data.Entity.Core.EntityCommandExecutionException)
            {
                MessageBox.Show("This instructor already exist");
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please Choose Instructor Name");
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Please Choose Instructor Name");
            }
            catch (System.FormatException)
            {
                MessageBox.Show("Please Choose Course ID");
            }
        }