private void updDisc() { int idDisc = ac.getIdDisc(dataGridView.CurrentRow.Index); FormAdd fa = new FormAdd(comboBoxVariants.Text, ac.getListTeachers(), dt.Rows[dataGridView.CurrentRow.Index][0].ToString(), dt.Rows[dataGridView.CurrentRow.Index][1].ToString()); fa.Text = "Изменить"; fa.buttonOK.Click += (senderSlave, eSlave) => { //валидация if (!validate(fa.textBox1.Text)) { MessageBox.Show("Данные введены не верно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { ac.updateDiscipline(fa.textBox1.Text, fa.comboBox1.SelectedIndex, idDisc); MessageBox.Show("Обновлено", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; fa.ShowDialog(); }
private void задатьПарольToolStripMenuItem_Click(object sender, EventArgs e) { FileManager fm = new FileManager(); FormAdd fa = new FormAdd("Пароль", fm.getPasswd()); fa.Text = "Изменить пароль"; fa.buttonOK.Click += (senderSlave, eSlave) => { //валидация if (!validate(fa.textBox1.Text)) { MessageBox.Show("Данные введены не верно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { fm.setPasswd(fa.textBox1.Text); MessageBox.Show("Пароль изменён", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); }catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; fa.ShowDialog(); }
private void updPupil() { FormAdd fa = new FormAdd(comboBoxVariants.Text, dt.Rows[dataGridView.CurrentRow.Index][0].ToString(), dt.Rows[dataGridView.CurrentRow.Index][1].ToString(), dt.Rows[dataGridView.CurrentRow.Index][2].ToString()); fa.Text = "Изменить"; fa.buttonOK.Click += (senderSlave, eSlave) => { if (!validate(fa.textBox1.Text, fa.textBox2.Text, fa.textBox3.Text)) { MessageBox.Show("Данные введены не верно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { ac.updatePupil(fa.textBox1.Text, fa.textBox2.Text, fa.textBox3.Text, dataGridView.CurrentRow.Index); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } MessageBox.Show("Обновлено", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); }; fa.ShowDialog(); }
private void insPupil() { FormAdd fa = new FormAdd(comboBoxVariants.Text); fa.Text = "Добавить"; fa.buttonOK.Click += (senderSlave, eSlave) => { //валидация if (!validate(fa.textBox1.Text, fa.textBox2.Text, fa.textBox3.Text)) { MessageBox.Show("Данные введены не верно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { ac.insertPupil(fa.textBox1.Text, fa.textBox2.Text, fa.textBox3.Text, CBClass.Text, CBLetter.Text); MessageBox.Show("Добавлено", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; fa.ShowDialog(); }
private void insDisc() { FormAdd fa = new FormAdd(comboBoxVariants.Text, ac.getListTeachers()); fa.Text = "Добавить"; fa.buttonOK.Click += (senderSlave, eSlave) => { //валидация if (!validate(fa.textBox1.Text)) { MessageBox.Show("Данные введены не верно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { ac.insertDiscipline(fa.textBox1.Text, fa.comboBox1.SelectedIndex); MessageBox.Show("Добавлено", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("У одного учителя может быть только одна дисциплина\r\n" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; fa.ShowDialog(); }
private void insTeachers() { FormAdd fa = new FormAdd(comboBoxVariants.Text); fa.Text = "Добавить"; fa.buttonOK.Click += (senderSlave, eSlave) => { //валидация if (!validate(fa.textBox1.Text, fa.textBox2.Text, fa.textBox3.Text, fa.textBox4.Text)) { MessageBox.Show("Данные введены не верно", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //insert try { ac.insertTeacher(fa.textBox1.Text, fa.textBox2.Text, fa.textBox3.Text, fa.textBox4.Text); MessageBox.Show("Добавлено\r\nНе забудьте довабить дисциплину", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; fa.ShowDialog(); }
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]); } }