estadisticas del mes

This commit is contained in:
carlos
2024-01-28 22:51:04 -06:00
parent ccbdc1d323
commit c81f56bf7b
22 changed files with 592 additions and 68 deletions
+32 -6
View File
@@ -777,7 +777,7 @@ namespace compabetov2.database
{
try
{
string sqlVenta = "INSERT INTO venta (fecha, total) VALUES(@fecha, @total);";
string sqlVenta = "INSERT INTO venta (fecha, total,responzable) VALUES(@fecha, @total,@responzable);";
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_producto, cantidad) VALUES(@idVenta, @idProducto, @cantidada);";
string sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
@@ -787,6 +787,7 @@ namespace compabetov2.database
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
commandVenta.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
commandVenta.Parameters.AddWithValue("@total", venta.total);
commandVenta.Parameters.AddWithValue("@responzable", venta.responzable);
commandVenta.ExecuteNonQuery();
SQLiteCommand commandConsulta = new SQLiteCommand(sqlIdVenta, conexion);
@@ -1137,7 +1138,7 @@ namespace compabetov2.database
}
public static SQLiteDataReader filtrarVentaFechaMesDAO(DateTime fecha)
public static SQLiteDataReader conseguirVentasMesDAO(DateTime fecha)
{
SQLiteDataReader reader = null;
var db_conexion = new Conexion();
@@ -1147,9 +1148,9 @@ namespace compabetov2.database
conexion.Open();
string sql = "SELECT * FROM venta WHERE fecha LIKE '%@fecha%'";
string sql = "SELECT * FROM venta WHERE fecha LIKE @fecha";
SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue("@fecha", $"{fecha.Month}/{fecha.Year}");
command.Parameters.AddWithValue("@fecha", $"%{fecha.Month}/{fecha.Year}%");
reader = command.ExecuteReader();
return reader;
@@ -1162,7 +1163,32 @@ namespace compabetov2.database
}
}
public static Dictionary<string, dynamic> filtrarVentaFechaMes(DateTime fecha)
public static SQLiteDataReader conseguirDetalleVenta(VentaModel venta)
{
SQLiteDataReader reader = null;
var db_conexion = new Conexion();
try
{
SQLiteConnection conexion = db_conexion.get_connection();
conexion.Open();
string sql = "select * from detalle_venta dv, Producto p WHERE dv.fk_producto = p.idproducto and dv.fk_venta = @idVenta";
SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue("@idVenta", venta.id);
reader = command.ExecuteReader();
return reader;
}
catch (SQLiteException ex)
{
MessageBox.Show(ex.Message);
return reader;
}
}
/*public static SQLiteDataReader filtrarVentaFechaMes(DateTime fecha)
{
Dictionary<string, dynamic> estadisticas = new Dictionary<string, dynamic>();
SQLiteDataReader reader = DAO.filtrarVentaFechaMesDAO(fecha);
@@ -1191,7 +1217,7 @@ namespace compabetov2.database
estadisticas.Add("ventasMes", totalMes);
return estadisticas;
}
}*/
public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio)
{