Esempio n. 1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(textBoxSurName.Text) ||
         String.IsNullOrEmpty(textBoxName.Text) ||
         String.IsNullOrEmpty(textBoxLastName.Text) ||
         String.IsNullOrEmpty(textBoxAdress.Text) ||
         comboBoxSex.SelectedItem == null &&
         comboBoxAgent.SelectedItem == null)
     {
         MessageBox.Show("Введите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         PersonSet person = new PersonSet();
         person.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
         person.Name     = textBoxName.Text;
         person.Surname  = textBoxSurName.Text;
         person.LastName = textBoxLastName.Text;
         person.Adress   = textBoxAdress.Text;
         person.Sex      = comboBoxSex.SelectedItem.ToString();
         Program.Edb.PersonSet.Add(person);
         Program.Edb.SaveChanges();
         ShowPerson();
     }
 }
Esempio n. 2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewPerson.SelectedItems.Count == 1)
     {
         PersonSet person = listViewPerson.SelectedItems[0].Tag as PersonSet;
         person.Surname  = textBoxSurName.Text;
         person.Name     = textBoxName.Text;
         person.LastName = textBoxLastName.Text;
         person.Adress   = textBoxAdress.Text;
         person.Sex      = comboBoxSex.SelectedItem.ToString();
         person.IdAgent  = Convert.ToInt32(comboBoxAgent.SelectedItem.ToString().Split('.')[0]);
         Program.Edb.SaveChanges();
         ShowPerson();
     }
 }
Esempio n. 3
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewPerson.SelectedItems.Count == 1)
         {
             PersonSet person = listViewPerson.SelectedItems[0].Tag as PersonSet;
             Program.Edb.PersonSet.Remove(person);
             Program.Edb.SaveChanges();
             ShowPerson();
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта кнопка используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }