Example #1
0
        private void nudEmpleados_ValueChanged(object sender, EventArgs e)
        {
            if (int.TryParse(nudEmpleados.Value.ToString(), out int value))
            {
                if (bar.Empleados.Count < value)
                {
                    FrmDatos     frm       = new FrmDatos();
                    DialogResult resultado = frm.ShowDialog();
                    if (resultado == DialogResult.OK)
                    {
                        empleado = new Empleado(frm.Nombre, frm.Edad, frm.Dni);
                        bool rta = bar + empleado;

                        if (rta)
                        {
                            MessageBox.Show("Se AGREGO un empleado!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("No cumple los requisitos!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    //nudEmpleados.Value = bar.Empleados.Count;
                }
                else if (bar.Empleados.Count > value)
                {
                    MessageBox.Show("Se QUITO un empleado!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    bar.Empleados.RemoveAt(bar.Empleados.Count - 1);
                }
            }
        }
Example #2
0
        private void nudGente_ValueChanged(object sender, EventArgs e)
        {
            if (int.TryParse(nudGente.Value.ToString(), out int value))
            {
                if (value != 0 && value > 0)
                {
                    if (bar.Gente.Count < value)
                    {
                        FrmDatos     frm       = new FrmDatos();
                        DialogResult resultado = frm.ShowDialog();
                        if (resultado == DialogResult.OK)
                        {
                            if (frm.Edad > 0)
                            {
                                gente = new Gente(frm.Nombre, frm.Edad);
                            }
                            else
                            {
                                gente = new Gente(frm.Edad);
                            }

                            if (gente.Validar())
                            {
                                bool rta = bar + gente;
                                MessageBox.Show("Se AGREGO una gentuza!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("No cumple los requisitos!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        nudGente.Value = bar.Gente.Count;
                    }
                    else if (bar.Gente.Count > value)
                    {
                        FrmDatos frm = new FrmDatos();
                        bar.Gente.Remove(bar.Gente.First());
                        MessageBox.Show("Se QUITO una gentuza!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        nudGente.Value = bar.Gente.Count;
                    }
                }
            }
        }