Example #1
0
    private void GetUserRoles()
    {
        MasterUserCompanyGroupDAL _dalUserCompanyGroup = null;
        MasterGroupRoleDAL        _dalGroupRole        = null;

        Hashtable _htParameter = null;
        ArrayList _alRole      = null;

        try
        {
            //System.Diagnostics.Debugger.Break();
            _dalUserCompanyGroup = new MasterUserCompanyGroupDAL();
            _dalGroupRole        = new MasterGroupRoleDAL();

            _htParameter = new Hashtable();
            _htParameter["p_user_id"] = txtUID.Text;
            _htParameter["p_c_code"]  = Session[SessionKey.CURRENT_ENTITY_SESSION_KEY].ToString();

            DataTable _dt = _dalUserCompanyGroup.GetRowByUserIDCCode(_htParameter);

            if (_dt.Rows.Count == 0)
            {
                _alRole = new ArrayList();
                Session[SessionKey.CURRENT_USER_ROLE_SESSION_KEY] = _alRole;
            }
            else
            {
                //ada di database, lalu ambil data role

                _htParameter["p_group_code"] = _dt.Rows[0]["GROUP_CODE"];

                DataTable _dtRoles = _dalGroupRole.GetRowByGroupCode(_htParameter);
                _alRole = new ArrayList();

                foreach (DataRow dr in _dtRoles.Rows)
                {
                    _alRole.Add(dr["ROLE_CODE"]);
                }

                Session[SessionKey.CURRENT_USER_ROLE_SESSION_KEY] = _alRole;
            }
        }
        catch (Exception ex)
        {
        }
    }