public void getDiscipline(string login) { //запрос дисциплины по учителю string sql = String.Format("select discipline.name,discipline.id_discipline from discipline " + "join teacher on discipline.id_teacher = teacher.id_teacher " + "where teacher.famil = '{0}'; ", login); dt = mdb.selectionQuery(sql); if (dt.Rows.Count == 0) { throw new Exception("Дисциплина не найдена"); } if (dt.Rows.Count > 1) { FormAdd fa = new FormAdd("Логин", dt); fa.Text = "Выбор дисциплины"; //fa.ControlBox = false; fa.buttonOK.Click += (senderSlave, eSlave) => { discipline = dt.Rows[fa.comboBox1.SelectedIndex][0].ToString(); idDiscipline = Convert.ToInt32(dt.Rows[fa.comboBox1.SelectedIndex][1]); }; fa.FormClosed += (senderSlave, eSlave) => { discipline = dt.Rows[fa.comboBox1.SelectedIndex][0].ToString(); idDiscipline = Convert.ToInt32(dt.Rows[fa.comboBox1.SelectedIndex][1]); }; fa.ShowDialog(); } else { discipline = dt.Rows[0][0].ToString(); idDiscipline = Convert.ToInt32(dt.Rows[0][1]); } }