<%@ page language="C#" masterpagefile="AdminIndexMaster.master" autoeventwireup="true" inherits="Admin_Message, HoWaveIMSV5.0" title="短信息管理" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
<script type="text/javascript">
function FControl(ctlName)        
{            
   var rowIndex=document.getElementById(ctlName).selectedIndex;
   var selectname=document.getElementById(ctlName).options[rowIndex].innerText;
   switch (selectname){
      case "指定会员名":
         document.getElementById('Sendto').style.display="";
         document.getElementById('SendtoGroup').style.display="none";
         break;
      case "指定会员组":
         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:600px; dialogHeight:450px; help: no; scroll: yes; status: no');
    if (arr != null){
       document.getElementById(ctlName).value=arr;
    }
}
</script>
   
     <table width="100%" border="0">
     <tr>
      <td valign="top" align="center" style=" width:100%; height: 54px;">
	       <table class="adminheading">
               <tr>
                  <th valign="middle" class="menus" style="height: 54px; width: 629px;" align="left">
                      短信息管理</th>
                  <td valign="middle" style="height: 54px">
                  <table border="0" align="right" cellpadding="3" cellspacing="0">
                     <tr>                        
                       <td>&nbsp;</td>
                       <td>
                       <div onclick="MessageBar.style.display=''">
                       <asp:Image ImageUrl="~/Images/Manage/edit.png" AlternateText="发布消息" id="SendMessage" 
                            BorderWidth="0" ImageAlign="Middle" runat="server" CssClass="Imagebutton"/><br />
                           发布消息&nbsp;</div></td>
                        <td>&nbsp;</td> 
                        <td>
                           <asp:Image  ID="help" runat="server" AlternateText="帮助"  ImageUrl="~/Images/Manage/help.png" /><BR>
                           帮助
                      </td>
                   </tr>                     
                </table>
              </td>
             </tr>
          </table> 
       </td>
     </tr>
  </table>
    <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>
     <fieldset class="FieldSetStlye">
         <legend>短信息管理</legend>
         <table class="adminlist">
             <tr>
                <td>                    
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
                              DataKeyNames="MessageID" DataSourceID="ObjectDataSource1" Width="100%" RowStyle-HorizontalAlign="Center">
                         <Columns>
                             <asp:BoundField DataField="MessageID" HeaderText="短信编号ID" InsertVisible="False" ReadOnly="True"
                                 SortExpression="MessageID" />                             
                             <asp:BoundField DataField="Sender" HeaderText="发送人" SortExpression="Sender" />                            
                             <asp:BoundField DataField="Receiver" HeaderText="收信人" SortExpression="Receiver" />                             
                             <asp:BoundField DataField="Title" HeaderText="标题" SortExpression="Title" />                             
                             <asp:BoundField DataField="Content" HeaderText="内容" SortExpression="Content" />
                             <asp:BoundField DataField="SendTime" HeaderText="发送时间" SortExpression="SendTime"/>                            
                             <asp:BoundField DataField="IsRead" HeaderText="已读" SortExpression="IsRead" />
                             <asp:CommandField HeaderText="操作" ShowDeleteButton="True"/>                                 
                         </Columns>
                         <RowStyle HorizontalAlign="Center" />
                         <EmptyDataTemplate><div style="text-align:center">暂无短消息！</div></EmptyDataTemplate>
                     </asp:GridView>
                     
                        </ContentTemplate>
                     </asp:UpdatePanel>
                 </td>
             </tr>
         </table>
         <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 class="tdbgborder" width="100%">
                    <tr class="tdbg">
                         <td align="center" colspan="2" class="title">发布网站短消息</td> 
                     </tr>
                     <tr class="tdbg">
                         <td style="width:20%" align="right">选择接收方</td>
                         <td style="width:80%" align="left">
                            <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:ListItem Text="公司职员" Value="5"/>
                                         </asp:CheckBoxList>
                                     </div> 
                                  </td>
                               </tr>
                            </table> 
                         </td>
                      </tr>
                      <tr class="tdbg">
                         <td style="width:20%" align="right">消息发送人</td>
                         <td style="width:80%" align="left">
                            <asp:TextBox ID="Sender" Text='<%# Bind("Sender") %>' runat="server"/>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                               ErrorMessage="请填写发送人" ControlToValidate="Sender"/> 
                         </td>
                     </tr>
                     <tr class="tdbg">
                         <td style="width:20%" align="right">短消息标题</td>
                         <td style="width:80%" align="left">
                             <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 class="tdbg">
                         <td style="width:20%" align="right">短消息内容</td>
                         <td style="width:80%" align="left">                        
                         <asp:TextBox ID="Content" Text='<%# Bind("Content") %>' runat="server" TextMode="MultiLine" Height="300px" Width="400px"/></td>
                     </tr>                    
                     <tr class="tdbg">
                        <td style="width:100%" align="center" colspan="2">
                           <asp:linkButton 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">
              <ProgressTemplate>
                   <div class="wait">
                     <img src="../Images/wait.gif" align="middle"/>请稍等...
                    </div>
              </ProgressTemplate>
            </asp:UpdateProgress>
     </fieldset>
</asp:Content>

