Exemplo n.º 1
0
        public List <Book.Model.T_Base_Menu> GetList(int RoleId, string Controller, string Action)
        {
            SqlConnection co = SQLServerOpen();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = co;
            cmd.CommandText = "select * from v_role_menu where roleId = "
                              + RoleId + " and Controller = '" + Controller + "' and Action='"
                              + Action + "'";
            SqlDataReader reader = cmd.ExecuteReader();

            List <Book.Model.T_Base_Menu> list = new List <Model.T_Base_Menu>();

            while (reader.Read())
            {
                Book.Model.T_Base_Menu menu = new Model.T_Base_Menu();
                menu.Id         = Convert.ToInt32(reader["Id"]);
                menu.Controller = Convert.ToString(reader["Controller"]);
                menu.Action     = Convert.ToString(reader["Action"]);
                menu.Display    = Convert.ToString(reader["Display"]);
                menu.Type       = Convert.ToInt32(reader["Type"]);
                menu.ParentId   = Convert.ToInt32(reader["ParentId"]);
                list.Add(menu);
            }
            reader.Close();
            co.Close();
            return(list);
        }
Exemplo n.º 2
0
        public List <Book.Model.T_Base_Menu> GetMenuList(int RoleId, string Controller, string Action)
        {
            SqlConnection co = new SqlConnection();

            co.ConnectionString = connstring;
            co.Open();
            SqlCommand cm = new SqlCommand();

            cm.Connection  = co;
            cm.CommandText = "select * from V_Role_Menu where RoleId = @RoleId and Controller=@Controller and Action=@Action ";
            cm.Parameters.AddWithValue("@RoleId", RoleId);
            cm.Parameters.AddWithValue("@Controller", Controller);
            cm.Parameters.AddWithValue("@Action", Action);

            SqlDataReader dr = cm.ExecuteReader();
            List <Book.Model.T_Base_Menu> lst = new List <Model.T_Base_Menu>();

            while (dr.Read())
            {
                Book.Model.T_Base_Menu item = new Model.T_Base_Menu();
                item.Id         = Convert.ToInt32(dr["Id"]);
                item.Action     = Convert.ToString(dr["Action"]);
                item.Controller = Convert.ToString(dr["Controller"]);
                item.Display    = Convert.ToString(dr["Display"]);
                item.Type       = Convert.ToInt32(dr["Type"]);
                item.ParentId   = Convert.ToInt32(dr["ParentId"]);
                lst.Add(item);
            }
            dr.Close();
            co.Close();

            return(lst);
        }