<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="HL_Admin_Admin_HotKey, WebApp_deploy" title="热门关键字" enableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script  type="text/javascript">
   var HotKeyArray = new Array();//关键字数组:名称,点击数,URL
   <asp:Literal ID="JavascriptLiteral" runat="server" />
   	function selectHotKey(obj){
   	 
		var da = HotKeyArray[obj];
			if(da){
				var key_name = da[0];
				var key_hits = da[1];
				var key_url  = da[2];
			
				document.getElementById('ctl00_ContentPlaceHolder1_hot_key_name').value = key_name;
				document.getElementById('ctl00_ContentPlaceHolder1_hot_key_hits').value = key_hits;
				document.getElementById('ctl00_ContentPlaceHolder1_hot_key_url').value = key_url;
				document.getElementById('add_search_type').style.display ="none" ;
				document.getElementById('h_action').value = "modify";	
				document.getElementById('id').value = obj;	
				document.getElementById('search_url').style.display="";

				document.getElementById('hot_key_title').innerHTML="修改热门关键字";
				document.getElementById('Add_HotKey').style.display="";
				document.getElementById('ctl00_ContentPlaceHolder1_AddNewHotKey').value="保存";
				
			}
	}	
	
	function addNewHotkey()
	{
	            document.getElementById('ctl00_ContentPlaceHolder1_hot_key_name').value ="";
				document.getElementById('ctl00_ContentPlaceHolder1_hot_key_hits').value ="" ;
				document.getElementById('ctl00_ContentPlaceHolder1_hot_key_url').value ="" ;
				document.getElementById('add_search_type').style.display ="" ;
				document.getElementById('search_url').style.display="none";
				document.getElementById('h_action').value = "";
				document.getElementById('hot_key_title').innerHTML="新增热门关键字";
				document.getElementById('Add_HotKey').style.display="none";
				document.getElementById('ctl00_ContentPlaceHolder1_AddNewHotKey').value="新增关键字";
	}
		
 </script>
 <script src="Js/Function.js" type="text/javascript"></script>

<table class="adminheading">                       
          <tr>
            <th class="msgconfig">热门搜索管理</th>
            <td align="right">
            <div style="width:100px"><a href="#" onclick="addNewHotkey();" >添加热门搜索</a></div>  
            </td>
            <td class="rtdw"></td>
          </tr>     
                     
</table> 
<asp:GridView ID="GridView1" runat="server" DataKeyNames="id" AutoGenerateColumns="False" CssClass="adminlist"  OnDataBound="GridView1_DataBound" OnRowDeleting="GridView1_RowDeleting"> 
    <Columns>
         <asp:TemplateField HeaderText="操作">
           <HeaderTemplate>
              <input id="chkAll" onclick="SelectAllCheckboxes(this,'chk_select');" type="checkbox" />                                     
           </HeaderTemplate>
           <ItemTemplate>
              <input type="checkbox" id="chk_select" name="chk_select" value='<%# Eval("id") %>'/>              
           </ItemTemplate>
             <HeaderStyle Width="50px" />
        </asp:TemplateField>
        <asp:BoundField DataField="id" HeaderText="编号" >
            <HeaderStyle Width="40px" />
        </asp:BoundField>
        <asp:HyperLinkField Text="热门搜索" DataNavigateUrlFields="search_url" DataTextField="KeyName" DataNavigateUrlFormatString="{0}" Target="_blank"  HeaderText="热门关键字"/>
        <asp:BoundField HeaderText="点击次数"  DataField="Hits">
            <HeaderStyle Width="80px" />
        </asp:BoundField>
        <asp:TemplateField HeaderText="操作">
           <ItemTemplate>
              <a href="javascript:selectHotKey('<%# Eval("id") %>')"></a> 
               <asp:LinkButton ID="btn_update" runat="server" CommandArgument='<%# Eval("id") %>'
                   OnCommand="btn_update_Command">修改</asp:LinkButton>
              <asp:LinkButton runat="server" ID="Link"  Text="删除" CommandArgument='<%# Eval("id") %>' OnCommand="Link_Command" />             
           </ItemTemplate>
            <HeaderStyle Width="100px" />
        </asp:TemplateField>
    </Columns>
    <EmptyDataTemplate>
        <tr>
	  <th scope="col" style="width:50px;"><input id="chkAll" type="checkbox" /></th>
	  <th scope="col" style="width:40px;">编号</th>
	  <th scope="col">热门关键字</th>
	  <th scope="col" style="width:80px;">点击次数</th>
	  <th scope="col" style="width:100px;">操作</th>
	</tr>
	<tr><td colspan="5">暂无信息！</td></tr>
    </EmptyDataTemplate>
</asp:GridView>  

<div class="div_btm"> 
    <div style="float:left"><asp:Button ID="DelButton" runat="server" Text="批量删除选中"  OnClick="DelButton_Click"/></div>
    <div style="float:right">
        <asp:DropDownList ID="ConditonsDrop" runat="server">
           <asp:ListItem Text="点击次数小于" Value="less" />      
       </asp:DropDownList>
       <asp:TextBox ID="DeleteNums" runat="server" Text="1" />
       <asp:Button ID="DelConditions" runat="server" Text="删除符合条件关键字" OnClick="DelConditions_Click" />
    </div>
</div>

<table class="nick">
   <tr><td class="tit" colspan="2">添加新热门搜索关键字</td></tr>
   <tr>
      <td class="ltd">关键字名称：</td>
      <td class="rtd"><asp:TextBox ID="hot_key_name" runat="server" Width="200" /></td>
   </tr>
   <tr>
      <td class="ltd">点击数：</td>
      <td class="rtd"><asp:TextBox ID="hot_key_hits" runat="server" Width="60px"/>
          <asp:HiddenField ID="hotkey_id" runat="server" />
      </td>
   </tr>
   <tr id="add_search_type" style="display:none;">
      <td class="ltd">搜索类型：</td>
      <td class="rtd"><asp:DropDownList ID="hot_key_type" runat="server">
              <asp:ListItem Text="商品搜索" Value="Search_Product"  Selected="True"/>
              <asp:ListItem Text="店铺搜索" Value="Search_Shop" />
         </asp:DropDownList></td>
   </tr>
   <tr id="search_url" style="display:block;">
       <td class="ltd">URL：</td>
       <td class="rtd"><asp:TextBox ID="hot_key_url" runat="server" Width="60%"/></td>
   </tr>
   <tr>
       <td colspan="2" class="btm"><asp:Button ID="AddNewHotKey" runat="server" Text="新增关键字" OnClick="AddNewHotKey_Click" />
           <asp:Button ID="btn_updateHotKey" runat="server" Text="保存" Visible="False" OnClick="btn_updateHotKey_Click" />&nbsp;</td>
   </tr>
</table>
<br>
 <input type="hidden" id="h_action" value="" name="h_action" />
 <input type="hidden" id="id" value="" name="id" />

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeleteHotKey"
        InsertMethod="AddHotKey" SelectMethod="GetAllHotKeys" TypeName="Shop_HotKey"
        UpdateMethod="AddHotKey">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="keyName" Type="String" />
            <asp:Parameter Name="url" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="keyName" Type="String" />
            <asp:Parameter Name="url" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
</asp:Content>

