示例#1
0
 private void listViewEmployees_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewEmployees.SelectedItems.Count == 1)
     {
         EmployeeSet employeesSet = listViewEmployees.SelectedItems[0].Tag as EmployeeSet;
         textBoxFirstName.Text      = employeesSet.FirstName;
         textBoxMiddleName.Text     = employeesSet.MiddleName;
         textBoxLastName.Text       = employeesSet.LastName;
         textBoxPhone.Text          = employeesSet.Phone;
         textBoxAddress_City.Text   = employeesSet.Address_City;
         textBoxAddress_House.Text  = employeesSet.Address_House;
         textBoxAddress_Street.Text = employeesSet.Address_Street;
         textBoxAddress_Number.Text = employeesSet.Address_Number;
     }
     else
     {
         textBoxFirstName.Text      = "";
         textBoxMiddleName.Text     = "";
         textBoxLastName.Text       = "";
         textBoxPhone.Text          = "";
         textBoxAddress_City.Text   = "";
         textBoxAddress_House.Text  = "";
         textBoxAddress_Street.Text = "";
         textBoxAddress_Number.Text = "";
     }
 }
示例#2
0
 private void buttonDel_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (listViewEmployees.SelectedItems.Count == 1)
         {
             EmployeeSet employeesSet = listViewEmployees.SelectedItems[0].Tag as EmployeeSet;
             Program.master.EmployeeSet.Remove(employeesSet);
             Program.master.SaveChanges();
             ShowEmployee();
         }
         textBoxFirstName.Text      = "";
         textBoxMiddleName.Text     = "";
         textBoxLastName.Text       = "";
         textBoxPhone.Text          = "";
         textBoxAddress_City.Text   = "";
         textBoxAddress_House.Text  = "";
         textBoxAddress_Street.Text = "";
         textBoxAddress_Number.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#3
0
        private void buttonAdd_Click_1(object sender, EventArgs e)
        {
            EmployeeSet employeesSet = new EmployeeSet();

            employeesSet.FirstName      = textBoxFirstName.Text;
            employeesSet.LastName       = textBoxLastName.Text;
            employeesSet.MiddleName     = textBoxMiddleName.Text;
            employeesSet.Phone          = textBoxPhone.Text;
            employeesSet.Address_City   = textBoxAddress_City.Text;
            employeesSet.Address_House  = textBoxAddress_House.Text;
            employeesSet.Address_Street = textBoxAddress_Street.Text;
            employeesSet.Address_Number = textBoxAddress_Number.Text;
            Program.master.EmployeeSet.Add(employeesSet);
            Program.master.SaveChanges();
            ShowEmployee();
        }
示例#4
0
 private void buttonEdit_Click_1(object sender, EventArgs e)
 {
     if (listViewEmployees.SelectedItems.Count == 1)
     {
         EmployeeSet employeesSet = listViewEmployees.SelectedItems[0].Tag as EmployeeSet;
         employeesSet.FirstName      = textBoxFirstName.Text;
         employeesSet.MiddleName     = textBoxMiddleName.Text;
         employeesSet.LastName       = textBoxLastName.Text;
         employeesSet.Phone          = textBoxPhone.Text;
         employeesSet.Address_City   = textBoxAddress_City.Text;
         employeesSet.Address_House  = textBoxAddress_House.Text;
         employeesSet.Address_Street = textBoxAddress_Street.Text;
         employeesSet.Address_Number = textBoxAddress_Number.Text;
         Program.master.SaveChanges();
         ShowEmployee();
     }
 }