private void btnGuardar3_Click(object sender, RoutedEventArgs e) { if (txbNombreServicio.Text != "" && txbDescripcion.Text != "") { if (!int.TryParse(txbNombreServicio.Text, out x) && !int.TryParse(txbDescripcion.Text, out x)) { if (accionOtro == accion.Nuevo) { OtrosServicios pro = new OtrosServicios() { NombreServicio = txbNombreServicio.Text, Descripcion = txbDescripcion.Text, FotografiaServicio = ImageToByte(imgFotoServicio.Source), }; if (manejadorOtroServicio.Agregar(pro)) { MessageBox.Show("El servicio fue agregado correctamente", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Information); ActualizarTabla(); HabilitarBotonesOtrosServicios(true); HabilitarCajasOtrosServicios(false); } else { MessageBox.Show("El servicio no se pudo agregar", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Error); } } else { OtrosServicios pro = dtgOtrosServicios.SelectedItem as OtrosServicios; pro.NombreServicio = txbNombreServicio.Text; pro.Descripcion = txbDescripcion.Text; if (manejadorOtroServicio.Modificar(pro)) { MessageBox.Show("Servicio modificado correctamente", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Information); ActualizarTabla(); HabilitarBotonesOtrosServicios(true); HabilitarCajasOtrosServicios(false); } else { MessageBox.Show("El servicio no se pudo actualizar", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Error); } } } else { MessageBox.Show("El campo del Nombre del servicio o la descripcion no acptan ese tipo de caracteres", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Aun le faltan Campos por rellenar", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnEditar3_Click(object sender, RoutedEventArgs e) { OtrosServicios pro = dtgOtrosServicios.SelectedItem as OtrosServicios; if (pro != null) { HabilitarCajasOtrosServicios(true); txbNombreServicio.Text = pro.NombreServicio; txbDescripcion.Text = pro.Descripcion; imgFotoServicio.Source = ByteToImage(pro.FotografiaServicio); accionOtro = accion.Editar; HabilitarBotonesOtrosServicios(false); } else { MessageBox.Show("Seleccione el servicio que desea editar", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Question); } }
private void btnEliminar3_Click(object sender, RoutedEventArgs e) { OtrosServicios pro = dtgOtrosServicios.SelectedItem as OtrosServicios; if (pro != null) { if (MessageBox.Show("Realmente deseas eliminar este servicio?", "Habitaciones", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { if (manejadorOtroServicio.Eliminar(pro.Id)) { MessageBox.Show("El servicion ha sido eliminado correctamente", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Information); ActualizarTabla(); } else { MessageBox.Show("El servicio no se pudo eliminar", "Habitaciones", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
public bool Modificar(OtrosServicios entidad) { return(repositorio.Update(entidad)); }
public bool Agregar(OtrosServicios entidad) { return(repositorio.Create(entidad)); }