Ejemplo n.º 1
0
        private void InsetarDetalleFactura(facturadetalle detalle)
        {
            string Query = "proc_FACTURADETALLEINSERT";

            using (ComandoSQL = new SqlCommand())
            {
                if (AccesoDatos.Transaction != null)
                {
                    ComandoSQL.Transaction = AccesoDatos.Transaction;
                }

                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.StoredProcedure;
                ComandoSQL.CommandText = Query;
                try
                {
                    ComandoSQL.Parameters.AddWithValue("@productoid", detalle.PRODUCTOID);
                    ComandoSQL.Parameters.AddWithValue("@facturaid", detalle.FACTURAID);
                    ComandoSQL.Parameters.AddWithValue("@cantidad", detalle.CANTIDAD);
                    ComandoSQL.Parameters.AddWithValue("@precio", detalle.PRECIO);
                    //Ejecutar Comando
                    var resultado = ComandoSQL.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            #endregion
        }
Ejemplo n.º 2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            var fact = new factura();

            fact.ID_CLIENTE  = int.Parse(txtCodCliente.Text);
            fact.ID_VENDEDOR = 1;

            foreach (DataGridViewRow row in DataGridViewDetalleFactura.Rows)
            {
                var detallefact = new facturadetalle();
                detallefact.PRODUCTOID = int.Parse(row.Cells["ColumnCodProducto"].Value.ToString());
                detallefact.CANTIDAD   = int.Parse(row.Cells["ColumnCantidad"].Value.ToString());
                detallefact.PRECIO     = float.Parse(row.Cells["ColumnPrecio"].Value.ToString());

                fact.FACTURADETALLE.Add(detallefact);
            }

            int          facturaid = facturaBL.Insertarfactura(fact);
            Form_Reporte factura   = new Form_Reporte(facturaid);

            factura.Show();
            Limpiar(txtCodCliente, txtCodFactura, txtCodProducto, txtNombreProducto, txtSaldoFinal, txtSaldoInicial
                    , txtPrecio, txtCantidad, txtClienteNombre, txtVendedorNombre, txtCodVendedor);
            DataGridViewDetalleFactura.Rows.Clear();
        }