private void lvContractors_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            foreach (CheckBox c in lbSkills.Items)
            {
                c.IsChecked = false;
            }


            Contractor con = (Contractor)lvContractors.SelectedItem;

            if (lvContractors.SelectedItem == null)
            {
                foreach (CheckBox c in lbSkills.Items)
                {
                    c.IsChecked = false;
                }
            }
            else if (lvContractors.SelectedItem != null)
            {
                SkillCollection skills = new SkillCollection(con);
                //int i = 0;
                foreach (Skill s in skills)
                {
                    foreach (CheckBox c in lbSkills.Items)
                    {
                        if (c.Content.ToString() == s.SkillTitle.ToString())
                        {
                            c.IsChecked = true;
                        }
                        // if (c.Content.ToString() != s.SkillTitle.ToString())
                        //{ c.IsChecked = false; }
                    }
                }
            }
            else
            {
                foreach (CheckBox c in lbSkills.Items)
                {
                    c.IsChecked = false;
                }
            };
        }
        private void btnContractorUpdate_Click(object sender, RoutedEventArgs e)
        {
            Contractor newCon = (Contractor)lvContractors.SelectedItem;

            if (!IsValidEmail(txtContractorEmail.Text))
            {
                MessageBox.Show("Please enter a valid email address.");
                return;
            }
            if (txtContractorFName.Text == "" || txtContractorLName.Text == "" || txtContractorPhone.Text == "" || txtContractorEmail.Text == "" || txtContractorUnit.Text == "" || txtContractorStreet.Text == "" || txtContractorSuburb.Text == "" || txtContractorPostcode.Text == "" || txtContractorState.Text == "" || txtBxUsername.Text == "" || txtBxPassword.Text == "")
            {
                var result = MessageBox.Show("Is this correct? Do you want to proceed with the update?", "You have some empty fields.", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    newCon.EmployeeFName            = txtContractorFName.Text;
                    newCon.EmployeeLName            = txtContractorLName.Text;
                    newCon.EmployeePhone            = txtContractorPhone.Text;
                    newCon.EmployeeEmail            = txtContractorEmail.Text;
                    newCon.EmployeeLocationUnit     = txtContractorUnit.Text;
                    newCon.EmployeeLocationStreet   = txtContractorStreet.Text;
                    newCon.EmployeeLocationSuburb   = txtContractorSuburb.Text;
                    newCon.EmployeeLocationPostcode = txtContractorPostcode.Text;
                    newCon.EmployeeLocationState    = txtContractorState.Text;
                    newCon.EmployeeUsername         = txtBxUsername.Text;
                    newCon.EmployeePassword         = txtBxPassword.Text;
                    newCon.Status = 1;
                    foreach (CheckBox c in lbSkills.Items)
                    {
                        if (c.IsChecked == true)
                        {
                            newCon.SkillID.Add(Convert.ToInt32(c.Tag));
                        }
                    }
                    newCon.UpdateContractor();
                    ShowData();
                }
            }
        }
 private void btnContractorAdd_Click(object sender, RoutedEventArgs e)
 {
     if (txtContractorFName.Text == "" || txtContractorLName.Text == "" || txtContractorPhone.Text == "" || txtContractorEmail.Text == "" || txtContractorUnit.Text == "" || txtContractorStreet.Text == "" || txtContractorSuburb.Text == "" || txtContractorPostcode.Text == "" || txtContractorState.Text == "" || txtBxUsername.Text == "" || txtBxPassword.Text == "")
     {
         MessageBox.Show("Please fill in all fields before adding a contractor.");
         return;
     }
     if (!IsValidEmail(txtContractorEmail.Text))
     {
         MessageBox.Show("Please enter a valid email address.");
         return;
     }
     else
     {
         Contractor newCon = new Contractor();
         newCon.EmployeeFName            = txtContractorFName.Text;
         newCon.EmployeeLName            = txtContractorLName.Text;
         newCon.EmployeePhone            = txtContractorPhone.Text;
         newCon.EmployeeEmail            = txtContractorEmail.Text;
         newCon.EmployeeLocationUnit     = txtContractorUnit.Text;
         newCon.EmployeeLocationStreet   = txtContractorStreet.Text;
         newCon.EmployeeLocationSuburb   = txtContractorSuburb.Text;
         newCon.EmployeeLocationPostcode = txtContractorPostcode.Text;
         newCon.EmployeeLocationState    = txtContractorState.Text;
         newCon.EmployeeUsername         = txtBxUsername.Text;
         newCon.EmployeePassword         = txtBxPassword.Text;
         newCon.Status = 1;
         foreach (CheckBox c in lbSkills.Items)
         {
             if (c.IsChecked == true)
             {
                 newCon.SkillID.Add(Convert.ToInt32(c.Tag));
             }
         }
         newCon.AddContractor();
         ShowData();
     }
 }