Exemplo n.º 1
0
        //--- Display instructor coursrs in list
        private void listBox11_SelectedIndexChanged(object sender, EventArgs e)
        {
            Courses.Items.Clear();
            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();

            label7.Text = "of" + " " + insName;
            //--get courses of same instructor
            var items = ent.get_instructor_course(insId);

            foreach (var i in items)
            {
                Courses.Items.Add(i);
            }
        }
Exemplo n.º 2
0
        //add instructor to choosen course
        private void button5_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 = comboBox3.Text.ToString();
                    var    insId   = (int)(ent.Get_insid_by_inname(insName)).First();

                    //--add instractor to course
                    ent.Add_Course_instractor(crsId, insId);

                    MessageBox.Show("Added 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");
            }
        }