using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using LayUIMvcTest.Models;
namespace LayUIMvcTest.Controllers
{
public class MainController : Controller
{
//
// GET: /main/
public ActionResult Index()
{
return View();
}
#region 加载菜单数据
/// <summary>
/// 加载菜单数据
/// </summary>
/// <returns></returns>
public string LoadMenu()
{
StringBuilder str = new StringBuilder();
wgh_schoolEntities db = new wgh_schoolEntities();
var menulist = db.sys_menu.SqlQuery("select top 100 * from sys_menu where sys_pid=0 and sys_state=0").ToList();
if (menulist != null)
{
foreach (var item in menulist)
{
var pid = item.id;
str.Append("<li>");
str.Append("<a href=\"javascript:;\">");
str.Append("<i class=\"iconfont\"></i> <cite>" + item.sys_menuname + "</cite> <i class=\"iconfont nav_right\"></i>");
str.Append("</a>");
var childmenulist = db.sys_menu.SqlQuery("select top 100 * from sys_menu where sys_pid=" + pid + " and sys_state=0").ToList();
if (childmenulist != null)
{
str.Append("<ul class=\"sub-menu\">");
foreach (var submenu in childmenulist)
{
str.Append("<li>");
str.Append("<a _href=\"/" + (submenu.sys_menuurl) + "\">");
str.Append("<i class=\"iconfont\"></i> <cite>" + submenu.sys_menuname + "</cite>");
str.Append("</a>");
str.Append("</li>");
}
str.Append("</ul>");
}
str.Append("</li>");
}
}
return str.ToString();
}
#endregion
}
}