Beispiel #1
0
        private Gente GenteNueva(string edad)
        {
            Gente nuevo;
            short edadAux;

            if (short.TryParse(edad, out edadAux))
            {
                nuevo = new Gente(edadAux);
                if (nuevo.Validar())
                {
                    return(nuevo);
                }
            }
            return(null);
        }
Beispiel #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;
                    }
                }
            }
        }