<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="HL_Admin_Admin_Card, HoWaveVGO" title="充值卡管理" enableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script src="Js/getdate.js" type="text/javascript"></script>   
<script src="Js/Function.js" type="text/javascript"></script>  
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/>
<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">
    <tr>
       <th valign="middle" class="menus" align="left" style="width: 444px">充值卡管理 </th>
       <td align="right">        
          <div style="text-align:center; cursor:pointer; float:right;"><img src="../IMS_Img/Manage/addcar.png"  ID="addcard" alt="添加充值卡"  class="Imagebutton" onclick="ModifyCard('','Add')"/></div>
       </td>

    </tr>                     
   </table>
   
     <table class="nick"><tr><td colspan="4" class="tit">充值卡列表</td></tr>
     <tr><td class="ltd"> 状态：</td>
           <td class="rtd" style="width:35%">
           <asp:DropDownList ID="DropMoment" runat="server" AutoPostBack="true">
               <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" />
           </td>
          </tr>
          </table>
          <br />
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
            <asp:GridView id="GridView1" runat="server" CssClass="adminlist" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="CardID" DataSourceID="ObjectDataSource1" 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);" 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="#" onclick="ModifyCard('<%# Eval("CardID") %>','Modify')" >修改</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="#" onclick="ModifyCard('<%# Eval("CardID") %>','Show')" >查看</a>
                       </asp:Panel>   
                    </ItemTemplate>
                   <HeaderStyle Width="15%" />
              </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <table class="adminlist">
                  
                  <tr>
                     <td colspan="8">暂无充值卡!</td>
                  </tr>
                </table>
                     
              </EmptyDataTemplate>
         </asp:GridView><br />
          <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; 
       </ContentTemplate>
       <Triggers>
           <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click"></asp:AsyncPostBackTrigger>
       </Triggers>
     </asp:UpdatePanel> 
       
   <p>
      <ul style=" margin:0; padding:0; text-align:left; line-height:20px" >
         <li>充值卡有<span style="color:Red">未使用，已使用，已失效，已售出</span>四种状态</li>
         <li>已售出或已使用的充值卡不能修改或单个删除，但可以批量清理。</li>
     </ul>
   </p>

  
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeleteCard"
                   SelectMethod="GetCardByStatus" TypeName="CardBLL"  >
             <DeleteParameters>
                 <asp:Parameter Name="CardID" Type="Int32" />
             </DeleteParameters>
            
    <SelectParameters>
        <asp:ControlParameter ControlID="DropMoment" Name="Status" PropertyName="SelectedValue"
            Type="Int32" />
        <asp:ControlParameter ControlID="TextBox1" Name="UserName" PropertyName="Text" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource> 
       
</asp:Content>

