private bool Validar()
        {
            bool paso = true;
            errorProvider1.Clear();

            if (DescripciontextBox.Text == string.Empty)
            {
                errorProvider1.SetError(DescripciontextBox, "El campo Descripcion no puede estar vacĂ­o");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (RolesBLL.ExisteDescripcion(DescripciontextBox.Text, (int)idnumericUpDown.Value))
            {
                errorProvider1.SetError(DescripciontextBox, "Este Rol ya existe");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (PermisocomboBox.Text == string.Empty)
            {
                errorProvider1.SetError(PermisocomboBox, "Debe seleccionar un Id");
                PermisocomboBox.Focus();
                paso = false;
            }
            if (this.Detalles.Count == 0)
            {
                errorProvider1.SetError(DetalledataGridView, "Debe agregar un Permiso");
                PermisocomboBox.Focus();
                paso = false;
            }

            return paso;
        }
Example #2
0
        private bool Validar()
        {
            bool paso = true;

            if (DescripciontextBox.Text == string.Empty)
            {
                ErroreserrorProvider.SetError(DescripciontextBox, "Este campo no puede quedar vacio");
                DescripciontextBox.Focus();
                paso = false;
            }

            if (RolesBLL.ExisteDescripcion(DescripciontextBox.Text))
            {
                ErroreserrorProvider.SetError(DescripciontextBox, "Esta descripcion ya existe en la base de datos");
                DescripciontextBox.Focus();
                paso = false;
            }

            if (PermisoscomboBox.Text == string.Empty)
            {
                ErroreserrorProvider.SetError(PermisoscomboBox, "Debe seleccion un Id");
                PermisoscomboBox.Focus();
                paso = false;
            }

            if (this.Detalle.Count == 0)
            {
                ErroreserrorProvider.SetError(DetalledataGridView, "Es necesario agregar un permis");
                DetalledataGridView.Focus();
                paso = false;
            }

            return(paso);
        }
        private bool Validar()
        {
            bool paso = true;

            if (DescripciontextBox.Text == string.Empty)
            {
                ErrorProvider.SetError(DescripciontextBox, "Este Campo no puede estar vacio");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (RolesBLL.ExisteDescripcion(DescripciontextBox.Text, (int)IdnumericUpDown.Value))
            {
                ErrorProvider.SetError(DescripciontextBox, "Esta Descripcion ya existe");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (PermisocomboBox.Text == string.Empty)
            {
                ErrorProvider.SetError(PermisocomboBox, "Debe seleccionar un Permiso Id");
                PermisocomboBox.Focus();
                paso = false;
            }
            if (this.Detalle.Count == 0)
            {
                ErrorProvider.SetError(DetallesdataGridView, "Debe agregar un Permiso");
                DetallesdataGridView.Focus();
                paso = false;
            }

            return(paso);
        }
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Roles rol;
            bool  paso = false;

            if (!Validar())
            {
                return;
            }

            try
            {
                rol = LlenarClase();
            }
            catch (Exception)
            {
                MessageBox.Show("Dato invalido en ID", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Limpiar();
                return;
            }


            if (!EstaEnLaBD() && !RolesBLL.ExisteDescripcion(DescripcionTextBox.Text))
            {
                paso = RolesBLL.Guardar(rol);
            }

            else
            {
                MessageBox.Show("No se puede guardar el rol ya que este existe. Verifique Id o Descripcion", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Limpiar();
                return;
            }

            if (paso)
            {
                Limpiar();
                MessageBox.Show("Guardado!!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No fue posible guardar!!", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Actualizar_ConsulaRoles();
        }