corregi bug del desplazamiento

This commit is contained in:
Michael Robles
2024-06-18 16:51:43 -07:00
22 changed files with 302 additions and 57 deletions
+4 -2
View File
@@ -1,7 +1,9 @@
{
"ExpandedNodes": [
""
"",
"\\database",
"\\Ventas"
],
"SelectedNode": "\\Solution.sln",
"SelectedNode": "\\database\\DAO.cs",
"PreviewInSolutionExplorer": false
}
+18 -1
View File
@@ -116,11 +116,20 @@ namespace compabetov2
btnVer.Click += new EventHandler(delegate (object sender, EventArgs e)
{
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
List<DetalleImporteCuenta> importes = service.conseguirImportesCuenta(cuenta.id);
string mensaje = $"Cliente: {cuenta.cliente}\n";
foreach (DetalleCuentaModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
}
decimal totalImporte = 0;
foreach (DetalleImporteCuenta importe in importes)
{
totalImporte += importe.cantidad * importe.precioImporte;
}
mensaje += $"Importe: {totalImporte}\n";
MessageBox.Show(mensaje);
});
@@ -139,7 +148,8 @@ namespace compabetov2
if (result == DialogResult.Yes)
{
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
if (service.saldarCuenta(cuenta, detalles))
List<DetalleImporteCuenta> importes = service.conseguirImportesCuenta(cuenta.id);
if (service.saldarCuenta(cuenta, detalles, importes))
{
llenarPanel();
}
@@ -196,11 +206,18 @@ namespace compabetov2
btnVer.Click += new EventHandler(delegate (object sender, EventArgs e)
{
List<DetalleCuentaModel> detalles = service.conseguirDetalleCuante(cuenta.id);
List<DetalleImporteCuenta> importes = service.conseguirImportesCuenta(cuenta.id);
string mensaje = $"Cliente: {cuenta.cliente}\n";
foreach (DetalleCuentaModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
}
decimal totalImporte = 0;
foreach (DetalleImporteCuenta importe in importes)
{
totalImporte += importe.cantidad * importe.precioImporte;
}
mensaje += $"Importe: {totalImporte}\n";
MessageBox.Show(mensaje);
});
+13 -3
View File
@@ -68,9 +68,10 @@ namespace compabetov2
private void llenarPanel()
{
panelEnvio.Controls.Clear();
List<Envio> envios = service.conseguirEnvio();
foreach(Envio envio in envios)
List<Dictionary<string, dynamic>> envios_importes_list = service.conseguirEnvio();
foreach(Dictionary<string, dynamic> envio_importes in envios_importes_list)
{
Envio envio = envio_importes["envio"];
if (envio.estado.Equals("EN PROCESO"))
{
TableLayoutPanel carta = new TableLayoutPanel();
@@ -133,11 +134,20 @@ namespace compabetov2
{
List<DetalleEnvioModel> detalles = service.conseguirDetalleEnvio(envio.id);
string mensaje = "";
decimal cantidadImportes = 0;
foreach (DetalleEnvioModel detalle in detalles)
{
mensaje += $"{detalle.producto.nombre} - {detalle.cantidad}\n";
foreach(DetalleImporteEnvio importe in envio_importes["importes"])
{
cantidadImportes = importe.cantidad * importe.precioImporte;
}
}
mensaje += $"Importe: {cantidadImportes}\n";
mensaje += $"Total: {envio.total}";
MessageBox.Show(mensaje);
});
@@ -156,7 +166,7 @@ namespace compabetov2
if (result == DialogResult.Yes)
{
List<DetalleEnvioModel> detalles = service.conseguirDetalleEnvio(envio.id);
if (service.concluirEnvio(envio, detalles))
if (service.concluirEnvio(envio, detalles, envio_importes["importes"]))
{
llenarPanel();
ImprimirTicketConcluido(envio);
+1 -1
View File
@@ -156,7 +156,7 @@ namespace compabetov2.Ventas
private void modificarCantidad(int cantidad, int idImporte)
{
detalles[idImporte-1].catidad = cantidad;
detalles[idImporte-1].cantidad = cantidad;
}
private void Importe1_Load(object sender, EventArgs e)
+5 -2
View File
@@ -17,12 +17,14 @@ namespace compabetov2.Ventas
private Cuenta ventaModel;
private List<DetalleCuentaModel> detalles;
private vender ventanaPadre;
public datosCuenta(Cuenta ventaModel, List<DetalleCuentaModel> detalles, vender ventanaPadre)
private List<DetalleImporte> importes;
public datosCuenta(Cuenta ventaModel, List<DetalleCuentaModel> detalles, List<DetalleImporte> importes, vender ventanaPadre)
{
InitializeComponent();
this.ventaModel = ventaModel;
this.detalles = detalles;
this.ventanaPadre = ventanaPadre;
this.importes = importes;
}
private void datosCuenta_Load(object sender, EventArgs e)
@@ -33,12 +35,13 @@ namespace compabetov2.Ventas
private void btnAceptar_Click(object sender, EventArgs e)
{
ventaModel.cliente = txtCliente.Text;
if (service.crearCuenta(ventaModel, detalles))
if (service.crearCuenta(ventaModel, detalles, importes))
{
MessageBox.Show("Fiado");
ventanaPadre.eliminarProductosTocket();
ventanaPadre.llenarLayout();
ventanaPadre.total = 0;
ventanaPadre.importes.Clear();
Close();
}
}
+7 -4
View File
@@ -21,13 +21,15 @@ namespace compabetov2.Ventas
public string Telefono => txtTelefono.Text;
private Envio envio;
List<DetalleEnvioModel> detallesEnvio;
List<DetalleImporte> importes;
vender ventanaPadre;
public datosEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio, vender ventanaPadre)
public datosEnvio(Envio envio, List<DetalleEnvioModel> detallesEnvio, List<DetalleImporte> importes, vender ventanaPadre)
{
InitializeComponent();
this.envio = envio;
this.detallesEnvio = detallesEnvio;
this.ventanaPadre = ventanaPadre;
this.importes = importes;
txtTelefono.KeyPress += new KeyPressEventHandler(txtTelefono_KeyPress);
}
@@ -38,14 +40,15 @@ namespace compabetov2.Ventas
envio.cliente = txtCliente.Text;
envio.direccion = txtDireccion.Text;
envio.telefono = txtTelefono.Text;
if (service.crearEnvio(envio, detallesEnvio))
if (service.crearEnvio(envio, detallesEnvio, importes))
{
MessageBox.Show("Envio hecho");
ImprimirTicketEnvio();
ventanaPadre.eliminarProductosTocket();
ventanaPadre.llenarLayout();
ventanaPadre.total = 0;
ventanaPadre.importes.Clear();
this.Close();
}
}
@@ -197,7 +200,7 @@ namespace compabetov2.Ventas
envio.cliente = txtCliente.Text;
envio.direccion = txtDireccion.Text;
envio.telefono = txtTelefono.Text;
if (service.crearEnvio(envio, detallesEnvio))
if (service.crearEnvio(envio, detallesEnvio, importes))
{
MessageBox.Show("Envio hecho");
ImprimirTicketEnvio();
+6 -4
View File
@@ -75,7 +75,9 @@ namespace compabetov2
private void FlowLayoutPanel3_MouseUp(object sender, MouseEventArgs e)
{
flowLayoutPanel3.Capture = false;
lastPoint = new Point(e.X, e.Y);
flowLayoutPanel3.Capture = true;
}
@@ -777,7 +779,7 @@ namespace compabetov2
{
Cuenta ventaModel = new Cuenta(total);
datosCuenta datoCuenta = new datosCuenta(ventaModel, detallesCuenta, this);
datosCuenta datoCuenta = new datosCuenta(ventaModel, detallesCuenta,importes, this);
datoCuenta.Show();
}
@@ -837,7 +839,7 @@ namespace compabetov2
Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable, "", "", total);
if (detallesEnvio.Count > 0)
{
datosEnvio datosEnvio = new datosEnvio(envio, detallesEnvio, this);
datosEnvio datosEnvio = new datosEnvio(envio, detallesEnvio,importes ,this);
datosEnvio.Show();
}
else
@@ -879,7 +881,7 @@ namespace compabetov2
decimal totalImporte = 0;
foreach(DetalleImporte importe in importes)
{
totalImporte += importe.precioImporte * importe.catidad;
totalImporte += importe.precioImporte * importe.cantidad;
}
total += totalImporte;
label1.Text = $"Total: ${total}";
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+2
View File
@@ -108,6 +108,8 @@
<ItemGroup>
<Compile Include="database\modelos\DetalleEnvioModel.cs" />
<Compile Include="database\modelos\DetalleImporte.cs" />
<Compile Include="database\modelos\DetalleImporteCuenta.cs" />
<Compile Include="database\modelos\DetalleImporteEnvio.cs" />
<Compile Include="database\modelos\Envio.cs" />
<Compile Include="database\modelos\ImporteModel.cs" />
<Compile Include="database\modelos\Variante.cs" />
+125 -15
View File
@@ -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();
@@ -752,11 +752,11 @@ namespace compabetov2.database
try
{
string sqlVenta = "INSERT INTO venta (fecha, total,responzable) VALUES(@fecha, @total,@responzable);";
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_variante, cantidad) VALUES(@idVenta, @fk_variante, @cantidada);";
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_variante, cantidad,precioCompra,precioVenta) VALUES(@idVenta, @fk_variante, @cantidada,@precioCompra,@precioVenta);";
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);
@@ -782,6 +782,8 @@ namespace compabetov2.database
commandEmpleado.Parameters.AddWithValue("@idVenta", idVenta);
commandEmpleado.Parameters.AddWithValue("@fk_variante", detalleVenta.producto.idVariante);
commandEmpleado.Parameters.AddWithValue("@cantidada", detalleVenta.cantidad);
commandEmpleado.Parameters.AddWithValue("@precioCompra", detalleVenta.producto.precioCompra);
commandEmpleado.Parameters.AddWithValue("@precioVenta", detalleVenta.producto.precio);
commandEmpleado.ExecuteNonQuery();
SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion);
@@ -807,13 +809,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 +856,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 +970,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 +988,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 +1032,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 +1089,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 +1153,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 +1170,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 +1200,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 +1308,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
@@ -1272,8 +1327,9 @@ namespace compabetov2.database
try
{
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 sqlDetalle = "INSERT INTO detalle_envios (fk_envios, fk_variante, cantidad,precioVenta,precioCompra) VALUES(@fk_envios, @fk_variante, @cantidad, @precioVenta,@precioCompra);";
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);
@@ -1299,9 +1355,24 @@ namespace compabetov2.database
commandDetalle.Parameters.AddWithValue("@fk_envios", idEnvio);
commandDetalle.Parameters.AddWithValue("@fk_variante", detalleEnvio.producto.idVariante);
commandDetalle.Parameters.AddWithValue("@cantidad", detalleEnvio.cantidad);
commandDetalle.Parameters.AddWithValue("@precioVenta", detalleEnvio.producto.precio);
commandDetalle.Parameters.AddWithValue("@precioCompra", detalleEnvio.producto.precioCompra);
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 +1416,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 +1611,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 +1630,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 +1669,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;
}
+5 -3
View File
@@ -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;
}
}
}
+24
View File
@@ -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;
}
}
}
+24
View File
@@ -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;
}
}
}
+1
View File
@@ -13,6 +13,7 @@ namespace compabetov2.database.modelos
public Variante producto;
public decimal total;
public DetalleVentaModel(int cantidad, Variante producto, int id = -1, decimal total = 0)
{
this.cantidad = cantidad;
+3 -1
View File
@@ -14,8 +14,9 @@ namespace compabetov2.database.modelos
public int cantidad;
public string img;
public int fkProducto;
public decimal precioCompra;
public Variante(int idVariante, string nombre, decimal precio, int cantidad, string img, int fkProducto)
public Variante(int idVariante, string nombre, decimal precio, int cantidad, string img, int fkProducto,decimal precioCompra)
{
this.idVariante = idVariante;
this.nombre = nombre;
@@ -23,6 +24,7 @@ namespace compabetov2.database.modelos
this.cantidad = cantidad;
this.img = img;
this.fkProducto = fkProducto;
this.precioCompra = precioCompra;
}
}
}
+63 -20
View File
@@ -45,10 +45,7 @@ namespace compabetov2.database
while (reader.Read())
{
Categoria categoria = new Categoria(
int.Parse(reader["idcategoria"].ToString()),
reader["nombre"].ToString(),
reader["descripcion"].ToString());
Categoria categoria = new Categoria();
Producto producto = new Producto(
int.Parse(reader["idproducto"].ToString()),
@@ -222,9 +219,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()
@@ -263,8 +260,9 @@ namespace compabetov2.database
while (reader.Read())
{
int idVariaante = (int)reader.GetInt64(0);
decimal precioCompra = reader.GetOrdinal("precioCompra");
DetalleCuentaModel detalleCuenta = new DetalleCuentaModel(
new Variante(idVariaante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"",(int)reader.GetInt64(3)),
new Variante(idVariaante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"",(int)reader.GetInt64(3), precioCompra),
(int)reader.GetInt64(4)
);
detallesCuentas.Add(detalleCuenta);
@@ -273,14 +271,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 +333,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 +358,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;
@@ -353,9 +389,10 @@ namespace compabetov2.database
while (reader.Read())
{
int idVariante = (int)reader.GetInt64(0);
decimal precioCompra = reader.GetOrdinal("precioCompra");
DetalleEnvioModel detalleEnvio = new DetalleEnvioModel(
idEnvio,
new Variante(idVariante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"", (int)reader.GetInt64(3)),//fkproducto
new Variante(idVariante, reader["nombre"].ToString(),0,(int)reader.GetInt64(2),"", (int)reader.GetInt64(3), precioCompra),//fkproducto
(int)reader.GetInt64(4)//cantidad
);
detallesEnvio.Add(detalleEnvio);
@@ -375,9 +412,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)
@@ -403,6 +440,7 @@ namespace compabetov2.database
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),
@@ -410,7 +448,8 @@ namespace compabetov2.database
readerDetalleVenta.GetDecimal(5),
(int)readerDetalleVenta.GetInt64(6),
"",
(int)readerDetalleVenta.GetInt64(8))
(int)readerDetalleVenta.GetInt64(8),
precioCompra)
);
detallesVenta.Add( detalleVenta );
}
@@ -449,6 +488,7 @@ namespace compabetov2.database
int cantidadIndex = reader.GetOrdinal("cantidad");
int imgIndex = reader.GetOrdinal("img");
int fkProductoIndex = reader.GetOrdinal("fk_producto");
decimal precioCompra = reader.GetOrdinal("precioCompra");
while (reader.Read())
{
@@ -459,7 +499,8 @@ namespace compabetov2.database
reader.GetDecimal(precioIndex),
reader.GetInt32(cantidadIndex),
reader.GetString(imgIndex),
reader.GetInt32(fkProductoIndex)
reader.GetInt32(fkProductoIndex),
precioCompra
);
productos.Add(producto);
@@ -505,6 +546,7 @@ namespace compabetov2.database
while (reader.Read())
{
decimal precio = reader.GetDecimal(2);
decimal precioCompra = reader.GetDecimal(6);
int cantidad = (int)reader.GetInt64(3);
int fkProducto = (int)reader.GetInt64(5);
Variante vaiante = new Variante(
@@ -513,7 +555,8 @@ namespace compabetov2.database
precio,
cantidad,
reader["img"].ToString(),
fkProducto
fkProducto,
precioCompra
);
variantes.Add(vaiante);
}
@@ -1 +1 @@
7b47ab10239919af7b32ed2b287710792024b987ca7846a8d66ef868f8836793
589875dc9085d077e48293cb909f4ec97a14e8901c3e585e6068a4b13e6e810b
Binary file not shown.
Binary file not shown.
Binary file not shown.