diff --git a/RegistroVentas.cs b/RegistroVentas.cs index 389de64..4af87fa 100644 --- a/RegistroVentas.cs +++ b/RegistroVentas.cs @@ -63,7 +63,7 @@ namespace compabetov2 lbResponzable.Width = 700; Label lbTotal = new Label(); - lbTotal.Text = $"Total: {venta.total}"; + lbTotal.Text = $"Total: ${venta.total}"; lbTotal.Font = new Font(lbTotal.Font.FontFamily, 16); lbTotal.Width = 700; @@ -91,7 +91,12 @@ namespace compabetov2 { mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n"; } - mensaje += $"Total: {venta.total}"; + decimal totalImporte = 0; + foreach (DetalleImporte importe in ventaYDetalles["importes"]) { + totalImporte += importe.cantidad * importe.precioImporte; + } + mensaje += $"Importe: ${totalImporte}\n"; + mensaje += $"Total: ${venta.total}"; MessageBox.Show(mensaje); }); diff --git a/admin/Variantes.cs b/admin/Variantes.cs index ee547bb..4d4c815 100644 --- a/admin/Variantes.cs +++ b/admin/Variantes.cs @@ -70,7 +70,7 @@ namespace compabetov2.admin Label nombreStock = new Label(); - nombreStock.Text = variante.nombre + " - $" + variante.precio; + nombreStock.Text = variante.nombre + " - $" + variante.precio + $"\nPrecio de compra: ${variante.precioCompra}"; nombreStock.Font = new Font(nombreStock.Font.FontFamily, 14); nombreStock.Dock = DockStyle.Fill; nombreStock.TextAlign = ContentAlignment.MiddleCenter; diff --git a/bin/Debug/compabetov2.exe b/bin/Debug/compabetov2.exe index e7f4857..21034e9 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 02129c7..331df24 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 e8a21c7..5d1166c 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 f49af23..b8835a7 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -1056,7 +1056,7 @@ namespace compabetov2.database try { string sqlCuenta = "INSERT INTO cuenta (total, fecha, estado, descripcion,cliente) VALUES(@total, @fecha, 'ACTIVO', @descripcion,@cliente);"; - string sqlDetalle = "INSERT INTO detalle_cuenta (fk_cuenta, fk_variante, cantidad) VALUES(@fk_cuenta, @fk_variante, @cantidad);"; + string sqlDetalle = "INSERT INTO detalle_cuenta (fk_cuenta, fk_variante, cantidad, precioVenta, precioCompra) VALUES(@fk_cuenta, @fk_variante, @cantidad,@precioVenta,@precioCompra);"; string sqlIdCuenta = "SELECT idCuenta FROM cuenta ORDER BY idCuenta DESC LIMIT 1"; string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto"; string sqlProductoUpdate = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto"; @@ -1084,6 +1084,8 @@ namespace compabetov2.database commandDetalle.Parameters.AddWithValue("@fk_cuenta", idCuenta); commandDetalle.Parameters.AddWithValue("@fk_variante", detalleCuenta.producto.idVariante); commandDetalle.Parameters.AddWithValue("@cantidad", detalleCuenta.cantidad); + commandDetalle.Parameters.AddWithValue("@precioVenta", detalleCuenta.producto.precio); + commandDetalle.Parameters.AddWithValue("@precioCompra", detalleCuenta.producto.precioCompra); commandDetalle.ExecuteNonQuery(); //modificar stock @@ -1145,7 +1147,7 @@ namespace compabetov2.database conexion.Open(); - string sql = "Select v.idVariante , v.nombre ,v.cantidad ,v.fk_producto , dc.cantidad from detalle_cuenta dc, variantes v " + + string sql = "Select v.idVariante , v.nombre ,v.cantidad ,v.fk_producto , dc.cantidad, dc.precioCompra , dc.precioVenta from detalle_cuenta dc, variantes v " + "WHERE dc.fk_variante = v.idVariante and dc.fk_cuenta = @fk_cuenta;"; SQLiteCommand command = new SQLiteCommand(sql, conexion); command.Parameters.AddWithValue("@fk_cuenta", idCuenta); @@ -1525,7 +1527,7 @@ namespace compabetov2.database conexion.Open(); - string sql = "Select v.idVariante, v.nombre, v.cantidad, v.fk_producto, de.cantidad from detalle_envios de,variantes v " + + string sql = "Select v.idVariante, v.nombre, v.cantidad, v.fk_producto, de.cantidad,de.precioCompra , de.precioVenta from detalle_envios de,variantes v " + "WHERE de.fk_variante = v.idVariante and de.fk_envios = @fk_envios;"; SQLiteCommand command = new SQLiteCommand(sql, conexion); command.Parameters.AddWithValue("@fk_envios", idEnvio); diff --git a/database/modelos/DetalleCuentaModel.cs b/database/modelos/DetalleCuentaModel.cs index 6512bcc..6c0460f 100644 --- a/database/modelos/DetalleCuentaModel.cs +++ b/database/modelos/DetalleCuentaModel.cs @@ -11,14 +11,14 @@ namespace compabetov2.database.modelos public int idCuenta; public Variante producto; public int cantidad; - public string nombreProducto; + public decimal total; - public DetalleCuentaModel(Variante producto, int cantidad, int idCuenta =-1, string nombreProducto = "") + public DetalleCuentaModel(Variante producto, int cantidad, int idCuenta =-1, decimal total = 0) { this.idCuenta = idCuenta; this.producto = producto; this.cantidad = cantidad; - this.nombreProducto = nombreProducto; + this.total = total; } } } diff --git a/database/service.cs b/database/service.cs index ea51aaa..f017c84 100644 --- a/database/service.cs +++ b/database/service.cs @@ -270,9 +270,10 @@ namespace compabetov2.database while (reader.Read()) { int idVariaante = (int)reader.GetInt64(0); - decimal precioCompra = reader.GetOrdinal("precioCompra"); + decimal precioCompra = reader.GetDecimal(5); + decimal precio = reader.GetDecimal(6); DetalleCuentaModel detalleCuenta = new DetalleCuentaModel( - new Variante(idVariaante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"",(int)reader.GetInt64(3), precioCompra), + new Variante(idVariaante, reader["nombre"].ToString(),precio,(int)reader.GetInt64(2),"",(int)reader.GetInt64(3), precioCompra), (int)reader.GetInt64(4) ); detallesCuentas.Add(detalleCuenta); @@ -399,10 +400,11 @@ namespace compabetov2.database while (reader.Read()) { int idVariante = (int)reader.GetInt64(0); - decimal precioCompra = reader.GetOrdinal("precioCompra"); + decimal precioCompra = reader.GetDecimal(5); + decimal precio = reader.GetDecimal(6); DetalleEnvioModel detalleEnvio = new DetalleEnvioModel( idEnvio, - new Variante(idVariante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"", (int)reader.GetInt64(3), precioCompra),//fkproducto + new Variante(idVariante, reader["nombre"].ToString(),precio,(int)reader.GetInt64(2),"", (int)reader.GetInt64(3), precioCompra),//fkproducto (int)reader.GetInt64(4)//cantidad ); detallesEnvio.Add(detalleEnvio); diff --git a/obj/Debug/compabetov2.exe b/obj/Debug/compabetov2.exe index e7f4857..21034e9 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 02129c7..331df24 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ