<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Msg.aspx.cs" Inherits="_Msg" %>
<%@ Register TagPrefix="anthem" Namespace="Anthem" Assembly="Anthem" %>
<html>
<head>
<title>短消息</title>
<link href="css/StyleSheet.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">
<!--
window.onerror = function(){
return true;
}

function doKeyDown()
{ 
   if (event.ctrlKey && event.keyCode == 13) 
   {
      document.getElementById("sendMsgBtn").click();
   }
}

function Anthem_Error(result) 
{
    alert('页面显示出现错误,请将此错误报告管理员Email:webmaster@aspxcn.cn,错误信息如下: ' + result.error);
}

var divTime;
function Anthem_PreCallBack()
{
    divTime = setTimeout("document.getElementById('loading').style.visibility = 'visible'","1000");
}

function Anthem_PostCallBack() 
{
    clearTimeout(divTime);
	document.getElementById("loading").style.visibility="hidden";
}

function CancelAsyncPostBack() 
{
    Anthem_GetXMLHttpRequest().abort();
}

function popWinDel() 
{
    return confirm('是否要删除所选的短信息?');
}

function popWinClear() 
{
    return confirm('是否要清空您的内容?');
}

String.prototype.len=function()
{ 
return this.replace(/[^\x00-\xff]/g,"**").length; 
} 

function CheckNameLength(source, arguments) 
{ 
if (arguments.Value.len()<=18) 
arguments.IsValid = true; 
else 
arguments.IsValid = false; 
}

function CheckTitleLength(source, arguments) 
{ 
if (arguments.Value.len()<=50) 
arguments.IsValid = true; 
else 
arguments.IsValid = false; 
}
//--> 
</script>
</head>
<body onkeydown="doKeyDown()">
    <form id="form1" runat="server">
        <br />
        <table align=center>
            <tr>
                <td align="center" valign="top">
                    <anthem:Button ID="inBox" AutoUpdateAfterCallBack=true EnabledDuringCallBack=false runat="server" Text="收件箱" OnClick="inBox_Click" Width="70px"></anthem:Button>
                    &nbsp;&nbsp;&nbsp;
                    <anthem:Button ID="sendBox" AutoUpdateAfterCallBack=true EnabledDuringCallBack=false runat="server" Text="发件箱" OnClick="sendBox_click" Width="70px"></anthem:Button>
                    &nbsp;&nbsp;&nbsp;
                    <anthem:Button ID="send" AutoUpdateAfterCallBack=true EnabledDuringCallBack=false runat="server" Text="发消息" OnCommand="send_Command" Width="70px"></anthem:Button><br />
                    <br />
                    <anthem:panel ID="viewMSgTitle" AutoUpdateAfterCallBack=true runat=server>
                    <anthem:GridView ID="ListGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                        BorderStyle="Dashed" BorderWidth="1px" CellPadding="5" DataKeyNames="ID" Width="100%" AllowPaging="True" OnPageIndexChanging="ListGrid_PageIndexChanging" >
                        <Columns>
                             <asp:TemplateField HeaderText="序 号">
                                <ItemTemplate>
                                <%# this.ListGrid.PageIndex * this.ListGrid.PageSize + this.ListGrid.Rows.Count + 1%>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="40px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="标 题">
                                <ItemTemplate>
                                    <asp:LinkButton ID="ListTitle" runat="server" CommandArgument='<%# StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).ID%>'
                                        Text="<%# Server.HtmlEncode(StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).Msg_Title) %>"
                                        ToolTip="点击打开短消息" OnCommand="ListTitle_Command"></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle Height="25px" HorizontalAlign=Left Width="400px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="发件人">
                                <ItemTemplate>
                                    <asp:LinkButton ID="FUserName" runat="server"
                                        OnClientClick=<%# "showModalDialog('userInfo.aspx?user="+Server.UrlEncode(StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).From_userName)+"','info','dialogWidth:300pt;dialogHeight:250pt;status:0');"%>
                                        Text='<%# StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).From_userName %>'
                                        ToolTip="点击查看用户信息"></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="120px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="收件人" >
                                <ItemTemplate>
                                    <asp:LinkButton ID="TUserName" OnClientClick=<%# "showModalDialog('userInfo.aspx?user="+Server.UrlEncode(StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).To_userName)+"','info','dialogWidth:300pt;dialogHeight:250pt;status:0');"%>
                                         runat="server" Text='<%# StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).To_userName %>'></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="120px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="Msg_DateTime" DataFormatString="{0:yyyy/MM/dd HH:mm}" HeaderText="接收日期"
                                HtmlEncode="False" ReadOnly="True">
                                <ItemStyle HorizontalAlign="Center" Width="100px" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="已 读">
                                <ItemTemplate>
                                <%# StrongTyped<Aspxcn.Entities.Msg>(Container.DataItem).IsRead==true ? "是":"否" %>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="40px" />
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="选 定">
        <HeaderTemplate>
                <asp:CheckBox ID="checkall" runat="server" Text="全选" 
                        AutoPostBack="true" OnCheckedChanged="checkAll" />
         </HeaderTemplate>
          <ItemTemplate>
                   <asp:CheckBox ID="check" runat="server" />
            </ItemTemplate>     
            <ItemStyle HorizontalAlign="Center" Width="80px" />
</asp:TemplateField>

                        </Columns>
                        <EmptyDataTemplate>
                            <br />
                            <div id="nodata" align="center">
                                **没有匹配的显示数据!**</div>
                            <br />
                        </EmptyDataTemplate>
                        <FooterStyle BackColor="#507CD1" ForeColor="White" />
                        <RowStyle BackColor="#EFF3FB" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" />
                        <PagerStyle BackColor="#507CD1" />
                        <PagerSettings Mode="NumericFirstLast" />
                    </anthem:GridView>
                        <br />
                    <anthem:Button ID="selectAllBtn" AutoUpdateAfterCallBack=true EnabledDuringCallBack=false runat="server" OnClick="selectAllBtn_Click" Text="全选" BorderStyle="Dashed" />
                    &nbsp;&nbsp;
                    <anthem:Button ID="deleteBtn" runat="server"  AutoUpdateAfterCallBack=true EnabledDuringCallBack=false PreCallBackFunction="popWinDel" CommandName="inBox"  OnClick="deleteBtn_Click" Text="删除" BorderStyle="Dashed" /></anthem:panel>
                    <anthem:Panel ID="viewMSgContent"  AutoUpdateAfterCallBack=true runat=server Visible="False">
                        <table height="300" style="border-style:dashed ;border-color:#CCCCCC ;" border=1px width="640">
                       
                            <tr>
                                <td style="height: 20px"align="left" bordercolorlight="#CCCCCC" bordercolordark="#CCCCCC" bgcolor="#507cd1">
                                    <font color=white>&nbsp;查看短消息</font></td>
                            </tr>
                            <tr>
                                <td style="height: 20px" align="left" bordercolorlight="#cccccc" bordercolordark="#cccccc"  bgcolor="#EFF3FB">
                                作者：<asp:Literal ID="Msg_userName"  runat=server />
                                </td>
                            </tr>
                            <tr>
                                <td style="height: 20px" align="left" bordercolorlight="#cccccc" bordercolordark="#cccccc"  bgcolor="#EFF3FB">
                                标题：<asp:Literal ID="Msg_title" runat= server></asp:Literal></td>
                            </tr>
                            <tr>
                                <td style="height: 20px" bordercolorlight="#cccccc" bordercolordark="#cccccc" bgcolor="#EFF3FB"  align="left">
                                时间：<asp:Literal ID="Msg_dateTime" runat= server></asp:Literal>
                                </td>
                            </tr>
                             <tr>
                                <td style="height: 20px ; word-break:break-all" bordercolorlight="#cccccc" bordercolordark="#cccccc" bgcolor="#EFF3FB" align="left">
                                内 容：
                                </td>
                            </tr>
                             <tr>
                                <td style="height: 180px"  bordercolorlight="#cccccc" valign=top bordercolordark="#cccccc" align="left"><br />
                                <asp:Literal ID="Msg_Content" runat= server></asp:Literal>
                                </td>
                            </tr>
                             <tr>
                                <td style="height: 20px" bordercolorlight="#CCCCCC" bordercolordark="#CCCCCC" bgcolor="#507cd1" align="left">
                                <font color=white>选项：[<asp:LinkButton ID="replyMsg" OnCommand="send_Command" runat=server ForeColor="White" Text="回复"></asp:LinkButton>][<Anthem:LinkButton ID="delBtn" OnCommand="delBtn_command"  PreCallBackFunction="popWinDel" ForeColor="White" runat=server Text="删除"></Anthem:LinkButton>][<asp:LinkButton ID="returnList" Text="返回" ForeColor=white OnClick="inBox_Click" runat=server></asp:LinkButton>]</font></td>
                            </tr>
                        </table>
                    </anthem:Panel>
                    <anthem:Panel ID="sendMsgContent"  AutoUpdateAfterCallBack=true Visible=false runat=server>
                        <table style="border-style:dashed ;border-color:#CCCCCC ;" align=center border=1px>
                        <tr>
                                <td align="left" bordercolorlight="#CCCCCC" height=20px bordercolordark="#CCCCCC" bgcolor="#507cd1"><font color="white">&nbsp;发送短消息</font></td>
                            </tr>
                        <tr>
                                <td align="left" bordercolorlight="#CCCCCC" bordercolordark="#CCCCCC">
                                    接收方：<asp:TextBox ID="sendToUsername" runat="server" Width="163px" MaxLength="18"></asp:TextBox>
                                    <Anthem:RequiredFieldValidator ID="RequiredFieldValidator1"  AutoUpdateAfterCallBack=true runat="server" ControlToValidate="sendToUsername"
                                        Display="Dynamic" ErrorMessage="*用户名不能为空!" SetFocusOnError="True" ValidationGroup="post">*用户名不能为空!</Anthem:RequiredFieldValidator>
                                    <Anthem:CustomValidator ID="CustomValidator1" runat="server" AutoUpdateAfterCallBack=true ClientValidationFunction="CheckNameLength"
                                        ControlToValidate="sendToUsername" Display="Dynamic" ErrorMessage="*用户名不能大于18个字符或9个汉字!"
                                        ValidationGroup="post"></Anthem:CustomValidator></td>
                            </tr>
                            <tr>
                                <td align="left" bordercolorlight="#CCCCCC" bordercolordark="#CCCCCC">
                                    标题：<asp:TextBox ID="MsgTitle" runat="server" Width="350px" MaxLength="50"></asp:TextBox>
                                    <Anthem:RequiredFieldValidator ID="RequiredFieldValidator5" AutoUpdateAfterCallBack=true runat="server" ControlToValidate="MsgTitle"
                                        Display="Dynamic" ErrorMessage="*标题不能为空!" SetFocusOnError="True" ValidationGroup="post">*标题不能为空!</Anthem:RequiredFieldValidator>
                                    <Anthem:CustomValidator ID="CustomValidator2" runat="server" AutoUpdateAfterCallBack=true ClientValidationFunction="CheckTitleLength"
                                        ControlToValidate="MsgTitle" Display="Dynamic" ErrorMessage="*标题不能大于50个字符或25个汉字!"
                                        ValidationGroup="post"></Anthem:CustomValidator></td>
                            </tr>
                            <tr>
                                <td align="left" style="height: 182px" bordercolorlight="#CCCCCC" bordercolordark="#CCCCCC">
                                    内容：<Anthem:RequiredFieldValidator ID="RequiredFieldValidator2" AutoUpdateAfterCallBack=true runat="server" ControlToValidate="MsgContent"
                                        Display="Dynamic" ErrorMessage="*内容不能为空!" SetFocusOnError="True" ValidationGroup="post">*内容不能为空!</Anthem:RequiredFieldValidator><br />
                                    <asp:TextBox ID="MsgContent" runat="server" Height="158px" TextMode="MultiLine" Width="624px" MaxLength="150"></asp:TextBox></td>
                            </tr>
                            <tr>
                            <td bordercolorlight="#CCCCCC" bordercolordark="#CCCCCC">
                                <br />
                                &nbsp;<Anthem:Button ID="sendMsgBtn" runat="server" Text="发送" OnClick="sendMsgBtn_Click" ValidationGroup="post" BorderStyle="Dashed" />
                                &nbsp;
                                <Anthem:Button ID="clearAll" runat="server" Text="清空" AutoUpdateAfterCallBack=true PreCallBackFunction="popWinClear" OnClick="clearAll_Click" BorderStyle="Dashed" />&nbsp;
                                <anthem:CheckBox ID="saveBox" runat="server" Text="保存到发件箱" /><br />
                                <br />
                                [完成后可按Ctrl+Enter提交][字数限制：150字][UBB：不支持]</td>
                            </tr>
                        </table>
                    
                    </anthem:Panel>
                </td>
            </tr>
        </table>

<div id="loading" style="background-color: #FFFFFF; color: #000000; font-size:9pt; position:absolute;width: 270px; height: 100px; border:Dashed 1px #333333 ; visibility:hidden ">
    <br />
    &nbsp;
执行操作中,请稍等......<br />
    <center><img src="images/pleasewait.gif"/></center>
    <br />
    <center><anthem:Button runat=server ID="canclloading" Text=" 取 消 " EnabledDuringCallBack=false  PreCallBackFunction="CancelAsyncPostBack()" style="border-style:dashed" /><br />
        <br />
        &nbsp;</center>
</div>
<script type="text/javascript">
var load=document.getElementById('loading');
load.style.left=(document.body.offsetWidth-load.offsetWidth)/2;
load.style.top=(document.body.offsetHeight-load.offsetHeight)/2;
</script>
</form>
</body>
</html>