private void btnEliminar_Click(object sender, RoutedEventArgs e) { Empleados em = ((Button)sender).DataContext as Empleados; MessageBoxResult result = MessageBox.Show("Estas seguro que quieres eliminar al empleado " + em.Nombre + " "+ em.Apellido + " " + em.Apellido2 + ".", "Eliminar", MessageBoxButton.OKCancel, MessageBoxImage.Question); if (result == MessageBoxResult.OK) { TDAService.TDAServiceClient tda = new TDAService.TDAServiceClient(); em = tda.BuscarEmpleadoID(em.ID).First(); Resultado r = tda.DeleteEmpleado(em); if (r.ErrorDB) { MessageBox.Show("No se pudo eliminar el estado " + em.Nombre + "."); } realizarBusqueda(new Empleados()); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Llenado.cargarCBPais(new Paises(), cbPais); Llenado.cargarCBEstado(new Estados(), cbEstado); Llenado.cargarCBBaseSalario(cbBaseSalario); if (lID == 0) { btnRegistrar.Visibility = Visibility.Visible; Llenado.seleccionarDefaultPais(cbPais); } else if (lID != 0) { btnModificar.Visibility = Visibility.Visible; TDAService.TDAServiceClient tda = new TDAService.TDAServiceClient(); var resultado = tda.BuscarEmpleadoID(lID); tda.Close(); foreach (var r in resultado) { txtApellidoPaterno.Text = r.Apellido; txtApellidoMaterno.Text = r.Apellido2; txtNombre.Text = r.Nombre; if (r.RFC != null) { txtRFC.Text = r.RFC; } if (r.CURP != null) { txtCURP.Text = r.CURP; } if (r.NSS != null) { txtNSS.Text = r.NSS; } Llenado.seleccionarComboBoxUid(r.BaseSalario.ToString(), cbBaseSalario); txtSalario.Text = r.Salario.ToString(); Llenado.seleccionarComboBoxUid(r.Pais.ToString(), cbPais); Llenado.seleccionarComboBoxUid(r.Estado.ToString(), cbEstado); txtCiudad.Text = r.Ciudad; if (r.Localidad != null) { txtLocalidad.Text = r.Localidad; } txtCalle.Text = r.Calle; if (r.NumeroExterior != null) { txtNumeroExterior.Text = r.NumeroExterior; } if (r.NumeroInterior != null) { txtNumeroInterior.Text = r.NumeroInterior; } if (r.Colonia != null) { txtColonia.Text = r.Colonia; } txtCP.Text = r.CP.ToString(); txtTelefono.Text = r.Telefono; if (r.Email != null) { txtEmail.Text = r.Email; } } } }