diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 6fc01b8..59390c5 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -4,6 +4,6 @@ "\\database", "\\Ventas" ], - "SelectedNode": "\\Ventas\\vender.cs", + "SelectedNode": "\\database\\DAO.cs", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/compabetoOG/v17/.wsuo b/.vs/compabetoOG/v17/.wsuo index d191d6a..385c8e5 100644 Binary files a/.vs/compabetoOG/v17/.wsuo and b/.vs/compabetoOG/v17/.wsuo differ diff --git a/bin/Debug/compabetov2.exe b/bin/Debug/compabetov2.exe index 9c7e5e7..4fb06ec 100644 Binary files a/bin/Debug/compabetov2.exe and b/bin/Debug/compabetov2.exe differ diff --git a/bin/Debug/compabetov2.pdb b/bin/Debug/compabetov2.pdb index 98ad5f7..3f34717 100644 Binary files a/bin/Debug/compabetov2.pdb and b/bin/Debug/compabetov2.pdb differ diff --git a/bin/Debug/data.db b/bin/Debug/data.db index caef42a..f1e2f4b 100644 Binary files a/bin/Debug/data.db and b/bin/Debug/data.db differ diff --git a/database/DAO.cs b/database/DAO.cs index 2002fa3..c6a0a2b 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -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); diff --git a/database/modelos/DetalleVentaModel.cs b/database/modelos/DetalleVentaModel.cs index 52c73cb..8de0221 100644 --- a/database/modelos/DetalleVentaModel.cs +++ b/database/modelos/DetalleVentaModel.cs @@ -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; diff --git a/database/modelos/Variante.cs b/database/modelos/Variante.cs index bf1ca3a..671547a 100644 --- a/database/modelos/Variante.cs +++ b/database/modelos/Variante.cs @@ -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; } } } diff --git a/database/service.cs b/database/service.cs index d6db13e..cbd03b2 100644 --- a/database/service.cs +++ b/database/service.cs @@ -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); } diff --git a/obj/Debug/compabetov2.exe b/obj/Debug/compabetov2.exe index 9c7e5e7..4fb06ec 100644 Binary files a/obj/Debug/compabetov2.exe and b/obj/Debug/compabetov2.exe differ diff --git a/obj/Debug/compabetov2.pdb b/obj/Debug/compabetov2.pdb index 98ad5f7..3f34717 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ