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

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