private void GuardarButton_Click(object sender, RoutedEventArgs e) { Contexto context = new Contexto(); if (!Validar()) { return; } if (context.juegos.Any(p => p.Descripcion == DescripcionTextBox.Text)) { MessageBox.Show("Este Juego ya existe.", "Juego existente", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show("Si profesor pense en eso, pruebe con mas cosas."); } else { var proceso = JuegosBLL.Guardar(Juego); if (proceso == true) { Refrescar(); MessageBox.Show("Guardado Correctamente.", "Complete", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Guardado Fallido", "Incompleto", MessageBoxButton.OK, MessageBoxImage.Error); } Refrescar(); } }
private void GuardarButton_Click(object sender, RoutedEventArgs e) { if (!Validar()) { return; } var ingreso = JuegosBLL.Buscar(JuegoIdComboBox.SelectedIndex + 1); if (int.Parse(CantidadTextBox.Text) < 1) { CantidadTextBox.Text = "1"; MessageBox.Show("La cantidad minima es 1", "Error de cantidad", MessageBoxButton.OK, MessageBoxImage.Error); } JuegosBLL.Entrada(ingreso, int.Parse(CantidadTextBox.Text)); var proceso = EntradasBLL.Guardar(Entrada); if (proceso == true) { Refrescar(); MessageBox.Show("Guardado Correctamente.", "Complete", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Guardado Fallido", "Incompleto", MessageBoxButton.OK, MessageBoxImage.Error); } Refrescar(); }
private static bool Insertar(Entradas Entrada) { Juegos Juego; Contexto contexto = new Contexto(); bool paso = false; try { if (contexto.Entradas.Add(Entrada) != null) { Juego = JuegosBLL.Buscar(Entrada.JuegoId); Juego.Existencia += Entrada.Existencia; JuegosBLL.Guardar(Juego); paso = (contexto.SaveChanges() > 0); } } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
public static bool Modificar(Entradas Entrada) { Contexto contexto = new Contexto(); bool paso = false; try { var anterior = EntradasBLL.Buscar(Entrada.EntradaId); var Juego = JuegosBLL.Buscar(anterior.JuegoId); int cant = anterior.Existencia; Juego.Existencia -= cant; JuegosBLL.Guardar(Juego); var Juego1 = JuegosBLL.Buscar(Entrada.JuegoId); Juego1.Existencia = Entrada.Existencia; JuegosBLL.Guardar(Juego1); contexto.Entry(Entrada).State = EntityState.Modified; paso = (contexto.SaveChanges() > 0); } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
private void AgregarFilaButton_Click(object sender, RoutedEventArgs e) { if (!ValidarJuego()) { return; } Juegos juego = JuegosBLL.Buscar(Convert.ToInt32(JuegoComboBox.SelectedIndex + 1)); if (juego != null) { PrestamosDetalle prd; Prestamo.Detalles.Add( prd = new PrestamosDetalle { PrestamoId = Prestamo.PrestamoId, JuegoId = JuegoComboBox.SelectedIndex + 1, Cantidad = Convert.ToInt32(CantidadTextBox.Text), Descripcion = juego.Descripcion } ); Prestamo.CantidadJuegos += prd.Cantidad; juego.Existencia -= prd.Cantidad; CantidadJuegosTextBox.Text = Prestamo.CantidadJuegos.ToString(); Cargar(); } }
private void AñadirButton_Click(object sender, RoutedEventArgs e) { if (int.Parse(CantidadJuegosTextBox.Text) < 1) { CantidadJuegosTextBox.Text = "1"; MessageBox.Show("La cantidad minima es 1", "Error de cantidad", MessageBoxButton.OK, MessageBoxImage.Error); } if (AmigoComboBox.Text.Length != 0 && CantidadJuegosTextBox.Text.Length != 0 && ObsevacionTextBox.Text.Length != 0 && JuegoIdComboBox.Text.Length != 0) { var remover = JuegosBLL.Buscar(JuegoIdComboBox.SelectedIndex + 1); JuegosBLL.Salida(remover, int.Parse(CantidadJuegosTextBox.Text)); if (remover.Existencias >= 0) { JuegosBLL.Guardar(remover); Prestamo.Detalles.Add(new PrestamosDetalle(Prestamo.PrestamoId, JuegoIdComboBox.SelectedIndex + 1, int.Parse(CantidadJuegosTextBox.Text), AmigoComboBox.Text, JuegoIdComboBox.Text)); Cargar(); CantidadJuegosTextBox.Text = "0"; JuegoIdComboBox.Text = string.Empty; AmigoComboBox.Text = string.Empty; } else { MessageBox.Show("Se ha agotado las existencias del juego: " + remover.Descripcion, "Sin existencias", MessageBoxButton.OK, MessageBoxImage.Information); } } }
public rEntrada() { InitializeComponent(); DataContext = Entrada; JuegoIdComboBox.ItemsSource = JuegosBLL.GetList(x => true); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "Descripcion"; }
public RegistroEntradas() { InitializeComponent(); JuegoIdComboBox.ItemsSource = JuegosBLL.GetList(); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "Descripcion"; Entrada = new Entradas(); this.DataContext = Entrada; }
public rEntradaJuegos() { InitializeComponent(); this.DataContext = entradaJuegos; JuegoIdComboBox.ItemsSource = JuegosBLL.GetJuegos(); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "Descripcion"; }
//——————————————————————————————————————————————————————————————[ Guardar ]——————————————————————————————————————————————————————————————— private void GuardarButton_Click(object sender, RoutedEventArgs e) { { if (!Validar()) { return; } //———————————————————————————————————————————————————————[ VALIDAR SI ESTA VACIO ]——————————————————————————————————————————————————————— //—————————————————————————————————[ EntradaJuego Id ]————————————————————————————————— if (EntradaJuegoIdTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (EntradaJuego Id) está vacío.\n\nDebe asignar un Id a la Entrada del Juego.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); EntradaJuegoIdTextBox.Text = "0"; EntradaJuegoIdTextBox.Focus(); EntradaJuegoIdTextBox.SelectAll(); return; } //—————————————————————————————————[ Juego Id ]————————————————————————————————— if (JuegoIdComboBox.Text == string.Empty) { MessageBox.Show("El Campo (Juego Id) está vacío.\n\nAsigne un Id al Juego.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); JuegoIdComboBox.IsDropDownOpen = true; return; } //—————————————————————————————————[ Fecha ]————————————————————————————————— if (FechaDatePicker.Text.Trim() == string.Empty) { MessageBox.Show($"El Campo (Fecha) está vacío.\n\nSeleccione una fecha para la Salida del Juego.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); FechaDatePicker.Focus(); return; } //—————————————————————————————————[ Cantidad ]————————————————————————————————— if (CantidadTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Cantidad) está vacío.\n\nEscriba la cantidad de Juegos.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); CantidadTextBox.Text = "0"; CantidadTextBox.Focus(); CantidadTextBox.SelectAll(); return; } //———————————————————————————————————————————————————————[ VALIDAR SI ESTA VACIO - FIN ]——————————————————————————————————————————————————————— JuegosBLL.SumarJuegos(Convert.ToInt32(JuegoIdComboBox.SelectedValue), Convert.ToDouble(CantidadTextBox.Text)); //suma la existencia var paso = EntradasJuegosBLL.Guardar(entradasJuegos); if (paso) { Limpiar(); MessageBox.Show("Transacción Exitosa", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Transacción Fallida", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void GuardarButton_Click(object sender, RoutedEventArgs e) { if (!Validar()) { return; } if (EntradaIdTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Entrada Id) está vacío.\n\nDebe asignar un Id a la Entrada del Juego.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); EntradaIdTextBox.Text = "0"; EntradaIdTextBox.Focus(); EntradaIdTextBox.SelectAll(); return; } if (JuegoIdComboBox.Text == string.Empty) { MessageBox.Show("El Campo (Juego Id) está vacío.\n\nPorfavor, Seleccione El Nombre del juego.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); JuegoIdComboBox.IsDropDownOpen = true; return; } if (FechaDatePicker.Text.Trim() == string.Empty) { MessageBox.Show($"El Campo (Fecha) está vacío.\n\nSeleccione una fecha para la Entrada del Juego.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); FechaDatePicker.Focus(); return; } if (CantidadTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Cantidad) está vacío.\n\nEscriba la cantidad de Juegos.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); CantidadTextBox.Text = "0"; CantidadTextBox.Focus(); CantidadTextBox.SelectAll(); return; } JuegosBLL.EntradaJuegos(Convert.ToInt32(JuegoIdComboBox.SelectedValue), Convert.ToInt32(CantidadTextBox.Text)); //----------------- var paso = EntradasJuegosBLL.Guardar(entradaJuegos); if (paso) { Limpiar(); MessageBox.Show("Transacción Exitosa", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Transacción Fallida", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public rEntradas() { InitializeComponent(); this.DataContext = entrada; EntradaIdTextBox.Text = "0"; this.entrada.EntradaId = 1; entrada.Fecha = DateTime.Now; JuegoIdComboBox.ItemsSource = JuegosBLL.GetJuegos(); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "JuegoId"; }
private void JuegoIdComboBox_DropDownClosed(object sender, EventArgs e) { Juegos juego = JuegosBLL.Buscar(Convert.ToInt32(JuegoIdComboBox.SelectedValue)); if (juego == null) { return; } DescripcionLabel.Content = juego.Descripcion; }
public rPrestamos() { InitializeComponent(); DataContext = Prestamo; JuegoIdComboBox.ItemsSource = JuegosBLL.GetList(x => true); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "Descripcion"; AmigoComboBox.ItemsSource = AmigosBLL.GetList(x => true); AmigoComboBox.SelectedValuePath = "AmigoId"; AmigoComboBox.DisplayMemberPath = "Nombre"; }
private void EliminarButton_Click(object sender, RoutedEventArgs e) { if (JuegosBLL.Eliminar(Utilidades.ToInt(JuegoIdTextBox.Text))) { Limpiar(); MessageBox.Show("Registro Eliminado", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No se pudo eliminar el registro", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public registroPrestamos() { InitializeComponent(); Prestamo = new Prestamos(); AmigoComboBox.ItemsSource = AmigosBLL.GetList(); AmigoComboBox.SelectedValuePath = "AmigoId"; AmigoComboBox.DisplayMemberPath = "Nombres"; JuegoComboBox.ItemsSource = JuegosBLL.GetList(); JuegoComboBox.SelectedValuePath = "JuegoId"; JuegoComboBox.DisplayMemberPath = "Descripcion"; this.DataContext = Prestamo; }
public rPrestamos() { InitializeComponent(); this.DataContext = prestamos; JuegoIdComboBox.ItemsSource = JuegosBLL.GetJuegos(); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "Descripcion"; AmigoIdComboBox.ItemsSource = AmigosBLL.GetAmigos(); AmigoIdComboBox.SelectedValuePath = "AmigoId"; AmigoIdComboBox.DisplayMemberPath = "Nombres"; }
private void EliminarButton_Click(object sender, RoutedEventArgs e) { if (EntradasJuegosBLL.Eliminar(Utilidades.ToInt(EntradaIdTextBox.Text))) { JuegosBLL.DisminuirEntradaJuegos(Convert.ToInt32(JuegoIdComboBox.SelectedValue), Convert.ToInt32(CantidadTextBox.Text)); //----------------- Limpiar(); MessageBox.Show("Registro Eliminado", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No se pudo eliminar el registro", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void EliminarButton_Click(object sender, RoutedEventArgs e) { if (JuegosBLL.Eliminar(int.Parse(JuegoIdTextBox.Text))) { Refrescar(); MessageBox.Show("Datos Eliminados", "Completo", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No se pudo Eliminar los datos", "Incompleto", MessageBoxButton.OK, MessageBoxImage.Error); } Refrescar(); }
private void JuegoIdComboBox_DropDownClosed(object sender, EventArgs e) { Juegos juego = JuegosBLL.Buscar(Convert.ToInt32(JuegoIdComboBox.SelectedValue)); if (juego == null) { return; } prestamo.CantidadJuegos = juego.Existencia; Cantidaddisponible.Content = prestamo.CantidadJuegos.ToString(); DescripcionJuegoLabel.Content = juego.Descripcion; }
private bool ValidarJuego() { bool paso = true; int id = Convert.ToInt32(JuegoComboBox.SelectedIndex); id = id + 1; Juegos juego = JuegosBLL.Buscar(id); if (Convert.ToInt32(JuegoComboBox.SelectedIndex + 1) <= 0) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("Debe haber almenos 1 Juego elegido", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } if (CantidadTextBox.Text.Length == 0) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("Debe Elejir una cantidad Apropiada", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } if (Convert.ToInt32(CantidadTextBox.Text) > juego.Existencia) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("La cantidad que escogio es mayor a la existente", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } if (!Regex.IsMatch(CantidadTextBox.Text, @"^[0-9]+$")) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("Debe agregar una cantidad", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } return(paso); }
private void BuscarButton_Click(object sender, RoutedEventArgs e) { var jueguito = JuegosBLL.Buscar(int.Parse(JuegoIdTextBox.Text)); if (jueguito != null) { Juego = jueguito; } else { Juego = new Juegos(); } DataContext = Juego; }
public rEntradas() { InitializeComponent(); this.DataContext = entradas; var Lista = JuegosBLL.GetList(x => true); this.JuegoIdComboBox.ItemsSource = Lista; this.JuegoIdComboBox.SelectedValuePath = "JuegoId"; this.JuegoIdComboBox.DisplayMemberPath = "Descripcion"; if (Lista.Count > 0) { this.JuegoIdComboBox.SelectedIndex = 0; } }
private void EliminarButton_Click(object sender, RoutedEventArgs e) { if (JuegosBLL.Eliminar(Convert.ToInt32(JuegoIdTextBox.Text))) { Limpiar(); MessageBox.Show("Producto eliminado!", "Exito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No fue posible eliminar el producto", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ConsultarButton_Click(object sender, RoutedEventArgs e) { var listado = new List <Juegos>(); if (CriterioTextBox.Text.Trim().Length > 0) { switch (FiltroComboBox.SelectedIndex) { case 0: try { listado = JuegosBLL.GetList(e => e.JuegoId == Utilidades.ToInt(CriterioTextBox.Text)); } catch (FormatException) { MessageBox.Show("Debes ingresar un Critero valido para aplicar este filtro.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); } break; case 1: try { listado = JuegosBLL.GetList(e => e.Descripcion.Contains(CriterioTextBox.Text)); } catch (FormatException) { MessageBox.Show("Debes ingresar un Critero valido para aplicar este filtro.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); } break; } } else { listado = JuegosBLL.GetList(c => true); } if (DesdeDatePicker.SelectedDate != null) { listado = JuegosBLL.GetList(c => c.FechaCompra.Date >= DesdeDatePicker.SelectedDate); } if (HastaDatePicker.SelectedDate != null) { listado = JuegosBLL.GetList(c => c.FechaCompra.Date <= HastaDatePicker.SelectedDate); } DatosDataGrid.ItemsSource = null; DatosDataGrid.ItemsSource = listado; }
public rPrestamos() { InitializeComponent(); this.DataContext = prestamo; this.prestamo.PrestamoId = 1; prestamo.Fecha = DateTime.Now; JuegoIdComboBox.ItemsSource = JuegosBLL.GetJuegos(); JuegoIdComboBox.SelectedValuePath = "JuegoId"; JuegoIdComboBox.DisplayMemberPath = "JuegoId"; AmigoIdComboBox.ItemsSource = AmigosBLL.GetAmigos(); AmigoIdComboBox.SelectedValuePath = "AmigoId"; AmigoIdComboBox.DisplayMemberPath = "AmigoId"; }
private void EliminarButton_Click(object sender, RoutedEventArgs e) { var ingreso = JuegosBLL.Buscar(JuegoIdComboBox.SelectedIndex + 1); JuegosBLL.Salida(ingreso, int.Parse(CantidadTextBox.Text)); if (EntradasBLL.Eliminar(int.Parse(EntradaIdTextBox.Text))) { Refrescar(); MessageBox.Show("Datos Eliminados", "Completo", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No se pudo Eliminar los datos", "Incompleto", MessageBoxButton.OK, MessageBoxImage.Error); } Refrescar(); }
private void ConsultarButton_Click(object sender, RoutedEventArgs e) { var listado = new List <Juegos>(); if (CriterioTextBox.Text.Trim().Length > 0) { switch (FiltroComboBox.SelectedIndex) { case 0: listado = JuegosBLL.GetList(e => true); break; case 1: listado = JuegosBLL.GetList(e => e.JuegoId == Convert.ToInt32(CriterioTextBox.Text)); break; case 2: listado = JuegosBLL.GetList(e => e.Descripcion.Contains(CriterioTextBox.Text)); break; case 3: listado = JuegosBLL.GetList(e => e.Precio == Convert.ToDecimal(CriterioTextBox.Text)); break; case 4: listado = JuegosBLL.GetList(e => e.Existencia == Convert.ToInt32(CriterioTextBox.Text)); break; } } else { listado = JuegosBLL.GetList(c => true); } if (DesdeDataPicker.SelectedDate != null) { listado = JuegosBLL.GetList(c => c.FechaCompra.Date >= DesdeDataPicker.SelectedDate); } if (HastaDatePicker.SelectedDate != null) { listado = JuegosBLL.GetList(c => c.FechaCompra.Date <= HastaDatePicker.SelectedDate); } DatosDataGrid.ItemsSource = null; DatosDataGrid.ItemsSource = listado; }
private void EliminarButton_Click(object sender, RoutedEventArgs e) { bool paso = JuegosBLL.Eliminar(Convert.ToInt32(JuegoIdTextBox.Text)); if (paso) { Juego = new Juegos(); Limpiar(); MessageBox.Show("eliminado correctamente", "Exito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Error no se pudo Eliminar", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void BuscarButton_Click(object sender, RoutedEventArgs e) { var juego = JuegosBLL.Buscar(int.Parse(JuegoIdTextBox.Text)); if (juego != null) { this.juego = juego; } else { this.juego = new Entidades.Juegos(); MessageBox.Show("El Producto no existe", "Fallo", MessageBoxButton.OK, MessageBoxImage.Information); Limpiar(); } this.DataContext = this.juego; }