Example #1
0
    protected void btn_actualizar_Click(object sender, EventArgs e)
    {
        int     i = -1;
        Boolean _Pasa;
        String  Id_User = cbo_usuario.SelectedValue;

        foreach (GridViewRow row in dgw_permisos.Rows)
        {
            i++;
            CheckBox sup     = (CheckBox)dgw_permisos.Rows[i].FindControl("chk_acceso");
            String   _Acceso = sup.Checked.ToString();
            sup = (CheckBox)dgw_permisos.Rows[i].FindControl("chk_lectura");
            String _Lectura = sup.Checked.ToString();
            sup = (CheckBox)dgw_permisos.Rows[i].FindControl("chk_escritura");
            String _Escritura = sup.Checked.ToString();
            sup = (CheckBox)dgw_permisos.Rows[i].FindControl("chk_exportar");
            String _Exportar = sup.Checked.ToString();
            sup = (CheckBox)dgw_permisos.Rows[i].FindControl("chk_eliminar");
            String _Eliminar = sup.Checked.ToString();
            Label  _Pag      = (Label)dgw_permisos.Rows[i].FindControl("lbl_id");
            String _Id_Pag   = _Pag.Text;
            _Pasa = _U._Get_Asigna_Roles(_Id_Pag, Id_User, _Acceso, _Lectura, _Escritura, _Exportar, _Eliminar);

            if (!_Pasa)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Actualizacion Roles", "swal('Error', 'HUBO EN ERROR AL ASIGNAR ROLES, FAVOR INTENTA DENUEVO', 'error');", true);
                return;
            }
        }


        if (i == -1)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Actualizacion Rol", "swal('Error', 'Realizar busqueda empleado', 'error');", true);
            return;
        }
        else
        {
            Boolean _updatepass_usuario = false;
            if (txt_pass.Text != "")
            {
                _updatepass_usuario = true;
            }

            Boolean _Existe_en_panelcontrol = _U._Existe_usuario_panelControl(cbo_usuario.SelectedValue.ToString());
            if (chk_panel_control.Checked)
            {
                if (!_Existe_en_panelcontrol)
                {
                    // **** SE CREA ACCESO PANEL DE CONTROL SUPI ****
                    _U._Nuevo_UsuarioPanelControl_Supi(cbo_usuario.SelectedValue.ToString(), true, _updatepass_usuario);
                }
            }
            else
            {
                if (_Existe_en_panelcontrol)
                {
                    // **** elimina ACCESO PANEL DE CONTROL SUPI ****
                    _U._Elimina_UsuarioPanelControl_Supi(cbo_usuario.SelectedValue.ToString());
                }
            }

            // *** OTORGAR ACCESO WEB ****
            Boolean _Success2 = _U._Set_Acceso_Web(cbo_usuario.SelectedValue, chk_acceso_sistema.Checked.ToString());


            if (txt_pass.Text != "")
            {
                // *** SETEAR PASS ****
                Boolean _Success = _U._Set_Resetar_Pass(cbo_usuario.SelectedValue, txt_pass.Text, chk_panel_control.Checked);
            }

            if (chk_admin.Checked)
            {
                // **** OTORGAR ADMIN WEB ****
                Boolean _Success3 = _U._Set_Acceso_Admin(Id_User);
            }
        }

        ClientScript.RegisterStartupScript(this.GetType(), "Actualizacion Rol", "swal('Actualizacion', 'Se han asignados los nuevos roles', 'success');", true);
        btn_cancelar_Click(null, null);
    }