Beispiel #1
0
 /// <summary>
 /// 检查是否有权限
 /// </summary>
 public bool Exists(int role_id, string nav_name, string action_type)
 {
     Model.managers.manager_role model = dal.GetModel(role_id);
     if (model != null)
     {
         if (model.role_type == 1)
         {
             return(true);
         }
         Model.managers.manager_role_value modelt = model.manager_role_values.Find(p => p.nav_name == nav_name && p.action_type == action_type);
         if (modelt != null)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
 private void ShowInfo(int _id)
 {
     BLL.managers.manager_role   bll   = new BLL.managers.manager_role();
     Model.managers.manager_role model = bll.GetModel(_id);
     txtRoleName.Text          = model.role_name;
     ddlRoleType.SelectedValue = model.role_type.ToString();
     //管理权限
     if (model.manager_role_values != null)
     {
         for (int i = 0; i < rptList.Items.Count; i++)
         {
             string       navName       = ((HiddenField)rptList.Items[i].FindControl("hidName")).Value;
             CheckBoxList cblActionType = (CheckBoxList)rptList.Items[i].FindControl("cblActionType");
             for (int n = 0; n < cblActionType.Items.Count; n++)
             {
                 Model.managers.manager_role_value modelt = model.manager_role_values.Find(p => p.nav_name == navName && p.action_type == cblActionType.Items[n].Value);
                 if (modelt != null)
                 {
                     cblActionType.Items[n].Selected = true;
                 }
             }
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.managers.manager_role GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,role_name,role_type,is_sys from " + databaseprefix + "manager_role ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.managers.manager_role model = new Model.managers.manager_role();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                #region 父表信息
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.role_name = ds.Tables[0].Rows[0]["role_name"].ToString();
                if (ds.Tables[0].Rows[0]["role_type"].ToString() != "")
                {
                    model.role_type = int.Parse(ds.Tables[0].Rows[0]["role_type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_sys"].ToString() != "")
                {
                    model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString());
                }
                #endregion

                #region 子表信息
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,role_id,nav_name,action_type from " + databaseprefix + "manager_role_value ");
                strSql2.Append(" where role_id=@role_id");
                SqlParameter[] parameters2 =
                {
                    new SqlParameter("@role_id", SqlDbType.Int, 4)
                };
                parameters2[0].Value = id;
                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    List <Model.managers.manager_role_value> models = new List <Model.managers.manager_role_value>();
                    Model.managers.manager_role_value        modelt;
                    foreach (DataRow dr in ds2.Tables[0].Rows)
                    {
                        modelt = new Model.managers.manager_role_value();
                        if (dr["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(dr["id"].ToString());
                        }
                        if (dr["role_id"].ToString() != "")
                        {
                            modelt.role_id = int.Parse(dr["role_id"].ToString());
                        }
                        modelt.nav_name    = dr["nav_name"].ToString();
                        modelt.action_type = dr["action_type"].ToString();
                        models.Add(modelt);
                    }
                    model.manager_role_values = models;
                }
                #endregion

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.managers.manager_role GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,role_name,role_type,is_sys from " + databaseprefix + "manager_role ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.managers.manager_role model = new Model.managers.manager_role();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region ������Ϣ
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.role_name = ds.Tables[0].Rows[0]["role_name"].ToString();
                if (ds.Tables[0].Rows[0]["role_type"].ToString() != "")
                {
                    model.role_type = int.Parse(ds.Tables[0].Rows[0]["role_type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_sys"].ToString() != "")
                {
                    model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString());
                }
                #endregion

                #region �ӱ���Ϣ
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,role_id,nav_name,action_type from " + databaseprefix + "manager_role_value ");
                strSql2.Append(" where role_id=@role_id");
                SqlParameter[] parameters2 = {
                    new SqlParameter("@role_id", SqlDbType.Int,4)};
                parameters2[0].Value = id;
                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    List<Model.managers.manager_role_value> models = new List<Model.managers.manager_role_value>();
                    Model.managers.manager_role_value modelt;
                    foreach (DataRow dr in ds2.Tables[0].Rows)
                    {
                        modelt = new Model.managers.manager_role_value();
                        if (dr["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(dr["id"].ToString());
                        }
                        if (dr["role_id"].ToString() != "")
                        {
                            modelt.role_id = int.Parse(dr["role_id"].ToString());
                        }
                        modelt.nav_name = dr["nav_name"].ToString();
                        modelt.action_type = dr["action_type"].ToString();
                        models.Add(modelt);
                    }
                    model.manager_role_values = models;
                }
                #endregion

                return model;
            }
            else
            {
                return null;
            }
        }