예제 #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewGroup.SelectedItems.Count == 1)
     {
         GroupSet groupSet = listViewGroup.SelectedItems[0].Tag as GroupSet;
         groupSet.NameGroup = textBoxNameGroup.Text;
         groupSet.Specialty = textBoxSpecialty.Text;
         groupSet.Year      = Convert.ToInt32(textBoxYear.Text);
         Program.dean.SaveChanges();
         ShowGroup();
     }
 }
예제 #2
0
 private void listViewGroup_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewGroup.SelectedItems.Count == 1)
     {
         GroupSet groupSet = listViewGroup.SelectedItems[0].Tag as GroupSet;
         textBoxNameGroup.Text = groupSet.NameGroup;
         textBoxSpecialty.Text = groupSet.Specialty;
         textBoxYear.Text      = groupSet.Year.ToString();
     }
     else
     {
         textBoxNameGroup.Text = "";
         textBoxSpecialty.Text = "";
         textBoxYear.Text      = "";
     }
 }
예제 #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         GroupSet groupSet = new GroupSet();
         groupSet.NameGroup = textBoxNameGroup.Text;
         groupSet.Specialty = textBoxSpecialty.Text;
         groupSet.Year      = Convert.ToInt32(textBoxYear.Text);
         Program.dean.GroupSet.Add(groupSet);
         Program.dean.SaveChanges();
         ShowGroup();
     }
     catch
     {
         MessageBox.Show("Невозможно добавить, введите другие значения.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewGroup.SelectedItems.Count == 1)
         {
             GroupSet groupSet = listViewGroup.SelectedItems[0].Tag as GroupSet;
             Program.dean.GroupSet.Remove(groupSet);
             Program.dean.SaveChanges();
             ShowGroup();
         }
         textBoxNameGroup.Text = "";
         textBoxSpecialty.Text = "";
         textBoxYear.Text      = "";
     }
     //При ошибке
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }