Esempio n. 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();
     }
 }
Esempio n. 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      = "";
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }