예제 #1
0
 private void listViewGroup_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewGroup.SelectedItems.Count == 1)
     {
         GroupsSet groupset = listViewGroup.SelectedItems[0].Tag as GroupsSet;
         textBoxGroup.Text = groupset.Name;
     }
     else
     {
         textBoxGroup.Text = "";
     }
 }
예제 #2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewGroup.SelectedItems.Count == 1)
         {
             GroupsSet groupset = listViewGroup.SelectedItems[0].Tag as GroupsSet;
             Program.EduDb.GroupsSet.Remove(groupset);
             Program.EduDb.SaveChanges();
             ShowGroups();
         }
         textBoxGroup.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         GroupsSet groupset = new GroupsSet();
         if (textBoxGroup.Text != "")
         {
             groupset.Name = textBoxGroup.Text;
         }
         Program.EduDb.GroupsSet.Add(groupset);
         Program.EduDb.SaveChanges();
     }
     catch
     {
         { MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); }
     }
     ShowGroups();
 }
예제 #4
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (textBoxGroup.Text != "")
     {
         if (listViewGroup.SelectedItems.Count == 1)
         {
             GroupsSet groupset = listViewGroup.SelectedItems[0].Tag as GroupsSet;
             if (textBoxGroup.Text != "")
             {
                 groupset.Name = textBoxGroup.Text;
             }
             Program.EduDb.SaveChanges();
             ShowGroups();
         }
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }