<%@ Page Language="C#" MasterPageFile="~/admin/admin_page.master" AutoEventWireup="true" CodeBehind="freedomlabel_edit.aspx.cs" Inherits="YXShop.Web.admin.templates.label.freedomlabel_edit" %>

<asp:Content ID="ContHead" runat="server" ContentPlaceHolderID="head">
<link rel="stylesheet" href="../../style/admin.css" type="text/css" />
    <script src="../../../scripts/prototype.js" type="text/javascript"></script>
    <link rel="stylesheet" href="../../style/validator.css" type="text/css" />
    <script type="text/javascript" src="../../../scripts/validate.js"></script>
    <script src="../../scripts/freedom.js" type="text/javascript"></script>
    <script type="text/javascript">
function GoNext()
{
    var snm = encodeURIComponent(document.getElementById('<%=TxtName.ClientID %>').value.trim());
    if(snm == '')
    { 
        document.getElementById('<%=TxtName.ClientID %>').focus();
        document.getElementById("divName").className="msgError";       
        return;
    }else
    {   
        document.getElementById("divName").className="msgNormal";
    }
    var s = encodeURIComponent(document.getElementById('TxtSql').value.trim());
    if(s == '')
    {
        document.getElementById('TxtSql').focus();
        document.getElementById("divSql").className="msgError";
        return;
    }else
    {
        document.getElementById("divSql").className="msgNormal";
    }
    if(s.length > 4000)
    {
        document.getElementById('TxtSql').focus();
        document.getElementById("divSql").className="msgError";
        return;
    }else
    {
       document.getElementById("divSql").className="msgNormal";
    }    
    var id=document.getElementById('tid').value;
    var scon=encodeURIComponent(document.getElementById('tcon').value);
    var des=encodeURIComponent(document.getElementById('Descrpt').value);
    var otb0 = document.getElementById('SelPrin');
    var otb1 = document.getElementById('SelSub');
    var tb0 = otb0.options[otb0.selectedIndex].value;
    var tb1 = otb1.options[otb1.selectedIndex].value;      
    window.location.href=encodeURI("freedomlabel_edit_end.aspx?name="+snm+"&sql="+s+"&lid="+id+"&con="+scon+"&des="+des+"&SelPrin="+tb0+"&SelSub="+tb1);
}
function CheckSqlSubmit(obj){

   var sql=encodeURIComponent(document.getElementById('TxtSql').value);
   if(sql==''){
      document.getElementById("divSql").className="msgError";
      return;
   }
   else
   {
     document.getElementById("divSql").className="msgNormal";
   }
   window.location.href=encodeURI("freedomlabel_test.aspx?sql="+sql);
  
}
</script>
</asp:Content>
<asp:Content ID="ContTitle" runat="server" ContentPlaceHolderID="pagetitle">
编辑自由标签
<asp:HyperLink ID="HyperLink2" runat="server"  CssClass="inputbutton" NavigateUrl="#"  onclick="GoNext()" Width="65px" Height="24px" onMouseOver="javascript:document.getElementById(this.id).className='inputbutton_a'" onMouseOut="javascript:document.getElementById(this.id).className='inputbutton'">下一步</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  NavigateUrl="~/admin/templates/label/freedomlabel_list.aspx" runat="server"  CssClass="inputbutton" Width="65px" Height="24px" onMouseOver="javascript:document.getElementById(this.id).className='inputbutton_a'" onMouseOut="javascript:document.getElementById(this.id).className='inputbutton'">返回列表</asp:HyperLink>
</asp:Content>
<asp:Content ID="ContInfo" runat="server" ContentPlaceHolderID="pageinfo">
</asp:Content>
<asp:Content ID="ContSarch" ContentPlaceHolderID="pagesarch" runat="server">
<asp:Panel ID="pnlMsg" runat="server" Visible="false" CssClass="pnlReturnMessageErr ">
    <asp:Literal ID="ltlMsg" runat="server"></asp:Literal>
</asp:Panel>
</asp:Content>
<asp:Content ID="ContMain" runat="server" ContentPlaceHolderID="workspace">        
  <table width="98%"  cellspacing="1" cellpadding="1" style="background-color:White;" align="center" class="form_table_input">
                <tr>
                    <td>
                        标签名称：<span style="font-weight:bold;color:Red">{#YXShopFreeTag*</span><asp:TextBox 
                            ID="TxtName"  runat="server" ontextchanged="TxtName_TextChanged" AutoPostBack="true"></asp:TextBox><span style="font-weight:bold;color:Red">#}</span>
                    </td>
                    <td>
                       <div id="divName" class="msgNormal">标签名称不能为空</div>
                    </td>
          
                </tr>
                <tr>
                    <td>主 &nbsp;&nbsp; 表： 
                        <select id="SelPrin" name="SelPrin" onchange="ChangeDbTable(this,0)">
                            <option value="0">请选择</option>
                            <%# TabList1%>
                         </select>
                    </td>
                    <td>从 &nbsp;&nbsp; 表： 
                        <select id="SelSub" name="SelSub" onchange="ChangeDbTable(this,1)">
                            <option value="0">请选择</option>
                            <%# TabList2%>
                        </select>
                    </td>
               </tr>
               <tr>
                    <td>
                        <div style="background-color:White;width:100%;height:200px;overflow:auto;border-color:#cccccc;border-width:1px;border-style:groove;padding-left:3px;padding-top:5px;">
                            <table id="TBL0" width="96%" cellpadding="0" cellspacing="0">
                                <tbody id="TBD0">
                                    <tr>
                                        <td align="center" width="40%">字段名</td><td align="center" width="15%">类型</td><td align="center" width="10%">
                                        显示</td><td align="center" width="25%">条件</td><td align="center" width="10%">排序</td>
                                    </tr>
                                    <%# List1%>
                                </tbody>
                            </table>
                        </div>
                    </td>
                    <td>
                        <div style="background-color:White;width:100%;height:200px;overflow:auto;border-color:#cccccc;border-width:1px;border-style:groove;padding-left:3px;padding-top:5px;">
                            <table id="TBL1" width="96%" cellpadding="0" cellspacing="0">
                                <tbody id="TBD1">
                                    <tr>
                                        <td align="center" width="40%">字段名</td><td align="center" width="15%">类型</td><td align="center" width="10%">
                                        显示</td><td align="center" width="25%">条件</td><td align="center" width="10%">排序</td>
                                    </tr>
                                    <%# List2%>
                                </tbody>
                            </table>
                        </div>
                   </td>
               </tr>
                <tr>
                    <td colspan="2">
                        联接字段：主表字段 <select id="SelJoinPrin" onchange="ChangeSql(this)"><option value="0">请选择</option><%# JoinFlds1%></select> 
                        从表字段 <select id="SelJoinSub" onchange="ChangeSql(this)"><option value="0">请选择</option><%# JoinFlds2%></select>
                    </td>
                </tr>
                <tr>
                    <td>SQL语句  <input id="btnSql" type="button" onclick="CheckSqlSubmit(this)" value="执行SQL语句" /></td>
                    <td><div id="divSql" class="msgNormal">标签的SQL语句不能为空,语句长度不能超过4000</div></td>
                </tr>
                <tr>
                    <td colspan="2">                       
                         <textarea cols="7" rows="7" id="TxtSql" name="TxtSql" readonly="readonly" style="width:99%;height:70px; overflow:auto;"><%# lblsql%></textarea>
                    </td>
                </tr>
                </table>
            <div class="msgFree">
<p>说明：</p>
<p>1.此功能建议具有一定SQL基础的人使用。如果不熟悉SQL，<span style="color:Red">请谨慎使用，以防误操作引起的数据损坏。</span></p>
<p>2.判断型数字赋值：0为否，1为是。</p>
<p>3.如果设置条件的字段为文本、文本型ID、时间日期等类型，赋值时请前后加 &#39; ，如：= &#39;内容&#39; 、In(&#39;内容1&#39;，&#39;内容2&#39;),<br />&nbsp;&nbsp;否则会出错；Like关系除外。</p>
<p>4.在下一步设置之前，建议先点击测试按钮确认sql语句没有问题再继续。</p>
<p>5.<span style="color:Red">注意：</span>如果需要对SQL语句执行结果进行分页，SQL语句中必须要有where条件与order by 排序。</p>
            </div>
            <br />
            <table width="100%" border="0" cellpadding="8" cellspacing="0"
                style="height: 76px">
                <tr>
                    <td align="center">                  
                    </td>
                </tr>
            </table>
        
        <input id="tid" type="hidden" name="LID" value="<%# id%>" />
        <textarea id="tcon" style="display:none;" name="StyleCon" rows="1" cols="1"><%# stylecon%></textarea>
        <input  id="Descrpt" type="hidden" name="Descrpt" value="<%# descrpt%>" />
</asp:Content>