bajo cambios 20012024a
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
"ExpandedNodes": [
|
"ExpandedNodes": [
|
||||||
""
|
""
|
||||||
],
|
],
|
||||||
|
<<<<<<< HEAD
|
||||||
"SelectedNode": "\\agregarmermas.cs",
|
"SelectedNode": "\\agregarmermas.cs",
|
||||||
|
=======
|
||||||
|
"SelectedNode": "\\vender.cs",
|
||||||
|
>>>>>>> 53dd047ba99d9fe2f8dc36472f5d1441d992e695
|
||||||
"PreviewInSolutionExplorer": false
|
"PreviewInSolutionExplorer": false
|
||||||
}
|
}
|
||||||
+35
-1
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.SQLite;
|
using System.Data.SQLite;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
@@ -534,9 +535,22 @@ namespace compabetov2.database
|
|||||||
foreach (var item in stockNuevo)
|
foreach (var item in stockNuevo)
|
||||||
{
|
{
|
||||||
string sql = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto;";
|
string sql = "UPDATE Producto SET stock = @stock WHERE idproducto = @idproducto;";
|
||||||
|
string sqlProductoStock = "SELECT stock FROM Producto WHERE idproducto = @idproducto";
|
||||||
|
|
||||||
|
SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion);
|
||||||
|
commandProdcutoStock.Parameters.AddWithValue("@idproducto", item.idProducto);
|
||||||
|
SQLiteDataReader stockReader = commandProdcutoStock.ExecuteReader();
|
||||||
|
|
||||||
|
int stockActual = -1;
|
||||||
|
while (stockReader.Read())
|
||||||
|
{
|
||||||
|
stockActual = int.Parse(stockReader["stock"].ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||||
command.Parameters.AddWithValue("@idproducto", item.idProducto);
|
command.Parameters.AddWithValue("@idproducto", item.idProducto);
|
||||||
command.Parameters.AddWithValue("@stock", item.stock);
|
command.Parameters.AddWithValue("@stock", stockActual + item.stock);
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -767,6 +781,8 @@ namespace compabetov2.database
|
|||||||
string sqlVenta = "INSERT INTO venta (fecha, total) VALUES(@fecha, @total);";
|
string sqlVenta = "INSERT INTO venta (fecha, total) VALUES(@fecha, @total);";
|
||||||
string sqlDetalle = "INSERT INTO detalle_venta (fk_venta, fk_producto, cantidad) VALUES(@idVenta, @idProducto, @cantidada);";
|
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 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";
|
||||||
|
|
||||||
|
|
||||||
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
|
SQLiteCommand commandVenta = new SQLiteCommand(sqlVenta, conexion);
|
||||||
@@ -790,6 +806,24 @@ namespace compabetov2.database
|
|||||||
commandEmpleado.Parameters.AddWithValue("@idProducto", detalleVenta.producto.idProducto);
|
commandEmpleado.Parameters.AddWithValue("@idProducto", detalleVenta.producto.idProducto);
|
||||||
commandEmpleado.Parameters.AddWithValue("@cantidada", detalleVenta.cantidad);
|
commandEmpleado.Parameters.AddWithValue("@cantidada", detalleVenta.cantidad);
|
||||||
commandEmpleado.ExecuteNonQuery();
|
commandEmpleado.ExecuteNonQuery();
|
||||||
|
|
||||||
|
SQLiteCommand commandProdcutoStock = new SQLiteCommand(sqlProductoStock, conexion);
|
||||||
|
commandProdcutoStock.Parameters.AddWithValue("@idproducto", detalleVenta.producto.idProducto);
|
||||||
|
SQLiteDataReader stockReader = commandProdcutoStock.ExecuteReader();
|
||||||
|
|
||||||
|
int stockActual = -1;
|
||||||
|
while (stockReader.Read())
|
||||||
|
{
|
||||||
|
stockActual = int.Parse(stockReader["stock"].ToString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLiteCommand commandProdcutoUpdate = new SQLiteCommand(sqlProductoUpdate, conexion);
|
||||||
|
commandProdcutoUpdate.Parameters.AddWithValue("@stock", stockActual - detalleVenta.cantidad);
|
||||||
|
commandProdcutoUpdate.Parameters.AddWithValue("@idproducto", detalleVenta.producto.idProducto);
|
||||||
|
commandProdcutoUpdate.ExecuteNonQuery();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transaccion.Commit();
|
transaccion.Commit();
|
||||||
|
|||||||
+25
-16
@@ -102,9 +102,16 @@ namespace compabetov2
|
|||||||
btnMenos.BackColor = Color.FromArgb(33, 90, 255);
|
btnMenos.BackColor = Color.FromArgb(33, 90, 255);
|
||||||
btnMenos.Anchor = AnchorStyles.None;
|
btnMenos.Anchor = AnchorStyles.None;
|
||||||
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
|
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
int numeroContador = int.Parse(txtStockAgregar.Text);
|
int numeroContador = int.Parse(txtStockAgregar.Text);
|
||||||
txtStockAgregar.Text = (numeroContador - 1).ToString();
|
txtStockAgregar.Text = (numeroContador - 1).ToString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
txtStockAgregar.Text = "0";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button btnMas = new Button();
|
Button btnMas = new Button();
|
||||||
@@ -118,9 +125,16 @@ namespace compabetov2
|
|||||||
btnMas.FlatAppearance.BorderSize = 0;
|
btnMas.FlatAppearance.BorderSize = 0;
|
||||||
btnMas.Anchor = AnchorStyles.None;
|
btnMas.Anchor = AnchorStyles.None;
|
||||||
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
|
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
int numeroContador = int.Parse(txtStockAgregar.Text);
|
int numeroContador = int.Parse(txtStockAgregar.Text);
|
||||||
txtStockAgregar.Text = (numeroContador + 1).ToString();
|
txtStockAgregar.Text = (numeroContador + 1).ToString();
|
||||||
|
}catch (Exception ex)
|
||||||
|
{
|
||||||
|
txtStockAgregar.Text = "0";
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -149,19 +163,7 @@ namespace compabetov2
|
|||||||
|
|
||||||
private void button6_Click(object sender, EventArgs e)
|
private void button6_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
/*Categoria categoria = new Categoria(comboBox1.SelectedIndex + 1);
|
|
||||||
Producto producto = new Producto(
|
|
||||||
0,
|
|
||||||
txtnombreproducto.Text,
|
|
||||||
txtdescripcionproducto.Text,
|
|
||||||
decimal.Parse(txtprecioproducto.Text),
|
|
||||||
"",
|
|
||||||
int.Parse(txtstockproducto.Text),
|
|
||||||
categoria);
|
|
||||||
if (service.insertarProducto(producto)) {
|
|
||||||
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -169,7 +171,8 @@ namespace compabetov2
|
|||||||
private void button6_Click_1(object sender, EventArgs e)
|
private void button6_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
List<Producto> stockNuevo = new List<Producto>();
|
List<Producto> stockNuevo = new List<Producto>();
|
||||||
foreach(Control control in stockPanel.Controls)
|
try {
|
||||||
|
foreach (Control control in stockPanel.Controls)
|
||||||
{
|
{
|
||||||
TableLayoutPanel informacionProducto = control.Controls[0] as TableLayoutPanel;
|
TableLayoutPanel informacionProducto = control.Controls[0] as TableLayoutPanel;
|
||||||
TableLayoutPanel agregarPanel = control.Controls[1] as TableLayoutPanel;
|
TableLayoutPanel agregarPanel = control.Controls[1] as TableLayoutPanel;
|
||||||
@@ -182,7 +185,8 @@ namespace compabetov2
|
|||||||
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
|
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
|
||||||
int stock = int.Parse(txtStock.Text);
|
int stock = int.Parse(txtStock.Text);
|
||||||
|
|
||||||
if(stock > 0) {
|
if (stock != 0)
|
||||||
|
{
|
||||||
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
|
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
|
||||||
stockNuevo.Add(productoStockNuuevo);
|
stockNuevo.Add(productoStockNuuevo);
|
||||||
}
|
}
|
||||||
@@ -190,7 +194,7 @@ namespace compabetov2
|
|||||||
}
|
}
|
||||||
|
|
||||||
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
|
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
|
||||||
for(int i = 0; i < stockNuevo.Count; i++)
|
for (int i = 0; i < stockNuevo.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
|
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
|
||||||
@@ -198,7 +202,7 @@ namespace compabetov2
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(stockNuevo.Count > 0)
|
if (stockNuevo.Count > 0)
|
||||||
{
|
{
|
||||||
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
@@ -207,6 +211,11 @@ namespace compabetov2
|
|||||||
llenarPanel();
|
llenarPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
|
MessageBox.Show("Solo debe introducir numeros","Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user