Exemplo n.º 1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            EmployeeSet employeeSet = new EmployeeSet();

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