<%@ Page Language="C#" MasterPageFile="~/Dialog/DialogMaster.Master" AutoEventWireup="true"
    CodeBehind="SearchFormDesign.aspx.cs" Inherits="OAWeb.Modules.SearchFormDesign"
    Title="无标题页" Theme="Default" EnableViewState="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function OpenFieldEditDialog(Id) {
            var ViewName = '<%=ViewName %>';
            if (Id != "" && Id != null && Id != undefined)
                OpenDialog("/Modules/SearchFormFieldEdit.aspx?view=" + ViewName + "&ID=" + Id, "编辑字段");
            else
                OpenDialog("/Modules/SearchFormFieldEdit.aspx?view=" + ViewName, "新增字段");
        }
    </script>
    <script type="text/javascript">
        function OpenFormEditDialog(module) {
            OpenDialog("/Modules/SearchFormEdit.aspx?ViewName=" + module, "视图信息");
        }

        //隐藏指定控件
        function dispalyControl(obj, controlid, values) {
            var control = document.getElementById(controlid);

            if (control == null) return;
            if (obj.value == values) {
                control.style.display = "";
            }
            else {
                control.style.display = "none";
            }

            var txtId = obj.id.replace("ddl", "txt");
            if (obj.value == "SomeDayBefore" || obj.value == "SomeDayIn") {

                document.getElementById(txtId).style.display = "";
            }
            else {
                document.getElementById(txtId).style.display = "none";
            }
        }

        //通过ajax获取下拉框数据
        function AjaxLoadListBoxData(url, ListBoxID, DefaultValue) {
            var item = document.getElementsByName(ListBoxID)[0];
            if (item == null || item == undefined) return;
            var result = "";
            var xmlHttp = createXMLRequest();
            xmlHttp.onreadystatechange = function () {
                if (xmlHttp.readyState == 4) {
                    if (xmlHttp.status == 200) {
                        result = xmlHttp.responseText;
                        if (result != "") {
                            item.options.length = 0;
                            item.options.add(new Option("请选择", ""));
                            var piArray = eval(result);
                            for (var i = 0; i < piArray.length; i++) {
                                if (piArray[i] == "undefined" || piArray[i] == null) continue;
                                item.options.add(new Option(piArray[i].Text, piArray[i].Value));
                                if (piArray[i].Value == DefaultValue) {
                                    item.selectedIndex = item.length - 1;
                                }
                            }
                        }
                        else {
                            //alert(result);
                        }
                    }
                    delete xmlHttp;
                    xmlHttp = null;
                }
            }
            xmlHttp.open("GET", url, true);
            xmlHttp.send("");
        }

        //通过JSON获取城市地区数据
        function LoadCity(ProvinceValue, CityID, CityValue) {
            var webUrl = "/Ajax.aspx?op=LoadCityJson&id=" + ProvinceValue;
            AjaxLoadListBoxData(webUrl, CityID, CityValue);
        }

        //创建XMLHTTP对象
        function createXMLRequest() {
            var xmlHttp = false;
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (E) {
                    xmlHttp = false;
                }
            }
            if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
                xmlHttp = new XMLHttpRequest();
            }
            return xmlHttp;
        }
    </script>

    <table>
        <tr>
            <td>
                <table align="left">
                    <tr>
                        <td >
                            <asp:Button ID="btnEditInfo" runat="server" Text="编辑视图信息" CssClass="btn_77px" />
                            <asp:Button ID="btnAddField" runat="server" Text="添加字段" CssClass="btn_77px" />
                            <asp:Button ID="btnCancel" runat="server" Text="刷新" CssClass="btn_77px" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <table id="tblMain" runat="server" cellpadding="0" border="0" cellspacing="5">
                </table>
            </td>
        </tr>
    </table>
    <div style="height: 30px">
        &nbsp;</div>
</asp:Content>
