Beispiel #1
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewAgents.SelectedItems.Count == 1)
         {
             AgentsSet stud = listViewAgents.SelectedItems[0].Tag as AgentsSet;
             Program.Edb.AgentsSet.Remove(stud);
             Program.Edb.SaveChanges();
             ShowAg();
         }
         textBoxSurName.Text  = "";
         textBoxName.Text     = "";
         textBoxLastName.Text = "";
         textBoxEmail.Text    = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта кнопка используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(textBoxSurName.Text) ||
         String.IsNullOrEmpty(textBoxName.Text) ||
         String.IsNullOrEmpty(textBoxLastName.Text) ||
         String.IsNullOrEmpty(textBoxEmail.Text))
     {
         MessageBox.Show("Введите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         AgentsSet agents = new AgentsSet();
         agents.Name     = textBoxName.Text;
         agents.Surname  = textBoxSurName.Text;
         agents.LastName = textBoxLastName.Text;
         agents.Email    = textBoxEmail.Text;
         Program.Edb.AgentsSet.Add(agents);
         Program.Edb.SaveChanges();
         ShowAg();
     }
 }
Beispiel #3
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(textBoxSurName.Text) ||
         String.IsNullOrEmpty(textBoxName.Text) ||
         String.IsNullOrEmpty(textBoxLastName.Text) ||
         String.IsNullOrEmpty(textBoxEmail.Text))
     {
         MessageBox.Show("Введите данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         if (listViewAgents.SelectedItems.Count == 1)
         {
             AgentsSet ag = listViewAgents.SelectedItems[0].Tag as AgentsSet;
             ag.Surname  = textBoxSurName.Text;
             ag.Name     = textBoxName.Text;
             ag.LastName = textBoxLastName.Text;
             ag.Email    = textBoxEmail.Text;
             Program.Edb.SaveChanges();
             ShowAg();
         }
     }
 }