Ejemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            SubjectsSet subjectsSet = new SubjectsSet();

            subjectsSet.Name = textBoxName.Text;
            Program.school.SubjectsSet.Add(subjectsSet);
            Program.school.SaveChanges();
            ShowSubject();
        }
Ejemplo n.º 2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewSubjects.SelectedItems.Count == 1)
     {
         SubjectsSet subjectsSet = listViewSubjects.SelectedItems[0].Tag as SubjectsSet;
         subjectsSet.Name = textBoxName.Text;
         Program.school.SaveChanges();
         ShowSubject();
     }
 }
Ejemplo n.º 3
0
 private void listViewSubjects_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewSubjects.SelectedItems.Count == 1)
     {
         SubjectsSet subjectsSet = listViewSubjects.SelectedItems[0].Tag as SubjectsSet;
         textBoxName.Text = subjectsSet.Name;
     }
     else
     {
         textBoxName.Text = "";
     }
 }
Ejemplo n.º 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewSubjects.SelectedItems.Count == 1)
         {
             SubjectsSet subjectsSet = listViewSubjects.SelectedItems[0].Tag as SubjectsSet;
             Program.school.SubjectsSet.Remove(subjectsSet);
             Program.school.SaveChanges();
         }
         textBoxName.Text = "";
         ShowSubject();
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }