<%@ page language="C#" masterpagefile="MyShopMasterPage.master" autoeventwireup="true" inherits="Member_Shop_Message, WebApp_deploy" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        function setButtonActive(flags) {
            var _flag = parseInt(flags);
            var ulObj = document.getElementById("M1");
            for (var i = 0; i < ulObj.childNodes.length; i++)
            { ulObj.childNodes[i].className = ""; }
            if (ulObj.childNodes.length > 2)
            { _flag = _flag * 2 + 1; }
            ulObj.childNodes[_flag].className = "active";
        }
    </script>
    <script type="text/javascript">
        function fun_back() {
            var hfFromName = $("#<%=hfRendOrSendFromName.ClientID %>");
            var newurl = "Shop_Message.aspx";
            var newtag = "";
            if (hfFromName != null) {
                if (hfFromName.val() == "sendfolder") {
                    newtag = "?tag=S";
                }
                else if (hfFromName.val() == "receivefolder") {
                    newtag = "?tag=R";
                }
            }
            if (newtag.length > 0) {
                window.location.href = newurl + newtag;
            }
        }
    </script>
    <div class="pageTitle">
        短消息管理</div>
    <div id="MainMenu" style="height: 100%">
        <div class="TabMenu">
            <!--一级导航-->
            <ul id="M1">
                <li class="active"><a href="Shop_Message.aspx?tag=R" onclick="setButtonActive(0)">收件夹</a></li>
                <li><a href="Shop_Message.aspx?tag=S" onclick="setButtonActive(1)">发件夹</a></li>
            </ul>
        </div>
        <div class="TabText">
            <asp:HiddenField ID="hfRendOrSendFromName" runat="server" Value="" />
            <asp:Panel ID="Panel1" runat="server" Width="100%" Height="100%" HorizontalAlign="Center"
                Visible="True">
                <div style="clear: both; width: 98%; padding: 5px 0 0 5px">
                    <div class="NewMail">
                        <%--<a id="sendPic" href="Shop_Message.aspx?from=&action=send"><img alt="" src="/Images/Member/sendmsg.gif" /></a>--%>
                        <a id="Pic_R" runat="server" href="Shop_Message.aspx?from=receivefolder&action=send">
                            <img alt="" src="/Images/Member/sendmsg.gif" /></a> <a id="Pic_S" runat="server"
                                href="Shop_Message.aspx?from=sendfolder&action=send">
                                <img alt="" src="/Images/Member/sendmsg.gif" /></a>
                    </div>
                </div>
                <div style="clear: both; height: 3px;">
                </div>
                <asp:GridView ID="GridView_R" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    PageSize="20" Width="98%" Height="100%" CssClass="tableHead" OnPageIndexChanging="GridView_R_PageIndexChanging">
                    <Columns>
                        <asp:TemplateField HeaderText="发送者">
                            <ItemTemplate>
                                <asp:HyperLink ID="Message_User" runat="server" Target="_blank" Text='<%#Eval("Sender") %>' />
                            </ItemTemplate>
                            <HeaderStyle Width="20%" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="主题">
                            <ItemTemplate>
                                <asp:HyperLink ID="Message_Title" Text='<%# Eval("Title") %>' runat="server" NavigateUrl='<%# "?from=receivefolder&action=read&tag=R&re=true&MessageID="+Eval("MessageID") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="SendTime" HeaderText="发送日期" HeaderStyle-Width="15%" />
                        <asp:TemplateField HeaderText="状态" HeaderStyle-Width="10%">
                            <ItemTemplate>
                                <asp:Literal ID="txtIsRead" runat="server" Text='<%# (Eval("IsRead").ToString()=="1")?"已读":"未读" %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                <asp:HyperLink ID="HLRead" Text="打开" runat="server" NavigateUrl='<%# "?from=receivefolder&action=read&MessageID="+Eval("MessageID") %>' />
                                |
                                <asp:LinkButton ID="HLDelete" Text="删除" runat="server" CommandName='<%# Eval("MessageID") %>'
                                    OnCommand="DeleteMessage" OnClientClick="return confirm('确定要删除此站内短信吗？');" />
                            </ItemTemplate>
                            <HeaderStyle Width="15%" />
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <table class="tableHeader" style="width: 98%">
                            <th>
                                发送者
                            </th>
                            <th>
                                主题
                            </th>
                            <th>
                                发送日期
                            </th>
                            <th>
                                状态
                            </th>
                            <th>
                                操作
                            </th>
                            <tr>
                                <td colspan="5">
                                    暂无短消息！
                                </td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                </asp:GridView>
                <asp:GridView ID="GridView_S" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    PageSize="20" Width="98%" Height="100%" CssClass="tableHead">
                    <Columns>
                        <asp:TemplateField HeaderText="接收者">
                            <ItemTemplate>
                                <asp:HyperLink ID="Message_User" runat="server" Target="_blank" Text='<%#Eval("Receiver") %>' />
                            </ItemTemplate>
                            <HeaderStyle Width="20%" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="主题">
                            <ItemTemplate>
                                <asp:HyperLink ID="Message_Title" Text='<%# Eval("Title") %>' runat="server" NavigateUrl='<%# "?from=sendfolder&action=read&MessageID="+Eval("MessageID") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="SendTime" HeaderText="发送日期" HeaderStyle-Width="15%" />
                        <asp:TemplateField HeaderText="状态" HeaderStyle-Width="10%">
                            <ItemTemplate>
                                <asp:Literal ID="txtIsRead" runat="server" Text='<%# (Eval("IsRead").ToString()=="1")?"已读":"未读" %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="操作">
                            <ItemTemplate>
                                <asp:HyperLink ID="HLRead" Text="查看" runat="server" NavigateUrl='<%# "?from=sendfolder&action=read&MessageID="+Eval("MessageID") %>' />
                                |
                                <asp:LinkButton ID="HLDelete" Text="删除" runat="server" CommandName='<%# Eval("MessageID") %>'
                                    OnCommand="DeleteMessage" OnClientClick="return confirm('确定要删除此站内短信吗？');" />
                            </ItemTemplate>
                            <HeaderStyle Width="15%" />
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <table class="tableHeader" style="width: 98%">
                            <th>
                                接收者
                            </th>
                            <th>
                                主题
                            </th>
                            <th>
                                发送日期
                            </th>
                            <th>
                                状态
                            </th>
                            <th>
                                操作
                            </th>
                            <tr>
                                <td colspan="5">
                                    暂无短消息！
                                </td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                </asp:GridView>
            </asp:Panel>
            <asp:Panel ID="Panel0" runat="server" Width="100%" HorizontalAlign="Center" Visible="False">
                <div style="clear: both; width: 98%; padding: 5px 0 5px 0; margin: 0 auto">
                    <asp:PlaceHolder ID="SendPanel" runat="server">
                        <table class="ShopOrderStyle" style="width: 100%">
                            <caption>
                                <asp:Literal ID="MessageTitle" runat="server" Text="发送站内短信" /></caption>
                            <tr>
                                <td class="OrderTitle">
                                    收件人：
                                </td>
                                <td>
                                    <asp:TextBox ID="TxtReceiver" runat="server" Width="300px" />使用","分割同时给多位会员发送信息。
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtReceiver"
                                        ErrorMessage="收件人不能空" />
                                </td>
                            </tr>
                            <tr>
                                <td class="OrderTitle">
                                    主题：
                                </td>
                                <td>
                                    <asp:TextBox ID="TxtTitle" runat="server" Width="300px" /><asp:Label ID="LbTxtError"
                                        runat="server" ForeColor="Red" Text=""></asp:Label>
                                    <span style="color: Black">(注：标题长度不能超过50个字符)</span>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TxtTitle"
                                        ErrorMessage="主题不能空" Display="Dynamic" />
                                </td>
                            </tr>
                            <tr>
                                <td class="OrderTitle">
                                    内容：
                                </td>
                                <td>
                                    <asp:TextBox ID="TxtContent" runat="server" Height="300px" TextMode="MultiLine" Width="400px" /><asp:Label
                                        ID="LbComtentError" runat="server" Text="" ForeColor="Red"></asp:Label>
                                    <span style="color: Black">(注：内容长度不能超过1500个字符)</span>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TxtContent"
                                        ErrorMessage="内容不能空" Display="Dynamic" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:CheckBox ID="CheckBox1" runat="server" Text="发送同时保存副本" Checked="true" />
                                    <asp:Button ID="ButdSave" runat="server" OnClick="ButdSave_Click" Text="发 送" />
                                    <%--<asp:Button ID="ButtonBack" runat="server" OnClick="ButdBack_Click" Text="返 回" />--%>
                                    <button type="button" id="btn_back" onclick="fun_back()">返回</button>
                                </td>
                            </tr>
                        </table>
                    </asp:PlaceHolder>
                    <asp:PlaceHolder ID="ReadPanel" runat="server">
                        <table class="ShopOrderStyle" style="width: 100%">
                            <caption>
                                <asp:Literal ID="Literal1" runat="server" Text="查看短消息" /></caption>
                            <tr>
                                <td class="OrderTitle">
                                    <asp:Literal ID="LiSender" Text="收件人：" runat="server" Visible="false" /><asp:Literal
                                        runat="server" ID="LiReceiver" Text="发件人：" Visible="false" />
                                </td>
                                <td>
                                    <asp:Literal ID="TextReceiver" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td class="OrderTitle">
                                    主题：
                                </td>
                                <td>
                                    <asp:Literal ID="TextTitle" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td class="OrderTitle">
                                    内容：
                                </td>
                                <td>
                                    <asp:TextBox ID="TextContent" ReadOnly="true" runat="server" Height="300px" TextMode="MultiLine"
                                        Width="400px" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Button ID="Button1" runat="server" OnClick="ReSend_OnClick" Text="回 复" />
                                    <asp:Button ID="ButtonReply" runat="server" OnClick="ButdBack_Click" Text="返 回" />
                                </td>
                            </tr>
                        </table>
                    </asp:PlaceHolder>
                </div>
            </asp:Panel>
            <div class="clear" style="height: 3px">
            </div>
        </div>
    </div>
    <script type="text/javascript">setButtonActive(<%=m_flag %>);</script>
</asp:Content>
