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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user