private void CargarCombox() { herramientaEmpleados = new HerramientaEmpleados(); repositorioDeCliente = new RepositorioDeCliente(); herramientaProductos = new HerramientaProductos(); cmbEmpleado.ItemsSource = herramientaEmpleados.Leer(); cmbCliente.ItemsSource = repositorioDeCliente.LeerCliente(); cmbProductos.ItemsSource = herramientaProductos.Leer(); }
private void ActualizarTabla() { dtgProductos.ItemsSource = null; dtgProductos.ItemsSource = herramientas.Leer(); }
private void btnAgregar_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(cmbProductos.Text)) { MessageBox.Show("No ha colocado que producto!!!", "Productos", MessageBoxButton.YesNo, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(txtCantidad.Text)) { MessageBox.Show("No ha colocado la cantidad del producto: " + cmbProductos.Text, "Productos", MessageBoxButton.YesNo, MessageBoxImage.Error); return; } if (int.Parse(txtCantidad.Text) <= 0) { MessageBox.Show("Cantidad invalida", "Venta", MessageBoxButton.OK, MessageBoxImage.Error); txtCantidad.Clear(); return; } if (N == false) { VentaVenta ventaVenta = new VentaVenta(); ProductosFarmacia a = cmbProductos.ItemsSource as ProductosFarmacia; foreach (var item in herramientaProductos.Leer()) { if (item.Nombre == cmbProductos.Text) { a = item; } } /*Aqui comienza lo modificado*/ if (int.Parse(a.Stock) < int.Parse(txtCantidad.Text)) { MessageBox.Show("No hay suficiente Stock. Almacenamiento: " + a.Stock + " De: " + txtCantidad.Text, "Venta", MessageBoxButton.OK, MessageBoxImage.Exclamation); txtCantidad.Clear(); return; } /*Aqui comienza lo modificado*/ ventaVenta.Producto = a.Nombre; ventaVenta.Precio = float.Parse(a.PrecioVenta); ventaVenta.Cantidad = int.Parse(txtCantidad.Text); ventaVenta.Total = (float.Parse(a.PrecioVenta)) * (int.Parse(txtCantidad.Text)); venta.Add(ventaVenta); ActualizarTabla(); } else { VentaVenta a = cmbProductos.ItemsSource as VentaVenta; foreach (var item in venta) { if (item.Producto == cmbProductos.Text) { a = item; } } a.Producto = cmbProductos.Text; a.Cantidad = int.Parse(txtCantidad.Text); a.Precio = (a.Precio); a.Total = ((a.Precio)) * (int.Parse(txtCantidad.Text)); ActualizarTabla(); txtCantidad.Clear(); } }