4、VS2010+ASP.NET MVC4+EF4+JqueryEasyUI+Oracle项目开发之——后台管理界面

这一章节比较简单,我就直接贴代码了,后台管理登陆界面如下:

4、VS2010+ASP.NET MVC4+EF4+JqueryEasyUI+Oracle项目开发之——后台管理界面

对应的控制器HomeController.cs,代码如下:

using YKT.Model;
using YKT.Common;
using YKT.BLL;
using YKT.Common.HtmlHelpers;
using YKT.Common.Functions;
using Microsoft.Practices.Unity;
using YKT.IBLL;

namespace YKT.Controllers
{
    public class HomeController : BaseController
    {
        #region 通用部分-实例化业务逻辑对象

        ValidationErrors validationErrors = new ValidationErrors();
        HomeService m_BLL = new HomeService();
        ISysMenuRoleFuncService _menuRoleFunService = new SysMenuRoleFuncService();

        #endregion
      
        public ActionResult Index()
        {
            Account account = GetCurrentAccount();
            if (account == null)
            {
                return RedirectToAction("Index", "Account");
            }
            else
            {
                ViewData["PersonName"] = account.UID;

                ViewData["Menu"] = m_BLL.GetMenuByAccount(ref account);// 获取菜单
            }

            return View();
        }

        //[SupportFilter]
        public ActionResult Main()
        {
            SysInfo model = m_BLL.GetSysInfoModel() as SysInfo;

            return View(model);
        }

        /// <summary>
        /// 根据父节点获取数据字典,绑定二级下拉框的时候使用
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetSysFieldByParent(string id, string parentid, string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return null;
            }
            ISysFieldHander baseDDL = new SysFieldHander();
            return Json(new SelectList(baseDDL.GetSysFieldByParent(id, parentid, value), "MyTexts", "MyTexts"), JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获取列表中的按钮导航
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetToolbar(int id)
        {
            Account account = GetCurrentAccount();
            if (account == null)
            {
                return Content(" <script type=‘text/javascript‘> window.top.location=‘Account‘; </script>");
            }

            List<SMFUNCTB> sysOperations = _menuRoleFunService.GetByRefSysMenuIdAndSysRoleId(id, account.RoleIds);
            List<toolbar> toolbars = new List<toolbar>();
            foreach (SMFUNCTB item in sysOperations)
            {
                toolbars.Add(new toolbar() { handler = item.EVENT_NAME, iconCls = item.ICONIC, text = item.FUNC_NAME });
            }
            return Json(toolbars, JsonRequestBehavior.AllowGet);

        }
    }
}
这里我继承了一个基控制器BaseController如下:

/*Company:EMPEROR*/
/*Author:Zouqj*/
/*Date:2014-02-20*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.EnterpriseServices;
using YKT.Model;
using System.Web.Mvc;
using System.Configuration;
using System.Web;
using System.IO.Compression;
using YKT.Common;

namespace YKT.Controllers
{
    [SupportFilter]//此处如果去掉注释,则全部继承BaseController的Controller,都将执行SupportFilter过滤
    public class BaseController : Controller
    {
        /// <summary>
        /// 是否添加选择行
        /// </summary>
        public bool IsAddSelect = true;
        /// <summary>
        /// //选择行的文本
        /// </summary>
        public string DefaultSelectText = "——请选择——";
        /// <summary>
        /// //默认选择的值
        /// </summary>
        public string DefaultSelectValue = "";
        /// <summary>
        /// 默认选择的整数值
        /// </summary>
        public int? DefaultIntValue = -1;

        /// <summary>
        /// 是否是Oracle数据库
        /// </summary>
        public bool IsOracle = ConfigurationManager.AppSettings["DataBase"] == "Oracle" ? true : false;

        /// <summary>
        /// 根据序列名称获取oracle序列
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Decimal GetProblemXH(string name)
        {
            Decimal maxXh = 90000000;
            using (YKTEntities entity = new YKTEntities())
            {
                String strDBType = ((System.Data.EntityClient.EntityConnection)(entity.Connection)).StoreConnection.ToString();
                if (entity != null)
                {
                    string strSeqIDQuerySQL;
                    if (strDBType == "System.Data.SqlClient.SqlConnection")
                    {
                        strSeqIDQuerySQL = "insert into dual(NewDate) values(GETDATE()) select @@identity";
                    }
                    else
                    {
                        strSeqIDQuerySQL = "select " + name + ".nextval from dual";
                    }
                    Decimal decSeqID = entity.ExecuteStoreQuery<Decimal>(strSeqIDQuerySQL).First();
                    maxXh = decSeqID;
                }
            }
            return maxXh;
        }

        /// <summary>
        /// 获取当前登陆人的名称
        /// </summary>
        /// <returns></returns>
        public string GetCurrentPerson()
        {
            Account account = GetCurrentAccount();
            if (account != null && !string.IsNullOrWhiteSpace(account.UID))
            {
                return account.UID;
            }
            return string.Empty;
        }
        /// <summary>
        /// 获取当前登陆人的账户信息
        /// </summary>
        /// <returns>账户信息</returns>
        public Account GetCurrentAccount()
        {
            if (Session["account"] != null)
            {
                Account account = (Account)Session["account"];
                return account;
            }

            return null;
        }

        public BaseController()
        { }

    }

}
View如下:

@{
    ViewBag.Title = "一卡通企业平台";
    Layout =null;
}
<!DOCTYPE html>
<html>
<head id="Head1">
    <title>一卡通企业平台</title>
    <base target="_self"/>  
    <link href=‘@Url.Content("~/Res/easyui/themes/default/easyui.css")‘ rel="stylesheet" type="text/css" />
    <link href=‘@Url.Content("~/Content/Default.css")‘ rel="stylesheet" type="text/css" />
    <link href=‘@Url.Content("~/Res/easyui/themes/icon.css")‘ rel="stylesheet" type="text/css" />
    <script src=‘@Url.Content("~/Scripts/jquery-1.8.0.min.js")‘ type="text/javascript"></script>
    <script src=‘@Url.Content("~/Res/easyui/jquery.easyui.min.js")‘ type="text/javascript"></script>
    <script src=‘@Url.Content("~/Res/easyui/locale/easyui-lang-zh_CN.js")‘ type="text/javascript"></script>
   <script type="text/javascript">
       function closeErrors() {
           return true;
       }
       window.onerror = closeErrors;    
           $(function () {
               //var w = $(document).width();
               //$("#banner").width(w); //设置bannar的宽度
               tabCloseEven();
               addTab("我的工作台", "Home/Main", "xiongdi", false);
               $(‘ul li a‘).click(function () {
                   var tabTitle = $(this).text();
                   var url = $(this).attr("rel"); //获取地址
                   var id = $(this).attr("id"); //获取id
                   var icon = $(this).attr("icon"); //获取图标
                   if (icon == "") {
                       icon = "icon-save";
                   }
                   addTab(tabTitle, url, icon, true, id);

               });
               $(‘#loginOut‘).click(function () {

                   $.messager.confirm(‘系统提示‘, ‘您确定要退出本次登录吗?‘, function (r) {

                       if (r) {
                           location.href = ‘/Account/LogOff‘;
                       }
                   });
               });
               $(‘#ChangePassword‘).click(function () {
                   showPwdWindow("修改密码", "Account/ChangePassword");
               });

           })

           function addTab(subtitle, url, icon, closable, id) {

               if (!$(‘#tabs‘).tabs(‘exists‘, subtitle)) {
                   $(‘#tabs‘).tabs(‘add‘, {
                       title: subtitle,
                       content: createFrame(url, id),
                       closable: closable
                    , icon: icon
                   });
               } else {
                   $(‘#tabs‘).tabs(‘select‘, subtitle);

               }
               tabClose();
           }

           function createFrame(url, id) {
               var s = ‘<iframe id="‘ + id + ‘" scrolling="no" frameborder="0"  src="‘ + url + ‘" style="width:100%;height:99%; "></iframe>‘;
               return s;
           }
           function tabClose() {
               /*双击关闭TAB选项卡*/
               $(".tabs-inner").dblclick(function () {
                   var subtitle = $(this).children(".tabs-closable").text();
                   $(‘#tabs‘).tabs(‘close‘, subtitle);
               })
               /*为选项卡绑定右键*/
               $(".tabs-inner").bind(‘contextmenu‘, function (e) {
                   $(‘#mm‘).menu(‘show‘, {
                       left: e.pageX,
                       top: e.pageY
                   });

                   var subtitle = $(this).children(".tabs-closable").text();

                   $(‘#mm‘).data("currtab", subtitle);
                   $(‘#tabs‘).tabs(‘select‘, subtitle);
                   return false;
               });
           }
           //绑定右键菜单事件
           function tabCloseEven() {
               //刷新
               $(‘#mm-tabupdate‘).click(function () {
                   var currTab = $(‘#tabs‘).tabs(‘getSelected‘);
                   var url = $(currTab.panel(‘options‘).content).attr(‘src‘);
                   var id = $(currTab.panel(‘options‘).content).attr(‘id‘); ; //获取id

                   $(‘#tabs‘).tabs(‘update‘, {
                       tab: currTab,
                       options: {
                           content: createFrame(url, id)
                       }
                   })
               })
               //关闭
               $(‘#mm-tabclose‘).click(function () {
                   var currtab_title = $(‘#mm‘).data("currtab");
                   $(‘#tabs‘).tabs(‘close‘, currtab_title);
               })
               //在新窗口打开该标签
               $(‘#tab_menu-openFrame‘).click(function () {
                   var url = $(".tabs-panels .panel").eq($(‘.tabs-selected‘).index()).find("iframe").attr("src");
                   window.open(url);
               });
               //全部关闭
               $(‘#tab_menu-tabcloseall‘).click(function () {
                   $(‘.tabs-inner span‘).each(function (i, n) {
                       if ($(this).parent().next().is(‘.tabs-close‘)) {
                           var t = $(n).text();
                           $(‘#tabs‘).tabs(‘close‘, t);
                       }
                   });
                   //open menu
                   $(".layout-button-right").trigger("click");
               });
               //关闭除当前之外的TAB
               $(‘#tab_menu-tabcloseother‘).click(function () {
                   var currtab_title = $(‘.tabs-selected .tabs-inner span‘).text();
                   $(‘.tabs-inner span‘).each(function (i, n) {
                       if ($(this).parent().next().is(‘.tabs-close‘)) {
                           var t = $(n).text();
                           if (t != currtab_title)
                               $(‘#tabs‘).tabs(‘close‘, t);
                       }
                   });
               });
               //关闭当前右侧的TAB
               $(‘#tab_menu-tabcloseright‘).click(function () {
                   var nextall = $(‘.tabs-selected‘).nextAll();
                   if (nextall.length == 0) {
                       $.messager.alert(‘提示‘, ‘前面没有了!‘, ‘warning‘);
                       return false;
                   }
                   nextall.each(function (i, n) {
                       if ($(‘a.tabs-close‘, $(n)).length > 0) {
                           var t = $(‘a:eq(0) span‘, $(n)).text();
                           $(‘#tabs‘).tabs(‘close‘, t);
                       }
                   });
                   return false;
               });
               //关闭当前左侧的TAB
               $(‘#tab_menu-tabcloseleft‘).click(function () {

                   var prevall = $(‘.tabs-selected‘).prevAll();
                   if (prevall.length == 0) {
                       $.messager.alert(‘提示‘, ‘后面没有了!‘, ‘warning‘);
                       return false;
                   }
                   prevall.each(function (i, n) {
                       if ($(‘a.tabs-close‘, $(n)).length > 0) {
                           var t = $(‘a:eq(0) span‘, $(n)).text();
                           $(‘#tabs‘).tabs(‘close‘, t);
                       }
                   });
                   return false;
               });
           }
           //修改密码
           function showPwdWindow(title, href) {
               $(‘#myWindow‘).window({
                   title: title,
                   width: 600,
                   height: 400,
                   content: ‘<iframe scrolling="no" frameborder="0"  src="‘ + href + ‘" style="width:100%;height:98%;"></iframe>‘,
                   shadow: false,
                   cache: false,
                   closed: false,
                   collapsible: false,
                   resizable: false,
                   loadingMessage: ‘正在加载数据,请稍等片刻......‘
               });
           }
           function showMyWindow(title, href, width, height, modal, minimizable, maximizable, isScrolling) {
               var isScroll = isScrolling == undefined ? "yes" : "no";
               $(‘#myWindow‘).window({
                   title: title,
                   width: width === undefined ? 600 : width,
                   height: height === undefined ? 450 : height,
                   content: ‘<iframe scrolling="‘ + isScroll + ‘" frameborder="0"  src="‘ + href + ‘" style="width:100%;height:98%;"></iframe>‘,
                   //        href: href === undefined ? null : href, 
                   modal: modal === undefined ? true : modal,
                   minimizable: minimizable === undefined ? false : minimizable,
                   maximizable: maximizable === undefined ? false : maximizable,
                   shadow: false,
                   cache: false,
                   closed: false,
                   collapsible: false,
                   resizable: false,
                   loadingMessage: ‘正在加载数据,请稍等片刻......‘
               });

           }
    </script>
    <style type="text/css">
        body
        {
            font-family: 微软雅黑,新宋体;
        }
        a
        {
            color: Black;
            text-decoration: none;
        }
        .easyui-tree li
        {
            margin: 5px 0px 0px 0px;
            padding: 1px;
        }
        
        #mainlogo
        {
            position: absolute;
            top: 0px;
            left: 0px;
            width: 575px;
            height: 72px;
        }
        #center
        {
            padding-left: 575px;
            padding-right: 425px;
        }
        #mainctrl
        {
            position: absolute;
            top: 0px;
            right: 0px;
            height: 72px;
            width: 425px;
        }
        
        .top
        {
            height: 76px;
            background-color: #00211D;
        }
        
        .wel
        {
            height: 30px;
            line-height: 30px;
            color: #FFFFFF;
            font-size: 14px;
            text-align: right;
            padding-right: 5px;
        }
        .ctr
        {
            vertical-align: middle;
            margin-top: 18px;
            height: 24px;
            text-align: right;
            background-image: url(../images/beijing.gif);
            background-repeat: repeat-x;
        }
        .ctr li
        {
            float: left;
            list-style: none;
        }
        .zi
        {
            padding-right: 16px;
            padding-left: 3px;
        }
        
        
        a.v1:visited, a.v1:active, a.v1:link
        {
            font-size: 14px;
            color: #000;
            text-decoration: none;
        }
        a.v1:hover
        {
            font-size: 14px;
            color: #005500;
            text-decoration: none;
        }
    </style>
</head>
<body class="easyui-layout">
    <noscript>
        <div style="position: absolute; z-index: 100000; height: 2046px; top: 0px; left: 0px;
            width: 100%; background: white; text-align: center;">
            <img src="images/noscript.gif" alt=‘抱歉,请开启脚本支持!‘/>
        </div>
    </noscript>
    <div region="north" split="true" border="false" style="overflow: hidden; height: 76px;
        line-height: 20px; color: #fff; font-family: 微软雅黑,黑体">
        <div class="top" style="background-color:#204478; width:100%;">
            <div id="mainlogo">
                <img id="banner" src="images/hzbanner.png"  alt="一卡通" style="height:72px;"/>
            </div>
            <div id="center">
            </div>
            <div id="mainctrl">
                <div class="wel">
                    @ViewData["PersonName"]
                    ,欢迎您的光临!</div>
                <div class="ctr">
                    <li>
                        <img src="images/yuanjiao.png" alt="" /></li>
                    <li><a href="#">
                        <img src="images/mimaxiugai.gif" alt="" border="0" /></a></li>
                    <li class="zi"><a href="#" id="ChangePassword" class="v1">密码修改</a></li>
                    <li><a href="#">
                        <img src="images/anquantuichu.gif" alt="" border="0" /></a></li>
                    <li class="zi"><a href="#" id="loginOut" class="v1">安全退出</a></li>
                    <li><a href="#">
                        <img src="images/bangzhu.gif" border="0"></a></li>
                    <li class="zi"><a href="http://www.xiongdi.cn" class="v1">帮助中心</a></li>
@*                   <li><a href="#">
                        <img src="images/duanxinxi.gif" alt="" border="0" /></a></li>
                    <li class="zi"><a href="#" class="v1">短消息(0)</a></li>*@
                </div>
            </div>
        </div>
    </div>
  
    <div region="west" hide="true" split="true" title="导航菜单" style="width: 180px;" id="west">
        <div class="easyui-accordion" fit="true" border="false">
         @Html.Raw(ViewData["Menu"])
        </div>
    </div>
    <div id="mainPanle" region="center" style="background: #eee;">
        <div id="tabs" class="easyui-tabs" fit="true" border="false">
        </div>
    </div>
    <div region="south" split="true" style="height: 29px;">
        <div style="padding: 0px; margin-left: 50%;">
            技术支持 <a href="http://www.xiongdi.cn" target="_blank">雄帝股份</a>
        </div>
    </div>
    <div id="mm" class="easyui-menu" style="width: 150px;">
        <div id="mm-tabupdate" data-options="iconCls:‘icon-reload‘">
            刷新</div>
       <div id="tab_menu-openFrame">
           在新的窗体打开</div>
        <div class="menu-sep">
        </div>
        <div id="mm-tabclose" data-options="iconCls:‘icon-cancel‘">
            关闭</div>
         <div id="tab_menu-tabcloseright">
           关闭右边</div>
        <div id="tab_menu-tabcloseleft">
           关闭左边</div>
        <div id="tab_menu-tabcloseall">
         关闭所有</div>
        <div id="tab_menu-tabcloseother">
          关闭其他标签页</div>
    </div>
    <div id="myWindow">
    </div>
</body>
</html>


4、VS2010+ASP.NET MVC4+EF4+JqueryEasyUI+Oracle项目开发之——后台管理界面,布布扣,bubuko.com

4、VS2010+ASP.NET MVC4+EF4+JqueryEasyUI+Oracle项目开发之——后台管理界面

上一篇:3、VS2010+ASP.NET MVC4+EF4+JqueryEasyUI+Oracle项目开发之——用户登录


下一篇:浅谈oracle中rowid和rownum