<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/Sys.Master" AutoEventWireup="true" CodeBehind="DataView.aspx.cs" Inherits="yueyaCMS.Admin.Page.DataView" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<ul class="breadcrumb">
<li><i class="icon-tags"></i> 您当前的位置：<a href="/Admin/Site/Default.aspx">系统首页</a></li>
<li><span class="divider">/</span> 数据查看</li>
</ul>
    
    <form id="Form1" runat="server" style="min-height:800px;">
    <div style="margin:10px 0px;">
    <div class="btn-group">
    <a class="btn btn-warning" href="DataView.aspx">选择数据表</a>
    <button class="btn dropdown-toggle  btn-warning" data-toggle="dropdown">
    <span class="caret"></span>
    </button>
    <ul id="TableNames" class="dropdown-menu">
        <li><a href="javascript:void(0)" tb="yy_Banner">yy_Banner</a></li>
        <li><a href="javascript:void(0)" tb="yy_FriendLink">yy_FriendLink</a></li>
        <li><a href="javascript:void(0)" tb="yy_Message">yy_Message</a></li>
        <li><a href="javascript:void(0)" tb="yy_News">yy_News</a></li>
        <li><a href="javascript:void(0)" tb="yy_News_Type">yy_News_Type</a></li>
        <li><a href="javascript:void(0)" tb="yy_Page">yy_Page</a></li>
        <li><a href="javascript:void(0)" tb="yy_Page_BuildTask">yy_Page_BuildTask</a></li>
        <li><a href="javascript:void(0)" tb="yy_Page_Type">yy_Page_Type</a></li>
        <li><a href="javascript:void(0)" tb="yy_Platforms">yy_Platforms</a></li>
        <li><a href="javascript:void(0)" tb="yy_Product">yy_Product</a></li>
        <li><a href="javascript:void(0)" tb="yy_Product_Type">yy_Product_Type</a></li>
        <li><a href="javascript:void(0)" tb="yy_SinglePage">yy_SinglePage</a></li>
        <li><a href="javascript:void(0)" tb="yy_SiteSetting">yy_SiteSetting</a></li>
        <li><a href="javascript:void(0)" tb="yy_User">yy_User</a></li>
    </ul>
    </div>      
    &nbsp;
    <asp:Button ID="Button1" runat="server" Text="执行" OnClientClick="return SetValue();" CssClass="btn btn-success" OnClick="Button1_Click" />
    </div>


      <pre id="editor" style="margin-bottom:10px;min-height:100px;"></pre>
        <asp:HiddenField ID="HiddenField1" runat="server" />

<script src="/Plugins/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    var editor = ace.edit("editor");
editor.setTheme("ace/theme/dreamweaver");
editor.getSession().setMode("ace/mode/sql");
 function SetValue() {
     $("#<%=HiddenField1.ClientID%>").val(editor.getValue());
     return true;
 }
    $(function () {
        $("#TableNames a").click(function ()
        {
            editor.setValue("SELECT TOP 20 * FROM " + $(this).attr("tb") + " WITH(NOLOCK)");
        });
        
        var sqlcmd = "<%=HiddenField1.Value%>";
        if (sqlcmd != "") { editor.setValue(sqlcmd); }
    });
</script>

    <%if(!String.IsNullOrEmpty(errorMsg)){ %><h4><%=errorMsg %></h4><%} %>
    <%else{ %>
<table id="PageTable" class="table table-bordered table-hover">
    <thead><%foreach (System.Data.DataColumn c in dt.Columns.Cast<System.Data.DataColumn>()){ %>
        <th><%=c.ColumnName %></th><%} %>
    </thead>
    <tbody>
        <%foreach(System.Data.DataRow r in dt.Rows.Cast<System.Data.DataRow>() ) {%>
        <tr>
        <%for(Int32 i=0;i<dt.Columns.Count;i++){ %>
        <td><%=r[i] %></td>
        <%} %>
            </tr>
        <%} %>
    </tbody>
</table>
        <%} %>
        </form>
</asp:Content>
