Example #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            EmployerSet employerSet = new EmployerSet();

            employerSet.FirstName  = textBoxFirstName.Text;
            employerSet.LastName   = textBoxLastName.Text;
            employerSet.MiddleName = textBoxMiddleName.Text;
            employerSet.Phone      = textBoxPhone.Text;
            employerSet.Email      = textBoxEmail.Text;
            Program.znt.EmployerSet.Add(employerSet);
            Program.znt.SaveChanges();
            ShowEmployer();
        }
Example #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewEmployer.SelectedItems.Count == 1)
     {
         EmployerSet employerSet = listViewEmployer.SelectedItems[0].Tag as EmployerSet;
         employerSet.FirstName  = textBoxFirstName.Text;
         employerSet.LastName   = textBoxLastName.Text;
         employerSet.MiddleName = textBoxMiddleName.Text;
         employerSet.Phone      = textBoxPhone.Text;
         employerSet.Email      = textBoxEmail.Text;
         Program.znt.SaveChanges();
         ShowEmployer();
     }
 }
Example #3
0
 private void listViewEmployer_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     if (listViewEmployer.SelectedItems.Count == 1)
     {
         EmployerSet employerSet = listViewEmployer.SelectedItems[0].Tag as EmployerSet;
         textBoxFirstName.Text  = employerSet.FirstName;
         textBoxLastName.Text   = employerSet.LastName;
         textBoxMiddleName.Text = employerSet.MiddleName;
         textBoxPhone.Text      = employerSet.Phone;
         textBoxEmail.Text      = employerSet.Email;
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxLastName.Text   = "";
         textBoxMiddleName.Text = "";
         textBoxPhone.Text      = "";
         textBoxEmail.Text      = "";
     }
 }
Example #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewEmployer.SelectedItems.Count == 1)
         {
             EmployerSet employerSet = listViewEmployer.SelectedItems[0].Tag as EmployerSet;
             Program.znt.EmployerSet.Remove(employerSet);
             Program.znt.SaveChanges();
             ShowEmployer();
         }
         textBoxFirstName.Text  = "";
         textBoxLastName.Text   = "";
         textBoxMiddleName.Text = "";
         textBoxPhone.Text      = "";
         textBoxEmail.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }