<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="Admin_Admin_ShopProduct, mallz" title="商城商品管理" enableEventValidation="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript">
function checktypeselct(){
    var show_type = document.getElementById("ctl00_ContentPlaceHolder1_show_type");
    if(show_type.value=="ProductID"){
        alert("请先选择排序方式！")
        return false;
    }
    return true;
}
</script>
<script src="Js/Function.js" type="text/javascript"></script> 

 <table class="adminheading">
       <tr>
          <th valign="middle" class="cpane" >商城商品管理</th>
           <td align="right"></td>
           <td class="rtdw"></td>
     </tr>
  </table> 

 <table class="nick"><tr><td colspan="4" class="tit">商品查找</td></tr>
    <tr><td class="ltd" style="width:11%;">快速查找：</td><td class="rtd" style="width:33%">
    <asp:DropDownList ID="QuickSearch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="QuickSearch_SelectedIndexChanged">
          <asp:ListItem Text="所有商城商品" Value="all_product" />
          <asp:ListItem Text="所有上架商品" Value="on_sale" />
          <asp:ListItem Text="停止销售商品" Value="stop_sale" />
          <asp:ListItem Text="仓库里的商品" Value="on_stock" />
          <asp:ListItem Text="首页推荐商品" Value="on_elite" />
          <asp:ListItem Text="橱窗推荐商品" Value="saler_recommend" />
       </asp:DropDownList>
       <asp:DropDownList ID="show_type" runat="server" AutoPostBack="true" OnSelectedIndexChanged="show_type_OnChange">
         <asp:ListItem Text="选择排序方式" Value="ProductID" Selected="True" />
         <asp:ListItem Text="上架时间排序" Value="BeginDate" />
         <asp:ListItem Text="价格高低排序" Value="StandPrice" />
         <asp:ListItem Text="浏览次数排序" Value="Hits" />
         <asp:ListItem Text="库存大小排序" Value="Stocks" />
      </asp:DropDownList>&nbsp;<asp:CheckBox ID="CheckBox1" runat="server" Text="降序" AutoPostBack="true" OnCheckedChanged="CheckBox1_OnChange" onclick="if(!checktypeselct()) return false" />
       </td>
        <td class="ltd" style="width:11%;">高级查找：</td><td class="rtd">
       <asp:DropDownList ID="DetailSearchType" runat="server" AppendDataBoundItems="True">
         <asp:ListItem Selected="True" Value="product_name" Text="按商品名称"/>
         <asp:ListItem Value="saler_name" Text="按卖家名称"/>
         <asp:ListItem Value="product_class" Text="按商品分类"/>
         <asp:ListItem Value="product_place" Text="商品所在地" /> 
       </asp:DropDownList>
      <asp:TextBox ID="DetailSearchName" runat="server"  Width="150px" AutoPostBack="false"/>
      <asp:Button ID="AdminSearch" Text=" 查 询 " runat="server" OnClick="AdminSearch_Click"/>
      </td></tr>
 </table>
        
 <div id="product_history">
        <asp:GridView id="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" HeaderStyle-HorizontalAlign="Center" CssClass="adminlist" AllowSorting="True" DataKeyNames="ProductID" RowStyle-HorizontalAlign="Center" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField  HeaderStyle-Width="4%">
                    <HeaderTemplate>
                        <input id="chkAll" onclick="SelectAllCheckboxes(this,'chk_select');" runat="server" type="checkbox" />
                    </HeaderTemplate>
                    <ItemTemplate>
                       <input type="checkbox" id="chk_select" name="chk_select" value='<%# Eval("ProductID") %>' />                        
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="商品名称" ItemStyle-HorizontalAlign="Left">
                    <ItemTemplate>
                        <b><asp:HyperLink Target="_blank" ID="ProductNameUrl" runat="server" Text='<%# Bind("ProductName") %>' NavigateUrl='<%#"../ShowProduct.aspx?ProductID="+Eval("ProductID") %>'/></b><br />
                        [ <asp:HyperLink ID="ClassName" runat="server" NavigateUrl='<%# "?classid=" + Eval("ClassID") %>' Text='<%#Eval("ClassName")%>'/> ]
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="卖家名称" HeaderStyle-Width="10%">
                    <ItemTemplate>
                       <asp:HyperLink ID="Saler" runat="server" Text='<%# m_user.GetUserNameByID(Convert.ToInt32(Eval("SalerId"))) %>' NavigateUrl='<%#"Admin_UserDetail.aspx?UserID="+Eval("SalerID") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="类型" HeaderStyle-Width="6%">
                    <ItemTemplate>
                        <asp:Literal ID="ProductType" runat="server" Text='<%# MallZ.Web.Shop.TextFormat.GetProductType(Eval("ProductType").ToString()) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="StandPrice" HeaderText="价格"  HeaderStyle-Width="10%">
                </asp:BoundField>
                <asp:BoundField DataField="Stocks" HeaderText="库存" HeaderStyle-Width="8%" />
                <asp:TemplateField HeaderText="人气(购买/点击)" HeaderStyle-Width="10%">
                    <ItemTemplate>
                       <asp:Literal ID="Bid_Times_Or_Hits" runat="server" Text='<%#Eval("BuyTimes")+"/"+Eval("Hits") %>'/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="商品属性" HeaderStyle-Width="9%">
                    <ItemTemplate>
                         <asp:Literal ID="OnTop" runat="server" Text='<%# (Eval("OnTop").ToString() == "True")?"顶":"" %>'/>
                         <asp:Literal ID="IsHot" runat="server" Text='<%# (Eval("IsHot").ToString() == "True")?"热":"" %>'/>
                         <asp:Literal ID="IsElite" runat="server" Text='<%# (Eval("IsElite").ToString() == "True")?"荐":"" %>'/>
                         <asp:Literal ID="ImgUrl" runat="server" Text='<%# (Eval("ProductImageUrl").ToString() != "")?"图":"" %>' />
                         <asp:Literal ID="Literal1" runat="server" Text='<%# (Eval("UploadVideoUrl").ToString() != "")?"视":"" %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="销售" HeaderStyle-Width="5%">
                    <ItemTemplate>
                         <asp:LinkButton ID="ProductOnSale" runat="server" Text='<%# (Eval("EnableSingleSell").ToString()=="True" && Eval("EnableSale").ToString()=="True")?"√":"×" %>' OnCommand="Saell_OnCommand" CommandArgument='<%#Eval("ProductID") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="操作" HeaderStyle-Width="8%">
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="modify" Text="修改" OnClientClick='<%# "javascript:{location.href=\"Admin_ShopProductEdit.aspx?id="+ Eval("ProductID") +"\";return false;}" %>' />
                        <asp:LinkButton runat="server" ID="del" Text="删除" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <RowStyle HorizontalAlign="Center"></RowStyle>
            <EmptyDataTemplate>
                <tr>
                    <th>ID</th>
                    <th>商品名称</th>
                    <th>卖家名称</th>
                    <th>类型</th>
                    <th>价格</th>
                    <th>库存</th>
                    <th>人气值</th>
                    <th>商品属性</th>
                    <th>销售</th>
                    <th>操作</th>
                </tr>
                <tr><td colspan="10">暂无商品！</td></tr>      
                    
            </EmptyDataTemplate>

            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
        </asp:GridView>
 </div>
    
    <div class="page">
        <asp:Label ID="PagePanel" runat="server" />
    </div>
    
 <div class="div_btm">
     <asp:Button ID="AllowSale_Button" runat="server" Text="设为上架"  CommandName="EnableSale" OnCommand="Button_Command" />
     <asp:Button ID="StopSale" runat="server" Text="暂时下架"  CommandName="StopSale" OnCommand="Button_Command" />
     <asp:Button ID="DisableSale" runat="server" Text="禁止上架"  CommandName="DisableSale" OnCommand="Button_Command" />
     <asp:Button ID="Elite_Button" runat="server" Text="首页推荐" CommandName="IndexElite" OnCommand="Button_Command" />
     <asp:Button ID="CancleElite" runat="server" Text="取消推荐" CommandName="CancleIndexElite" OnCommand="Button_Command" />
     <asp:Button ID="Button5" runat="server" Text="橱窗推荐" CommandName="ShopElite" OnCommand="Button_Command" />
     <asp:Button ID="Button6" runat="server" Text="橱荐取消" CommandName="CancleShopElite" OnCommand="Button_Command" />
     <asp:Button ID="Button1" runat="server" Text="设为热卖" CommandName="IsHot" OnCommand="Button_Command" />
     <asp:Button ID="Button2" runat="server" Text="取消热卖" CommandName="CancleIsHot" OnCommand="Button_Command" />
     <asp:Button ID="Button3" runat="server" Text="设为置顶" CommandName="OnTop" OnCommand="Button_Command" />
     <asp:Button ID="Button4" runat="server" Text="取消置顶" CommandName="CancleOnTop" OnCommand="Button_Command" />
     <asp:Button ID="Delete_Button" runat="server" Text="批量删除" CommandName="Delete" OnCommand="Button_Command"  OnClientClick="return confirm('您确定要删除吗？此操作将删除所有跟删除商品相关联的数据，并且删除后不能恢复?')"/>
 </div>
 
 <div style="padding:10px;" align="center">
    <div style="margin-right:20px;">批量移动至：<asp:DropDownList ID="ProductNewClass" DataTextField="ClassName" DataValueField="ClassID" runat="server" Width="200px" /> <asp:Button ID="SetProductNewClassButton" runat="server" Text="确定" OnClick="SetProductNewClassButton_Click" OnClientClick="return confirm('确定执行吗？')" /></div>
 </div>
   
</asp:Content>

