estadisticas en proceso
This commit is contained in:
+46
-37
@@ -427,18 +427,32 @@ namespace compabetov2.database
|
||||
return DAO.concluirEnvioDAO(envio, detallesEnvio, importes);
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<Dictionary<string,dynamic>>> estadisticas(DateTime fecha)
|
||||
public static List<VentaModel> conseguirVentasMes(DateTime 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>>();
|
||||
List<VentaModel> ventasMes = new List<VentaModel>();
|
||||
SQLiteDataReader readerVentas = DAO.conseguirVentasMesDAO(fecha);
|
||||
|
||||
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),
|
||||
@@ -446,45 +460,16 @@ namespace compabetov2.database
|
||||
readerVentas.GetString(3)
|
||||
);
|
||||
|
||||
List<DetalleVentaModel> detallesVenta = new List<DetalleVentaModel>();
|
||||
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),
|
||||
readerDetalleVenta["nombre"].ToString(),
|
||||
readerDetalleVenta.GetDecimal(5),
|
||||
(int)readerDetalleVenta.GetInt64(6),
|
||||
"",
|
||||
(int)readerDetalleVenta.GetInt64(8),
|
||||
precioCompra)
|
||||
);
|
||||
detallesVenta.Add( detalleVenta );
|
||||
}
|
||||
|
||||
dicVenta.Add("venta", venta);
|
||||
dicVenta.Add("detalles", detallesVenta as List<DetalleVentaModel>);
|
||||
|
||||
string[] fecha_hora = venta.fecha.Split(' ');
|
||||
string fechaVentaStr = fecha_hora[0];
|
||||
|
||||
DateTime.TryParseExact(fechaVentaStr, formato, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime fechaVenta);
|
||||
if (fecha.Day == fechaVenta.Day)
|
||||
{
|
||||
listDia.Add(dicVenta);
|
||||
ventasDia.Add(venta);
|
||||
}
|
||||
|
||||
listMes.Add(dicVenta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
resumen.Add("mes", listMes);
|
||||
resumen.Add("dia", listDia);
|
||||
|
||||
return resumen;
|
||||
return ventasDia;
|
||||
}
|
||||
|
||||
public static List<Variante> conseguirProductosFiltrados(string nombreProducto)
|
||||
@@ -519,6 +504,30 @@ namespace compabetov2.database
|
||||
return productos;
|
||||
}
|
||||
|
||||
public static List<DetalleVentaModel> conseguirDetallesVenta(VentaModel venta)
|
||||
{
|
||||
List<DetalleVentaModel> detallesVenta = new List<DetalleVentaModel>();
|
||||
SQLiteDataReader readerDetalleVenta = DAO.conseguirDetalleVenta(venta);
|
||||
while (readerDetalleVenta.Read())
|
||||
{
|
||||
decimal precioCompra = readerDetalleVenta.GetDecimal(3);
|
||||
Variante variante = 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);
|
||||
|
||||
DetalleVentaModel detalleVenta = new DetalleVentaModel(
|
||||
(int)readerDetalleVenta.GetInt64(2),
|
||||
variante
|
||||
);
|
||||
detallesVenta.Add( detalleVenta );
|
||||
}
|
||||
return detallesVenta;
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<Envio>> conseguirEnvioMes(DateTime fecha)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user