diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 044ae22..ef240ac 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,8 +1,11 @@ { "ExpandedNodes": [ "", - "\\Empleados" + "\\database", + "\\Empleados", + "\\Properties", + "\\Properties\\DataSources" ], - "SelectedNode": "\\Solution.sln", + "SelectedNode": "\\database\\service.cs", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/compabetoOG/v17/.wsuo b/.vs/compabetoOG/v17/.wsuo index 5be49d3..fd94a37 100644 Binary files a/.vs/compabetoOG/v17/.wsuo and b/.vs/compabetoOG/v17/.wsuo differ diff --git a/database/DAO.cs b/database/DAO.cs index 5fa8049..4436b78 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -1137,6 +1137,31 @@ namespace compabetov2.database } + public static SQLiteDataReader filtrarVentaFechaMesDAO(DateTime fecha) + { + SQLiteDataReader reader = null; + var db_conexion = new Conexion(); + try + { + SQLiteConnection conexion = db_conexion.get_connection(); + + conexion.Open(); + + string sql = "SELECT * FROM venta WHERE fecha LIKE '%@fecha%'"; + SQLiteCommand command = new SQLiteCommand(sql, conexion); + command.Parameters.AddWithValue("@fecha", $"{fecha.Month}/{fecha.Year}"); + reader = command.ExecuteReader(); + + return reader; + + } + catch (SQLiteException ex) + { + MessageBox.Show(ex.Message); + return reader; + } + } + private static void crearDB() { var db_conexion = new Conexion(); diff --git a/database/service.cs b/database/service.cs index 0de6eea..932ed09 100644 --- a/database/service.cs +++ b/database/service.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data.SQLite; +using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -283,5 +284,36 @@ namespace compabetov2.database { return DAO.saldarCuentaDAO(cuenta, detallesCuentas); } + + public static Dictionary filtrarVentaFechaMes(DateTime fecha) + { + Dictionary estadisticas = new Dictionary(); + SQLiteDataReader reader = DAO.filtrarVentaFechaMesDAO(fecha); + string formatoFecha = "dd/MM/yyyy h:mm:ss tt"; + decimal totalDia = 0; + decimal totalMes = 0; + List ventas = new List(); + while (reader.Read()) + { + VentaModel venta = new VentaModel( + reader.GetDecimal(2), + (int)reader.GetInt64(0), + reader.GetString(1) + ); + DateTime fechaVenta = DateTime.ParseExact(venta.fecha, formatoFecha, CultureInfo.InvariantCulture); + if (fecha.Day == fechaVenta.Day) + { + totalDia += venta.total; + } + totalMes += venta.total; + ventas.Add(venta); + } + + estadisticas.Add("ventasDia", totalDia); + estadisticas.Add("ventasMes", totalMes); + MessageBox.Show($"{totalDia} -- {totalMes}"); + + return estadisticas; + } } } diff --git a/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 10a1a65..4382aa9 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ