ASP.NET 实现站内信功能(点对点发送,管理员群发)

  正好这段时间在研究这个功能,还是得感谢这位大神,没有他的引路,我就不可能把站内信做出来。

http://www.cnblogs.com/grenet/archive/2010/03/08/1680655.html

  哈哈,再次感谢。

  我们先来说说单点传送站内信,所谓的单点传送,就是用户与用户之间的短信发送,这里的用户可以是一个人,也可以是多个人,

上面的文章大家如果看了的话,想必有一个疑问,就是用户的阅读状态怎么定义?

我这里给大家一种解决方案,再建立一张表,也就是说,建立一张用户阅读状态表,因为每个用户的阅读状态都是不同的,如果照上面的方法,

肯定是不行的,一个人改变了状态,另外的人也改变了。

上面的是我建立的3张表,具体的SQL如下,包含注释

--短信表
create table cms_message
(
id varchar(50) primary key, 
senduserid varchar(50), --发送用户的ID
recuserid varchar(50),    --接收用户的ID
messageid varchar(50), --短信ID
Msgstatus varchar(10)   --查看状态(是否被查询)

)

--短信内容表
create table cms_messagetext
(
idc varchar(50) primary key,
messagetext text,   --站内信内容
pdate varchar(50)  --站内信发送时间
)

--阅读状态表
create table cms_message_read
(
uniqueid varchar(50) primary key,
idm varchar(50) ,--和MESSAGEID相同
userid varchar(50), --用户ID
flag varchar(5) --阅读状态:0未读,1:已读,2:删除
)

大家也许会问一个问题,你已经在阅读状态表里定义了阅读状态,为什么还要短信表里再定义一次呢?这个其实是有用的,尤其是在发件箱功能里要标记自己的信件的时候,稍后会提到哦。

先让大家来看看主界面。

其中有发件箱,未读信息和已读消息。

发件箱的功能就是查看自己已经发送的信件,未读和已读信息就是表示自己是否已经点击过短信。

下面给大家来看一下发送短信的界面。

下面是普通的点对点发送。

下面是短信群发的界面,我这里的群发是选择发送给某个用户组。

 

我先把代码都放出来,然后我们再来慢慢分析。

其中有用到公司的框架,大家知道意思就行,没必要过分纠结。

这是发送短信的窗口的代码

<%@ Page Language="C#" MasterPageFile="~/Core/Public/WebControls/Main.master" AutoEventWireup="true" CodeFile="AdminSend.aspx.cs" Inherits="MsgSend_AdminSend" %>

<asp:Content ID="cssContent" ContentPlaceHolderID="cssContent" runat="server">
<style type="text/css">

    .Row
    {
        width:100%;
        border-bottom:1px solid #BBE9FF;
        font-size:12px;
        font-family:宋体;
        height:30px;
    }
    
    .Row .Caption
    {
        float:left;
        width:80px;
        text-align:left;
        padding-left:20px;
        padding-top:8px;
    }
    
    .Row .Data
    {
        float:left;
        text-align:left;
        padding-top:2px;
        width:317px;
    }
    
    .Row .Validate
    {
        float:left;
        color:red;
        padding-top:8px;
    }
    
    .Row .Data .Field
    {
        width:256px;
        float:left;
    }
    
    .Row .Data .Select
    {
        float:left;
        padding-left:1px;
        padding-top:1px;
    }
    
    .Bottom
    {
        width:100%;
        height:40px;
        border-bottom:1px solid #BBE9FF;
        font-size:12px;
        font-family:宋体;
    }
    
    .Bottom .Button
    {
        margin-top:5px;
        float:right;
        text-align:left;
        padding-right:10px;
    }

</style>
</asp:Content>

<asp:Content ID="bodyContent" ContentPlaceHolderID="bodyContent" runat="server">
    
    
    <div class="Row">
        <div class="Caption">收件人&nbsp;&nbsp;&nbsp;&nbsp;:</div>
        <div class="Data"> <asp:TextBox runat="server" ID="recieveid" style="width:311px;height:17px;"></asp:TextBox>
            <%--下拉列表,仅仅用户管理员可用--%>
            <asp:DropDownList runat="server" ID="ddlUserGroup"></asp:DropDownList>

        </div>
        <div class="Validate">&nbsp;*</div>
    </div>


    

        <div class="Row" id="divMemo">
            <div class="Caption">内容&nbsp;&nbsp;&nbsp;&nbsp;:</div>
            <div class="Data"> <asp:TextBox TextMode="MultiLine" runat="server" ID="msgText" style="width:311px;"></asp:TextBox></div>
            <div class="Validate">&nbsp;*</div>
        </div>


    <div class="Bottom">
    <div class="Button">
         <asp:Button ID="sendMsg" runat="server" Text="发送" OnClick="sendMsg_Click" CssClass="buttonblue_100_27" OnClientClick="return ValidateEmpty();" />&nbsp;
        <asp:Button ID="cancel" runat="server" Text="取消" CssClass="buttonblue_100_27" OnClientClick="return winClose()" />
    </div>
</div>


    
   
</asp:Content>

<asp:Content runat="server" ID="jsContent" ContentPlaceHolderID="jsContent">
        <script type="text/javascript">
        $( document ).load( function()
        {
            var bottom = $( "#divMemo" );
            bottom.height( $( document.body ).height() - 120 - 15 );
            bottom.children().eq( 0 ).css( "margin-top" , 70 );
            bottom.children().eq( 1 ).height( bottom.height() - 15 );
            bottom.children().eq( 1 ).children().eq( 0 ).height( bottom.children().eq( 1 ).height() );
        }
    );
            //内容判断不能为空
        function ValidateEmpty()
        {
            if($("#<%=this.msgText.ClientID%>").val()=="")
            {
                alert("请输入短信内容");
                return false;
            }

            else {
                return true;
            }
           
        }


        </script>
</asp:Content>
AdminSend.aspx(发送短信前台)
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class MsgSend_AdminSend :cs.Common.Web.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {


            //如果是查询信件的话
            if (Request["id"] != null && Request["id"] != "")
            {
                //recieveid.Visible = false; //如果是单纯的查询信件的话,隐去接收人
                recieveid.Enabled = false;
                DataSet setRequest = this.DataManager.Fill("select * from cms_message a,cms_messagetext b  where a.messageid=b.idc and a.id='" +Request["id"]+ "'");

                foreach(DataRow row in setRequest.Tables[0].Rows)
                {
                    msgText.Text= row["messagetext"].ToString(); //短信内容
                    sendMsg.Text = row["recuserid"].ToString();  //接收人
            
                }
                msgText.Enabled = false;
                sendMsg.Enabled = false;
                ddlUserGroup.Visible = false;

            }
            ddlUserGroup.Visible = false;
             //群发短信
            if (Request["group"] == "yes"&&!IsPostBack)
            {
                recieveid.Visible = false;
                ddlUserGroup.Visible = true; //显示下拉
               
                //绑定数据
                //不为顶级栏目
                DataS
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值