-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrmModificar.cs
More file actions
138 lines (121 loc) · 5.08 KB
/
Copy pathFrmModificar.cs
File metadata and controls
138 lines (121 loc) · 5.08 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace pizza
{
public partial class FrmModificar : Form
{
bool existencia = false;
int indice;
public void calcular()
{
txtbPrecio.Text = Convert.ToString((nudSize.Value * 150) * (nudCantidad.Value));
}
public FrmModificar()
{
InitializeComponent();
txtbNombreCliente.Enabled = true;
nudId.Enabled = true;
btnBuscar.Enabled = true;
}
private void btnBuscar_Click(object sender, EventArgs e)
{
foreach(ClsPizza pizza in FrmMenuPrincipal.ListaPizza)
{
if (pizza.Id == nudId.Value && pizza.Cliente == txtbNombreCliente.Text)
{
txtbCliente.Enabled = true;
cmbbDescripcion.Enabled = true;
nudCantidad.Enabled = true;
nudSize.Enabled = true;
txtbNombreCliente.Enabled = false;
nudId.Enabled = false;
txtbCliente.Text = pizza.Cliente;
cmbbDescripcion.Text = pizza.Descripcion;
nudCantidad.Value = pizza.Cantidad;
nudSize.Value = pizza.Size;
txtbPrecio.Text = Convert.ToString(pizza.Precio);
existencia = true;
btnBuscar.Enabled = false;
btnAgregar.Enabled = true;
indice = FrmMenuPrincipal.ListaPizza.IndexOf(pizza);
MessageBox.Show("Se encontró una incidencia", "Genial", MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
if(existencia == false)
{
MessageBox.Show("No se encontraron incidencias", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnAgregar_Click(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(txtbCliente.Text) && !string.IsNullOrEmpty(cmbbDescripcion.Text))
{
DialogResult resultado = MessageBox.Show("¿Desea guardar las modificaciones?", "Guardar modificaciones", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (resultado == DialogResult.Yes)
{
FrmMenuPrincipal.ListaPizza[indice].Size = Convert.ToInt32(nudSize.Value);
FrmMenuPrincipal.ListaPizza[indice].Cliente = txtbCliente.Text;
FrmMenuPrincipal.ListaPizza[indice].Descripcion = cmbbDescripcion.Text;
FrmMenuPrincipal.ListaPizza[indice].Cantidad = Convert.ToInt32(nudCantidad.Value);
FrmMenuPrincipal.ListaPizza[indice].Precio = Convert.ToDouble(txtbPrecio.Text);
MessageBox.Show("Modificación realizada", "Genial", MessageBoxButtons.OK, MessageBoxIcon.Information);
btnAgregar.Enabled = false;
txtbCliente.Enabled = false;
cmbbDescripcion.Enabled = false;
nudCantidad.Enabled = false;
nudSize.Enabled = false;
txtbNombreCliente.Enabled = true;
nudId.Enabled = true;
btnBuscar.Enabled = true;
txtbCliente.Text = "";
cmbbDescripcion.Text = "";
nudCantidad.Value = nudCantidad.Minimum;
nudSize.Value = nudSize.Minimum;
txtbNombreCliente.Text = "";
nudId.Value = nudId.Minimum;
}
else
{
btnAgregar.Enabled = false;
txtbCliente.Enabled = false;
cmbbDescripcion.Enabled = false;
nudCantidad.Enabled = false;
nudSize.Enabled = false;
txtbNombreCliente.Enabled = true;
nudId.Enabled = true;
btnBuscar.Enabled = true;
txtbCliente.Text = "";
cmbbDescripcion.Text = "";
nudCantidad.Value = nudCantidad.Minimum;
nudSize.Value = nudSize.Minimum;
txtbNombreCliente.Text = "";
nudId.Value = nudId.Minimum;
}
}
else
{
MessageBox.Show("Llene los datos necesarios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnCancelar_Click(object sender, EventArgs e)
{
Close();
}
private void nudSize_ValueChanged(object sender, EventArgs e)
{
calcular();
}
private void nudCantidad_ValueChanged(object sender, EventArgs e)
{
calcular();
}
}
}