<%@ page language="C#" validaterequest="false" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="Admin_Admin_ManageAdZone, mallz" title="广告模板管理" enableeventvalidation="false" viewstateencryptionmode="never" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script type="text/javascript">

function ShowJsCode(JsName,ZoneName)
{
  var showJsObj=document.getElementById("AdZoneJS");
  var Jstext=document.getElementById("JsCode");
  showJsObj.style.display="block";
 
  
   Jstext.value ="<!----广告AD-----"+ZoneName+"--开始-->\r\n";
   Jstext.value +="<script type='text/javascript' src='/AD/"+JsName+"' charset='gb2312'></";
   Jstext.value +="script>\r\n";
   Jstext.value +="<!----广告AD-----"+ZoneName+"--结束-->";
}
</script>


 <table class="nick">
            <tr><td colspan="4" class="tit">快速查找</td></tr>
            <tr>
                <td class="ltd">版位名称：</td>
                <td class="rtd" style="width: 35%;">
                    <asp:TextBox ID="ZoneName"  runat="server" AutoPostBack="true"/></td>
                <td class="ltd">版位类型：</td>
                <td class="rtd" style="width: 35%;">
                  <asp:DropDownList ID="ZoneType" runat="server" AutoPostBack="true" >
                    <asp:ListItem  value="">全部</asp:ListItem>
                    <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:DropDownList>
                </td>
             </tr>
        </table>

         <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="AdZoneDatasource"  DataKeyNames="zoneid" OnRowDataBound="GridView1_RowDataBound" OnDataBound="GridView1_DataBound" CssClass="adminlist">
                    <Columns>
                        <asp:TemplateField HeaderText="选择" HeaderStyle-Width="4%">
                            <ItemTemplate>
                                <input type="checkbox" id="ids" name="ids" value="<%# Eval("ZoneID") %>"/>
                            </ItemTemplate>
                            <HeaderTemplate>
                               <input id="chkAll" onclick="SelectAllCheckboxes(this,'ids');" type="checkbox" />
                            </HeaderTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Zonename" HeaderText="名称" ItemStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left" />
                        <asp:TemplateField HeaderText="类型" HeaderStyle-Width="8%" >
                            <ItemTemplate>
                                <asp:Literal ID="Zonetype" runat="server" Text='<%# GetType(Eval("Zonetype").ToString()) %>'  />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="显示" HeaderStyle-Width="10%" >
                            <ItemTemplate>
                                <asp:Literal ID="ShowType" runat="server" Text='<%# GetShowType(Eval("ShowType").ToString()) %>'  />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="zoneWidth" HeaderText="长(px)" HeaderStyle-Width="6%"/>
                        <asp:BoundField DataField="zoneHeight" HeaderText="宽(px)" HeaderStyle-Width="6%" />
                        <asp:TemplateField HeaderText="状态" HeaderStyle-Width="6%" >
                            <ItemTemplate>
                                <asp:LinkButton ID="kaiguan" runat="server" Text='<%# (Eval("Active").ToString()=="True")?"开启":"关闭" %>' CommandArgument='<%#Eval("ZoneID") %>' CommandName='<%# Eval("Active") %>' OnCommand="SetActiveByID" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="操作" HeaderStyle-Width="22%">
                          <ItemTemplate>
                               <a href="<%# "Admin_ManageAd.aspx?zoneid="+Eval("ZoneID") %>">查看广告</a>
                               <asp:HyperLink ID="butupdate" runat="server"  Text="修改" NavigateUrl='<%#"Admin_UpdateAdzone.aspx?UpdateZoneID="+Eval("ZoneID") %>'  /> 
                               <asp:LinkButton ID="HyperLink1" runat="server"  Text="生成" CommandArgument='<%# Eval("ZoneID") %>' OnCommand="CreateJS"  /> 
                               <asp:HyperLink ID="PreviewAD" runat="server" NavigateUrl='<%#"../AD/admin_adprevrew.aspx?js="+Eval("zoneJSName") %>' Text='预览' target="_blank"/> 
                               <a href="javascript:void(0)" onclick="return ShowJsCode('<%# Eval("ZoneJSName") %>','<%#Eval("Zonename") %>')">调用</a> 
                               <asp:LinkButton ID="butdelete" runat="server" Text="删除"  CommandName='<%#Eval("ZoneID") %>' OnClientClick="{if(confirm('确定删除吗？')) return true;return false;}" OnCommand="Delete_Click" /> 
                          </ItemTemplate>
                        </asp:TemplateField>                      
                    </Columns>
                    <EmptyDataTemplate>
                    <tr>
                      <th>选择</th><th>名称</th><th scope="col">类型</th><th scope="col">显示</th><th scope="col">长(px)</th><th scope="col">宽(px)</th><th scope="col">状态</th><th scope="col">操作</th>
		              </tr>
		            <tr>
		               <td colspan="12">暂无广告版位！</td>
		            </tr>
                    </EmptyDataTemplate>
                </asp:GridView>              
            <div class="div_btm">
                <input type="button" value="反向选择" name="ddd" onclick="return SelectCheckboxes()" />
                <asp:Button ID="Button1" runat="server" Text="批量开启" OnClick="Button4_Click" />
                <asp:Button ID="Button2" runat="server" Text="批量关闭" OnClick="Button7_Click" />
                <asp:Button ID="Button4" runat="server" Text="生成广告" OnClick="Button8_Click" />
                <asp:Button ID="Button3" runat="server" OnClientClick="{if(confirm('确定删除吗？')) return true;return false;}" OnClick="Button3_Click" Text="批量删除" />
                
            </div>
             <div id="AdZoneJS" style="display:none;"> 
                 <textarea id="JsCode" cols="600" style="width:80%; height:60px;font-family:Verdana;" rows="4" ></textarea>
                 <div><input type="button" value="复制到粘贴板" onclick="copyCcode()" /></div>
             </div>
            <div class="help_intro" >
               <h1>新增广告流程：</h1>
               
                 <ul>
                    <li>第一步：新增广告版位---(注：广告版位作用是用于放置广告，相当于报纸杂志的广告版位，每个版位可放置1个或多个广告)</li>
                    <li>第二步：新增广告,在左侧选择该广告所投放的版位，设置权重及有效期.注（广告权重表示广告显示的机率，权重越大，显示的机率越大，若为0则不显示。<br />有效期--是指广告显示的有效期限，过期广告不显示）</li>
                    <li>第三步：在管理广告版位，选择刚才新增广告所选择的版位，点击预览，若能正确显示表示该广告生成成功。</li>
                    <li>第四步：点击调用JS代码，复制文本框的JS代码内容，将其放入模板合适的位置内，保存模板。</li>
                    <li>至此结束。</li>
                 </ul>
               
              
            </div>
        

    <asp:ObjectDataSource ID="AdZoneDatasource" runat="server" DeleteMethod="DelectAdZone" SelectMethod="GetAdZoneByNameOrType" TypeName="MallZ.Data.AdZoneBll"  OldValuesParameterFormatString="original_{0}">
        <DeleteParameters>
            <asp:Parameter Name="AdZoneID" Type="Int32" />
        </DeleteParameters>  
        <SelectParameters>
            <asp:ControlParameter Name="ZoneName"  DefaultValue="" ControlID="ZoneName" PropertyName="Text" Type="string" />
            <asp:ControlParameter Name="ZoneType"  DefaultValue="0" ControlID="ZoneType" PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>    
</asp:Content>

