bajo cambios 20012024a
This commit is contained in:
+60
-51
@@ -103,8 +103,15 @@ namespace compabetov2
|
||||
btnMenos.Anchor = AnchorStyles.None;
|
||||
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
int numeroContador = int.Parse(txtStockAgregar.Text);
|
||||
txtStockAgregar.Text = (numeroContador - 1).ToString();
|
||||
try
|
||||
{
|
||||
int numeroContador = int.Parse(txtStockAgregar.Text);
|
||||
txtStockAgregar.Text = (numeroContador - 1).ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
txtStockAgregar.Text = "0";
|
||||
}
|
||||
});
|
||||
|
||||
Button btnMas = new Button();
|
||||
@@ -119,8 +126,15 @@ namespace compabetov2
|
||||
btnMas.Anchor = AnchorStyles.None;
|
||||
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
int numeroContador = int.Parse(txtStockAgregar.Text);
|
||||
txtStockAgregar.Text = (numeroContador + 1).ToString();
|
||||
try
|
||||
{
|
||||
int numeroContador = int.Parse(txtStockAgregar.Text);
|
||||
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)
|
||||
{
|
||||
/*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,44 +171,51 @@ namespace compabetov2
|
||||
private void button6_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
List<Producto> stockNuevo = new List<Producto>();
|
||||
foreach(Control control in stockPanel.Controls)
|
||||
{
|
||||
TableLayoutPanel informacionProducto = control.Controls[0] as TableLayoutPanel;
|
||||
TableLayoutPanel agregarPanel = control.Controls[1] as TableLayoutPanel;
|
||||
|
||||
//id
|
||||
Label lbIdProducto = informacionProducto.Controls[0].Controls[0] as Label;
|
||||
int idProducto = int.Parse(lbIdProducto.Text);
|
||||
|
||||
//stock a agregar
|
||||
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
|
||||
int stock = int.Parse(txtStock.Text);
|
||||
|
||||
if(stock > 0) {
|
||||
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
|
||||
stockNuevo.Add(productoStockNuuevo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
|
||||
for(int i = 0; i < stockNuevo.Count; i++)
|
||||
{
|
||||
|
||||
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(stockNuevo.Count > 0)
|
||||
{
|
||||
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
try {
|
||||
foreach (Control control in stockPanel.Controls)
|
||||
{
|
||||
service.aumentarStock(stockNuevo);
|
||||
llenarPanel();
|
||||
TableLayoutPanel informacionProducto = control.Controls[0] as TableLayoutPanel;
|
||||
TableLayoutPanel agregarPanel = control.Controls[1] as TableLayoutPanel;
|
||||
|
||||
//id
|
||||
Label lbIdProducto = informacionProducto.Controls[0].Controls[0] as Label;
|
||||
int idProducto = int.Parse(lbIdProducto.Text);
|
||||
|
||||
//stock a agregar
|
||||
TextBox txtStock = agregarPanel.Controls[0] as TextBox;
|
||||
int stock = int.Parse(txtStock.Text);
|
||||
|
||||
if (stock != 0)
|
||||
{
|
||||
Producto productoStockNuuevo = new Producto(idProducto, "", "", 0, "", stock, null);
|
||||
stockNuevo.Add(productoStockNuuevo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
string mensajeConfirmacion = "Se aumentara el stock a los\nsiguientes productos\n";
|
||||
for (int i = 0; i < stockNuevo.Count; i++)
|
||||
{
|
||||
|
||||
mensajeConfirmacion += productos[i].nombre + ": " + stockNuevo[i].stock + "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (stockNuevo.Count > 0)
|
||||
{
|
||||
DialogResult result = MessageBox.Show(mensajeConfirmacion, "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
service.aumentarStock(stockNuevo);
|
||||
llenarPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex) {
|
||||
MessageBox.Show("Solo debe introducir numeros","Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user