private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Prepods p = new Prepods(); p.OpenConnection(connectionString); People pe = p.GetPrepodByFIO(comboBox1.SelectedItem.ToString()); int idprep = p.GetIdByFIO(pe.name, pe.surname, pe.patronumic); p.CloseConnection(); this.label_Fio.Text = pe.surname + " " + pe.name[0] + '.' + pe.patronumic[0]; this.label_birthday.Text = pe.ConvertDate(); this.richTextBox_Info.Text = pe.information; Predmets pr = new Predmets(); pr.OpenConnection(connectionString); this.richTextBox1.Text = ""; this.richTextBox1.Text = String.Join("\n", pr.GetPredmetsByPrepodId(idprep)); pr.CloseConnection(); this.Text = comboBox1.Text; pictureBox1.Visible = true; label_Fio.Visible = true; label_birthday.Visible = true; label1.Visible = true; richTextBox_Info.Visible = true; richTextBox1.Visible = true; }
private void button1_Click(object sender, EventArgs e) { if (comboBox_Group.Text == "Выберите группу" || comboBox_Predmet.Text == "Выберите предмет") { MessageBox.Show("Выберите группу и предмет!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DateTime date = DateTime.Now; Predmets pr = new Predmets(); pr.OpenConnection(connectionString); int idprd = pr.GetIdByName(comboBox_Predmet.Text); pr.CloseConnection(); Marks m = new Marks(); int j = 1; m.OpenConnection(connectionString); foreach (var item in d) { if (this.Controls["t" + j].Text == "") { continue; } int nzach = item.Key; char mark = this.Controls["t" + j].Text[0]; m.InsertMark(nzach, id, idprd, mark, date); j++; } m.CloseConnection(); MessageBox.Show("Оценки были успешно сохранены!"); this.Close(); }
private void View_Journal_Load(object sender, EventArgs e) { Predmets pr = new Predmets(); pr.OpenConnection(connectionString); comboBox1.Items.AddRange(pr.GetPredmetsByNzach(nzach)); pr.CloseConnection(); }
public DeletePredmet() { InitializeComponent(); connectionString = ConfigurationManager.AppSettings["connectionString"]; Predmets p = new Predmets(); p.OpenConnection(connectionString); comboBox1.Items.AddRange(p.GetAllPredmets()); p.CloseConnection(); }
private void button_Add_Click(object sender, EventArgs e) { if (textBox_Name.Text == "" || comboBox_Prepods.Text == "Выберите") { MessageBox.Show("Повторите ввод!"); return; } Predmets p = new Predmets(); p.OpenConnection(connectionString); p.InsertPredmet(textBox_Name.Text, comboBox_Prepods.Text, connectionString); p.CloseConnection(); MessageBox.Show("Предмет был добавлен успешно!"); this.Close(); }
public EnterMarks(int id) { InitializeComponent(); this.id = id; connectionString = ConfigurationManager.AppSettings["connectionString"]; Predmets pr = new Predmets(); pr.OpenConnection(connectionString); comboBox_Predmet.Items.AddRange(pr.GetPredmetsByPrepodId(id)); pr.CloseConnection(); Grups g = new Grups(); g.OpenConnection(connectionString); comboBox_Group.Items.AddRange(g.GetAllGrups()); g.CloseConnection(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Grups g = new Grups(); g.OpenConnection(connectionString); int idgr = g.GetIdByNzach(nzach); g.CloseConnection(); Predmets p = new Predmets(); p.OpenConnection(connectionString); int idprd = p.GetIdByName(comboBox1.Text); p.CloseConnection(); Marks m = new Marks(); m.OpenConnection(connectionString); dataGridView1.DataSource = m.GetMarksByGroupAndPredmet(idgr, idprd); m.CloseConnection(); }
private void button_Delete_Click(object sender, EventArgs e) { if (comboBox1.Text == "Выберите предмет") { MessageBox.Show("Вы не предмет!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Predmets p = new Predmets(); int idprd = -1; try { p.OpenConnection(connectionString); idprd = p.GetIdByName(comboBox1.Text); p.DeletePredmet(comboBox1.Text); p.CloseConnection(); } catch (SqlException ex) { DialogResult result = MessageBox.Show("Невозможно удалить предмет!\nВ журнале присутствуют оценки!\nУдалить все оценки?", "Error!", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { Marks m = new Marks(); m.OpenConnection(connectionString); m.DeleteMarksByPredmetId(idprd); m.CloseConnection(); p.DeletePredmet(comboBox1.Text); MessageBox.Show("Предмет был успешно удален!"); } p.CloseConnection(); return; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } MessageBox.Show("Предмет был успешно удален!"); this.Close(); }