private void cantidad_textbox_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar)) { e.Handled = true; } if (e.KeyChar == (char)Keys.Enter) { int cantidad = 0; if (!int.TryParse(cantidad_textbox.Text, out cantidad)) { MessageBox.Show("Debe ingresar un número entero.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (ObtenerCantidadProducto(Codigo_textbox.Text) == 0) { MessageBox.Show("Error en la busqueda de la cantidad del producto seleccionado.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ObtenerCantidadProducto(Codigo_textbox.Text) < int.Parse(cantidad_textbox.Text)) { MessageBox.Show("La cantidad ingresada es mayor a la vendida.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ObtenerCantidadProducto(Codigo_textbox.Text) >= int.Parse(cantidad_textbox.Text)) { //Se hace la devolucion del producto //Obtener el precio del producto e ingresarlo, al igual ingresarlo en la base de datos Detalle detalle = new Detalle(); detalle.id_producto = Codigo_textbox.Text; detalle.id_venta = new Validaciones().LimpiarString(clave_venta_textbox.Text); detalle.cantidad = ObtenerCantidadProducto(Codigo_textbox.Text) - int.Parse(cantidad_textbox.Text); detalle.precio = productoDetalle.precio; detalle.total = productoDetalle.precio * detalle.cantidad; new DAODetalle().ModificarDetalle(detalle); List <Detalle> detalles = new List <Detalle>(); detalles = new DAODetalle().GetDetails(new Validaciones().LimpiarString(clave_venta_textbox.Text)); Ventas devolucion = new DAOVentas().GetVentaXId(clave_venta_textbox.Text); devolucion.Total = ObtenerTotalVenta(detalles); new DAOVentas().ModificarVenta(devolucion); //Se verifica si el producto es una oferta para regresar la cantidad. DTOOfertas oferta = new DAOOfertas().GetOferta(Codigo_textbox.Text); if (oferta != null) { new DAOProductos().Aumentarproductos(oferta.codigo, oferta.cantidad * int.Parse(cantidad_textbox.Text)); } else { new DAOProductos().Aumentarproductos(Codigo_textbox.Text, int.Parse(cantidad_textbox.Text)); } MessageBox.Show("Devolución realizada con éxito.", "Devolución", MessageBoxButtons.OK, MessageBoxIcon.Information); FocusTicket(); } } } }
public modificar_producto_venta_form(Usuarios usuario, PantallaVenta ProductoIngresado) { InitializeComponent(); UsuarioActual = usuario; ProductoAnalizado = ProductoIngresado; Codigo_textbox.Text = ProductoAnalizado.Codigo; producto_textBox.Text = ProductoAnalizado.Producto; cantidad_textBox.Text = ProductoAnalizado.Cantidad; total_textBox.Text = ProductoAnalizado.Precio; DTOOfertas oferta = new DAOOfertas().GetOferta(ProductoIngresado.Codigo); if (oferta == null) { precio_textBox.Text = Convert.ToString(new DAOProductos().GetProducts(Codigo_textbox.Text).Precio); } else { precio_textBox.Text = oferta.precio.ToString(); } }
private void bttnModify_Click(object sender, EventArgs e) { DTOOfertas oferta = new DAOOfertas().GetOferta(idOferta); this.textBox1.Text = oferta.id; this.textBox2.Text = oferta.descripcion; this.textBox3.Text = oferta.cantidad.ToString(); this.textBox4.Text = oferta.precio.ToString(); this.textBox5.Text = oferta.codigo; this.panel1.Enabled = true; this.textBox1.Enabled = true; this.textBox2.Enabled = true; this.textBox3.Enabled = true; this.textBox4.Enabled = true; this.textBox5.Enabled = true; this.bttnAdd.Text = "Guardar"; this.bttnAdd.Enabled = true; this.bttnNueva.Enabled = false; }