<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="HL_Admin_Admin_Message, HoWaveVGO" title="短信息管理" enableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/>
<script src="Js/Function.js" type="text/javascript"></script> 
<script type="text/javascript">
function FControl(ctlName)        
{            
   var rowIndex=document.getElementById(ctlName).selectedIndex;
 
   switch (rowIndex){
      case 1:
         document.getElementById('Sendto').style.display="";
         document.getElementById('SendtoGroup').style.display="none";
         break;
      case 2:
         document.getElementById('Sendto').style.display="none";
         document.getElementById('SendtoGroup').style.display="";
         break;
      default:
         document.getElementById('Sendto').style.display="none";
         document.getElementById('SendtoGroup').style.display="none";
         break;            
   }
}
function SelectUser(ctlName){
    var arr=showModalDialog('Admin_SourceList.aspx?TypeSelect=UserList&DefaultValue='+document.getElementById(ctlName).value,'','dialogWidth:800px; dialogHeight:450px; help: no; scroll: yes; status: no');
    if (arr != null){
       document.getElementById(ctlName).value=arr;
    }
}
</script>
   
    
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeleteMessage"
        InsertMethod="AddMessage" SelectMethod="GetMessages" TypeName="MessageBLL" UpdateMethod="UpdateMessage">
        <DeleteParameters>
            <asp:Parameter Name="MessageID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="MessageID" Type="Int32" />
            <asp:Parameter Name="Sender" Type="String" />
            <asp:Parameter Name="Receiver" Type="String" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Content" Type="String" />
            <asp:Parameter Name="DelR" Type="Int32" />
            <asp:Parameter Name="SendTime" Type="DateTime" />
            <asp:Parameter Name="DelS" Type="Int32" />
            <asp:Parameter Name="IsSend" Type="Int32" />
            <asp:Parameter Name="IsRead" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Sender" Type="String" />
            <asp:Parameter Name="Receiver" Type="String" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Content" Type="String" />
            <asp:Parameter Name="DelR" Type="Int32" />
            <asp:Parameter Name="SendTime" Type="DateTime" />
            <asp:Parameter Name="DelS" Type="Int32" />
            <asp:Parameter Name="IsSend" Type="Int32" />
            <asp:Parameter Name="IsRead" Type="Int32" />
            <asp:Parameter Name="SendName" Type="String" />
            <asp:Parameter Name="SendGroup" Type="string" />
        </InsertParameters>
    </asp:ObjectDataSource>
         <table class="adminheading">
         <tr>
            <th valign="middle" class="inbox"> 短信息管理</th>                  
            <td align="right">              
               <div onclick="MessageBar.style.display=''" style="width:75px; text-align:center; cursor:pointer;">
                   <asp:Image ImageUrl="../IMS_Img/Manage/addmsg.png" AlternateText="发布消息" id="SendMessage" 
                    BorderWidth="0" ImageAlign="Middle" runat="server" CssClass="Imagebutton"/>
               </div>
             </td> 
             <td class="rtdw"></td> 
         </tr>
      </table> 

         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:GridView id="GridView1" runat="server" CssClass="adminlist" OnDataBound="GridView1_DataBound" EnableViewState="false"
                     AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="MessageID" DataSourceID="ObjectDataSource1" Width="100%" PageSize="20">
                <Columns>
                   <asp:TemplateField>
                       <ItemTemplate>                                        
                          <input name="chk_select" value='<%# Eval("MessageID") %>' type="checkbox" />                                        
                       </ItemTemplate>
                       <HeaderTemplate>
                           <input id="chkAll" onclick="SelectAllCheckboxes(this);" runat="server" type="checkbox" />                                     
                       </HeaderTemplate>
                       <ItemStyle Width="50px" />
                    </asp:TemplateField>                  
                    <asp:BoundField DataField="Sender" SortExpression="Sender" HeaderText="发送人" ItemStyle-Width="100px"/>
                    <asp:BoundField DataField="Receiver" SortExpression="Receiver" HeaderText="收信人" ItemStyle-Width="100px"/>
                    <asp:BoundField DataField="Title" SortExpression="Title" HeaderText="标题" ItemStyle-HorizontalAlign="Left"  />                   
                    <asp:BoundField DataField="SendTime" SortExpression="SendTime" HeaderText="发送时间" ItemStyle-Width="150px"/>
                    <asp:BoundField DataField="IsRead" SortExpression="IsRead" HeaderText="状态" ItemStyle-Width="50px"/>
                    <asp:TemplateField HeaderText="操作" ItemStyle-Width="50px">
                      <ItemTemplate>
                        <asp:LinkButton ID="cl" runat="server" CommandName="Delete" OnClientClick="{if(confirm('确定删除吗？')) return true;return false;}" Text="删除"  CausesValidation="false" />
                      </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <RowStyle HorizontalAlign="Center" height="15" />
                <EmptyDataTemplate>
                    <tr>
                      <th scope="col">编号ID</th><th scope="col">发送人</th><th scope="col">收信人</th><th scope="col">标题</th><th scope="col">内容</th><th scope="col">发送时间</th><th scope="col">已读</th><th scope="col">操作</th>
                    </tr>
                    <tr><td colspan="8">暂无短消息！</td></tr>
                </EmptyDataTemplate>
                </asp:GridView>
            </ContentTemplate>
         </asp:UpdatePanel>
         <br />
        <asp:Button ID="DeleteMessageButton" runat="server" Text="批量删除" OnCommand="DeleteMessageButton_Click" CausesValidation="false" OnClientClick="if(confirm('确定删除吗？')) return true; return false;"  /> 
<div id="MessageBar">
<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
   <asp:UpdatePanel ID="UpdatePanel2" runat="server">
      <ContentTemplate>
        <center>
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="MessageID" DataSourceID="ObjectDataSource1" 
             DefaultMode="Insert" CellPadding="0" OnItemCreated="FormView1_ItemCreated"  OnItemInserted="FormView1_ItemInserted">            
             <InsertItemTemplate>
                <div align="right" class="CancleButton" onclick="javascript:MessageBar.style.display='none'">&nbsp;&nbsp;</div> 
                 <table width="100%" class="tableadd" style="background-color:White">
                    <tr>
                         <th align="center" colspan="2"><strong>发布网站短消息</strong></th> 
                     </tr>
                     <tr>
                         <td class="tdbg1" width="20%">选择接收方</td>
                         <td class="tdbg2" width="80%">
                            <table>
                               <tr>
                                  <td>
                                     <asp:DropDownList ID="Receiver" runat="server" SelectedValue='<%# Bind("Receiver") %>' >
                                        <asp:ListItem Text="所有会员" Value="All"/>
                                        <asp:ListItem Text="指定会员组" Value="Group" />
                                        <asp:ListItem Text="指定会员名" Value="Users" />
                                     </asp:DropDownList>
                                  </td>
                                  <td>
                                     <div id="Sendto" style="display:none">
                                         <asp:TextBox ID="SendName" runat="server" Width="200px" Text='<%# Bind("SendName") %>'/>
                                       <a href="javascript:void(0)" id="ShowUser" runat="server">[会员列表]</a> 
                                     </div>
                                     <div id="SendtoGroup" style="display:none">
                                         <asp:CheckBoxList ID="SendGroup" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" SelectedValue='<%#Bind("SendGroup") %>'>
                                           <asp:ListItem Text="未验证用户" Value="0"/>
                                           <asp:ListItem Text="注册会员" Value="1"/>
                                           <asp:ListItem Text="VIP会员" Value="2"/>
                                           <asp:ListItem Text="商业客户" Value="3"/>
                                           <asp:ListItem Text="代理商" Value="4"/>    
                                         </asp:CheckBoxList>
                                     </div> 
                                  </td>
                               </tr>
                            </table> 
                         </td>
                      </tr>
                      <tr>
                         <td class="tdbg1">消息发送人</td>
                         <td class="tdbg2">
                            <asp:TextBox ID="Sender" Text='<%# Bind("Sender") %>' runat="server"/>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                               ErrorMessage="请填写发送人" ControlToValidate="Sender"/> 
                         </td>
                     </tr>
                     <tr>
                         <td  class="tdbg1">短消息标题</td>
                         <td  class="tdbg2">
                             <asp:TextBox ID="title" Text='<%# Bind("Title") %>' runat="server"/>
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                               ErrorMessage="请输入消息标题" ControlToValidate="title"/>
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                               ErrorMessage="请填写内容" ControlToValidate="Content"/> 
                         </td>
                     </tr>
                     <tr>
                         <td  class="tdbg1">短消息内容</td>
                         <td  class="tdbg2">                        
                         <asp:TextBox ID="Content" Text='<%# Bind("Content") %>' runat="server" TextMode="MultiLine" Height="200px" Width="400px"/></td>
                     </tr>                    
                     <tr>
                        <td  class="tdbg1"></td>
                        <td class="tdbg2" style="text-align:center;">
                           <asp:Button ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert" Text="发布"/>
                        </td>
                     </tr>                  
                 </table>
               
             </InsertItemTemplate>            
         </asp:FormView>
       </ContentTemplate>
     </asp:UpdatePanel>
  </asp:Panel>
  </div>
         <ajaxToolkit:PopupControlExtender ID="Pc1" runat="server"
               PopupControlID="Panel1" 
               Position="Left" 
               TargetControlID="SendMessage"/>
       
         <asp:UpdateProgress   ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
              <ProgressTemplate>
<DIV class="wait"><IMG src="../IMS_IMG/wait.gif" align=middle />请稍等... </DIV>
</ProgressTemplate>
            </asp:UpdateProgress>
      <script  type="text/javascript">
      //var height=document.body.scrollHeight;
     //var test=document.getElementById("ctl00_ContentPlaceHolder1_GridView1"); 
     //if(height<250)
        //test.style.height=250; 
     </script>--
</asp:Content>