コード例 #1
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            var datosGenero = new Genero();

            datosGenero.Nombre      = txtNombre.Text.Trim();
            datosGenero.Descripcion = txtDescripcion.Text.Trim();
            datosGenero.Id          = _id;

            if (!datosGenero.NombreValido())
            {
                MessageBox.Show("Nombre inválido!");
                txtNombre.Text = "";
                txtNombre.Focus();
                return;
            }
            if (datosGenero.Nombre != genero.Nombre)
            {
                if (datosGenero.NombreRepetido(datosGenero.Nombre))
                {
                    MessageBox.Show("Nombre ya existente!");
                    txtNombre.Text = "";
                    txtNombre.Focus();
                    return;
                }
            }

            if (!datosGenero.DescripcionValida())
            {
                MessageBox.Show("Descripción Inválida!");
                txtDescripcion.Text = "";
                txtDescripcion.Focus();
                return;
            }
            if (generosRepositorio.Editar(datosGenero))
            {
                MessageBox.Show("La edición ha finalizado correctamente.");
                this.Dispose();
            }
        }