campos de precio de comrpa y venta agregados a las ventas
This commit is contained in:
+3
-1
@@ -752,7 +752,7 @@ namespace compabetov2.database
|
||||
try
|
||||
{
|
||||
string sqlVenta = "INSERT INTO venta (fecha, total,responzable) VALUES(@fecha, @total,@responzable);";
|
||||
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_variante, cantidad) VALUES(@idVenta, @fk_variante, @cantidada);";
|
||||
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_variante, cantidad,precioCompra,precioVenta) VALUES(@idVenta, @fk_variante, @cantidada,@precioCompra,@precioVenta);";
|
||||
string sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
|
||||
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
|
||||
string sqlProductoUpdate = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto";
|
||||
@@ -782,6 +782,8 @@ namespace compabetov2.database
|
||||
commandEmpleado.Parameters.AddWithValue("@idVenta", idVenta);
|
||||
commandEmpleado.Parameters.AddWithValue("@fk_variante", detalleVenta.producto.idVariante);
|
||||
commandEmpleado.Parameters.AddWithValue("@cantidada", detalleVenta.cantidad);
|
||||
commandEmpleado.Parameters.AddWithValue("@precioCompra", detalleVenta.producto.precioCompra);
|
||||
commandEmpleado.Parameters.AddWithValue("@precioVenta", detalleVenta.producto.precio);
|
||||
commandEmpleado.ExecuteNonQuery();
|
||||
|
||||
SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion);
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace compabetov2.database.modelos
|
||||
public Variante producto;
|
||||
public decimal total;
|
||||
|
||||
|
||||
public DetalleVentaModel(int cantidad, Variante producto, int id = -1, decimal total = 0)
|
||||
{
|
||||
this.cantidad = cantidad;
|
||||
|
||||
@@ -14,8 +14,9 @@ namespace compabetov2.database.modelos
|
||||
public int cantidad;
|
||||
public string img;
|
||||
public int fkProducto;
|
||||
public decimal precioCompra;
|
||||
|
||||
public Variante(int idVariante, string nombre, decimal precio, int cantidad, string img, int fkProducto)
|
||||
public Variante(int idVariante, string nombre, decimal precio, int cantidad, string img, int fkProducto,decimal precioCompra)
|
||||
{
|
||||
this.idVariante = idVariante;
|
||||
this.nombre = nombre;
|
||||
@@ -23,6 +24,7 @@ namespace compabetov2.database.modelos
|
||||
this.cantidad = cantidad;
|
||||
this.img = img;
|
||||
this.fkProducto = fkProducto;
|
||||
this.precioCompra = precioCompra;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-9
@@ -45,10 +45,7 @@ namespace compabetov2.database
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
Categoria categoria = new Categoria(
|
||||
int.Parse(reader["idcategoria"].ToString()),
|
||||
reader["nombre"].ToString(),
|
||||
reader["descripcion"].ToString());
|
||||
Categoria categoria = new Categoria();
|
||||
|
||||
Producto producto = new Producto(
|
||||
int.Parse(reader["idproducto"].ToString()),
|
||||
@@ -263,8 +260,9 @@ namespace compabetov2.database
|
||||
while (reader.Read())
|
||||
{
|
||||
int idVariaante = (int)reader.GetInt64(0);
|
||||
decimal precioCompra = reader.GetOrdinal("precioCompra");
|
||||
DetalleCuentaModel detalleCuenta = new DetalleCuentaModel(
|
||||
new Variante(idVariaante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"",(int)reader.GetInt64(3)),
|
||||
new Variante(idVariaante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"",(int)reader.GetInt64(3), precioCompra),
|
||||
(int)reader.GetInt64(4)
|
||||
);
|
||||
detallesCuentas.Add(detalleCuenta);
|
||||
@@ -391,9 +389,10 @@ namespace compabetov2.database
|
||||
while (reader.Read())
|
||||
{
|
||||
int idVariante = (int)reader.GetInt64(0);
|
||||
decimal precioCompra = reader.GetOrdinal("precioCompra");
|
||||
DetalleEnvioModel detalleEnvio = new DetalleEnvioModel(
|
||||
idEnvio,
|
||||
new Variante(idVariante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"", (int)reader.GetInt64(3)),//fkproducto
|
||||
new Variante(idVariante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"", (int)reader.GetInt64(3), precioCompra),//fkproducto
|
||||
(int)reader.GetInt64(4)//cantidad
|
||||
);
|
||||
detallesEnvio.Add(detalleEnvio);
|
||||
@@ -441,6 +440,7 @@ namespace compabetov2.database
|
||||
SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta);
|
||||
while (readerDetalleVenta.Read())
|
||||
{
|
||||
decimal precioCompra = readerDetalleVenta.GetOrdinal("precioCompra");
|
||||
DetalleVentaModel detalleVenta = new DetalleVentaModel(
|
||||
(int)readerDetalleVenta.GetInt64(2),
|
||||
new Variante((int)readerDetalleVenta.GetInt64(3),
|
||||
@@ -448,7 +448,8 @@ namespace compabetov2.database
|
||||
readerDetalleVenta.GetDecimal(5),
|
||||
(int)readerDetalleVenta.GetInt64(6),
|
||||
"",
|
||||
(int)readerDetalleVenta.GetInt64(8))
|
||||
(int)readerDetalleVenta.GetInt64(8),
|
||||
precioCompra)
|
||||
);
|
||||
detallesVenta.Add( detalleVenta );
|
||||
}
|
||||
@@ -487,6 +488,7 @@ namespace compabetov2.database
|
||||
int cantidadIndex = reader.GetOrdinal("cantidad");
|
||||
int imgIndex = reader.GetOrdinal("img");
|
||||
int fkProductoIndex = reader.GetOrdinal("fk_producto");
|
||||
decimal precioCompra = reader.GetOrdinal("precioCompra");
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
@@ -497,7 +499,8 @@ namespace compabetov2.database
|
||||
reader.GetDecimal(precioIndex),
|
||||
reader.GetInt32(cantidadIndex),
|
||||
reader.GetString(imgIndex),
|
||||
reader.GetInt32(fkProductoIndex)
|
||||
reader.GetInt32(fkProductoIndex),
|
||||
precioCompra
|
||||
);
|
||||
|
||||
productos.Add(producto);
|
||||
@@ -543,6 +546,7 @@ namespace compabetov2.database
|
||||
while (reader.Read())
|
||||
{
|
||||
decimal precio = reader.GetDecimal(2);
|
||||
decimal precioCompra = reader.GetDecimal(6);
|
||||
int cantidad = (int)reader.GetInt64(3);
|
||||
int fkProducto = (int)reader.GetInt64(5);
|
||||
Variante vaiante = new Variante(
|
||||
@@ -551,7 +555,8 @@ namespace compabetov2.database
|
||||
precio,
|
||||
cantidad,
|
||||
reader["img"].ToString(),
|
||||
fkProducto
|
||||
fkProducto,
|
||||
precioCompra
|
||||
);
|
||||
variantes.Add(vaiante);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user