estadisticas terminadas con detalle del mejor vendedor

This commit is contained in:
Carlos Sandoval
2024-06-30 03:09:38 -06:00
parent d81f706053
commit 8e6571fbc9
15 changed files with 469 additions and 311 deletions
+54 -27
View File
@@ -209,9 +209,9 @@ namespace compabetov2.database
return DAO.crearVentaDAO(venta, detalleVentas,importes);
}
public static bool devolverImporte(List<DetalleImporte> importes)
public static bool devolverImporte(VentaModel venta,List<DetalleImporte> importes)
{
return DAO.devolverImporteDAO(importes);
return DAO.devolverImporteDAO(venta,importes);
}
public static bool insertarMerma(Merma merma)
@@ -427,49 +427,76 @@ namespace compabetov2.database
return DAO.concluirEnvioDAO(envio, detallesEnvio, importes);
}
public static List<VentaModel> conseguirVentasMes(DateTime fecha)
public static Dictionary<string, List<Dictionary<string, dynamic>>> estadisticas(DateTime fecha)
{
List<VentaModel> ventasMes = new List<VentaModel>();
SQLiteDataReader readerVentas = DAO.conseguirVentasMesDAO(fecha);
Dictionary<string, List<Dictionary<string, dynamic>>> resumen = new Dictionary<string, List<Dictionary<string, dynamic>>>();
List<Dictionary<string, dynamic>> listMes = new List<Dictionary<string, dynamic>>();
List<Dictionary<string, dynamic>> listDia = new List<Dictionary<string, dynamic>>();
while (readerVentas.Read())
{
VentaModel venta = new VentaModel(
readerVentas.GetDecimal(2),//total
(int)readerVentas.GetInt64(0),//id
readerVentas.GetString(1),//fecha
readerVentas.GetString(3)//resposable
);
ventasMes.Add(venta);
}
return ventasMes;
}
public static List<VentaModel> conseguirVentasDia(DateTime fecha)
{
List<VentaModel> ventasDia = new List<VentaModel>();
SQLiteDataReader readerVentas = DAO.conseguirVentasMesDAO(fecha);
string formato = "dd/MM/yyyy";
while (readerVentas.Read())
{
Dictionary<string, dynamic> dicVenta = new Dictionary<string, dynamic>();
VentaModel venta = new VentaModel(
readerVentas.GetDecimal(2),
(int)readerVentas.GetInt64(0),
readerVentas.GetString(1),
readerVentas.GetString(3)
readerVentas.GetDecimal(2),//total
(int)readerVentas.GetInt64(0),//id
readerVentas.GetString(1),//fecha
readerVentas.GetString(3)//responzable
);
List<DetalleVentaModel> detallesVenta = new List<DetalleVentaModel>();
SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta);
while (readerDetalleVenta.Read())
{
decimal precioCompra = readerDetalleVenta.GetDecimal(3);
DetalleVentaModel detalleVenta = new DetalleVentaModel(
(int)readerDetalleVenta.GetInt64(2),// cantidad
new Variante((int)readerDetalleVenta.GetInt64(5),//id
readerDetalleVenta["nombre"].ToString(),//nombre
readerDetalleVenta.GetDecimal(4),//precioVenta
(int)readerDetalleVenta.GetInt64(8),//cantidad
"",//img
(int)readerDetalleVenta.GetInt64(10),//fkProducto
precioCompra)
);
detallesVenta.Add(detalleVenta);
}
List<DetalleImporte> importes = new List<DetalleImporte>();
SQLiteDataReader readerImporte = DAO.conseguirImportesVentaDAO(venta);
while (readerImporte.Read())
{
DetalleImporte importe = new DetalleImporte(
(int)readerImporte.GetInt64(1),//fkImporte
(int)readerImporte.GetInt64(2),//cantidad
readerImporte.GetDecimal(3),//precio
(int)readerImporte.GetInt64(4)//fkVenta
);
importes.Add(importe);
}
string[] fecha_hora = venta.fecha.Split(' ');
string fechaVentaStr = fecha_hora[0];
dicVenta.Add("venta", venta);
dicVenta.Add("detalles", detallesVenta as List<DetalleVentaModel>);
dicVenta.Add("importes", importes);
DateTime.TryParseExact(fechaVentaStr, formato, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime fechaVenta);
if (fecha.Day == fechaVenta.Day)
{
ventasDia.Add(venta);
listDia.Add(dicVenta);
}
listMes.Add(dicVenta);
}
return ventasDia;
resumen.Add("mes", listMes);
resumen.Add("dia", listDia);
return resumen;
}
public static List<Variante> conseguirProductosFiltrados(string nombreProducto)