//Boton para realizar la accion de eliminar un Servicio extra. private void btnEliminarServicio_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(txtIdServicio.Text)) { MessageBox.Show("Debe seleccionar un campo de las tablas."); } else { sc = new ServicioExtraCollection(); sc.EliminaServicioExtraC(int.Parse(txtIdServicio.Text)); txtIdServicio.Text = string.Empty; txt1.Text = string.Empty; txt2.Text = string.Empty; lblmensaje.Content = "Eliminado!"; Limpiar(); datosServicio(); } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error, contacte al administrador: " + ex.Message, "Excepción detectada", MessageBoxButton.OK, MessageBoxImage.Warning); } }
//Metodo para mostrar los datos de Servicio extra. private void datosServicio() { sc = new ServicioExtraCollection(); dtgServicios.ItemsSource = sc.ListaServicioExtraC().DefaultView; dtgServicios.Items.Refresh(); }
//Metodo para guardar Tour en la Id de Servicio extra. private void CargaIdServicio() { ServicioExtraCollection sc = new ServicioExtraCollection(); var servicio = sc.ListaServicioExtraC(); cbxIdServicioTour.ItemsSource = servicio.DefaultView; cbxIdServicioTour.SelectedValuePath = "CÓDIGO"; cbxIdServicioTour.DisplayMemberPath = "CÓDIGO"; cbxIdServicioTour.Items.Refresh(); }
//Boton para realizar la accion de actualizar datos de Servicio extra. private void btnActualizarServicio_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(txtIdServicio.Text)) { MessageBox.Show("Debe seleccionar un campo de las tablas."); } else if (Regex.IsMatch(txtIdServicio.Text, "^[a-zA-Z]")) { MessageBox.Show("Código del servicio debe ser numérico."); } else if (string.IsNullOrEmpty(txt1.Text) || txt1.Text.Length < 5 && txt1.Text.Length > 200) { MessageBox.Show("Descripción no debe estar vacío y tiene que estar entre 5 a 200 carácteres."); } else if (Regex.IsMatch(txt2.Text, "^[a-zA-Z]")) { MessageBox.Show("Costo debe ser numérico."); } else if (string.IsNullOrEmpty(txt2.Text) || int.Parse(txt2.Text) <= 0 && int.Parse(txt2.Text) >= 999999) { MessageBox.Show("Costo no debe estar vacío y debe ser mayor a 0 o menor a 999.999"); } else { sc = new ServicioExtraCollection(); sc.ActualizaServicioExtraC(int.Parse(txtIdServicio.Text), txt1.Text, int.Parse(txt2.Text)); lblmensaje.Content = "Actualización correcta!"; Limpiar(); datosServicio(); } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error, contacte al administrador: " + ex.Message, "Excepción detectada", MessageBoxButton.OK, MessageBoxImage.Warning); } }
//Boton para realizar la accion de ingresar datos de Servicio extra. private void BtnRegistrarServicioExtra_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrEmpty(txtDescripcionServicio.Text) || txtDescripcionServicio.Text.Length < 5 && txtDescripcionServicio.Text.Length > 200) { MessageBox.Show("Descripción no debe estar vacío y tiene que estar entre 5 a 200 carácteres."); } else if (Regex.IsMatch(txtCostoServicio.Text, "^[a-zA-Z]")) { MessageBox.Show("Costo debe ser numérico."); } else if (string.IsNullOrEmpty(txtCostoServicio.Text) || int.Parse(txtCostoServicio.Text) <= 0 && int.Parse(txtCostoServicio.Text) >= 999999) { MessageBox.Show("Costo no debe estar vacío y debe ser mayor a 0 o menor a 999.999"); } else { sc = new ServicioExtraCollection(); string descripcion = txtDescripcionServicio.Text; int costo = int.Parse(txtCostoServicio.Text); var insercion = sc.InsertaServicioExtraC(descripcion, costo); if (insercion == true) { this.Close(); } else { lblmensaje.Content = "Error de inserción."; } } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error, contacte al administrador: " + ex.Message, "Excepción detectada", MessageBoxButton.OK, MessageBoxImage.Warning); } }