private void btnAdd_Click(object sender, EventArgs e) { if (comboBoxCourses.SelectedItem == null) { MessageBox.Show("Alegeti cursul pe care doriti sa il adaugati profesorului.", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (comboBoxSet.SelectedItem == null) { MessageBox.Show("Alegeti seria la care doriti sa adaugati cursul.", "Atentie", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { DataGridViewRow row = gridTeachers.SelectedRows[0]; BLAdmin bl = new BLAdmin(); bl.AddTeacherCourse(Convert.ToInt32(row.Cells["TeacherId"].Value), Convert.ToInt32(comboBoxCourses.SelectedValue), comboBoxSet.GetItemText(comboBoxSet.SelectedItem)); MessageBox.Show("Cursul a fost adaugat cu succes!", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Information); gridCourses.DataSource = bl.GetCourses(Convert.ToInt32(row.Cells["TeacherId"].Value)); DataTable tableCourses = bl.GetListOfCourses(Convert.ToInt32(row.Cells["TeacherId"].Value)); comboBoxCourses.ValueMember = "CourseId"; comboBoxCourses.DisplayMember = "CourseName"; comboBoxCourses.DataSource = tableCourses; comboBoxCourses.SelectedItem = null; comboBoxSet.SelectedItem = null; lblCourse.Visible = true; lblSet.Visible = true; } }