<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="Admin_Admin_LabelSqlBuild, mallz" title="配置查询语句" enableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<style type="text/css">
    .label_square{width:100px;height:30px;line-height:30px;border:solid 1px #449AE8;background:#E0EEF5;text-align:center;margin:5px;float:left;cursor: pointer;}
    .drag_lablestyle{width:100px;height:30px;line-height:30px;border:solid 1px #449AE8;background:#E0EEFE;text-align:center;margin:5px;float:left;}
</style>

<script type="text/javascript">
<!--
var dragspan;
var src;

function dragstart()
{
    window.drag = 1;
    window.event.returnValue = false;
    
    dragspan = document.createElement('div');
    dragspan.style.position = "absolute";
    dragspan.className = "drag_lablestyle";
    var mousePos = mouseCoords(window.event);
    dragspan.style.left = mousePos.x + 10;
    dragspan.style.top = mousePos.y + 8;
            
    dragspan.appendChild(document.createTextNode(window.event.srcElement.innerText));
    src = window.event.srcElement.innerText;

    document.body.appendChild(dragspan);
}

function dragend(type)
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        var target = window.event.srcElement;
        if(type == 1)
        {
            target.focus();
            var tarobj = document.selection.createRange();
            tarobj.text = "@" + src;
        }
        else
        {
            target.value = "@" + src;
        }
        window.drag = 0;
        window.event.returnValue = true;
    }
    
}

function dragmove()
{
    if(window.drag)
    {
        var ev = ev || window.event;
        var mousePos = mouseCoords(ev);

        ev.returnValue = false;
                 
        dragspan.style.left = mousePos.x + 10;
        dragspan.style.top = mousePos.y + 8;
    }
}

function dragclear()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        window.drag = 0;
        window.event.returnValue = true;
    }
    
}
   
function mouseCoords(ev) {
    if(ev.pageX || ev.pageY) {
      return {x:ev.pageX, y:ev.pageY};
    }
    return {
      x:ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft,
      y:ev.clientY + document.documentElement.scrollTop - document.body.clientTop
    };
}

function movePoint() 
{
    if(window.drag)
    {
        var rng = event.srcElement.createTextRange(); 
        rng.moveToPoint(event.x,event.y); 
        rng.select(); 
    }
}
function showHideCountPage()
{
   var obj=document.getElementById("showCount");
   var usepage = document.getElementById("ctl00_ContentPlaceHolder1_UsePage");
   if(usepage.checked==true)
   {
      obj.style.display="none";
   }
   else
   {
      obj.style.display="none";
   }
}
-->
</script>


   <table class="nick" cellpadding="1" cellspacing="1" onmouseup="dragclear()" onmousemove="dragmove()">
       <tr><td class="tit" colspan="2">标签查询设置</td></tr>
       <tr>
           <th>每页输出行数：</th>
           <td class="rtd"><asp:TextBox ID="OutPutNums" runat="server"  Text="10" MaxLength="3" Width="40" /> 
           <asp:CheckBox ID="UsePage" runat="server"  />启用分页</td>
       </tr>
       <tr>
           <th>选择数据：</th>
           <td class="rtd">
               <table width="80%" style="text-align:right;">
                  <tr>
                     <td width="150px" style="text-align:right;">主数据表：</td><td><asp:DropDownList ID="MainSheet" runat="server" AppendDataBoundItems="true" Width="200px" DataTextField="NAME" DataValueField="NAME" OnSelectedIndexChanged="MainSheet_SelectIndexChanged" AutoPostBack="true" EnableViewState="true" >
                        <asp:ListItem Text="请选择数据库表" Value="" />
                     </asp:DropDownList>
                     </td>
                     <td width="150px" style="text-align:right;">从数据表：</td><td><asp:DropDownList ID="SecondSheet" runat="server" AppendDataBoundItems="true" Width="200px" DataTextField="NAME" DataValueField="NAME" OnSelectedIndexChanged="SecondSheet_SelectIndexChanged" AutoPostBack="true" EnableViewState="true">
                        <asp:ListItem Text="请选择数据库表" Value="" />
                     </asp:DropDownList></td>
                  </tr>
                  <tr>
                     <td style="text-align:right;">输出字段：</td><td><asp:ListBox ID="MainList" runat="server" SelectionMode="Multiple" Width="200px" Height="250px" EnableViewState="true" /></td>
                     <td style="text-align:right;">输出字段：</td><td><asp:ListBox ID="SecondList" runat="server" SelectionMode="Multiple" Width="200px" Height="250px" EnableViewState="true" /></td>
                  </tr>
               </table>
               提示：按住 Ctrl 键可多选
           </td>
       </tr>
       <tr id="linkCondition" runat="server" visible="false">
           <th>约束条件：</th>
           <td class="rtd">
              <asp:DropDownList ID="JoinList" runat="server">
                 <asp:ListItem>Inner Join</asp:ListItem>
                 <asp:ListItem>Left Join</asp:ListItem>
                 <asp:ListItem>Right Join</asp:ListItem>
                 <asp:ListItem>Outer Join</asp:ListItem>
              </asp:DropDownList>
              <asp:DropDownList ID="MainList_Join" runat="server" />
              <asp:DropDownList ID="JoinLink" runat="server">
                  <asp:ListItem>=</asp:ListItem>
                   <asp:ListItem>like</asp:ListItem>
              </asp:DropDownList>
              <asp:DropDownList ID="SecondList_Join" runat="server" />
          </td>
       </tr>
       <tr>
           <th><asp:button runat="server" Text="生成查询条件"  ID="CreateSQLSearchButton" OnClick="CreateSQLSearchButton_Click"/></th>
           <td class="rtd">
              <div style="width:80%; text-align:center;">
                   <asp:PlaceHolder ID="CreateSQLSearch" runat="server"  />
              </div>
           </td>
       </tr>
       <tr>
           <th>自定义参数：</th>
           <td class="rtd"><asp:Literal ID="parmlist" runat="server" /> </td>
       </tr>
       <tr>
           <th><asp:Button ID="BuildSQl_Button" runat="server" Text="生成SQL语句"  OnClick="BuildSQl_Button_Click"/><br />
           <input onmouseover="this.select()" value="{Prefix}" style="border:0; text-align:right; width:60px;" /> -- 表前缀</th>
           <td class="rtd"><asp:TextBox ID="SqlContent" TextMode="MultiLine" Height="100px" Width="90%" runat="server" CssClass="TextBoxStyle" /></td>
       </tr>
       </table>
       <div class="div_btm">
              <asp:Button ID="PreStepButton" runat="server" Text=" 上一步 "  OnClick="PreStepButton_Click" />&nbsp;&nbsp;
              <asp:Button ID="NextStepButton" runat="server" Text=" 下一步 " OnClick="NextStepButton_Click" />&nbsp;
              <asp:Button ID="SaveButton" runat="server" Text=" 保 存 "   OnClick="SaveButton_Click" Visible="false"/>&nbsp;
              <input type="button" value=" 取 消 " onclick="location.href='Admin_Lable.aspx'" />
       </div>
   
   <asp:HiddenField ID="H_flag" runat="server" />

</asp:Content>

