private void tudengToolStripMenuItem_Click(object sender, EventArgs e) { StudentT student = new StudentT(); student.MdiParent = this; student.Show(); }
private void button1_Click(object sender, EventArgs e) { if ((ComboBoxItem)comboBox1.SelectedItem != null) { if (num == 1) { int arv = WorkDB.DeleteRuhm(Convert.ToInt32(((ComboBoxItem)comboBox1.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli delete " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); RuhmT obj = (RuhmT)Application.OpenForms["RuhmT"]; obj.UpdateForm(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Delete ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (num == 2) { int arv = WorkDB.DeleteTeacher(Convert.ToInt32(((ComboBoxItem)comboBox1.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli delete " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); TeacherT obj = (TeacherT)Application.OpenForms["TeacherT"]; obj.UpdateTable(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Delete ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { int arv = WorkDB.DeleteStudent(Convert.ToInt32(((ComboBoxItem)comboBox1.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli delete " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); StudentT obj = (StudentT)Application.OpenForms["StudentT"]; obj.UpdateTable(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Delete ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Check combo box", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { if (comboBox3.SelectedItem != null) { if (num == 1) { Ruhm ruhm = new Ruhm(); ruhm.NimiRuhm = textBox1.Text; int arv = WorkDB.UpdateRuhm(ruhm, Convert.ToInt32(((ComboBoxItem)comboBox3.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli lisatud " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); RuhmT obj = (RuhmT)Application.OpenForms["RuhmT"]; obj.UpdateForm(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Lisamine ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (num == 2) { Student student = new Student(); student.Nimi = textBox1.Text; student.Isikukood = textBox3.Text; student.Kool = textBox4.Text; student.Klass = int.Parse(comboBox1.SelectedItem.ToString()); student.Telefon = textBox6.Text; student.Aadress = textBox7.Text; student.RuhmID = Convert.ToInt32(((ComboBoxItem)comboBox2.SelectedItem).HiddenValue); int arv = WorkDB.UpdateStudent(student, Convert.ToInt32(((ComboBoxItem)comboBox3.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli lisatud " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); StudentT obj = (StudentT)Application.OpenForms["StudentT"]; obj.UpdateTable(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Lisamine ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { Teacher teacher = new Teacher(); teacher.Nimi = textBox1.Text; teacher.Isikukood = textBox3.Text; teacher.Telefon = textBox6.Text; teacher.Aadress = textBox7.Text; teacher.RuhmID = Convert.ToInt32(((ComboBoxItem)comboBox2.SelectedItem).HiddenValue); int arv = WorkDB.UpdateTeacher(teacher, Convert.ToInt32(((ComboBoxItem)comboBox3.SelectedItem).HiddenValue)); if (arv != 0) { MessageBox.Show("Oli lisatud " + arv + " rida", "Valmis", MessageBoxButtons.OK, MessageBoxIcon.Information); TeacherT obj = (TeacherT)Application.OpenForms["TeacherT"]; obj.UpdateTable(); obj.dataGridView1.Update(); obj.dataGridView1.Refresh(); this.Close(); } else { MessageBox.Show("Muutmine ebaõnnestus", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Check combo box", "Viga", MessageBoxButtons.OK, MessageBoxIcon.Error); } }