<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin.Shop.Admin_ShopCouponItem" Title="优惠券管理" Codebehind="KS.CouponItem.Aspx.cs" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
    <script type="text/javascript">
        function GetMyIds() {
            var sid = null;
            for (var i = 0; i < document.getElementsByName("ids").length; i++) {
                var KS = document.getElementsByName("ids")[i];
                if (KS.checked == true) {
                    if (sid == null)
                        sid = KS.value;
                    else
                        sid += "," + KS.value;
                }
            }
            return sid;
        } 

        function SendMsg() {
            var sid = GetMyIds();
            if (sid != null) {
                parent.openWin("批量设置发送的信息", "<%=KSCMS.GetInstallDir()+MyCache.GetCacheConfig(4)%>/User/KS.CouponSetPacketMsg.aspx?couponid=<%=couponId %>&couponType=" +<%=CouponType %> +"&ContentID=" + sid + "", false, 900, 500);

            }
            else {
                parent.openWin("批量设置发送的信息", "<%=KSCMS.GetInstallDir()+MyCache.GetCacheConfig(4)%>/User/KS.CouponSetPacketMsg.aspx?couponid=<%=couponId %>&couponType=" +<%=CouponType %> +"", false, 900, 500);
            }
        }

        function keyWordFocus() {
            if (jQuery("#<%=this.KeyWord.ClientID %>").val() == '请输入关键字！') {
                jQuery("#<%=this.KeyWord.ClientID %>").val('');
            }
        }
        function keyWordBlur() {
            if (jQuery("#<%=this.KeyWord.ClientID %>").val() == '') {
                jQuery("#<%=this.KeyWord.ClientID %>").val('请输入关键字！');
            }
        }
    </script>
    <asp:Panel ID="listPanel" runat="server" Width="100%">

       <div class="content-area mt20">  
       		<div class="myTitle">
                <div class="fr headOperation ">
                    <ul>
                     	<li id="p3" class="fl"><asp:LinkButton ID="LinkButton2" runat="server"  OnClientClick="return(GetIDS('del'));" OnClick="LinkButton2_Click" CssClass="button">批量删除<%=CouponType==2?"优惠券":"红包" %></asp:LinkButton></li>
                    	<li id="p5" class="fl"><asp:LinkButton ID="BtnSend" runat="server"  OnClientClick="SendMsg()"  CssClass="button">即将过期/未使用提醒</asp:LinkButton></li>
                      	<li id='p18' class="fl"><asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" CssClass="button">导出Excel</asp:LinkButton></li>
                    </ul>
                </div>
                查看[<span style="color:Red"><asp:Label ID="LabCouponName" runat="server" Text="Label"></asp:Label></span>]下的<%=CouponType==2?"优惠券":"红包" %>列表
            </div>   
            <div class="quickSearch clearfix">
                 <div class="fr">
                 	<a href="KS.Coupon.aspx" class="button">返 回</a>
                    <asp:LinkButton ID="addclass" runat="server" OnClientClick="window.print()" CssClass="button ml15">打 印 </asp:LinkButton>
                    <a href="KS.CouponPub.aspx?couponid=<%=couponId %>" class="button ml15">发 放</a>
                 </div>
                 <div class="SearchBox fl">
                     <asp:DropDownList ID="Condition" runat="server" style="margin-right:8px;">
                         <asp:ListItem Value="1">卡号</asp:ListItem>
                         <asp:ListItem Value="2">使用人</asp:ListItem>
                     </asp:DropDownList>
                     <asp:TextBox ID="KeyWord" runat="server" CssClass="textbox" onblur="keyWordBlur();" onfocus="keyWordFocus();" Style="color: #ccc" Text="请输入关键字！" Width="200"></asp:TextBox>
                     <asp:Button ID="BtnSearch0" runat="server" class="button" OnClick="BtnSearch_Click"  Text="查找" />
                 </div>
                 <div class="property">
                    <div class="name button ml15">筛选</div>
                    <div class="propertyBox">
                    	<ul class="tabs">
                            <span class="screen fl">使用状态：</span>
                            <li <%=KSCMS.S("UseFlag")==""?" class='active'":string.Empty %>><a href="KS.CouponItem.Aspx?couponId=<%=couponId %>&CouponType=<%=CouponType %>"><span>所有<%=CouponType==2?"优惠券":"红包" %>列表</span></a></li>       
                            <li <%=KSCMS.S("UseFlag")=="0"?" class='active'":string.Empty %>><a href="KS.CouponItem.Aspx?couponId=<%=couponId %>&UseFlag=0&CouponType=<%=CouponType %>"><span>未使用</span></a></li>
                            <li <%=KSCMS.S("UseFlag")=="1"?" class='active'":string.Empty %>><a href="KS.CouponItem.Aspx?couponId=<%=couponId %>&UseFlag=1&CouponType=<%=CouponType %>"><span>已使用</span></a></li>
                            <li <%=KSCMS.S("UseFlag")=="2"?" class='active'":string.Empty %>><a href="KS.CouponItem.Aspx?couponId=<%=couponId %>&UseFlag=2&CouponType=<%=CouponType %>"><span>未发放</span></a></li>
                            <li <%=KSCMS.S("UseFlag")=="3"?" class='active'":string.Empty %>><a href="KS.CouponItem.Aspx?couponId=<%=couponId %>&UseFlag=3&CouponType=<%=CouponType %>"><span>已发放</span></a></li>
                        </ul>
                    </div>
                </div>
            </div> 
       
    	<div>
        <KS:KSGV ID="ProListView" runat="server" CssClass="CTable" AutoGenerateColumns="False" DataKeyNames="FieldID" GridLines="None"
            OnRowDataBound="FieldListView_RowDataBound" PagerType="CustomNumeric" Width="99%" EnableTheming="True" OnRowCommand="FieldListView_RowCommand" EmptyDataText="没有记录!" >
            <Columns>
              <asp:TemplateField HeaderText="选择">
                <itemstyle horizontalalign="Center" width="50px" />
                <itemtemplate>
                    <input type="checkbox"  name="ids" id="ids" value="<%#Eval("CouponUserID") %>" />
                </itemtemplate>
              </asp:TemplateField>

          
              <asp:TemplateField HeaderText="卡号">
                  <itemstyle horizontalalign="Center" width="120px" />
                <itemtemplate>
                   <%#Eval("CouponNum") %>
                </itemtemplate>
              </asp:TemplateField>
             <asp:TemplateField HeaderText="面值">
                <itemstyle horizontalalign="Center" width="50px" />
                <itemtemplate>
                <%=MyCache.GetCurrencySymbol %><%# Kesion.APPCode.Public.ReturnShopPrice(Eval("FaceValue")) %><%=MyCache.GetCurrencyUnit %>
                </itemtemplate>
              </asp:TemplateField>

              <asp:TemplateField HeaderText="最大抵扣额" >
                <itemstyle horizontalalign="Center" width="200px" />
                <itemtemplate>
                <%# GetDiscoutStr(Convert.ToString(Eval("MaxDiscount"))) %>
                </itemtemplate>
              </asp:TemplateField>

                 <asp:TemplateField HeaderText="可用金额">
                <itemstyle horizontalalign="Center" width="70px" />
                <itemtemplate>
                <%=MyCache.GetCurrencySymbol %><%# Kesion.APPCode.Public.ReturnShopPrice(Eval("AvailableMoney")) %><%=MyCache.GetCurrencyUnit %>
                </itemtemplate>
              </asp:TemplateField>

   
              <asp:BoundField DataField="UserName" HeaderText="使用人">
                <itemstyle width="70px" horizontalalign="Center" />
                </asp:BoundField>
              
              <asp:TemplateField HeaderText="使用情况">
                <itemstyle horizontalalign="Center" width="150px" />
                <itemtemplate>
                <%# GetUseStr(Convert.ToInt16(Convert.ToString(Eval("UseFlag"))),Convert.ToString(Eval("AvailableMoney")),Convert.ToString(Eval("Note"))) %>
                </itemtemplate>
              </asp:TemplateField>
                <asp:TemplateField HeaderText="发放情况">
                <itemstyle horizontalalign="Center" width="150px" />
                <itemtemplate>
                <%# Convert.ToString(Eval("IsExtend"))=="0"?"<a href='?action=change&couponid="+couponId+"&userID=" +Eval("couponuserID")+"'>未发放</a>":"已发放" %>
                    
                </itemtemplate>
              </asp:TemplateField>
                <asp:TemplateField HeaderText="管理操作">
                <itemtemplate>
                     <asp:LinkButton runat="server" id="delete" commandargument=<%#Eval("couponuserID") %> commandname="del">删除</asp:LinkButton>
                
               </itemtemplate>
                <itemstyle horizontalalign="Center" width="100px" />
                </asp:TemplateField>
            </Columns>
            <HeaderStyle CssClass="CTitle" />
            <EmptyDataRowStyle CssClass="emptycss" />
        </KS:KSGV>
       </div>
       <div class="listedit">
        <label for="chkall"><input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);"/>全选</label>
        <asp:Button ID="Button1" runat="server" Text="批量发放"  CssClass="button" OnClick="Button1_Click" />
     <%--   <asp:Panel ID="Panel1" runat="server" Height="30px" Width="739px">
        
        &nbsp;&nbsp;<input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);"/><label for="chkall">全部选中</label>
           &nbsp; <input type="button" value="批量删除" onmouseover="this.className='button_on';" onmouseout="this.className='button';" class="button" onclick="if (GetIDS('del')){this.form.action='?couponid=<%=couponId %>&action=del';this.form.submit()}" />
           
           <input type="button" class="button" value="打印本页" onclick="PrintPage('PrintBox')" />
           
           <input class="button" type="button" value=" 发 放 " onclick="location.href='KS.CouponPub.aspx?couponid=<%=couponId %>';">
         </asp:Panel>--%>
        
        </div>
        <KS:Page ID="Page1" runat="server" />
        
        
        <script type="text/javascript">
            showtips('<span class="state"><strong>说明：</strong><br /></span>您可以在这里批量删除优惠券|红包或是打印优惠券|红包等管理操作!');
		</script>
     </asp:Panel>
    
    
  </div>
  
</asp:Content>