<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="Admin_Card, HoWaveIMSV5.0" title="充值卡管理" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script src="Js/Function.js" type="text/javascript"></script> 
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
<script type="text/javascript">
function ModifyCard(id,action){
var recdata=false;
  switch (action)
  {
      case "Add":
        recdata=showModalDialog('Admin_ModifyCard.aspx?Action=Add','','dialogWidth:650px; dialogHeight:600px; help: yes; scroll: yes; status: no');
      break;
      case "Modify":
        recdata=showModalDialog('Admin_ModifyCard.aspx?Action=Modify&CardID='+id,'','dialogWidth:400px; dialogHeight:350px; 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">充值卡管理</th>
       <td valign="middle" style=" width:15%; text-align:center;">
          <div id="AddCardScript" onclick="javascript:MenuBar.style.display=''">
             <asp:Image ImageUrl="~/Images/Manage/edit.png"  ID="addcard" AlternateText="添加充值卡"  CssClass="Imagebutton" runat="server"/><br />
                                添加充值卡&nbsp;</div>
       </td>
    </tr>                     
</table>
  <fieldset>
     <legend>充值卡管理</legend>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeleteCard"
                     InsertMethod="AddCard" SelectMethod="GetCards" TypeName="CardBLL" UpdateMethod="UpdateCard">
             <DeleteParameters>
                 <asp:Parameter Name="CardID" Type="Int32" />
             </DeleteParameters>
             <UpdateParameters>
                 <asp:Parameter Name="CardNum" Type="String" />
                 <asp:Parameter Name="CardPassword" Type="String" />
                 <asp:Parameter Name="CardType" Type="Int32" />
                 <asp:Parameter Name="CardAgentName" Type="String" />
                 <asp:Parameter Name="CardValidNum" Type="String" />
                 <asp:Parameter Name="CardMoney" Type="Decimal" />
                 <asp:Parameter Name="CardValidUnit" Type="String" />
                 <asp:Parameter Name="CardEndDate" Type="DateTime" />
                 <asp:Parameter Name="CardCreateTime" Type="DateTime" />
                 <asp:Parameter Name="CardUseTime" Type="DateTime" />
                 <asp:Parameter Name="CardSellFrom" Type="String" />
                 <asp:Parameter Name="CardID" Type="Int32" />
             </UpdateParameters>
             <InsertParameters>
                 <asp:Parameter Name="CardNum" Type="String" />
                 <asp:Parameter Name="CardPassword" Type="String" />
                 <asp:Parameter Name="CardType" Type="Int32" />
                 <asp:Parameter Name="CardAgentName" Type="String" />
                 <asp:Parameter Name="CardValidNum" Type="String" />
                 <asp:Parameter Name="CardMoney" Type="Decimal" />
                 <asp:Parameter Name="CardValidUnit" Type="String" />
                 <asp:Parameter Name="CardEndDate" Type="DateTime" />
                 <asp:Parameter Name="CardCreateTime" Type="DateTime" />
                 <asp:Parameter Name="CardUseTime" Type="DateTime" />
                 <asp:Parameter Name="CardSellFrom" Type="String" />
             </InsertParameters>
         </asp:ObjectDataSource>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
               <asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False" DataKeyNames="CardID" 
                    DataSourceID="ObjectDataSource1" CssClass="adminlist" OnDataBound="GridView1_DataBound">
             <Columns>
                  <asp:TemplateField>
                     <ItemTemplate><asp:CheckBox ID="chkSelect" runat="server"/></ItemTemplate>
                     <HeaderTemplate>
                        <input id="chkAll" onclick="SelectAllCheckboxes(this);" runat="server" type="checkbox" />                                     
                     </HeaderTemplate>
                     <ItemStyle HorizontalAlign="Left" Width="25px" />
                 </asp:TemplateField>     
                 <asp:BoundField DataField="CardID" HeaderText="ID" InsertVisible="False" ReadOnly="True"  SortExpression="CardID"/>
                 <asp:BoundField DataField="CardType" HeaderText="充值卡类型" SortExpression="CardType"/>                             
                 <asp:BoundField DataField="CardNum" HeaderText="卡号" SortExpression="CardNum"/>                             
                 <asp:BoundField DataField="CardMoney" HeaderText="面值" SortExpression="CardMoney"/>                             
                 <asp:BoundField DataField="CardValidNum" HeaderText="通行币" SortExpression="CardValidNum"/>
                 <asp:BoundField DataField="CardValidUnit" HeaderText="单位" SortExpression="CardValidUnit"/>                            
                 <asp:BoundField DataField="CardEndDate" HeaderText="截止期" SortExpression="CardEndDate"/>                            
                 <asp:BoundField DataField="CardUserName" HeaderText="使用者" SortExpression="CardUserName"/>             
                 <asp:TemplateField HeaderText="状态">
                    <ItemTemplate>
                      <asp:Literal ID="CardState" runat="server" Text='<%# Eval("CardState")%>' />
                    </ItemTemplate>
                 </asp:TemplateField>
                 <asp:BoundField DataField="CardUseTime" HeaderText="充值时间" SortExpression="CardUseTime"/>                            
                 <asp:BoundField DataField="CardSellFrom" HeaderText="用途" SortExpression="CardSellFrom"/> 
                   <asp:BoundField DataField="CardAgentName" HeaderText="代理商" SortExpression="CardAgentName"/>     
                 <asp:TemplateField HeaderText="操作">
                   <ItemTemplate>
                     <asp:Panel ID="ModifyPanel" runat="server">
                        <a href="javascript:void(0)" onclick="ModifyCard('<%# Eval("CardID") %>','Modify')">修改</a> &nbsp;
                        <asp:Button id="btnDelete" runat="server" OnClientClick ="return confirm('您真的要删除?')" CommandName='<%# Eval("CardID") %>' Text="删除" OnCommand="DeleteCard"/> 
                     </asp:Panel>   
                   </ItemTemplate>
                 </asp:TemplateField>                         
                
             </Columns>
                   <RowStyle HorizontalAlign="Center" />
          </asp:GridView>
            </ContentTemplate>
         </asp:UpdatePanel>
         <p></p>
         <div style="width:100%">
            <ul>
               <li>充值卡有<span style="color:Red">未使用，已使用，已失效，已售出</span>四种状态</li><li>已售出或已使用的充值卡不能修改或删除</li></ul>
         </div>
  </fieldset>
  <div id="MenuBar">
   
    <asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
         <asp:Panel ID="PanelHeader" CssClass="CancleButton" runat="server">     
            <div align="right" class="CancleButton" onclick="javascript:MenuBar.style.display='none'">&nbsp;&nbsp;</div> 
         </asp:Panel>
        <div align="right" class="CancleButton"></div>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
               <center>
                   <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" DefaultMode="Insert" OnDataBound="FormView1_DataBound">
                       <InsertItemTemplate>
                           <table class="adminlist" width="500px">
                              <tr>
                                  <td style=" width:100px; text-align:left">充值卡类型：</td>
                                  <td align="left">
                                      <asp:DropDownList ID="CardType" runat="server" SelectedValue='<%# Bind("CardType") %>'>
                                         <asp:ListItem Text="本站充值" Value="1" Selected="True" />
                                         <asp:ListItem Text="其它充值卡" Value="2" />
                                      </asp:DropDownList>   
                                   </td>
                              </tr>                             
                               <tr>
                                  <td style="text-align:left">充值卡卡号：</td>
                                  <td align="left"> 
                                     <asp:TextBox ID="CardNum" runat="server"  Text='<%# Bind("CardNum") %>' CssClass="unwatermarked"/>
                                     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                                           ControlToValidate="CardNum" ErrorMessage="充值卡卡号不能为空"/>
                                  </td>
                              </tr>
                               <tr>
                                  <td style="text-align:left">充值卡密码</td>
                                  <td align="left">
                                     <asp:TextBox ID="CardPassword" Text='<%# Bind("CardPassword") %>' runat="server" CssClass="unwatermarked"/>
                                     <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                                           ControlToValidate="CardPassword" ErrorMessage="充值卡密码不能为空"/>
                                  </td>
                               </tr>
                               <tr>
                                  <td style="text-align:left">充值卡面值</td>
                                  <td align="left">
                                     <asp:TextBox ID="CardValue" Text='<%# Bind("CardMoney") %>' runat="server" />
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                                           ControlToValidate="CardValue" ErrorMessage="充值卡面值不能为空"/>   
                                  </td>
                              </tr> 
                              <tr>
                                  <td style="text-align:left">充值卡单位</td>
                                  <td align="left">
                                      <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("CardValidUnit") %>'>
                                         <asp:ListItem Text="元" Value="元" Selected="True" />
                                         <asp:ListItem Text="点" Value="点" />
                                      </asp:DropDownList>                                      
                                  </td>
                              </tr>
                               <tr>
                                  <td style="text-align:left">购买人得到通行币</td>
                                  <td align="left">
                                      <asp:TextBox ID="CardCoin" runat="server" Text='<%# Bind("CardValidNum") %>'/>
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                                           ControlToValidate="CardCoin" ErrorMessage="充值卡通行币不能为空"/>  
                                  </td>
                              </tr>
                              <tr>
                                  <td style="text-align:left">充值卡截止日期</td>
                                  <td align="left">
                                      <asp:TextBox ID="CardEndDate" runat="server" Text='<%# Bind("CardEndDate") %>'/>
                                  </td>
                              </tr>
                              <tr>
                                  <td style="text-align:left">代理商</td>
                                  <td align="left">
                                      <asp:TextBox ID="CardAgent" runat="server" Text='<%# Bind("CardAgentName") %>'/>
                                  </td>
                              </tr>
                              <tr>
                                  <td>&nbsp;</td>
                                  <td style="text-align:left">
                                  <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
                                      Text="插入" /> 
                                  <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                      Text="取消" />
                                   </td>
                              </tr>                              
                           </table>
                           <ajaxToolkit:TextBoxWatermarkExtender ID="tb1" runat="server" TargetControlID="CardNum" WatermarkText="建议设为10--15位" WatermarkCssClass="watermarked" />
                           <ajaxToolkit:TextBoxWatermarkExtender ID="tb2" runat="server" TargetControlID="CardPassword" WatermarkText="建议设为6--10位" WatermarkCssClass="watermarked" />
                          
                       </InsertItemTemplate>
                   </asp:FormView>                    
                </center>
    
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
   </div>
   <ajaxToolkit:PopupControlExtender ID="Pc1" runat="server" TargetControlID="addcard" PopupControlID="Panel1" Position="Left" /> 
   <ajaxToolkit:DropShadowExtender ID="ds1" runat="server" TargetControlID="Panel1" TrackPosition="true" />    
    
</asp:Content>

