importe funcional sin haber hecho pruebas exaustivas
This commit is contained in:
+119
-13
@@ -440,7 +440,7 @@ namespace compabetov2.database
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "SELECT * FROM Producto INNER JOIN Categoria ON Producto.fk_idcategoria = Categoria.idcategoria";
|
||||
string sql = "SELECT * FROM Producto";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
@@ -756,7 +756,7 @@ namespace compabetov2.database
|
||||
string sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
|
||||
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
|
||||
string sqlProductoUpdate = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto";
|
||||
string sqlImporte = "INSERT INTO detalle_importe (fk_importe,cantidad,precio,fecha) VALUES (@fk_importe,@cantidad,@precio,@fecha)";
|
||||
string sqlImporte = "INSERT INTO detalle_importe (fk_importe,cantidad,precio,fk_venta) VALUES (@fk_importe,@cantidad,@precio,@fk_venta)";
|
||||
|
||||
// CREACION DE LA VENTA
|
||||
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
|
||||
@@ -807,13 +807,13 @@ namespace compabetov2.database
|
||||
//creacion del importe
|
||||
foreach (DetalleImporte importe in importes)
|
||||
{
|
||||
if (importe.catidad != 0)
|
||||
if (importe.cantidad != 0)
|
||||
{
|
||||
SQLiteCommand commandDetalleImporte = new SQLiteCommand(sqlImporte, conexion);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fk_importe", importe.fkImporte);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@cantidad", importe.catidad);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@cantidad", importe.cantidad);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@precio", importe.precioImporte);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fk_venta", idVenta);
|
||||
commandDetalleImporte.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@@ -854,11 +854,11 @@ namespace compabetov2.database
|
||||
//creacion del importe
|
||||
foreach (DetalleImporte importe in importes)
|
||||
{
|
||||
if (importe.catidad != 0)
|
||||
if (importe.cantidad != 0)
|
||||
{
|
||||
SQLiteCommand commandDetalleImporte = new SQLiteCommand(sqlImporte, conexion);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fk_importe", importe.fkImporte);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@cantidad", importe.catidad);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@cantidad", importe.cantidad);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@precio", importe.precioImporte);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
|
||||
commandDetalleImporte.ExecuteNonQuery();
|
||||
@@ -968,7 +968,7 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool crearCuentaDAO(Cuenta cuenta, List<DetalleCuentaModel> detalleCuentas)
|
||||
public static bool crearCuentaDAO(Cuenta cuenta, List<DetalleCuentaModel> detalleCuentas, List<DetalleImporte> importes)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
@@ -986,6 +986,7 @@ namespace compabetov2.database
|
||||
string sqlIdCuenta = "SELECT idCuenta FROM cuenta ORDER BY idCuenta DESC LIMIT 1";
|
||||
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
|
||||
string sqlProductoUpdate = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto";
|
||||
string sqlImporte = "INSERT INTO detalle_importe_cuenta (fk_importe, cantidad, precio, fk_cuenta) VALUES(@fk_importe, @cantidad, @precio, @fk_cuenta);";
|
||||
|
||||
SQLiteCommand commandCuenta = new SQLiteCommand(sqlCuenta, conexion);
|
||||
commandCuenta.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
|
||||
@@ -1029,6 +1030,18 @@ namespace compabetov2.database
|
||||
commandProdcutoUpdate.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
foreach(DetalleImporte importe in importes)
|
||||
{
|
||||
if(importe.cantidad != 0) {
|
||||
SQLiteCommand commandImportes = new SQLiteCommand(sqlImporte, conexion);
|
||||
commandImportes.Parameters.AddWithValue("@fk_importe", importe.fkImporte);
|
||||
commandImportes.Parameters.AddWithValue("@cantidad", importe.cantidad);
|
||||
commandImportes.Parameters.AddWithValue("@precio", importe.precioImporte);
|
||||
commandImportes.Parameters.AddWithValue("@fk_cuenta", idCuenta);
|
||||
commandImportes.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
transaccion.Commit();
|
||||
return true;
|
||||
}
|
||||
@@ -1074,6 +1087,31 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static SQLiteDataReader conseguirImportesCuentaDAO(int idCuenta)
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
SQLiteConnection conexion = db_conexion.get_connection();
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "SELECT * FROM detalle_importe_cuenta WHERE fk_cuenta = @fk_cuenta;";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@fk_cuenta", idCuenta);
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
return reader;
|
||||
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool cancelarCuentaDAO(int idCuenta)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
@@ -1113,7 +1151,7 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool saldarCuentaDAO(Cuenta cuenta, List<DetalleCuentaModel> detallesCuentas)
|
||||
public static bool saldarCuentaDAO(Cuenta cuenta, List<DetalleCuentaModel> detallesCuentas, List<DetalleImporteCuenta> importes)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
@@ -1130,6 +1168,8 @@ namespace compabetov2.database
|
||||
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_variante, cantidad) VALUES(@idVenta, @fk_variante, @cantidada);";
|
||||
string sqlCuenta = "UPDATE cuenta SET estado ='SALDADO' WHERE idCuenta = @idCuenta;";
|
||||
string sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
|
||||
string sqlImporte = "INSERT INTO detalle_importe (fk_importe,cantidad,precio,fk_venta) VALUES (@fk_importe,@cantidad,@precio,@fk_venta)";
|
||||
|
||||
|
||||
|
||||
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
|
||||
@@ -1158,6 +1198,19 @@ namespace compabetov2.database
|
||||
commandEmpleado.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
foreach (DetalleImporteCuenta importe in importes)
|
||||
{
|
||||
if (importe.cantidad != 0)
|
||||
{
|
||||
SQLiteCommand commandDetalleImporte = new SQLiteCommand(sqlImporte, conexion);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fk_importe", importe.fkImporte);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@cantidad", importe.cantidad);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@precio", importe.precioImporte);
|
||||
commandDetalleImporte.Parameters.AddWithValue("@fk_venta", idVenta);
|
||||
commandDetalleImporte.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
transaccion.Commit();
|
||||
return true;
|
||||
}
|
||||
@@ -1253,12 +1306,12 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio)
|
||||
public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio, List<DetalleImporte> importes)
|
||||
{
|
||||
return DAO.crearEnvioDAO(envio, detallesEnvio);
|
||||
return DAO.crearEnvioDAO(envio, detallesEnvio, importes);
|
||||
}
|
||||
|
||||
public static bool crearEnvioDAO(Envio envio, List<DetalleEnvioModel> detallesEnvio)
|
||||
public static bool crearEnvioDAO(Envio envio, List<DetalleEnvioModel> detallesEnvio, List<DetalleImporte> importes)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
@@ -1274,6 +1327,7 @@ namespace compabetov2.database
|
||||
string sqlEnvio = "INSERT INTO envios (fecha, direccion, telefono,responzable,total,cliente) VALUES(@fecha,@direccion , @telefono, @responzable, @total,@cliente);";
|
||||
string sqlDetalle = "INSERT INTO detalle_envios (fk_envios, fk_variante, cantidad) VALUES(@fk_envios, @fk_variante, @cantidad);";
|
||||
string sqlIdCuenta = "SELECT idEnvios FROM envios ORDER BY idEnvios DESC LIMIT 1";
|
||||
string sqlImporte = "INSERT INTO detalle_importe_envio (fk_importe, cantidad, precio, fk_envio) VALUES(@fk_importe, @cantidad, @precio, @fk_envio);";
|
||||
|
||||
SQLiteCommand commandCuenta = new SQLiteCommand(sqlEnvio, conexion);
|
||||
commandCuenta.Parameters.AddWithValue("@fecha", envio.fecha);
|
||||
@@ -1302,6 +1356,19 @@ namespace compabetov2.database
|
||||
commandDetalle.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
//creacion de importes
|
||||
foreach(DetalleImporte importe in importes)
|
||||
{
|
||||
if(importe.cantidad != 0) {
|
||||
SQLiteCommand commandImportes = new SQLiteCommand(sqlImporte, conexion);
|
||||
commandImportes.Parameters.AddWithValue("@fk_importe", importe.fkImporte);
|
||||
commandImportes.Parameters.AddWithValue("@cantidad", importe.cantidad);
|
||||
commandImportes.Parameters.AddWithValue("@precio", importe.precioImporte);
|
||||
commandImportes.Parameters.AddWithValue("@fk_envio", idEnvio);
|
||||
commandImportes.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
transaccion.Commit();
|
||||
return true;
|
||||
}
|
||||
@@ -1345,6 +1412,31 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static SQLiteDataReader conseguirImporteEnvio(int idEnvio)
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
SQLiteConnection conexion = db_conexion.get_connection();
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "SELECT * FROM detalle_importe_envio where fk_envio = @idEnvio";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@idEnvio", idEnvio);
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
return reader;
|
||||
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
|
||||
public static SQLiteDataReader conseguirDetalleEnvioDAO(int idEnvio)
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
@@ -1515,7 +1607,7 @@ namespace compabetov2.database
|
||||
|
||||
}
|
||||
|
||||
public static bool concluirEnvioDAO(Envio envio, List<DetalleEnvioModel> detallesEnvio)
|
||||
public static bool concluirEnvioDAO(Envio envio, List<DetalleEnvioModel> detallesEnvio, List<DetalleImporteEnvio> importes)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
@@ -1534,6 +1626,7 @@ namespace compabetov2.database
|
||||
string sqlIdVenta = "SELECT idVenta FROM venta ORDER BY idVenta DESC LIMIT 1";
|
||||
string sqlStock = "select stock from Producto p where idproducto = @idProducto";
|
||||
string sqlActualizarStock = "UPDATE Producto set stock = @stock WHERE idproducto = @idProducto";
|
||||
string sqlImporte = "INSERT INTO detalle_importe (fk_importe, cantidad, precio, fk_venta) VALUES(@fk_importe, @cantidad, @precio, @fk_venta);";
|
||||
|
||||
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
|
||||
commandVenta.Parameters.AddWithValue("@fecha", DateTime.Now.ToString());
|
||||
@@ -1572,6 +1665,19 @@ namespace compabetov2.database
|
||||
commandActualizarStock.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
foreach(DetalleImporteEnvio importe in importes)
|
||||
{
|
||||
if (importe.cantidad != 0)
|
||||
{
|
||||
SQLiteCommand commandImporte = new SQLiteCommand(sqlImporte, conexion);
|
||||
commandImporte.Parameters.AddWithValue("@fk_importe", importe.fkImporte);
|
||||
commandImporte.Parameters.AddWithValue("@cantidad", importe.cantidad);
|
||||
commandImporte.Parameters.AddWithValue("@precio", importe.precioImporte);
|
||||
commandImporte.Parameters.AddWithValue("@fk_venta", idVenta);
|
||||
commandImporte.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
transaccion.Commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,16 @@ namespace compabetov2.database.modelos
|
||||
public class DetalleImporte
|
||||
{
|
||||
public int fkImporte;
|
||||
public int catidad;
|
||||
public int cantidad;
|
||||
public decimal precioImporte;
|
||||
public int fkVenta;
|
||||
|
||||
public DetalleImporte(int fkImporte, int cantidad, decimal precioImporte)
|
||||
public DetalleImporte(int fkImporte, int cantidad, decimal precioImporte, int fkVenta = -1)
|
||||
{
|
||||
this.fkImporte = fkImporte;
|
||||
this.catidad = cantidad;
|
||||
this.cantidad = cantidad;
|
||||
this.precioImporte = precioImporte;
|
||||
this.fkVenta = fkVenta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace compabetov2.database.modelos
|
||||
{
|
||||
public class DetalleImporteCuenta
|
||||
{
|
||||
public int fkImporte;
|
||||
public int cantidad;
|
||||
public decimal precioImporte;
|
||||
public int fkCuenta;
|
||||
|
||||
public DetalleImporteCuenta(int fkImporte, int cantidad, decimal precioImporte, int fkCuenta = -1)
|
||||
{
|
||||
this.fkImporte = fkImporte;
|
||||
this.cantidad = cantidad;
|
||||
this.precioImporte = precioImporte;
|
||||
this.fkCuenta = fkCuenta;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace compabetov2.database.modelos
|
||||
{
|
||||
public class DetalleImporteEnvio
|
||||
{
|
||||
public int fkImporte;
|
||||
public int cantidad;
|
||||
public decimal precioImporte;
|
||||
public int fkEnvio;
|
||||
|
||||
public DetalleImporteEnvio(int fkImporte, int cantidad, decimal precioImporte, int fkEnvio = -1)
|
||||
{
|
||||
this.fkImporte = fkImporte;
|
||||
this.cantidad = cantidad;
|
||||
this.precioImporte = precioImporte;
|
||||
this.fkEnvio = fkEnvio;
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
-11
@@ -222,9 +222,9 @@ namespace compabetov2.database
|
||||
return DAO.actualizarMermaDAO(merma);
|
||||
}
|
||||
|
||||
public static bool crearCuenta(Cuenta cuenta, List<DetalleCuentaModel> detalleCuentas)
|
||||
public static bool crearCuenta(Cuenta cuenta, List<DetalleCuentaModel> detalleCuentas, List<DetalleImporte> importes)
|
||||
{
|
||||
return DAO.crearCuentaDAO(cuenta, detalleCuentas);
|
||||
return DAO.crearCuentaDAO(cuenta, detalleCuentas, importes);
|
||||
}
|
||||
|
||||
public static List<Cuenta> conseguirCuentaDAO()
|
||||
@@ -273,14 +273,35 @@ namespace compabetov2.database
|
||||
return detallesCuentas;
|
||||
}
|
||||
|
||||
public static List<DetalleImporteCuenta> conseguirImportesCuenta(int idCuenta)
|
||||
{
|
||||
List<DetalleImporteCuenta> importes = new List<DetalleImporteCuenta>();
|
||||
|
||||
SQLiteDataReader reader = DAO.conseguirImportesCuentaDAO(idCuenta);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
int idImporte = (int)reader.GetInt64(1);
|
||||
DetalleImporteCuenta importe = new DetalleImporteCuenta(
|
||||
idImporte,
|
||||
(int)reader.GetInt64(2),//cantidad
|
||||
(int)reader.GetDecimal(3),// precio
|
||||
(int)reader.GetInt64(4)//fk_cuenta
|
||||
);
|
||||
importes.Add(importe);
|
||||
}
|
||||
|
||||
return importes;
|
||||
}
|
||||
|
||||
public static bool cancelarCuenta(int idCuenta)
|
||||
{
|
||||
return DAO.cancelarCuentaDAO(idCuenta);
|
||||
}
|
||||
|
||||
public static bool saldarCuenta(Cuenta cuenta, List<DetalleCuentaModel> detallesCuentas)
|
||||
public static bool saldarCuenta(Cuenta cuenta, List<DetalleCuentaModel> detallesCuentas, List<DetalleImporteCuenta> importes)
|
||||
{
|
||||
return DAO.saldarCuentaDAO(cuenta, detallesCuentas);
|
||||
return DAO.saldarCuentaDAO(cuenta, detallesCuentas, importes);
|
||||
}
|
||||
|
||||
/*public static Dictionary<string, dynamic> filtrarVentaFechaMes(DateTime fecha)
|
||||
@@ -314,18 +335,19 @@ namespace compabetov2.database
|
||||
return estadisticas;
|
||||
}*/
|
||||
|
||||
public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio)
|
||||
public static bool crearEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio, List<DetalleImporte> importes)
|
||||
{
|
||||
return DAO.crearEnvio(envio, detallesEnvio);
|
||||
return DAO.crearEnvio(envio, detallesEnvio,importes);
|
||||
}
|
||||
|
||||
public static List<Envio> conseguirEnvio()
|
||||
public static List<Dictionary<string, dynamic>> conseguirEnvio()
|
||||
{
|
||||
List<Envio> envios = new List<Envio>();
|
||||
List<Dictionary<string, dynamic>> envios = new List<Dictionary<string, dynamic>>();
|
||||
SQLiteDataReader reader = DAO.conseguirEnvioDAO();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
Dictionary<string,dynamic> dict = new Dictionary<string,dynamic>();
|
||||
decimal total = reader.GetDecimal(6);
|
||||
Envio envio = new Envio(
|
||||
(int)reader.GetInt64(0),
|
||||
@@ -338,7 +360,23 @@ namespace compabetov2.database
|
||||
total
|
||||
) ;
|
||||
|
||||
envios.Add(envio);
|
||||
dict.Add("envio", envio);
|
||||
|
||||
List<DetalleImporteEnvio> importes = new List<DetalleImporteEnvio>();
|
||||
SQLiteDataReader readerImporte = DAO.conseguirImporteEnvio(envio.id);
|
||||
while (readerImporte.Read())
|
||||
{
|
||||
decimal precio = readerImporte.GetDecimal(3);
|
||||
importes.Add(new DetalleImporteEnvio(
|
||||
(int)readerImporte.GetInt64(1),//id
|
||||
(int)readerImporte.GetInt64(2),//cantidad
|
||||
precio,//precio
|
||||
(int)readerImporte.GetInt64(4)//fk_envio
|
||||
));
|
||||
}
|
||||
|
||||
dict.Add("importes",importes);
|
||||
envios.Add(dict);
|
||||
}
|
||||
|
||||
return envios;
|
||||
@@ -375,9 +413,9 @@ namespace compabetov2.database
|
||||
return DAO.cancelarEnvioDAO(envio, detalles);
|
||||
}
|
||||
|
||||
public static bool concluirEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio)
|
||||
public static bool concluirEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio, List<DetalleImporteEnvio> importes)
|
||||
{
|
||||
return DAO.concluirEnvioDAO(envio, detallesEnvio);
|
||||
return DAO.concluirEnvioDAO(envio, detallesEnvio, importes);
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<Dictionary<string,dynamic>>> estadisticas(DateTime fecha)
|
||||
|
||||
Reference in New Issue
Block a user