Exemple #1
0
    /// <summary>
    /// 得到角色模块上的所有权限
    /// </summary>
    /// <param name="RoleKey"></param>
    /// <returns></returns>
    public string  GetRoleModulePermission(int RoleId, out List <PermissionsModel> olist)
    {
        olist = null;
        string ret = Config.Fail;

        try
        {
            olist = pd.GetRoleModulePermission(RoleId);
            return(Config.Success);
        }
        catch (Exception ex)
        {
            WriteLog.WriteExceptionLog("ZB.BLL.Authorization.AdminBLL.GetRoleModulePermission()", ex);
            return(Config.ExceptionMsg);
        }
    }
Exemple #2
0
    /// <summary>
    /// 得到用户列表
    /// </summary>
    /// <param name="PageIndex"></param>
    /// <param name="PageNum"></param>
    /// <param name="where"></param>
    /// <param name="Count"></param>
    /// <returns></returns>
    public List <AdminModel> GetAdminList(int PageIndex, int PageNum, string where, out int Count)
    {
        List <AdminModel> olist = new List <AdminModel>();

        Count = 0;
        SqlConnection sqlConnection = new SqlConnection(Config.ConnectionString);
        SqlCommand    sqlcommand    = new SqlCommand("sp_AdminList", sqlConnection);

        sqlcommand.CommandType = CommandType.StoredProcedure;

        SqlParameter _PageIndex = new SqlParameter("@PageIndex", PageIndex);

        _PageIndex.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_PageIndex);

        SqlParameter _PageNum = new SqlParameter("@PageNum", PageNum);

        _PageNum.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_PageNum);

        SqlParameter _where = new SqlParameter("@where", where);

        _where.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_where);

        SqlParameter _Count = new SqlParameter("@Count", SqlDbType.Int);

        _Count.Direction = ParameterDirection.Output;
        sqlcommand.Parameters.Add(_Count);
        try
        {
            sqlConnection.Open();
            using (IDataReader idr = sqlcommand.ExecuteReader())
            {
                DealerDAL      dd   = new DealerDAL();
                StoreDAL       sd   = new StoreDAL();
                PermissionsDAL pDal = new PermissionsDAL();
                while (idr.Read())
                {
                    AdminModel oCModel = new AdminModel();
                    if (idr["AdminId"] != DBNull.Value)
                    {
                        oCModel.AdminId = (int)idr["AdminId"];
                    }
                    if (idr["AdminName"] != DBNull.Value)
                    {
                        oCModel.AdminName = (string)idr["AdminName"];
                    }
                    if (idr["AdminPassword"] != DBNull.Value)
                    {
                        oCModel.AdminPassword = (string)idr["AdminPassword"];
                    }
                    if (idr["Type"] != DBNull.Value)
                    {
                        oCModel.Type = (AdminType)idr["Type"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        oCModel.RoleId = (int)idr["RoleId"];
                    }
                    if (idr["Status"] != DBNull.Value)
                    {
                        oCModel.Status = (bool)idr["Status"];
                    }
                    if (idr["CreateTime"] != DBNull.Value)
                    {
                        oCModel.CreateTime = (DateTime)idr["CreateTime"];
                    }

                    if (idr["CreatorId"] != DBNull.Value)
                    {
                        oCModel.CreatorId = (int)idr["CreatorId"];
                    }
                    int Totoal = 0;
                    List <DealerModel> dModel = dd.GetDealerModelList(1, 1, "DealerInfo.AdminId=" + oCModel.AdminId, out Totoal);
                    if (dModel != null & dModel.Count > 0)
                    {
                        oCModel.Dealer = dModel[0];
                    }
                    List <StoreModel> oSMoel = sd.GetStoreModelList(1, 1, "StoreInfo.AdminId=" + oCModel.AdminId, out Totoal);
                    if (oSMoel != null & oSMoel.Count > 0)
                    {
                        oCModel.Store = oSMoel[0];
                    }
                    RoleModel role = new RoleModel();
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.RoleId = (int)idr["RoleId"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.RoleName = (string)idr["RoleName"];
                    }
                    if (idr["RoleId"] != DBNull.Value)
                    {
                        role.Permissions = pDal.GetRoleModulePermission(role.RoleId);
                    }
                    oCModel.Role = role;
                    olist.Add(oCModel);
                }
            }
            Count = int.Parse(_Count.Value.ToString());
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            sqlConnection.Close();
        }
        return(olist);
    }
Exemple #3
0
    /// <summary>
    ///得到角色列表
    /// </summary>
    /// <returns></returns>
    public List <RoleModel> GetRoleList(int?RoleId)
    {
        List <RoleModel> oLRModel      = new List <RoleModel>();
        SqlConnection    sqlConnection = new SqlConnection(Config.ConnectionString);
        SqlCommand       sqlcommand    = new SqlCommand("sp_RoleInfo", sqlConnection);

        sqlcommand.CommandType = CommandType.StoredProcedure;

        SqlParameter _op = new SqlParameter("@op", "Get");

        _op.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_op);

        SqlParameter _RoleId = new SqlParameter("@RoleId", RoleId == null?(Object)DBNull.Value:RoleId.Value);

        _RoleId.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_RoleId);

        SqlParameter _RoleName = new SqlParameter("@RoleName", (Object)DBNull.Value);

        _RoleName.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_RoleName);



        SqlParameter _CreatorId = new SqlParameter("@CreatorId", (Object)DBNull.Value);

        _CreatorId.Direction = ParameterDirection.Input;
        sqlcommand.Parameters.Add(_CreatorId);


        SqlParameter result = new SqlParameter("@result", SqlDbType.VarChar, 10);

        result.Direction = ParameterDirection.Output;
        sqlcommand.Parameters.Add(result);

        try
        {
            sqlConnection.Open();
            using (IDataReader idr = sqlcommand.ExecuteReader())
            {
                PermissionsDAL pDal = new PermissionsDAL();
                while (idr.Read())
                {
                    RoleModel oRoleModel = new RoleModel();
                    oRoleModel.RoleId    = (int)idr["RoleId"];
                    oRoleModel.RoleName  = (string)idr["RoleName"];
                    oRoleModel.CreatorId = (int)idr["CreatorId"];
                    if (idr["AdminName"] != DBNull.Value)
                    {
                        oRoleModel.Creator = (string)idr["AdminName"];
                    }
                    ;
                    oRoleModel.CreateTime  = (DateTime)idr["CreateTime"];
                    oRoleModel.Permissions = pDal.GetRoleModulePermission(oRoleModel.RoleId);
                    oLRModel.Add(oRoleModel);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            sqlConnection.Close();
        }
        return(oLRModel);
    }