importe en venta hecho
This commit is contained in:
+57
-8
@@ -30,6 +30,7 @@ namespace compabetov2
|
||||
private LoginModel loginPrincipal;
|
||||
private Dictionary<string, Image> imagenes = new Dictionary<string, Image>();
|
||||
private List<DetalleVentaModel> carrito = new List<DetalleVentaModel>();
|
||||
public List<DetalleImporte> importes = new List<DetalleImporte>();
|
||||
|
||||
|
||||
public vender(LoginModel loginPrincipal)
|
||||
@@ -173,7 +174,7 @@ namespace compabetov2
|
||||
{
|
||||
contador.Text = (numeroContador - 1).ToString();
|
||||
total -= producto.precio;
|
||||
label1.Text = $"Total: ${total}";
|
||||
label1.Text = $"Total: ${total} - Importe: $";
|
||||
|
||||
// Obtener información del Label id y precio
|
||||
decimal precioProducto = producto.precio;
|
||||
@@ -214,7 +215,7 @@ namespace compabetov2
|
||||
int numeroContador = int.Parse(contador.Text.ToString());
|
||||
contador.Text = (numeroContador + 1).ToString();
|
||||
total += producto.precio;
|
||||
label1.Text = $"Total: ${total}";
|
||||
label1.Text = $"Total: ${total} - Importe:";
|
||||
|
||||
// Obtener información del Label id y precio
|
||||
int idProducto = int.Parse(id.Text);
|
||||
@@ -526,17 +527,18 @@ namespace compabetov2
|
||||
if (resultado == DialogResult.Yes)
|
||||
{
|
||||
VentaModel ventaModel = new VentaModel(total, -1, "",
|
||||
responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text
|
||||
responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text,
|
||||
0
|
||||
);
|
||||
|
||||
if (service.crearVentaDAO(ventaModel, carrito))
|
||||
|
||||
if (service.crearVentaDAO(ventaModel, carrito, importes))
|
||||
{
|
||||
MessageBox.Show("Venta hecha");
|
||||
ImprimirTicket();
|
||||
eliminarProductosTocket();
|
||||
llenarLayout();
|
||||
total = 0;
|
||||
|
||||
importes.Clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -547,7 +549,33 @@ namespace compabetov2
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No hay ningun producto agregado");
|
||||
if(importes.Count > 0)
|
||||
{
|
||||
if (total < 0)
|
||||
{
|
||||
DialogResult resultado = MessageBox.Show("¿Quieres hacer la devolucion del importe?", "Confirmación devolucion de importe", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (resultado == DialogResult.Yes)
|
||||
{
|
||||
if (service.devolverImporte(importes))
|
||||
{
|
||||
MessageBox.Show("Importe devuelto");
|
||||
llenarLayout();
|
||||
total = 0;
|
||||
importes.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MessageBox.Show("No puede vender un importe sin seleccionar un producto");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No hay ningun producto agregado");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -826,7 +854,7 @@ namespace compabetov2
|
||||
c.Dispose();
|
||||
flowLayoutPanel1.Controls.Remove(c);
|
||||
}
|
||||
label1.Text = "Total: 0";
|
||||
label1.Text = "Total: 0 - Importe: 0";
|
||||
|
||||
txtbusqueda.Text = "";
|
||||
carrito.Clear();
|
||||
@@ -838,5 +866,26 @@ namespace compabetov2
|
||||
estadiscticas.Owner = this;
|
||||
estadiscticas.Show();
|
||||
}
|
||||
|
||||
private void btnImporte_Click(object sender, EventArgs e)
|
||||
{
|
||||
Importe1 importe = new Importe1(this);
|
||||
importe.Owner = this;
|
||||
importe.Show();
|
||||
}
|
||||
|
||||
public void actualizarImporteTotal()
|
||||
{
|
||||
string mensaje = "";
|
||||
decimal totalImporte = 0;
|
||||
foreach(DetalleImporte importe in importes)
|
||||
{
|
||||
totalImporte += importe.precioImporte * importe.catidad;
|
||||
mensaje += $"importe: {importe.fkImporte} - cantidad: {importe.catidad}\n";
|
||||
}
|
||||
MessageBox.Show(mensaje);
|
||||
total += totalImporte;
|
||||
label1.Text = $"Total: ${total}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user