Example #1
0
 private void IngresarCompraDetallada(int idCompra)
 {
     try
     {
         foreach (DataGridViewRow dr in dgvProductos.Rows)
         {
             MySqlCommand sql = new MySqlCommand();
             sql.CommandText = "INSERT INTO compra_producto (id_compra, id_producto, cantidad, precio, descuento) " +
                               "VALUES (?id_compra, ?id_producto, ?cantidad, ?precio, ?descuento)";
             sql.Parameters.AddWithValue("?id_compra", idCompra);
             sql.Parameters.AddWithValue("?id_producto", dr.Cells[0].Value);
             sql.Parameters.AddWithValue("?cantidad", dr.Cells[3].Value);
             sql.Parameters.AddWithValue("?precio", decimal.Parse(dr.Cells[2].Value.ToString(), System.Globalization.NumberStyles.Currency));
             sql.Parameters.AddWithValue("?descuento", decimal.Parse(dr.Cells[4].Value.ToString(), System.Globalization.NumberStyles.Currency));
             ConexionBD.EjecutarConsulta(sql);
             Producto.AgregarInventario(dr.Cells[0].Value.ToString(), (int)dr.Cells[3].Value);
         }
     }
     catch (MySqlException ex)
     {
         throw ex;
     }
     catch (FormatException ex)
     {
         throw ex;
     }
     catch (OverflowException ex)
     {
         throw ex;
     }
     catch (ArgumentNullException ex)
     {
         throw ex;
     }
     catch (ArgumentException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }