<%@ page language="C#" masterpagefile="~/MasterPage/UserMasterPage.master" autoeventwireup="true" inherits="Rest_Gift_GiftList, DoodiiShop" title="Untitled Page" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <style type="text/css">
.STYLE1 {color: #ff0048}
a.select:link, a.select:visited, a.select:hover{ display:block; width:75px;height:27px;
 background-image :url(/images/KcDefault/KcDefault_Search_btn02.gif);font-weight:bold;color:#982e00;}
.title ul li{float:left; width:75px; height:27px; line-height:27px; text-align:center;}
.title ul li a{color:#000000; }
.dd{float:left; width:800px; height:27px; margin-top:8px; margin-bottom:10px; }
.dg{float:left; width:75px; height:27px; background-image :url(/images/KcDefault/KcDefault_Search_btn01.gif); line-height:27px; margin-right:5px;}
.title ul{ float:left; width:660px; line-height:29px; background: url(/images/KcDefault/KcDefault_Search_bg.gif) repeat-x;}
.gg{float:left; width:76px; height:26px; line-height:26px; text-align:center;color:#000000; background-image :url(/images/v6top/msg.jpg); margin-right:8px}
.yy{float:left; width:650px; height:23px;}
.sui{ width:48px; background-color:green;color:#FFFFFF; margin-right:192px;
 height:25px; line-height:25px;  text-align:center;}
.cui{float:left; background-color:#008c00; color:#FFFFFF; width:72px;  height:25px; line-height:25px; text-align:center; margin-right:8px; cursor:pointer;}
</style>
    <div class="yy">
        礼品数量：<span class="STYLE1" runat="server" id="lbTotalCount">20</span> 已兑换：<span class="STYLE1"
            runat="server" id="lbChangeCount">10</span> 剩余：<span class="STYLE1" runat="server"
                id="lbLeaveCount">10</span> 兑换礼品积分：<span class="STYLE1" runat="server" id="lbIntegral">50000分</span>
    </div>
    <div>
        <a class="gg" id="btnAddGift" href="javascript:AddGift()">添加礼品</a> <a class="gg"
            id="btnAddClass" href="javascript:AddGiftClass()">类别管理</a>
        <%--  <input  type="Button" value="" onclick="" />
       <input class="gg" id="" type="Button" value="" onclick="()" />--%>
    </div>
    <div class="dd">
        <asp:HiddenField ID="hidType" runat="server" Value="0" />
        <div class="title">
            <ul>
                <li class="dg">
                    <asp:LinkButton ID="lbtUp" CssClass="select" runat="server" OnClick="lbtUp_Click">上架礼品</asp:LinkButton></li>
                <li class="dg">
                    <asp:LinkButton ID="lbtDown" runat="server" OnClick="lbtDown_Click">下架礼品</asp:LinkButton></li>
                <li class="dg">
                    <asp:LinkButton ID="lbtSave" runat="server" OnClick="lbtSave_Click">礼品回收站</asp:LinkButton>
                </li>
            </ul>
        </div>
    </div>
    <div style="margin-bottom: 6px; display: inline; float:left;">
        类别：<asp:DropDownList ID="ddGiftClass" runat="server" Style="line-height: 35px;">
        </asp:DropDownList>
        礼品名称：<asp:TextBox ID="tbGiftName" Width="80" runat="server"></asp:TextBox>
        库存：<asp:TextBox ID="tbStock" runat="server" Width="40"></asp:TextBox>至<asp:TextBox
            Width="40" ID="tbStock2" runat="server"></asp:TextBox>
        <asp:Button ID="Button5" CssClass="sui" runat="server" Text="查询" OnClick="Button5_Click" />
    </div>
    <div class='NewTable' style="clear:both;">
        <asp:Repeater ID="GridView1" runat="server">
            <HeaderTemplate>
                <table class='NewTable'>
                    <tr>
                        <th>
                            <input id='ckAll' type='checkbox' name="ckAll" />
                            全选
                        </th>
                        <th>
                            编号</th>
                        <th>
                            类别</th>
                        <th>
                            礼品名称</th>
                        <th>
                            礼品图片</th>
                        <th>
                            积分</th>
                        <th>
                            库存</th>
                        <th>
                            兑换</th>
                        <th>
                            排序</th>
                        <th>
                            推荐</th>
                        <th>
                            操作</th>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr style="text-align: center;">
                    <td>
                        <input type='checkbox' id='ck_<%# Eval("id") %>' value='<%# Eval("id") %>' name="ckId" /></td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%=Row++ %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%#getClassName(Eval("classid").ToString())%>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%#Eval("name") %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <asp:Image ID="Image1" Width="50" Height="50" runat="server" ImageUrl='<%# String.Format("~/getImage_{0}_50_50_0_0_0.aspx",Eval("photoID"))%>'
                            AlternateText="暂无图片" />
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%#Eval("ExpendIntegral") %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC; color: #009948'>
                        <%#Eval("stock") %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC; color: #ff0000'>
                        <%#Eval("ChangeCount") %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%#Eval("sort") %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%#getIsCommend(Eval("iscommend").ToString()) %>
                    </td>
                    <td style='border-left: 1px solid #CCCCCC;'>
                        <%#getLnk(Eval("id").ToString(), Eval("iscommend").ToString())%>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                <tr>
                    <td style="background: #f3f3f3;">
                        <input id='ckAll1' type='checkbox' name="ckAll" />
                        全选
                    </td>
                    <td colspan="10" style="background: #f3f3f3;">
                        <%#getAllControl()%>
                    </td>
                </tr>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <div style="width: 650px; text-align: center; float: left; padding: 2px 0 0 0;">
        <br />
        <PageControl:myPageControl ID="MyPageControl1" runat="server" PageSize="10" TotalRecord="20"
            IsDoPostBack="true" ItemSize="5" PageInfoShow="False" OnChangePageClick="myPageControl_OnChangePageClick" />
    </div>

    <script type="text/javascript">
    var IDs="";
    function AddGift()
    {
        location.href="/Rest/Gift/AddGift.aspx";
    }
    function AddGiftClass()
    {
        location.href="/Rest/Gift/AddGiftClass.aspx";
    }
    function bindEvent()
    {
        var flag = false;
        $("#ckAll").bind("click",function(){
        //$("input[name=ckAll]").bind("click",function(){
         $("input[name=ckId]").each(function(){ 
         $(this).attr("checked", $("#ckAll").attr("checked")); 
         $("#ckAll1").attr("checked", $("#ckAll").attr("checked"));
         });
        });
        $("#ckAll1").bind("click",function(){
         $("input[name=ckId]").each(function(){ 
         $(this).attr("checked", $("#ckAll1").attr("checked")); 
         $("#ckAll").attr("checked", $("#ckAll1").attr("checked"));
         });
        });
        $("input[name=ckId]").bind("click",function(){
           flag = $(this).attr("checked");
           $("input[name=ckAll]").attr("checked",isCheckAll());
        });
    }
    function isCheckAll()
    {
        var flag =true;
        if($("input[name=ckId]").length == 0)
        {
            flag = false;
            return flag;
        }
        
        $("input[name=ckId]").each(
            function(){
            if(!$(this).attr("checked"))
            {
               flag = false; 
            }
            });
            return flag;
    }
    function GetSelectIDs()
    {
        var IDArray = "";
        $("input:checkbox[name=ckId][checked]").each(function(i){
            if(i == 0)
            {
                IDArray =this.value;
            }
            else if(i>0)
            {
                IDArray = IDArray+","+this.value;
            }
        });
        if(IDArray == "")
        {
            alert("您还没有选择相应的礼品！");
            return false;
        }
        else
        {
            IDs = IDArray;
            return true;
        }
    }
    function edi(id)
    {window.location="/Rest/Gift/EditGift.aspx?ID="+id;}
    function up(id,iscommend,type)
    {
        var str="";
        if(type==1)
        {
            if(!GetSelectIDs())return;
            id=IDs;
            str="批量";
        }
        if(!confirm("是否"+str+"处理礼品！"))
        {return;}
        var ret=Rest_Gift_GiftList.up(""+id+"",iscommend).value;
        if(ret==0)
        {
            document.getElementById("<%=Button5.ClientID %>").click();
        }
        else
            alert("操作失败！");
    }
    function del(id,type)
    {
        var str="";
       if(type==1)
        {
            if(!GetSelectIDs())return;
            id=IDs;
            str="批量";
        }
        if(!confirm("是否"+str+"删除此礼品！"))
        {return;}
        var ret=Rest_Gift_GiftList.del(""+id+"").value;
        if(ret==1)
        {
            alert("礼品删除成功！");
            document.getElementById("<%=Button5.ClientID %>").click();
        }
        else
            alert("礼品删除失败！");
    }
    function rb(id,type)
    {
        var str="";
        if(type==1)
        {
            if(!GetSelectIDs())return;
            id=IDs;
            str="批量";
        }
        if(!confirm("是否"+str+"恢复礼品下架！"))return;
        var ret=Rest_Gift_GiftList.rb(""+id+"").value;
        if(ret==0)
        {
            alert("恢复下架成功！");
            document.getElementById("<%=Button5.ClientID %>").click();
        }
        else
            alert("恢复失败！");
    }
    function isShowIDs(isshow)
    {
        if(!GetSelectIDs())return;
        if(!confirm("是否批量处理礼品！"))
        {return;}
        var ret=Rest_Gift_GiftList.isShowIDs(IDs,isshow).value;
        if(ret==0)
            document.getElementById("<%=Button5.ClientID %>").click();
        else
            alert("恢复失败！");
    }
    function init()
    {
        bindEvent();
    }
    $(document).ready(init);
    </script>

</asp:Content>
