欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【改写即时消息的发送 包含同时给多人发送信息】,下面是详细的分享!
改写即时消息的发送 包含同时给多人发送信息
以前的的发送消息按钮事件改写如下:
'/////////////////////转到发送即时消息页面 PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.Click Dimi,jAsInteger j=0 Dimtostu_idAsString="" Fori=0Tomycheck.Items.Count-1 Ifmycheck.Items(i).SelectedThen '////////////////////////限制发送条数 j=j+1 Ifj<6Then |
'/////////////////////参数构造 |
这里发送信息的页面由于修改的比较多,所以把全部代码全都抓来了,呵呵:)
ImportsSystem.Data
ImportsSystem.Data.SqlClient
PublicClassinfo
InheritsSystem.Web.UI.Page
ProtectedWithEventsLabel1AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel2AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsTextBox2AsSystem.Web.UI.WebControls.TextBox
ProtectedWithEventsButton1AsSystem.Web.UI.WebControls.Button
ProtectedWithEventsButton2AsSystem.Web.UI.WebControls.Button
ProtectedWithEventsLabel3AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel4AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel5AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel6AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsTextBox3AsSystem.Web.UI.WebControls.TextBox
ProtectedWithEventsImage3AsSystem.Web.UI.WebControls.Image
ProtectedWithEventsLabel8AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel7AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel9AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsLabel10AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsButton3AsSystem.Web.UI.WebControls.Button
ProtectedWithEventsLabel11AsSystem.Web.UI.WebControls.Label
ProtectedWithEventsTextBox1AsSystem.Web.UI.WebControls.TextBox
#Region"WebFormDesignerGeneratedCode"
'ThiscallisrequiredbytheWebFormDesigner.
<System.Diagnostics.DebuggerStepThrough()>PrivateSubInitializeComponent()
EndSub
PrivateSubPage_Init(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Init
'CODEGEN:ThismethodcallisrequiredbytheWebFormDesigner
'Donotmodifyitusingthecodeeditor.
InitializeComponent()
EndSub
#EndRegion
DimconnAsSqlConnection=NewSqlConnection("server=lixinri;uid=sa;pwd=;database=99re1")
PublicSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
IfNotIsPostBackThen
Dimtostu_idAsString=Request.QueryString("tostu_id")
Dimsplitname()AsString
'///////////这里用了Split函数将传过来的参数取出
splitname=Split(tostu_id,"@")
Iftostu_id=""Then
'//////////////////当回复留言时
DimsqlAsString="selecta.*,b.nickfrominfoa,pwdbwherea.fromstu_id=b.stu_idanda.tostu_id='"&Session("stu_id")&"'anda.term=1"
DimcommAsSqlCommand=NewSqlCommand(sql,conn)
DimdrAsSqlDataReader
conn.Open()
dr=comm.ExecuteReader
Whiledr.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
EndWhile
dr.Close()
comm.Cancel()
'//////////////////////更新留言使留言属性为已阅读过
Dimsql_1AsString="updateinfosetterm=0wheretostu_id='"&Session("stu_id")&"'andterm=1andtim='"&Label4.Text&"'"
comm=NewSqlCommand(sql_1,conn)
comm.ExecuteNonQuery()
Else
'////////////////////当发送留言时
'/////////////////读取参数
DimiAsInteger
Fori=0ToUBound(splitname)-1
DimmysqlAsString="selectnickfrompwdwherestu_id='"&splitname(i)&"'"
DimcommAsSqlCommand=NewSqlCommand(mysql,conn)
DimdrAsSqlDataReader
Ifi=0Then
conn.Open()
dr=comm.ExecuteReader
Ifdr.ReadThen
TextBox1.Text=Trim(dr.item("nick"))&";"
EndIf
control()
dr.close()
Else
dr=comm.ExecuteReader
Ifdr.ReadThen
TextBox1.Text=TextBox1.Text&Trim(dr.item("nick"))&";"
EndIf
control()
dr.close()
EndIf
Nexti
EndIf
EndIf
EndSub
'/////////////////control事件,没有什么实际意义,使代码简单罢了。
Subcontrol()
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="<ahref=http://www.chinaz.com/program/2008/0910/board.aspx><<<返回学友录</a>"
EndSub
'/////////////////书写提交消息事件
PublicSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
Dimtostu_idAsString=Request.QueryString("tostu_id")
Dimsplitname()AsString
splitname=Split(tostu_id,"@")
Iftostu_id=""Then
'/////////////////////////当回复留言时
IfTextBox2.Text=""OrTextBox2.Text=""Then
Label10.Visible=True
Label10.Text="消息不能为空!"
Return
Else
Label10.Visible=False
conn.Open()
DimsqlAsString="insertintoinfo(fromstu_id,tostu_id,content,term,tim)values(@fromstu_id,@tostu_id,@content,@term,@tim)"
DimcommAsSqlCommand=NewSqlCommand(sql,conn)
comm.Parameters.Add(NewSqlParameter("@fromstu_id",SqlDbType.Int,4))
comm.Parameters("@fromstu_id").Value=Session("stu_id")
comm.Parameters.Add(NewSqlParameter("@tostu_id",SqlDbType.Int,4))
comm.Parameters("@tostu_id").Value=TextBox3.Text
comm.Parameters.Add(NewSqlParameter("@content",SqlDbType.VarChar,200))
comm.Parameters("@content").Value=TextBox2.Text
comm.Parameters.Add(NewSqlParameter("@term",SqlDbType.Int,4))
comm.Parameters("@term").Value="1"
comm.Parameters.Add(NewSqlParameter("@tim",SqlDbType.Char,20))
comm.Parameters("@tim").Value=Date.Now
comm.ExecuteNonQuery()
'TextBox2.Text=""
EndIf
Else
'/////////////////////////当发送留言时
IfTextBox2.Text=""OrTextBox2.Text=""Then
Label10.Visible=True
Label10.Text="消息不能为空!"
Return
Else
'////////////////插入i条数据
DimiAsInteger
Fori=0ToUBound(splitname)-1
Label10.Visible=False
Ifi=0Then
conn.Open()
Else
EndIf
DimsqlAsString="insertintoinfo(fromstu_id,tostu_id,content,term,tim)values(@fromstu_id,@tostu_id,@content,@term,@tim)"
DimcommAsSqlCommand=NewSqlCommand(sql,conn)
comm.Parameters.Add(NewSqlParameter("@fromstu_id",SqlDbType.Int,4))
comm.Parameters("@fromstu_id").Value=Session("stu_id")
comm.Parameters.Add(NewSqlParameter("@tostu_id",SqlDbType.Int,4))
comm.Parameters("@tostu_id").Value=splitname(i)
comm.Parameters.Add(NewSqlParameter("@content",SqlDbType.VarChar,200))
comm.Parameters("@content").Value=TextBox2.Text
comm.Parameters.Add(NewSqlParameter("@term",SqlDbType.Int,4))
comm.Parameters("@term").Value="1"
comm.Parameters.Add(NewSqlParameter("@tim",SqlDbType.Char,20))
comm.Parameters("@tim").Value=Date.Now
comm.ExecuteNonQuery()
'TextBox2.Text=""
Nexti
EndIf
EndIf
Response.Write("<scriptlanguage=javascript>alert('发送成功!')</script>")
EndSub
'////////////////////返回继续发送
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Click
Response.Redirect("boaman.aspx")
EndSub
PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.Click
Response.Write("<scriptlanguage=javascript>window.close()</script>")
EndSub
EndClass
以上所分享的是关于改写即时消息的发送 包含同时给多人发送信息,下面是编辑为你推荐的有价值的用户互动:
相关问题:如何发送陌生人即时消息
答:QQ聊天软件目前改版不能直接给陌生人发起临时会话,需要添加对方为好友。 如果和对方在同一个QQ群中可以是可以发即时消息的,而且会话框会显示来源。 >>详细
相关问题:用QQ怎么同时给好多人发消息
答:聊天菜单里有多人会话、 >>详细
相关问题:微信怎么同时给多个人发送消息
答:首先打开微信,接下来,点击右下角的“我”,点击设置框,点击通用框,再点击功能框,出现以下画面,往下拉,在下面找到“群发助手”,点击“群发助手”,点击“开始群发”,点击“新建群发”,你可以选择你要群发的好友,也可以全选,我们以全选为例,在... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
