改写我前面的即时消息的发送,包含同时给多人发送信息!
来源:互联网 发布:数据库实时同步软件 编辑:程序博客网 时间:2024/05/21 10:26
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
'/////////////////////转到发送即时消息页面
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim i, j As Integer
j = 0
Dim tostu_id As String = ""
For i = 0 To mycheck.Items.Count - 1
If mycheck.Items(i).Selected Then
'////////////////////////限制发送条数
j = j + 1
If j < 6 Then
'/////////////////////参数构造
tostu_id = tostu_id & CheckBoxList1.Items(i).Text & "@"
Else
Label2.Visible = True
Label2.Text = "一次最多能给五个用户发送信息!"
Return
'Response.Write("<script language=JavaScript>window.open('info.aspx?tostu_id=' & CheckBoxList1.Items(i).Text,'','height=330,width=560,status=no,location=no,toolbar=no,directories=no,menubar=no')</script>")
End If
End If
Next i
Response.Redirect("info.aspx?tostu_id=" & tostu_id)
End Sub
这里发送信息的页面由于修改的比较多,所以把全部代码全都抓来了,呵呵:)
codebebind部分:
Imports System.Data
Imports System.Data.SqlClient
Public Class info
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents Image3 As System.Web.UI.WebControls.Image
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label10 As System.Web.UI.WebControls.Label
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected WithEvents Label11 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim conn As SqlConnection = New SqlConnection("server=lixinri;uid=sa;pwd=;database=99re1")
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim tostu_id As String = Request.QueryString("tostu_id")
Dim splitname() As String
'///////////这里用了Split函数将传过来的参数取出
splitname = Split(tostu_id, "@")
If tostu_id = "" Then
'//////////////////当回复留言时
Dim sql As String = "select a.*,b.nick from info a,pwd b where a.fromstu_id=b.stu_id and a.tostu_id='" & Session("stu_id") & "' and a.term=1"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
While dr.Read
Label3.Text = dr.Item("nick")
Label4.Text = dr.Item("tim")
Label5.Text = " " & dr.Item("content")
TextBox1.Text = dr.Item("nick")
TextBox3.Text = dr.Item("fromstu_id")
TextBox1.Enabled = False
Label8.Visible = False
Label11.Visible = False
End While
dr.Close()
comm.Cancel()
'//////////////////////更新留言使留言属性为已阅读过
Dim sql_1 As String = "update info set term=0 where tostu_id='" & Session("stu_id") & "' and term=1 and tim='" & Label4.Text & "'"
comm = New SqlCommand(sql_1, conn)
comm.ExecuteNonQuery()
Else
'////////////////////当发送留言时
'/////////////////读取参数
Dim i As Integer
For i = 0 To UBound(splitname) - 1
Dim mysql As String = "select nick from pwd where stu_id='" & splitname(i) & "'"
Dim comm As SqlCommand = New SqlCommand(mysql, conn)
Dim dr As SqlDataReader
If i = 0 Then
conn.Open()
dr = comm.ExecuteReader
If dr.Read Then
TextBox1.Text = Trim(dr.item("nick")) & ";"
End If
control()
dr.close()
Else
dr = comm.ExecuteReader
If dr.Read Then
TextBox1.Text = TextBox1.Text & Trim(dr.item("nick")) & ";"
End If
control()
dr.close()
End If
Next i
End If
End If
End Sub
'/////////////////control事件,没有什么实际意义,使代码简单罢了。
Sub control()
TextBox1.Enabled = False : Label3.Text = "" : Label4.Text = "" : Label5.Visible = False
Label8.Visible = True : Label6.Visible = False : Label7.Visible = False : Label9.Visible = False
Button3.Visible = False : Label11.Visible = True
Label11.Text = "<a href=board.aspx><<<返回学友录</a>"
End Sub
'/////////////////书写提交消息事件
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tostu_id As String = Request.QueryString("tostu_id")
Dim splitname() As String
splitname = Split(tostu_id, "@")
If tostu_id = "" Then
'/////////////////////////当回复留言时
If TextBox2.Text = "" Or TextBox2.Text = " " Then
Label10.Visible = True
Label10.Text = "消息不能为空!"
Return
Else
Label10.Visible = False
conn.Open()
Dim sql As String = "insert into info(fromstu_id,tostu_id,content,term,tim) values(@fromstu_id,@tostu_id,@content,@term,@tim)"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@fromstu_id", SqlDbType.Int, 4))
comm.Parameters("@fromstu_id").Value = Session("stu_id")
comm.Parameters.Add(New SqlParameter("@tostu_id", SqlDbType.Int, 4))
comm.Parameters("@tostu_id").Value = TextBox3.Text
comm.Parameters.Add(New SqlParameter("@content", SqlDbType.VarChar, 200))
comm.Parameters("@content").Value = TextBox2.Text
comm.Parameters.Add(New SqlParameter("@term", SqlDbType.Int, 4))
comm.Parameters("@term").Value = "1"
comm.Parameters.Add(New SqlParameter("@tim", SqlDbType.Char, 20))
comm.Parameters("@tim").Value = Date.Now
comm.ExecuteNonQuery()
'TextBox2.Text = ""
End If
Else
'/////////////////////////当发送留言时
If TextBox2.Text = "" Or TextBox2.Text = " " Then
Label10.Visible = True
Label10.Text = "消息不能为空!"
Return
Else
'////////////////插入i条数据
Dim i As Integer
For i = 0 To UBound(splitname) - 1
Label10.Visible = False
If i = 0 Then
conn.Open()
Else
End If
Dim sql As String = "insert into info(fromstu_id,tostu_id,content,term,tim) values(@fromstu_id,@tostu_id,@content,@term,@tim)"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@fromstu_id", SqlDbType.Int, 4))
comm.Parameters("@fromstu_id").Value = Session("stu_id")
comm.Parameters.Add(New SqlParameter("@tostu_id", SqlDbType.Int, 4))共2页: 上一页 1 [2] 下一页 <script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
以前的的发送消息按钮事件改写如下:'/////////////////////转到发送即时消息页面
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim i, j As Integer
j = 0
Dim tostu_id As String = ""
For i = 0 To mycheck.Items.Count - 1
If mycheck.Items(i).Selected Then
'////////////////////////限制发送条数
j = j + 1
If j < 6 Then
'/////////////////////参数构造
tostu_id = tostu_id & CheckBoxList1.Items(i).Text & "@"
Else
Label2.Visible = True
Label2.Text = "一次最多能给五个用户发送信息!"
Return
'Response.Write("<script language=JavaScript>window.open('info.aspx?tostu_id=' & CheckBoxList1.Items(i).Text,'','height=330,width=560,status=no,location=no,toolbar=no,directories=no,menubar=no')</script>")
End If
End If
Next i
Response.Redirect("info.aspx?tostu_id=" & tostu_id)
End Sub
这里发送信息的页面由于修改的比较多,所以把全部代码全都抓来了,呵呵:)
codebebind部分:
Imports System.Data
Imports System.Data.SqlClient
Public Class info
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents Image3 As System.Web.UI.WebControls.Image
Protected WithEvents Label8 As System.Web.UI.WebControls.Label
Protected WithEvents Label7 As System.Web.UI.WebControls.Label
Protected WithEvents Label9 As System.Web.UI.WebControls.Label
Protected WithEvents Label10 As System.Web.UI.WebControls.Label
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected WithEvents Label11 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim conn As SqlConnection = New SqlConnection("server=lixinri;uid=sa;pwd=;database=99re1")
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim tostu_id As String = Request.QueryString("tostu_id")
Dim splitname() As String
'///////////这里用了Split函数将传过来的参数取出
splitname = Split(tostu_id, "@")
If tostu_id = "" Then
'//////////////////当回复留言时
Dim sql As String = "select a.*,b.nick from info a,pwd b where a.fromstu_id=b.stu_id and a.tostu_id='" & Session("stu_id") & "' and a.term=1"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
While dr.Read
Label3.Text = dr.Item("nick")
Label4.Text = dr.Item("tim")
Label5.Text = " " & dr.Item("content")
TextBox1.Text = dr.Item("nick")
TextBox3.Text = dr.Item("fromstu_id")
TextBox1.Enabled = False
Label8.Visible = False
Label11.Visible = False
End While
dr.Close()
comm.Cancel()
'//////////////////////更新留言使留言属性为已阅读过
Dim sql_1 As String = "update info set term=0 where tostu_id='" & Session("stu_id") & "' and term=1 and tim='" & Label4.Text & "'"
comm = New SqlCommand(sql_1, conn)
comm.ExecuteNonQuery()
Else
'////////////////////当发送留言时
'/////////////////读取参数
Dim i As Integer
For i = 0 To UBound(splitname) - 1
Dim mysql As String = "select nick from pwd where stu_id='" & splitname(i) & "'"
Dim comm As SqlCommand = New SqlCommand(mysql, conn)
Dim dr As SqlDataReader
If i = 0 Then
conn.Open()
dr = comm.ExecuteReader
If dr.Read Then
TextBox1.Text = Trim(dr.item("nick")) & ";"
End If
control()
dr.close()
Else
dr = comm.ExecuteReader
If dr.Read Then
TextBox1.Text = TextBox1.Text & Trim(dr.item("nick")) & ";"
End If
control()
dr.close()
End If
Next i
End If
End If
End Sub
'/////////////////control事件,没有什么实际意义,使代码简单罢了。
Sub control()
TextBox1.Enabled = False : Label3.Text = "" : Label4.Text = "" : Label5.Visible = False
Label8.Visible = True : Label6.Visible = False : Label7.Visible = False : Label9.Visible = False
Button3.Visible = False : Label11.Visible = True
Label11.Text = "<a href=board.aspx><<<返回学友录</a>"
End Sub
'/////////////////书写提交消息事件
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tostu_id As String = Request.QueryString("tostu_id")
Dim splitname() As String
splitname = Split(tostu_id, "@")
If tostu_id = "" Then
'/////////////////////////当回复留言时
If TextBox2.Text = "" Or TextBox2.Text = " " Then
Label10.Visible = True
Label10.Text = "消息不能为空!"
Return
Else
Label10.Visible = False
conn.Open()
Dim sql As String = "insert into info(fromstu_id,tostu_id,content,term,tim) values(@fromstu_id,@tostu_id,@content,@term,@tim)"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@fromstu_id", SqlDbType.Int, 4))
comm.Parameters("@fromstu_id").Value = Session("stu_id")
comm.Parameters.Add(New SqlParameter("@tostu_id", SqlDbType.Int, 4))
comm.Parameters("@tostu_id").Value = TextBox3.Text
comm.Parameters.Add(New SqlParameter("@content", SqlDbType.VarChar, 200))
comm.Parameters("@content").Value = TextBox2.Text
comm.Parameters.Add(New SqlParameter("@term", SqlDbType.Int, 4))
comm.Parameters("@term").Value = "1"
comm.Parameters.Add(New SqlParameter("@tim", SqlDbType.Char, 20))
comm.Parameters("@tim").Value = Date.Now
comm.ExecuteNonQuery()
'TextBox2.Text = ""
End If
Else
'/////////////////////////当发送留言时
If TextBox2.Text = "" Or TextBox2.Text = " " Then
Label10.Visible = True
Label10.Text = "消息不能为空!"
Return
Else
'////////////////插入i条数据
Dim i As Integer
For i = 0 To UBound(splitname) - 1
Label10.Visible = False
If i = 0 Then
conn.Open()
Else
End If
Dim sql As String = "insert into info(fromstu_id,tostu_id,content,term,tim) values(@fromstu_id,@tostu_id,@content,@term,@tim)"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@fromstu_id", SqlDbType.Int, 4))
comm.Parameters("@fromstu_id").Value = Session("stu_id")
comm.Parameters.Add(New SqlParameter("@tostu_id", SqlDbType.Int, 4))共2页: 上一页 1 [2] 下一页 <script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 改写我前面的即时消息的发送,包含同时给多人发送信息!
- 改写即时消息的发送,包含同时给多人发送信息!
- 改写即时消息的发送 包含同时给多人发送信息
- [转贴].net中即时消息发送的实现
- .net中即时消息发送的实现
- .net中即时消息发送的实现……
- .net中即时消息发送的实现……
- 这段代码是我用来提交svn代码,同时给团队的所有成员发送邮件的脚本。
- Android发送即时消息
- python发送邮件(带附件)、发送给多人、抄送给多人的示例
- 发送信息的程序
- 新用户注册,新订单生成,在给客户发送邮件的同时,也给管理员发送邮件
- daemon进程怎么给所有的终端(tty)发送信息?
- 给StatusBar发送消息,来更改状态栏的显示信息
- 获取控制台输出的信息,发送给前台页面
- 发送邮件给我
- Jmail的使用,可以发送给多人
- JAVA改写的QQ自动发送固定文本,很YD
- WINDOWS 2000下使用ISAPI方式安装PHP
- 利用.net来发送即时消息:)
- Windows下PHP5和Apache的安装与配置
- SUNWEN教程之----C#进阶10
- PHP5在Apache下的两种模式的安装
- 改写我前面的即时消息的发送,包含同时给多人发送信息!
- Win2003下APACHE+PHP5+MYSQL4+PHPMYADMIN 的简易安装配置
- SUNWEN教程之----C#进阶9
- 在Windows2000ADV下配置Apache+PHP5+MySql5
- ASP.NET验证控件祥解(转)
- IIS环境下安装PHP5手记
- C#首席设计师Anders Hejlsberg专访(一)
- PHPlet在Windows下的安装
- C#首席设计师Anders Hejlsberg专访(2)转