
Unificar Codigo
Publicado por Fede (5 intervenciones) el 28/06/2023 12:55:40
Hola Foro estoy tratando de unificar en un solo boton el codigo, pero no logro.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
private void btnagregarproducto_Click(object sender, EventArgs e)
{if (_producto == null)
{MessageBox.Show("Debe ingresar un producto", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
} decimal precioventa = 0; decimal subtotal = 0;if (!decimal.TryParse(txtprecioventa.Text , out precioventa))
{MessageBox.Show("Error al convertir internamente el tipo de moneda - Precio Venta\nEjemplo Formato ##.##", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}string mensaje = string.Empty;
int operaciones = VentaLogica.Instancia.reducirStock(_producto.IdProducto, Convert.ToInt32(txtcantidad.Value.ToString()), out mensaje);
if (operaciones > 0)
{subtotal = Convert.ToDecimal(txtcantidad.Value.ToString()) * Convert.ToDecimal(txtprecioventa.Text);
dgvdata.Rows.Add(new object[] {
_producto.IdProducto.ToString(),
_producto.Codigo,
_producto.Descripcion,
_producto.Familia,
txtcantidad.Value.ToString(),
precioventa.ToString("0.00"),
subtotal.ToString("0.00")
});
calcularTotal();
_producto = null;txtcodproducto.Text = "";
txtcodproducto.BackColor = Color.White;
txtproducto.Text = "";
txtstock.Text = "";
txtprecioventa.Text = "";
txtcantidad.Value = 1;
txtcodproducto.Select();
}else
{MessageBox.Show(mensaje, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
} }private void btnagregarcombo_Click(object sender, EventArgs e)
{if (_combo == null)
{MessageBox.Show("Debe ingresar un combo", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}string familia = "";
decimal precioventa = 0; decimal subtotal = 0;if (!decimal.TryParse(txtprecioventa.Text, out precioventa))
{MessageBox.Show("Error al convertir internamente el tipo de moneda - Precio Venta\nEjemplo Formato ##.##", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}string mensaje = string.Empty;
int operaciones = VentaLogica.Instancia.reducirStockCombo(_combo.IdCombo, Convert.ToInt32(txtcantidad.Value.ToString()), out mensaje);
if (operaciones > 0)
{subtotal = Convert.ToDecimal(txtcantidad.Value.ToString()) * Convert.ToDecimal(txtprecioventa.Text);
dgvdata.Rows.Add(new object[] {
_combo.IdCombo.ToString(),
_combo.Codigo,
_combo.Descripcion,
Familia,txtcantidad.Value.ToString(),
precioventa.ToString("0.00"),
subtotal.ToString("0.00")
});
calcularTotal();
_combo = null;txtcodproducto.Text = "";
txtcodproducto.BackColor = Color.White;
txtproducto.Text = "";
txtstock.Text = "";
txtprecioventa.Text = "";
txtcantidad.Value = 1;
txtcodproducto.Select();
}else
{MessageBox.Show(mensaje, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
} }Valora esta pregunta


0