<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="Admin_Admin_Card, mallz" title="充值卡管理" enableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script src="Js/Function.js" type="text/javascript"></script>   
<script type="text/javascript">
function ModifyCard(id,action){
var recdata=false;
  switch (action)
  {
      case "Add":
        recdata=showModalDialog('Admin_ModifyCard.aspx?Action=Add','','dialogWidth:560px; dialogHeight:320px; help: yes; scroll: yes; status: no');
      break;
      case "Modify":
        recdata=showModalDialog('Admin_ModifyCard.aspx?Action=Modify&CardID='+id,'','dialogWidth:550px; dialogHeight:320px; help: yes; scroll: yes; status: no');      
      break;
      case "Show":
        recdata=showModalDialog('Admin_ModifyCard.aspx?Action=Show&CardID='+id,'','dialogWidth:550px; dialogHeight:320px; help: yes; scroll: yes; status: no');      
      break;
  }   
   //判断对应的返回值
  if(recdata==true)
  {
     // 刷新当前窗口
    window.location.reload();       
  } 
}
</script>  


   <table class="adminheading" style="display:none">
    <tr>
       <th valign="middle" class="menus" align="left" style="width: 444px">充值卡管理 </th>
       <td align="right">        
          <div style="text-align:center; cursor:pointer; float:right;"><a href="javascript:void(0)" onclick="ModifyCard('','Add')">添加充值卡</a></div>
       </td>
    </tr>                     
   </table>

     <table class="nick"><tr><td colspan="4" class="tit" style="display:none">充值卡列表</td></tr>
     <tr><td class="ltd"> 状态：</td>
           <td class="rtd" style="width:35%">
           <asp:DropDownList ID="DropMoment" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropMoment_OnChange">
               <asp:ListItem Selected="True" Value="-1">所有充值卡</asp:ListItem>
               <asp:ListItem Value="0">可购买的卡</asp:ListItem>
               <asp:ListItem Value="1">使用中的卡</asp:ListItem>
               <asp:ListItem Value="2">已售出的卡</asp:ListItem>
               <asp:ListItem Value="3">已失效的卡</asp:ListItem>
           </asp:DropDownList>
           </td>
           <td class="ltd">代理商：</td>
           <td class="rtd" style="width:35%"><asp:TextBox ID="TextBox1" runat="server" Width="150"></asp:TextBox>&nbsp;
           <asp:Button ID="Button1" runat="server" Text="查询"  CausesValidation="false" OnClick="Button1_OnClick" />
           </td>
          </tr>
          </table>

            <asp:GridView id="GridView1" runat="server" CssClass="adminlist" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="CardID" OnDataBound="GridView1_DataBound" PageSize="20">
            <Columns>
                 <asp:TemplateField>
                    <ItemTemplate>                                        
                        <input type="checkbox" id="chk_select" name="chk_select" value='<%# Eval("cardid") %>' />              
                    </ItemTemplate>
                    <HeaderTemplate>
                        <input id="chkAll" onclick="SelectAllCheckboxes(this,'chk_select');" runat="server" type="checkbox" />                                     
                    </HeaderTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:TemplateField> 
                <asp:BoundField DataField="CardType" SortExpression="CardType" HeaderText="类型" />
                <asp:BoundField DataField="CardNum" SortExpression="CardNum" HeaderText="卡号 " />
                <asp:BoundField DataFormatString="{0:N0}" DataField="CardMoney" SortExpression="CardMoney" HeaderText="面值" />
                <asp:BoundField DataField="CardValidUnit" SortExpression="CardValidUnit" HeaderText="单位" />
                <asp:BoundField DataField="CardEndDate" SortExpression="CardEndDate" HeaderText="截止期"  />
                <asp:BoundField DataField="CardUserName" SortExpression="CardUserName" HeaderText="使用者" />
                <asp:TemplateField HeaderText="状态">
                    <ItemTemplate>
                          <asp:Literal ID="CardState" runat="server" Text='<%# Eval("CardState")%>' />
                    </ItemTemplate>
                </asp:TemplateField>
                 <asp:BoundField DataField="CardUseTime" SortExpression="CardUseTime" HeaderText="充值时间" />
                 <asp:TemplateField HeaderText="操作">
                    <ItemTemplate>
                       <asp:Panel ID="ModifyPanel" runat="server">
                         <asp:LinkButton id="btnSell" runat="server" OnClientClick ="return confirm('售出的充值卡不能再修改，确定售出吗?')" CommandName='<%# Eval("CardID") %>' Text="售出" OnCommand="Sell_Click" /> 
                         <a href='<%#"Admin_ModifyCard.aspx?Action=Modify&CardID="+Eval("CardID") %>' >修改</a>
                         <asp:LinkButton id="btnDelete" runat="server" OnClientClick ="return confirm('您真的要删除?')" CommandName='<%# Eval("CardID") %>' Text="删除" OnCommand="DeleteCard"/> 
                       </asp:Panel>
                       <asp:Panel ID="ShowPanl" Visible="false" runat="server">
                       <a href='<%#"Admin_ModifyCard.aspx?Action=Show&CardID="+Eval("CardID") %>' >查看</a>
                       </asp:Panel>   
                    </ItemTemplate>
                   <HeaderStyle Width="15%" />
              </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <table class="adminlist">
                  <tr>
                  <th></th>
                  </tr>
                  <tr>
                     <td colspan="8">暂无充值卡!</td>
                  </tr>
                </table>
                     
              </EmptyDataTemplate>
         </asp:GridView>
         
       <div class="page">
       <asp:Label ID="PagePanel" runat="server" />
       </div>

	<div class="div_btm">         
          <asp:Button id="ButDel" onclick="ButDel_Click" runat="server" CausesValidation="False" Text="批量删除" OnClientClick="return confirm('执行操作前请确保所选择的充值卡是无效的，否则可能会影响正在使用此卡的会员，您真的要删除?')"></asp:Button>&nbsp; 
          <asp:Button id="ButSell" onclick="ButSell_Click" runat="server" CausesValidation="False" Text="批量售出" OnClientClick="return confirm('售出的充值卡不能再修改，确定售出吗?')"></asp:Button>&nbsp; 
	</div>

	<div class="help_intro" >
	<h1>帮助说明：</h1>
	<ul style=" margin:0; padding:0; text-align:left; line-height:20px" >
         <li>充值卡有<span style="color:Red">未使用(0)，已使用(1)，已售出(2)，已失效(3)</span>四种状态</li>
         <li>已售出或已使用的充值卡不能修改或单个删除，但可以批量清理。</li>
	</ul>
	</div>       
</asp:Content>

