Ejemplo n.º 1
0
 /// <summary>
 /// Agrega una venta a la base de Datos
 /// </summary>
 /// <param name="idProducto"> id de Producto a agregar en la venta</param>
 /// <param name="idCliente"> id del cliente que realiza la compra </param>
 /// <param name="modoEntrega"> modo de entrega seleccionado para la venta </param>
 public static void AgregarVenta(int idProducto, int idCliente, modoEntrega modoEntrega)
 {
     try
     {
         string query = "insert into Ventas (idProducto, idCliente, modoEntrega) values (@idProducto, @idCliente, @modoEntrega)";
         cnx.Open();
         SqlCommand comando = new SqlCommand(query, cnx);
         comando.Parameters.AddWithValue("@idProducto", idProducto);
         comando.Parameters.AddWithValue("@idCliente", idCliente);
         comando.Parameters.AddWithValue("@modoEntrega", modoEntrega);
         comando.ExecuteNonQuery();
         if (modoEntrega.ToString() == "delivery")
         {
             Cliente cliente = GetDatosCliente(idCliente);
             GuardarPedidoDelivery(cliente);
         }
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         cnx.Close();
     }
 }
Ejemplo n.º 2
0
 public Venta(int idProducto, int idCliente, modoEntrega modoEntrega)
 {
     this.IdProducto  = idProducto;
     this.IdCliente   = idCliente;
     this.ModoEntrega = modoEntrega;
 }