Exemple #1
0
/////////////////////////////////////// Accion del boton Agregar //////////////////////////////////////////////////////////
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            if (txtCodProducto.Text == "" || txtProducto.Text == "" || txtPrecio.Text == "" || txtCantidadProducto.Text == "" || cboDescuento.Text == "")
            {
                MessageBox.Show("Debe de llenar todos los campos");
            }
            else
            {
                factura.setTotal(Convert.ToDouble(txtTotal.Text));

                bolAgregarEncabezado = clFactura.mInsertarFacturaEncabezado(conexion, factura, usuario);


                for (int i = 0; i < lvProductos.Items.Count; i++)
                {
                    facturaDetalle.setIdFactura(Convert.ToInt32(txtNumeroF.Text));
                    facturaDetalle.setIdProducto(Convert.ToInt32(this.lvProductos.Items[i].Text));
                    facturaDetalle.setCantidad(Convert.ToInt32(txtCantidad.Text));
                    facturaDetalle.setDescuento(descuento);
                    facturaDetalle.setSubTotal(Convert.ToDouble(txtSubTotal.Text));
                    clFactura.mInsertarFacturaDetalle(conexion, facturaDetalle);
                }//fin del for
                bolAgregarDetalle = true;

                if (bolAgregarEncabezado == true && bolAgregarDetalle == true)
                {
                    MessageBox.Show("La venta ha sido satisfactoria", "Registro correcto", MessageBoxButtons.OK);
                    this.Limpiar();
                }//fin del if de agregar
                else
                {
                    MessageBox.Show("Problemas al realizar la venta", "Error", MessageBoxButtons.OK);

                    this.Limpiar();
                }
            }//fin del else

            this.mConsultaIdFactura();
        }//fin de la accion del boton realizar venta