cambios carlos

This commit is contained in:
carlos
2024-01-22 21:01:27 -06:00
parent b17a386c0f
commit f522f00107
5 changed files with 62 additions and 2 deletions
+32
View File
@@ -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<string, dynamic> filtrarVentaFechaMes(DateTime fecha)
{
Dictionary<string, dynamic> estadisticas = new Dictionary<string, dynamic>();
SQLiteDataReader reader = DAO.filtrarVentaFechaMesDAO(fecha);
string formatoFecha = "dd/MM/yyyy h:mm:ss tt";
decimal totalDia = 0;
decimal totalMes = 0;
List<VentaModel> ventas = new List<VentaModel>();
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;
}
}
}