private void SaveDiscipline()
 {
     if (comboBoxDiscipline.Text != "")
     {
         if (DBobjects.Entities.Discipline.Where(p => p.nameDiscipline == comboBoxDiscipline.Text).Count() == 0)
         {
             discipline = new Discipline();
             discipline.nameDiscipline = comboBoxDiscipline.Text;
             DBobjects.Entities.Discipline.Add(discipline);
             DBobjects.Entities.SaveChanges();
         }
         else
         {
             discipline = DBobjects.Entities.Discipline.FirstOrDefault(p => p.nameDiscipline == comboBoxDiscipline.Text);
         }
         FinalGrade finalGrade = new FinalGrade();
         finalGrade.idDiscipline = discipline.idDiscipline;
         finalGrade.idFormContr  = DBobjects.Entities.FormOfControl.First().idFormContr;
         finalGrade.idSemestr    = DBobjects.Entities.Semestr.First().idSemestr;
         DBobjects.Entities.FinalGrade.Add(finalGrade);
         DBobjects.Entities.SaveChanges();
         comboBoxDiscipline.SelectedItem = discipline.nameDiscipline;
         fillCombobox();
         comboBoxDiscipline.SelectedIndex = comboBoxDiscipline.Items.Count - 1;
     }
 }
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     finalGrade = new FinalGrade();
     fillCombobox();
     panelFinalControl.Visible         = true;
     comboBoxDiscipline.SelectedIndex  = -1;
     comboBoxFormControl.SelectedIndex = -1;
     comboBoxSemestr.SelectedIndex     = -1;
     filltable();
 }
 private void dataGridViewDiscControl_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         finalGrade = (FinalGrade)dataGridViewDiscControl.Rows[e.RowIndex].DataBoundItem;
         fillCombobox();
         comboBoxDiscipline.SelectedItem  = finalGrade.Discipline;
         comboBoxFormControl.SelectedItem = finalGrade.FormOfControl;
         comboBoxSemestr.SelectedItem     = finalGrade.Semestr;
         filltable();
         panelFinalControl.Visible = true;
         dataGridViewMark.Visible  = true;
         buttonSaveALl.Visible     = true;
     }
 }