<%@ Page Language="C#" AutoEventWireup="true" Inherits="System_Label_PropertyList, QianboCMS" EnableEventValidation="false" %>
<!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 runat="server">
    <title>属性列表</title>
    <script type="text/javascript" src="../../Js/jquery.js"></script>
    <script type="text/javascript" src="../../Js/lhgdialog/lhgdialog.min.js?self=true"></script>
    <script language="javascript" type="text/javascript" src="../../Js/Common.js"></script>
    <link rel="stylesheet" type="text/css" href="../Css/layout.css" />
    <script type="text/javascript">
        var api = frameElement.api, W = api.opener, D = W.document;
    </script>
    <script language="javascript" type="text/javascript">
        function setPageStyle() {
            $('txtPageNav').focus();
            if (D.selection) {
                var range = D.selection.createRange();
                range.text = "{@page_nav}";
            }
        }
        function SwitchList() {
            window.location.href = document.form1.selectList.value
        }
        function FunShoHIdComp() {
            if ($("selColumns").value != "1")
                trCom.style.display = "none";
            else
                trCom.style.display = "";
        }
        function SelectSorce(obj) {
            if ($("ddlProperty").value == "sel") {
                alert("请选择属性！");
                obj.checked = false;
                return;
            }
            var propertyId = $("ddlProperty").value;
            trSelSorce.style.display = "";
            switch (obj.value) {
                case "0":
                    document.getElementById("spanProSorceNmae").innerText = "模型";
                    dataSorceObj = System_Label_PropertyList.GetDataSource("0" + "|" + propertyId);
                    $("tdDataSorce").innerHTML = GetSorceHtml(0, dataSorceObj);
                    break;
                case "1":
                    document.getElementById("spanProSorceNmae").innerText = "表单";
                    dataSorceObj = System_Label_PropertyList.GetDataSource("1" + "|" + propertyId);
                    $("tdDataSorce").innerHTML = GetSorceHtml(1, dataSorceObj);
                    break;
                case "2":
                    document.getElementById("spanProSorceNmae").innerText = "用户";
                    dataSorceObj = System_Label_PropertyList.GetDataSource("2" + "|" + propertyId);
                    $("tdDataSorce").innerHTML = GetSorceHtml(2, dataSorceObj);
                    break;
            }
        }
        function GetSorceHtml(type, obj) {
            switch (type) {
                case 0:
                    if (obj.value == null) {
                        return "该属性没有绑定模型";
                    }
                    break;
                case 1:
                    if (obj.value == null) {
                        return "该属性没有绑定表单";
                    }
                    break;
                case 2:
                    if (obj.value == null) {
                        return "该属性没有绑定用户";
                    }
                    break;
            }
            var count = obj.value.Rows.length;
            var htmlCode = "";
            for (var i = 0; i < count; i++) {
                switch (type) {
                    case 0:
                        htmlCode = htmlCode + "<input type=\"checkbox\" name=\"chkDataSorce\" value=\"" + obj.value.Rows[i]["ModelId"] + "\">" + obj.value.Rows[i]["ModelName"] + ""
                        break;
                    case 1:
                        htmlCode = htmlCode + "<input type=\"checkbox\" name=\"chkDataSorce\" value=\"" + obj.value.Rows[i]["CustomFormId"] + "\">" + obj.value.Rows[i]["FormName"] + ""
                        break;
                    case 2:
                        htmlCode = htmlCode + "<input type=\"checkbox\" name=\"chkDataSorce\" value=\"" + obj.value.Rows[i]["Id"] + "\">" + obj.value.Rows[i]["Name"] + ""
                        break;
                }
            }
            return htmlCode;
        }
        function SetPropertyType(val) {
            if ($("ddlProperty").value == "sel") {
                alert("请选择属性！");
                return;
            }
            var result = System_Label_PropertyList.GetPropertytype(val);
            if (result.value != null) {
                $('tbSelectType').options.length = 0;
                var count = result.value.Rows.length;
                for (var i = 0; i < count; i++) {
                    var text = result.value.Rows[i]["PropertyCName"];
                    var val = result.value.Rows[i]["Id"];
                    $('tbSelectType').options.add(new Option(text, val));
                }
            }
        }
        function CreatePropertyList() {
            var labelstr = "{$Qianbo id=\"propertylist\"";
            var propertyid = "";
            var propertytype = "";
            var datasorcetype = "";
            var datasorceidstr = "";
            var listcolumns = "";
            var ispage = "";
            var pagestyle = "";
            var pagesize = "";
            var pagemethod = "";
            var pagenav = "";
            var liststyle = "";
            var layoutmethod = "";
            var dateformat = "";
            var infocount = "";
            var daterange = "";
            var order = "";
            var titlelength = "";
            var rowscount = "";
            var compart = "";
            var ajaxflag = "";
            if ($("ddlProperty").value == "sel") {
                alert("请选择属性！");
                return;
            }
            else {
                propertyid = $("ddlProperty").value;
                labelstr = labelstr + " propertyid=\"" + propertyid + "\"";
            }
            var obj = document.getElementById("tbSelectType");
            for (var i = 0; i < obj.length; i++) {
                if (obj[i].selected == true) {
                    propertytype = propertytype + obj[i].value + ",";
                }
            }
            if (propertytype == "") {
                for (var i = 0; i < obj.length; i++) {
                    propertytype = propertytype + obj[i].value + ",";
                }
            }
            propertytype = propertytype.substring(0, propertytype.length - 1)
            labelstr = labelstr + " propertytype=\"" + propertytype + "\"";
            var datasorcetypeobj = document.getElementsByName("rdoPropertySorce");
            var datasorcetypeflag = false;
            for (var i = 0; i < datasorcetypeobj.length; i++) {
                if (datasorcetypeobj[i].checked == true) {
                    datasorcetype = datasorcetypeobj[i].value;
                    datasorcetypeflag = true;
                }
            }
            if (!datasorcetypeflag) {
                alert("请选择数据来源！");
                return;
            }
            else {
                labelstr = labelstr + " datasorcetype=\"" + datasorcetype + "\"";
            }
            var datasorceobj = document.getElementsByName("chkDataSorce");
            for (var i = 0; i < datasorceobj.length; i++) {
                if (datasorceobj[i].checked == true) {
                    datasorceidstr += datasorceobj[i].value + ",";
                }
            }
            if (datasorceidstr.length > 0) {
                datasorceidstr = datasorceidstr.substring(0, datasorceidstr.length - 1);
                labelstr = labelstr + " datasorceidstr=\"" + datasorceidstr + "\"";
            }
            else {
                alert("请选择具体数据源！");
                return;
            }
            labelstr = labelstr + " listcolumns=\"" + $("selColumns").value + "\"";
            if ($("chkIsPage").checked == true) {
                labelstr = labelstr + " ispage=\"true\"";
            }
            else {
                labelstr = labelstr + " ispage=\"false\"";
            }
            labelstr = labelstr + " pagemethod=\"" + $("txtPageStyle").value + "\"";
            labelstr = labelstr + " pagesize=\"" + $("txtPageSize").value + "\"";
            labelstr = labelstr + " pagestyle=\"" + $("txtPageCss").value + "\"";
            labelstr = labelstr + " pagenav=\"" + $("txtPageNav").value + "\"";
            labelstr = labelstr + " liststyle=\"" + $("ddlListStyle").value + "\"";
            labelstr = labelstr + " layoutmethod=\"" + $("selShowStyle").value + "\"";
            labelstr = labelstr + " dateformat=\"" + $("txtDateFormat").value + "\"";
            labelstr = labelstr + " infocount=\"" + $("txtArticleCount").value + "\"";
            labelstr = labelstr + " daterange=\"" + $("txtDateRange").value + "\"";
            labelstr = labelstr + " order=\"" + $("selectOrder").value + "\"";
            labelstr = labelstr + " titlelength=\"" + $("txtTitleCount").value + "\"";
            labelstr = labelstr + " rowscount=\"" + $("txtNewsRows").value + "\"";
            labelstr = labelstr + " compart=\"" + $("txtCompart").value + "\"";
            if ($("chkAjax").checked == true) {
                labelstr = labelstr + " ajaxflag=\"true\"";
            }
            else {
                labelstr = labelstr + " ajaxflag=\"false\"";
            }
            labelstr = labelstr + " /}";
            D.all.lblContent.focus();
            if (D.selection) {
                var reange = D.selection.createRange();
                reange.text = labelstr;
            }
            api.close();
        }
    </script>
</head>

<body>
    <form id="form1" runat="server">
        <div>
            <table cellspacing="1" cellpadding="0" class="wzdh" align="center">
                <tr>
                    <td>
						<span style="float: left;"><strong>属性列表参数设置</strong></span>
                        <span style="float: right;"><a href="#" onclick="javascript:api.close();">关闭</a>&nbsp;</span>
					</td>
                </tr>
            </table>
            <table border="0" cellpadding="0" cellspacing="1" class="border" align="center">
                <tr>
                    <td class="bqleft">标签所属类别：</td>
                    <td class="bqright">
                        <select id="selectList" onchange="SwitchList()">
                            <option value="PropertyList.aspx" selected="selected">属性列表</option>
                            <option value="PropertySyc.aspx">属性循环</option>
                        </select>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">请选择属性：</td>
                    <td class="bqright">
                        <asp:DropDownList ID="ddlProperty" runat="server" onchange="SetPropertyType(this.value)"></asp:DropDownList>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">选择类别：</td>
                    <td class="bqright">
                        <asp:ListBox ID="tbSelectType" runat="server" Width="150" Height="150" SelectionMode="Multiple"></asp:ListBox>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">数据来源：</td>
                    <td class="bqright">
                        <input id="Radio1" onclick="SelectSorce(this)" name="rdoPropertySorce" value="0" type="radio" />模型
                        <input id="Radio2" onclick="SelectSorce(this)" name="rdoPropertySorce" value="1" type="radio" />表单
                        <input id="Radio3" onclick="SelectSorce(this)" name="rdoPropertySorce" value="2" type="radio" />用户
					</td>
                </tr>
                <tr id="trSelSorce" style="display: none;">
                    <td class="bqleft">请选择<span id="spanProSorceNmae"></span>：</td>
                    <td class="bqright" id="tdDataSorce"></td>
                </tr>
                <tr>
                    <td class="bqleft">属性列表列数：</td>
                    <td class="bqright">
                        <select id="selColumns" onchange="FunShoHIdComp()">
                            <script language="javascript" type="text/javascript">
                                for (i = 1; i <= 5; i++) {
                                    document.write("<option value=" + i + ">" + i + "</option>");
                                }
                            </script>
                        </select>
					</td>
                </tr>
                <script type="text/javascript">
                    var jq = jQuery.noConflict();
                    jQuery(function () {
                        jQuery('#btnSetStyle').click(function () {
                            jQuery.dialog({
                                id: 'txtSetStyle',
                                lock: true,
                                title: '分页效果',
                                content: "url:SetPage.aspx",
                                width: 450,
                                height: 165
                            });
                        });
                    });
                </script>
                <tr id="trPage">
                    <td class="bqleft">是否使用分页：</td>
                    <td class="bqright">
                        <input id="chkIsPage" type="checkbox" checked="checked" />分页效果
                        <input id="txtPageStyle" size="1" type="text" value="1" />
                        <input id="btnSetStyle" class="btn" type="button" value="设置" />
                        每页数量
                        <input id="txtPageSize" type="text" size="2" value="10" />
                        分页Css：<input id="txtPageCss" size="50" type="text" />
					</td>
                </tr>
                <tr>
                    <td class="bqleft">分页样式：</td>
                    <td class="bqright">
                        <textarea id="txtPageNav" rows="5" style="width: 550px;">{@page_nav}</textarea>
                        <br />
                        <a href="#" onclick="setPageStyle()"><span style="color: #4975dc;">插入分页标签</span></a>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">引用列表样式：</td>
                    <td class="bqright">
                        <asp:DropDownList ID="ddlListStyle" runat="server"></asp:DropDownList>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">布局方式：</td>
                    <td class="bqright">
                        <select id="selShowStyle">
                            <option value="out_table" selected="selected">表格</option>
                            <option value="out_div">Div+Css</option>
                        </select>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">日期样式：</td>
                    <td class="bqright">
                        <input id="txtDateFormat" type="text" value="YY年MM月DD日" size="12" />
                        格式：YYYY(4位数年份 如：2012)、MM(月)、DD(日)、HH(小时)、MI(分)、SS(秒)
					</td>
                </tr>
                <tr id="ultimateList">
                    <td class="bqleft">调用记录条数：</td>
                    <td class="bqright">
                        <input name="txtArticleCount" id="txtArticleCount" type="text" value="10" size="3" maxlength="200" />
                        <span class="tips">为0则调用所有记录</span>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">日期范围：</td>
                    <td class="bqright">
						默认最近显示
						<input id="txtDateRange" type="text" value="0" size="4" maxlength="200" id="txtDateRange" />
                        天内的文章 <span class="tips">为0则显示所有文章</span>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">排序方式：</td>
                    <td class="bqright">
                        <select name="selectOrder" id="selectOrder">
                            <option value="datedesc">添加日期降序</option>
                            <option value="dateasc">添加日期升序</option>
                            <option value="hitasc">文章点击升序</option>
                            <option value="hitdesc">文章点击降序</option>
                        </select>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">标题字数：</td>
                    <td class="bqright">
                        <input name="txtTitleCount" type="text" value="30" size="3" maxlength="200" />
                        <span class="tips">为0则显示完整标题</span>
					</td>
                </tr>
                <tr id="trCom">
                    <td class="bqleft">循环行样式：</td>
                    <td class="bqright">
						每显示
						<input type="text" value="0" size="1" maxlength="200" id="txtNewsRows" />
                        行后，向循环列表中插入代码：
						<input type="text" value="&lt;hr&gt;" size="50" maxlength="200" id="txtCompart" />
                        <span class="tips">支持Html代码</span>
					</td>
                </tr>
                <tr>
                    <td class="bqleft">标签类型：</td>
                    <td class="bqright">
                        <input type="checkbox" id="chkAjax" />
                        <label for="chkAjax">设置该标签为ajax标签</label>
					</td>
                </tr>
                <tr>
                    <td class="bqleft"></td>
                    <td class="bqright">
                        <input id="btnSubmit" class="btn" type="button" value="确定创建此标签" onclick="CreatePropertyList()" />
                        <input class="btn" type="button" value="取消" onclick="javascript: api.close();" />
					</td>
                </tr>
            </table>
        </div>
    </form>
    <br />
</body>
</html>