<%@ Page Language="c#" CodeBehind="PostSearch.aspx.cs" AutoEventWireup="True" Inherits="MTCUN.Search.PostSearch"
    Title="Sql查询编辑-分析" %>

<%@ Import Namespace="MTCUN" %>
<%@ Register Src="../UserCol/CodeBox.ascx" TagName="CodeBox" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <link id="linkStyle" runat="server" href="../Themes/Blue/css.css" rel="stylesheet"
        type="text/css" />
    <script language="javascript" type="text/javascript">
        function checkIssueType(source, args) {
            var chkListaTipoModificaciones = document.getElementById('cblSetGroup');
            var chkLista = chkListaTipoModificaciones.getElementsByTagName("input");
            for (var i = 0; i < chkLista.length; i++) {
                if (chkLista[i].checked) {
                    args.IsValid = true;
                    return;
                }
            }
            args.IsValid = false;
        }
    </script>
    <script type="text/javascript">
        var h1 = 250;
        function AddHeight(num) {
            var div = document.getElementById("tbxContent_div_HtmlBox");
            if (num < 0 && h1 < 250) {

            } else {
                h1 += num;
            }

            if (h1 > 0) {
                div.style.height = h1 + "px";
            }

            document.getElementById("tbxContent_codeboxheight").value = h1;
        }

        var h2 = 150;
        function AddHeight2(num) {
            var div = document.getElementById("tbxShowContent_div_HtmlBox");
            if (num < 0 && h2 < 150) {

            } else {
                h2 += num;
            }

            if (h2 > 0) {
                div.style.height = h2 + "px";
            }

            document.getElementById("tbxShowContent_codeboxheight").value = h2;
        }

        function insertHTML(edit, html) {
            edit.focus();
            if (edit != null) {
                var r = edit.document.selection.createRange();
                r.pasteHTML(html);
            }
        }

        function insertText(editid, text) {

            var editor = document.getElementById(editid);
            var editorDoc = editor.contentWindow.document;
            var editorWindow = editor.contentWindow;


            if (editor != null) {
                editor.focus();
                if (editorDoc.selection && editorDoc.selection.createRange) {
                    var r = editorDoc.selection.createRange();
                    r.text = text;
                } else {
                    editorDoc.body.innerHTML += text;
                }
            }
        }

    </script>
    <script src="../JScript/HtmlEdit.js" type="text/javascript"></script>
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <div class="divpanel">
            <table class="table" cellspacing="0">
                <tr>
                    <th colspan="2">ＳＱＬ语句编辑
                    </th>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">标题：
                    </td>
                    <td class="required">
                        <asp:TextBox runat="server" ID="tbxSearchName" Width="288px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="_tbxSearchName" runat="server" ControlToValidate="tbxSearchName"
                            ErrorMessage="请输入查询标题！"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">&nbsp;
                    </td>
                    <td style="vertical-align: baseline">
                        <label class="lab_button">
                            <input id="btnAddHeight" onclick="AddHeight(50);" title="加高编辑器" type="button" value="+" /></label>
                        <label class="lab_button">
                            <input id="btnClearHeight" onclick="AddHeight(-50);" title="减高编辑器" type="button"
                                value="-" /></label>
                        <label class="lab_button">
                            <input id="Button1" type="button" unselectable="on" value="{@SchoolID}" onclick="insertText('tbxContent_HtmlEdit', ' in ({@SchoolID:校区})')"
                                title="校区" /></label>
                        <label class="lab_button">
                            <input id="Button2" type="button" unselectable="on" value="{@StartDate}" onclick="insertText('tbxContent_HtmlEdit', ' {@StartDate:开始日期}')"
                                title="开始日期" /></label>
                        <label class="lab_button">
                            <input id="Button3" type="button" unselectable="on" value="{@EndDate}" onclick="insertText('tbxContent_HtmlEdit', ' {@EndDate:结束日期}')"
                                title="结束日期" /></label>
                        <label class="lab_button">
                            <input id="Button4" type="button" unselectable="on" value="{@Key}" onclick="insertText('tbxContent_HtmlEdit', ' {@Key:关键词}')"
                                title="关键词，可增加多个，比如Key1,Key2..." /></label>
                        <label class="lab_button">
                            <input id="Button5" type="button" unselectable="on" value="{@UserID}" onclick="insertText('tbxContent_HtmlEdit', ' {@UserID}')"
                                title="当前登录用户工号" /></label>
                        <label class="lab_button">
                            <input id="Button6" type="button" unselectable="on" value="ShowKey" onclick="insertText('tbxContent_HtmlEdit', ' as ShowKey')"
                                title="用于“明细”传递参数的列名称" /></label>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">主查询：
                    </td>
                    <td style="vertical-align: baseline">
                        <div style="float: left; width: 65%">
                            <uc1:CodeBox ID="tbxContent" runat="server" Width="100%" Height="220px" />
                        </div>
                        <div style="float: left">
                            <span style="color: Red; margin-left: 10px">*</span>
                        </div>
                        <div style="clear: both">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">&nbsp;
                    </td>
                    <td>
                        <label class="lab_button">
                            <input id="btnAddHeight2" onclick="AddHeight2(50);" title="加高编辑器" type="button" value="+" /></label>
                        <label class="lab_button">
                            <input id="btnClearHeight2" onclick="AddHeight2(-50);" title="减高编辑器" type="button"
                                value="-" /></label>
                        <label class="lab_button">
                            <input id="Button7" type="button" unselectable="on" value="{@SchoolID}" onclick="insertText('tbxShowContent_HtmlEdit', ' in ({@SchoolID})')"
                                title="校区" /></label>
                        <label class="lab_button">
                            <input id="Button8" type="button" unselectable="on" value="{@StartDate}" onclick="insertText('tbxShowContent_HtmlEdit', ' {@StartDate}')"
                                title="开始日期" /></label>
                        <label class="lab_button">
                            <input id="Button9" type="button" unselectable="on" value="{@EndDate}" onclick="insertText('tbxShowContent_HtmlEdit', ' {@EndDate}')"
                                title="结束日期" /></label>
                        <label class="lab_button">
                            <input id="Button10" type="button" unselectable="on" value="{@Key}" onclick="insertText('tbxShowContent_HtmlEdit', ' {@Key}')"
                                title="关键词，可增加多个，比如Key1,Key2..." /></label>
                        <label class="lab_button">
                            <input id="Button11" type="button" unselectable="on" value="{@UserID}" onclick="insertText('tbxShowContent_HtmlEdit', ' {@UserID}')"
                                title="当前登录用户工号" /></label>
                        <label class="lab_button">
                            <input id="Button12" type="button" unselectable="on" value="{@ShowKey}" onclick="insertText('tbxShowContent_HtmlEdit', ' {@ShowKey}')"
                                title="用于接收“明细”参数" /></label>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">子查询：
                    </td>
                    <td>
                        <uc1:CodeBox ID="tbxShowContent" runat="server" Width="65%" Height="150px" />
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">访问权限：
                    </td>
                    <td>
                        <table>
                            <tr>
                                <td>已选用户/组<asp:DropDownList ID="ddlAllow" runat="server">
                                    <asp:ListItem Value="0">禁止访问</asp:ListItem>
                                    <asp:ListItem Value="1">允许访问</asp:ListItem>
                                </asp:DropDownList>
                                </td>
                                <td>&nbsp;
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlGroupAndUsers" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlGroupAndUsers_SelectedIndexChanged">
                                        <asp:ListItem Value="0">所有用户组</asp:ListItem>
                                        <asp:ListItem Value="1">所有用户</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:ListBox ID="lbxSelected" runat="server" Height="129px" Width="150px" SelectionMode="Multiple"></asp:ListBox>
                                </td>
                                <td>
                                    <label class="lab_button">
                                        <asp:Button ID="btnAdd" runat="server" Text="&lt;加入" OnClick="btnAdd_Click" />
                                    </label>
                                    <br />
                                    <br />
                                    <label class="lab_button">
                                        <asp:Button ID="btnClear" runat="server" Text="移除&gt;" OnClick="btnClear_Click" />
                                    </label>
                                </td>
                                <td>
                                    <asp:ListBox ID="lbxGroupAndUsers" runat="server" Height="129px" Width="150px" SelectionMode="Multiple"></asp:ListBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">出现位置：
                    </td>
                    <td>
                        <ul style="padding: 0px; margin: 0px">
                            <li style="list-style-type: none; float: left">
                                <asp:CheckBoxList ID="cblSetGroup" runat="server" RepeatDirection="Horizontal">
                                    <asp:ListItem Value="1">咨询报名</asp:ListItem>
                                    <asp:ListItem Value="2">老师工作台</asp:ListItem>
                                    <asp:ListItem Value="3">教务管理</asp:ListItem>
                                    <asp:ListItem Value="4">财务管理</asp:ListItem>
                                    <asp:ListItem Value="5">仓库管理</asp:ListItem>
                                    <asp:ListItem Value="6">人事管理</asp:ListItem>
                                    <asp:ListItem Value="7">行政管理</asp:ListItem>
                                    <asp:ListItem Value="9">系统设置</asp:ListItem>
                                </asp:CheckBoxList>
                            </li>
                            <li style="list-style-type: none; float: left">
                                <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="checkIssueType"
                                    Display="Dynamic" ErrorMessage="*请选择出现位置（至少选择一个）！"></asp:CustomValidator></li>
                            <li style="list-style-type: none; clear: both"></li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">状态：
                    </td>
                    <td>
                        <asp:RadioButtonList ID="rblLockState" runat="server" Width="120px" RepeatDirection="Horizontal">
                            <asp:ListItem Value="0" Text="禁用"></asp:ListItem>
                            <asp:ListItem Value="1" Text="启用"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px">备注：
                    </td>
                    <td>
                        <asp:TextBox ID="tbxRemark" runat="server" Width="448px" TextMode="MultiLine" Height="60px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 83px"></td>
                    <td>
                        <label class="lab_button">
                            <asp:Button ID="btnSubmit" runat="server" Text="提交" OnClick="btnSubmit_Click"></asp:Button>
                        </label>
                        <label class="lab_button" id="__mt_labBack" runat="server">
                            <input causesvalidation="false" type="button" runat="server" onclick="back(this)" value="返回" /></label>
                    </td>
                </tr>
            </table>
        </div>
        <input id="tbxContent_codeboxheight" name="tbxContent_codeboxheight" type="hidden"
            value="250" />
        <input id="tbxShowContent_codeboxheight" name="tbxShowContent_codeboxheight" type="hidden"
            value="150" />
    </form>
</body>
</html>
