Exemple #1
0
        //Esta funcion sirve para verificar que no falte ningun campo obligatorio por llenar
        private bool Validar()
        {
            bool paso = true;

            if (DescripcionTextBox.Text == "")
            {
                RolErrorProvider.SetError(DescripcionTextBox, "Campo obligatorio");
                DescripcionTextBox.Focus();
                paso = false;
            }
            if (RolesBLL.ExisteRol(DescripcionTextBox.Text))
            {
                RolErrorProvider.SetError(DescripcionTextBox, "rol existente");
                DescripcionTextBox.Focus();
                paso = false;
            }
            if (this.Detalle.Count == 0)
            {
                RolErrorProvider.SetError(RolDetalleDataGridView, "Favor de agregar un permiso");
                PermisoIdComboBox.Focus();
                paso = false;
            }

            return(paso);
        }
        private void AgregarButton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();
            if (DetalleDataGridView.DataSource != null)
            {
                this.Detalle = (List <RolesDetalle>)DetalleDataGridView.DataSource;
            }

            if (PermisoIdComboBox.Text == string.Empty)
            {
                MessageBox.Show("Debes seleccionar un permiso antes de continuar.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Permisos permiso = PermisosBLL.Buscar(PermisoIdComboBox.SelectedIndex + 1);

            this.Detalle.Add(
                new RolesDetalle(
                    ID: 0,
                    RolID: (int)RolIdNumericUpDown.Value,
                    PermisoID: permiso.PermisoID,
                    esAsignado: AsignadoCheckBox.Checked
                    )
                );
            CargarGrid();
            PermisoIdComboBox.Focus();
        }
Exemple #3
0
        private void AgregarButton_Click(object sender, EventArgs e)
        {
            if (RolDetalleDataGridView.DataSource != null)
            {
                this.Detalle = (List <RolesDetalle>)RolDetalleDataGridView.DataSource;
            }

            //Agregar un nuevo detalle con los datos introducidos
            this.Detalle.Add(
                new RolesDetalle(
                    rolDetalleId: 0,
                    rolId: (int)RolIdNumericUpDown.Value,
                    permisoId: Convert.ToInt32(PermisoIdComboBox.Text),
                    esAsignado: AsignadoCheckBox.Checked
                    )
                );
            CargarGrid();
            PermisoIdComboBox.Focus();
            AsignadoCheckBox.Checked = false;
        }
        private void AgregarButton_Click(object sender, EventArgs e)
        {
            if (RolesDataGridView.DataSource != null)
            {
                this.rolesDetalles = (List <RolesDetalle>)RolesDataGridView.DataSource;
            }

            this.rolesDetalles.Add(
                new RolesDetalle()
            {
                RolId      = (int)IdRolNumericUpDown.Value,
                PermisoId  = Convert.ToInt32(PermisoIdComboBox.Text),
                EsAsignado = EsAsignadoCheckBox.Checked
            }
                );

            LlenarGrid();
            PermisoIdComboBox.Focus();
            EsAsignadoCheckBox.Checked = true;
        }
Exemple #5
0
        private void AgregarButton_Click(object sender, EventArgs e)
        {
            if (DetallesDataGridView.DataSource != null)
            {
                this.Detalle = (List <RolesDetalle>)DetallesDataGridView.DataSource;
            }
            if (PermisoIdComboBox.Text == string.Empty)
            {
                MessageBox.Show("Debes seleccionar un permiso antes de continuar.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Detalle.Add(
                new RolesDetalle(
                    Id: 0,
                    IdRol: (int)RolIdNumericUpDown1.Value,
                    IdPermiso: Convert.ToInt32(PermisoIdComboBox.Text),
                    EsAsignado: EsAsinadoCheckBox.Checked
                    )
                );
            CargarGrid();
            PermisoIdComboBox.Focus();
        }