<%@ Page Language="C#" MasterPageFile="~/Admin/MainPage.Master" AutoEventWireup="true"
    Codebehind="MemberMessageList.aspx.cs" Inherits="PPFOR.Admin.UserInfo.MemberMessageList" Title="站内消息列表" %>
<%@ Register Src="~/Admin/Ascx/PageBar.ascx" TagName="PageBar" TagPrefix="page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_mainContent" runat="server">
<script src="/Admin/JS/gridview.js" type="text/javascript"></script>  
<script src="/Admin/JS/ajax.js" type="text/javascript"></script> 
<script language="javascript" type="text/javascript">
var activeMessagID='';
function openMessage(obj,msgId)
{ 
    var prevTrID="msgBodyRow_";  
    var prevTitleImageID="msgTitleImage_";
        
    if(activeMessagID!=null && activeMessagID!=''){
        var activeMessagRow=docEle(prevTrID + activeMessagID);
        if(activeMessagRow){
            activeMessagRow.style.display='none';
            changeTitleImage(prevTitleImageID + activeMessagID,0);  
            if(msgId==activeMessagID){         
                activeMessagID='';                 
                return;
            } 
        }     
    }
    activeMessagID=msgId;   
    var objTr= docEle(prevTrID + msgId);
    if(!objTr){
        var objNewTd=createMessageRow(obj,prevTrID + msgId);
        DoAjax("Servers.aspx?action=getmessagebody&msgid=" + msgId,"GET",null,showMessage,objNewTd);
    }else{
        objTr.style.display='';             
    }
    if(activeMessagID!=null && activeMessagID!=''){
        changeTitleImage(prevTitleImageID + activeMessagID,1);  
    }
}
function changeTitleImage(idTitleImage,type){
     var objTitleImage=docEle(idTitleImage);
     if(objTitleImage){
        objTitleImage.src="/Admin/Images/" + (type==1 ? 'move_up' : 'move_down') + ".gif";
     }
}
function createMessageRow(obj,idTr)
{    
    var objTd=obj.parentNode;
    if(objTd!=null){
        var objTr=objTd.parentNode;
        if(objTr!=null){
            var objTable=objTr.parentNode;
            if(objTable!=null){
                objNewTr=objTable.insertRow(objTr.rowIndex+1);                
                if(objNewTr!=null){                    
                    objNewTr.id=idTr;
                    var objNewTd=objNewTr.insertCell(0);
                    if(objNewTd!=null){
                        objNewTd.colSpan=objTr.cells.length;
                        objNewTd.align='center';
                        objNewTd.innerHTML="<img src=\"/Admin/Images/loading.gif\" alt=\"Loading...\" />"; 
                        return objNewTd;
                    }
                }
            }
        }
    }
    return false;
}
function showMessage(xmlHttp,objNewTd)
{
    if(xmlHttp!=null && xmlHttp.responseText!=null){        
        objNewTd.innerHTML="<p style='text-align:left; width:80%; white-space:normal;'>" + xmlHttp.responseText + "</p>";   
    }else{
        objNewTd.innerHTML='';
    }    
}
</script>
<form id="form1" action="MemberMessageList.aspx" method="post" runat="server">
 <div class="table-ppfor">
		<i></i><u></u>
		<ul>
			<li class="right">
			消息类型：<asp:DropDownList ID="PPFOR_messageTypeList" runat="server" OnSelectedIndexChanged="PPFOR_messageTypeListChanged" AutoPostBack="true" AppendDataBoundItems="true" >
                    </asp:DropDownList>
			</li>
		</ul>
	</div>       
    <asp:GridView ID="PPFOR_showMemberMessageList" CssClass="forgridview" runat="server" OnRowDataBound="PPFOR_gridViewRowDataBound" AllowPaging="false" AutoGenerateColumns="False"  DataKeyNames="MsgID"  Width="100%" CellPadding="0" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="0px" EmptyDataText="没有任何消息">
           <Columns>  
           <asp:TemplateField ShowHeader="False" HeaderText="" HeaderStyle-HorizontalAlign="Center">
                 <ItemStyle Wrap="False" HorizontalAlign="Center" />
                 <HeaderTemplate>
                     <asp:CheckBox ID="PPFOR_selectMemberMessage" runat="server"></asp:CheckBox>
                 </HeaderTemplate>
                 <ItemTemplate>
                     <asp:CheckBox ID="PPFOR_selectMemberMessage" runat="server"></asp:CheckBox>
                 </ItemTemplate>
             </asp:TemplateField>
             <asp:BoundField HeaderText="ID" DataField="MsgID" HeaderStyle-Font-Bold="false"/>
             <asp:TemplateField HeaderText="消息标题" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">
                <ItemTemplate>
                <a href="#" onclick='openMessage(this,<%# Eval("MsgID") %>);' title="查阅消息"><img id='msgTitleImage_<%# Eval("MsgID") %>' src="/User/Images/move_down.gif" alt=""/><%#PPFOR_getMessageMemberTitle(Eval("MsgBodyID"))%></a>
                </ItemTemplate>
             </asp:TemplateField>               
             <asp:TemplateField HeaderText="发送人" HeaderStyle-Font-Bold="false">
                <ItemTemplate>
                <%#PPFOR_getMessageMemberName(Eval("MsgSendMemberID"), Eval("MsgSendIsAdmin"))%>
                </ItemTemplate>
             </asp:TemplateField>    
            <asp:TemplateField HeaderText="接收人" HeaderStyle-Font-Bold="false">
                <ItemTemplate>
                <%#PPFOR_getMessageMemberName(Eval("MsgReceiveMemberID"), Eval("MsgReceiveIsAdmin"))%>
                </ItemTemplate>
             </asp:TemplateField>              
             <asp:BoundField HeaderText="发送时间" DataField="MsgSendTime" HeaderStyle-Font-Bold="false"/>                   
            </Columns>            
             <FooterStyle BackColor="#990000" ForeColor="White" /> 
             <RowStyle Wrap="False" HorizontalAlign="Center" Font-Bold="false" BackColor="#ffffff"/> 
             <HeaderStyle HorizontalAlign="Center" BackColor="#F5F5F5" Font-Bold="false" ForeColor="#000000" />
             <AlternatingRowStyle BackColor="#F5F5F5" />
        </asp:GridView>
        <br />
        <page:PageBar ID="PPFOR_pageBar" runat="server" />
        <br />
        <table width="100%" border="0" cellspacing="0" cellpadding="0" style="display:none;">
        <tr>
          <td>
              <asp:Button ID="PPFOR_deleteMemberMessage" CssClass="inputbutton" runat="server" Text="删除" OnClick="PPFOR_deleteMemberMessageClick" />
              <input name="reset" type="reset" id="reset1" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" value="重置" onclick="SelectAllRows('<%=form1.ClientID%>',false)"/>
                <script type="text/javascript">
                    if("<%=PPFOR_displayRecordOption %>"!='none'){
                        addButtonArray("<%= PPFOR_deleteMemberMessage.ClientID %>","reset1");
                    }
                </script>  
        </td>
        </tr>
      </table>
</form>  
</asp:Content>
