campos de precio de comrpa y venta agregados a las ventas

This commit is contained in:
carlos
2024-06-18 17:13:46 -06:00
parent 8ebdbf4f74
commit e489535f2f
11 changed files with 22 additions and 12 deletions
+1 -1
View File
@@ -4,6 +4,6 @@
"\\database", "\\database",
"\\Ventas" "\\Ventas"
], ],
"SelectedNode": "\\Ventas\\vender.cs", "SelectedNode": "\\database\\DAO.cs",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+3 -1
View File
@@ -752,7 +752,7 @@ namespace compabetov2.database
try try
{ {
string sqlVenta = "INSERT INTO venta (fecha, total,responzable) VALUES(@fecha, @total,@responzable);"; 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 sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto"; string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
string sqlProductoUpdate = "UPDATE Producto SET stock = @stock 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("@idVenta", idVenta);
commandEmpleado.Parameters.AddWithValue("@fk_variante", detalleVenta.producto.idVariante); commandEmpleado.Parameters.AddWithValue("@fk_variante", detalleVenta.producto.idVariante);
commandEmpleado.Parameters.AddWithValue("@cantidada", detalleVenta.cantidad); commandEmpleado.Parameters.AddWithValue("@cantidada", detalleVenta.cantidad);
commandEmpleado.Parameters.AddWithValue("@precioCompra", detalleVenta.producto.precioCompra);
commandEmpleado.Parameters.AddWithValue("@precioVenta", detalleVenta.producto.precio);
commandEmpleado.ExecuteNonQuery(); commandEmpleado.ExecuteNonQuery();
SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion); SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion);
+1
View File
@@ -13,6 +13,7 @@ namespace compabetov2.database.modelos
public Variante producto; public Variante producto;
public decimal total; public decimal total;
public DetalleVentaModel(int cantidad, Variante producto, int id = -1, decimal total = 0) public DetalleVentaModel(int cantidad, Variante producto, int id = -1, decimal total = 0)
{ {
this.cantidad = cantidad; this.cantidad = cantidad;
+3 -1
View File
@@ -14,8 +14,9 @@ namespace compabetov2.database.modelos
public int cantidad; public int cantidad;
public string img; public string img;
public int fkProducto; 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.idVariante = idVariante;
this.nombre = nombre; this.nombre = nombre;
@@ -23,6 +24,7 @@ namespace compabetov2.database.modelos
this.cantidad = cantidad; this.cantidad = cantidad;
this.img = img; this.img = img;
this.fkProducto = fkProducto; this.fkProducto = fkProducto;
this.precioCompra = precioCompra;
} }
} }
} }
+14 -9
View File
@@ -45,10 +45,7 @@ namespace compabetov2.database
while (reader.Read()) while (reader.Read())
{ {
Categoria categoria = new Categoria( Categoria categoria = new Categoria();
int.Parse(reader["idcategoria"].ToString()),
reader["nombre"].ToString(),
reader["descripcion"].ToString());
Producto producto = new Producto( Producto producto = new Producto(
int.Parse(reader["idproducto"].ToString()), int.Parse(reader["idproducto"].ToString()),
@@ -263,8 +260,9 @@ namespace compabetov2.database
while (reader.Read()) while (reader.Read())
{ {
int idVariaante = (int)reader.GetInt64(0); int idVariaante = (int)reader.GetInt64(0);
decimal precioCompra = reader.GetOrdinal("precioCompra");
DetalleCuentaModel detalleCuenta = new DetalleCuentaModel( 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) (int)reader.GetInt64(4)
); );
detallesCuentas.Add(detalleCuenta); detallesCuentas.Add(detalleCuenta);
@@ -391,9 +389,10 @@ namespace compabetov2.database
while (reader.Read()) while (reader.Read())
{ {
int idVariante = (int)reader.GetInt64(0); int idVariante = (int)reader.GetInt64(0);
decimal precioCompra = reader.GetOrdinal("precioCompra");
DetalleEnvioModel detalleEnvio = new DetalleEnvioModel( DetalleEnvioModel detalleEnvio = new DetalleEnvioModel(
idEnvio, 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 (int)reader.GetInt64(4)//cantidad
); );
detallesEnvio.Add(detalleEnvio); detallesEnvio.Add(detalleEnvio);
@@ -441,6 +440,7 @@ namespace compabetov2.database
SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta); SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta);
while (readerDetalleVenta.Read()) while (readerDetalleVenta.Read())
{ {
decimal precioCompra = readerDetalleVenta.GetOrdinal("precioCompra");
DetalleVentaModel detalleVenta = new DetalleVentaModel( DetalleVentaModel detalleVenta = new DetalleVentaModel(
(int)readerDetalleVenta.GetInt64(2), (int)readerDetalleVenta.GetInt64(2),
new Variante((int)readerDetalleVenta.GetInt64(3), new Variante((int)readerDetalleVenta.GetInt64(3),
@@ -448,7 +448,8 @@ namespace compabetov2.database
readerDetalleVenta.GetDecimal(5), readerDetalleVenta.GetDecimal(5),
(int)readerDetalleVenta.GetInt64(6), (int)readerDetalleVenta.GetInt64(6),
"", "",
(int)readerDetalleVenta.GetInt64(8)) (int)readerDetalleVenta.GetInt64(8),
precioCompra)
); );
detallesVenta.Add( detalleVenta ); detallesVenta.Add( detalleVenta );
} }
@@ -487,6 +488,7 @@ namespace compabetov2.database
int cantidadIndex = reader.GetOrdinal("cantidad"); int cantidadIndex = reader.GetOrdinal("cantidad");
int imgIndex = reader.GetOrdinal("img"); int imgIndex = reader.GetOrdinal("img");
int fkProductoIndex = reader.GetOrdinal("fk_producto"); int fkProductoIndex = reader.GetOrdinal("fk_producto");
decimal precioCompra = reader.GetOrdinal("precioCompra");
while (reader.Read()) while (reader.Read())
{ {
@@ -497,7 +499,8 @@ namespace compabetov2.database
reader.GetDecimal(precioIndex), reader.GetDecimal(precioIndex),
reader.GetInt32(cantidadIndex), reader.GetInt32(cantidadIndex),
reader.GetString(imgIndex), reader.GetString(imgIndex),
reader.GetInt32(fkProductoIndex) reader.GetInt32(fkProductoIndex),
precioCompra
); );
productos.Add(producto); productos.Add(producto);
@@ -543,6 +546,7 @@ namespace compabetov2.database
while (reader.Read()) while (reader.Read())
{ {
decimal precio = reader.GetDecimal(2); decimal precio = reader.GetDecimal(2);
decimal precioCompra = reader.GetDecimal(6);
int cantidad = (int)reader.GetInt64(3); int cantidad = (int)reader.GetInt64(3);
int fkProducto = (int)reader.GetInt64(5); int fkProducto = (int)reader.GetInt64(5);
Variante vaiante = new Variante( Variante vaiante = new Variante(
@@ -551,7 +555,8 @@ namespace compabetov2.database
precio, precio,
cantidad, cantidad,
reader["img"].ToString(), reader["img"].ToString(),
fkProducto fkProducto,
precioCompra
); );
variantes.Add(vaiante); variantes.Add(vaiante);
} }
Binary file not shown.
Binary file not shown.