private void btnActualizar_Click(object sender, RoutedEventArgs e) { try { producto = productoService.getProductoConID(productoID); if (producto.GetType().Equals(typeof(VideoJuegos))) { VideoJuegos v = (VideoJuegos)producto; v.titulo = ValidationUtil.NullOrEmpty(titulo.Text); v.anadirCopias(cantidadAnadir); if (btnPC.IsChecked == true) { v.plataforma = Plataforma.PC; } else if (btnXbox.IsChecked == true) { v.plataforma = Plataforma.Xbox; } else if (btnPS2.IsChecked == true) { v.plataforma = Plataforma.PS2; } else if (btnPS3.IsChecked == true) { v.plataforma = Plataforma.PS3; } else if (btnWii.IsChecked == true) { v.plataforma = Plataforma.Wii; } else { throw new Exception("Plataforma debe ser PC, Xbox, PS2, PS3 or Wii."); } productoService.actualizarVideoJuegos(v, v.productCodigo); } else { Pelicula pe = (Pelicula)producto; pe.titulo = ValidationUtil.NullOrEmpty(titulo.Text); pe.anadirCopias(cantidadAnadir); pe.duracion = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(duracion.Text)); pe.anoProduccion = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoProduccion.Text))); pe.anoCompra = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoCompra.Text))); productoService.actualizarPelicula(pe, pe.productCodigo); } mostrarInfo(productoService.getProductoConID(productoID)); } catch (Exception err) { MessageBox.Show(err.Message); } }
private void btnAnadir_Click(object sender, RoutedEventArgs e) { try { Cliente cliente = new Cliente(); cliente.nombre = ValidationUtil.NullOrEmpty(nombre.Text); cliente.apellidos = ValidationUtil.NullOrEmpty(apellidos.Text); cliente.direccion = ValidationUtil.NullOrEmpty(direccion.Text); cliente.nif = ValidationUtil.NIF(nif.Text); cliente.telefono = ValidationUtil.Telefono(telefono.Text); cliente.email = ValidationUtil.Email(email.Text); string tempDate = ValidationUtil.NullOrEmpty(fechaDeAlta.SelectedDate.ToString()); cliente.fechaDeAlta = DateTime.Parse(tempDate); cliente.estado = ClienteEstado.Activo; cliente.VIP = false; id.Text = clienteService.anadirCliente(cliente).ToString(); mostrarInfo(clienteService.getClienteConID(Int32.Parse(id.Text))); } catch (Exception err) { MessageBox.Show(err.Message); } }
private void btnAnadir_Click(object sender, RoutedEventArgs e) { try { int tiempo = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(tiempoDeAlquiler.Text)); string tempDate = ValidationUtil.NullOrEmpty(fechaDeAlquiler.SelectedDate.ToString()); DateTime fecha = DateTime.Parse(tempDate); alquilerId.Text = alquilerService.anadirAlquiler(productoID, clienteID, fecha, tiempo).ToString(); mostrarInfo(alquilerService.mostrarAlquilerConID(Int32.Parse(alquilerId.Text))); } catch (Exception err) { MessageBox.Show(err.Message); } }
private void btnActualizar_Click(object sender, RoutedEventArgs e) { try { cliente = clienteService.getClienteConID(clienteID); cliente.nombre = ValidationUtil.NullOrEmpty(nombre.Text); cliente.apellidos = ValidationUtil.NullOrEmpty(apellidos.Text); cliente.direccion = ValidationUtil.NullOrEmpty(direccion.Text); cliente.nif = ValidationUtil.NIF(nif.Text); cliente.telefono = ValidationUtil.Telefono(telefono.Text); cliente.email = ValidationUtil.Email(email.Text); clienteService.actualizarCliente(cliente, clienteID); mostrarInfo(clienteService.getClienteConID(clienteID)); } catch (Exception err) { MessageBox.Show(err.Message); } }
private void btnAnadir_Click(object sender, RoutedEventArgs e) { try { if (btnPelicula.IsSelected == true) { Pelicula pe = new Pelicula(); pe.tipo = Tipo.Pelicula; pe.titulo = ValidationUtil.NullOrEmpty(titulo.Text); pe.noDeCopias = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(noDeCopias.Text)); pe.duracion = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(duracion.Text)); pe.anoProduccion = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoProduccion.Text))); pe.anoCompra = ValidationUtil.Ano(ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(anoCompra.Text))); id.Text = productoService.anadirPelicula(pe).ToString(); } else if (btnVideoJuegos.IsSelected == true) { VideoJuegos v = new VideoJuegos(); v.tipo = Tipo.VideoJuegos; v.titulo = ValidationUtil.NullOrEmpty(titulo.Text); v.noDeCopias = ValidationUtil.NumeroInteger(ValidationUtil.NullOrEmpty(noDeCopias.Text)); if (btnPC.IsChecked == true) { v.plataforma = Plataforma.PC; } else if (btnXbox.IsChecked == true) { v.plataforma = Plataforma.Xbox; } else if (btnPS2.IsChecked == true) { v.plataforma = Plataforma.PS2; } else if (btnPS3.IsChecked == true) { v.plataforma = Plataforma.PS3; } else if (btnWii.IsChecked == true) { v.plataforma = Plataforma.Wii; } else { throw new Exception("Plataforma debe ser PC, Xbox, PS2, PS3 or Wii."); } id.Text = productoService.anadirVideoJuegos(v).ToString(); } else { throw new Exception("Eligir un tipo de el producto."); } mostrarInfo(productoService.getProductoConID(Int32.Parse(id.Text))); } catch (Exception err) { MessageBox.Show(err.Message); } }