⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goroom.aspx.cs

📁 ASP.NET构建的笑傲江湖社区(C#,全源码提供)
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace xajh.chat
{
	/// <summary>
	/// goroom 的摘要说明。
	/// </summary>
	public class goroom : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Literal byts_errormsg;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.Session["info"] == null)
			{
				this.Server.Transfer ("../error.aspx?v=relogin");
			}
			x.UserInfo info = (x.UserInfo) this.Session["info"];
			if (info.RoomID == "false")
			{
				this.Server.Transfer ("../error.aspx?v=outchat");
			}
			string roomid = this.Request.Form["roomid"];
			if (roomid == null || roomid == "")
			{
				this.byts_errormsg.Text = "请指定房间的ID号!";
				return;
			}
			roomid = roomid.Trim();
			if (var.public_roomlist.IndexOf(roomid) == -1)
			{
				this.byts_errormsg.Text = "不存在该房间!";
				return;
			}
			if (roomid == info.RoomID)
			{
				this.byts_errormsg.Text = "并没有转换到其他房间!";
				return;
			}
			x.RoomInfo roominfo = (x.RoomInfo) this.Application["byts_xajh_chat_roominfo_" + roomid];
			if (roominfo.MaxOnline != -1 && ((ArrayList) this.Application["byts_xajh_chat_online_" + roomid]).Count >= roominfo.MaxOnline)
			{
				this.byts_errormsg.Text = "该房间已经满员,请选择其他的房间进入!";
				return;
			}
			//检查开始
			if (roominfo.MinGrade != -1 && info.Grade < roominfo.MinGrade)
			{
				this.byts_errormsg.Text = "本房间禁止等级小于 " + roominfo.MinGrade + " 的用户进入!";
				return;
			}
			if (roominfo.MaxGrade != -1 && info.Grade > roominfo.MaxGrade)
			{
				this.byts_errormsg.Text = "本房间禁止等级大于 " + roominfo.MaxGrade + " 的用户进入!";
				return;
			}
			if (roominfo.MinFGrade != -1 && info.FGrade < roominfo.MinFGrade)
			{
				this.byts_errormsg.Text = "本房间禁止战斗等级小于 " + roominfo.MinFGrade + " 的用户进入!";
				return;
			}
			if (roominfo.MaxFGrade != -1 && info.FGrade > roominfo.MaxFGrade)
			{
				this.byts_errormsg.Text = "本房间禁止战斗等级大于 " + roominfo.MaxFGrade + " 的用户进入!";
				return;
			}
			if (roominfo.MinGGrade != -1 && info.Gold < roominfo.MinGGrade)
			{
				this.byts_errormsg.Text = "本房间禁止会员等级小于 " + roominfo.MinGGrade + " 的用户进入!";
				return;
			}
			if (roominfo.MaxGGrade != -1 && info.Gold > roominfo.MaxGGrade)
			{
				this.byts_errormsg.Text = "本房间禁止会员等级大于 " + roominfo.MaxGGrade + " 的用户进入!";
				return;
			}
			if (roominfo.CheckSex == "boy" && info.Sex != "boy")
			{
				this.byts_errormsg.Text = "本房间只允许性别为 男 的用户进入!";
				return;
			}
			if (roominfo.CheckSex == "girl" && info.Sex != "girl")
			{
				this.byts_errormsg.Text = "本房间只允许性别为 女 的用户进入!";
				return;
			}
			if (roominfo.CheckIn != "(无)")
			{
				OleDbConnection MyConn = new OleDbConnection(var.public_conn);
				MyConn.Open();
				OleDbCommand MyComm = new OleDbCommand(@"select null from [注册用户] where [id]=" + info.DataID + " and " + roominfo.CheckIn, MyConn);
				OleDbDataReader dr = MyComm.ExecuteReader();
				if (!dr.Read())
				{
					dr.Close();
					MyConn.Close();
					MyConn.Dispose();
					this.byts_errormsg.Text = "进入本房间必须符合 " + roominfo.CheckIn + " 的条件!";
					return;
				}
				else
				{
					dr.Close();
					MyConn.Close();
					MyConn.Dispose();
				}
			}
			//检查结束
			info.MsgLine = (int) this.Application["byts_xajh_chat_line_" + roomid];
			string byts_oldroom = "<font style=\\\"color:#0000FF\\\">" + ((x.RoomInfo) this.Application["byts_xajh_chat_roominfo_" + info.RoomID]).RoomName + "</font>";
			string byts_newroom = "<font style=\\\"color:#0000FF\\\">" + roominfo.RoomName + "</font>";
			string[] aword = new string[9];
			aword[0] = "del";
			aword[1] = info.UserName;
			aword[2] = "";
			aword[3] = "";
			aword[4] = "";
			aword[5] = "";
			aword[6] = var.public_delroom.Replace("(old)",byts_oldroom).Replace("(new)",byts_newroom);
			aword[7] = "退出";
			aword[8] = DateTime.Now.ToLongTimeString();
			ArrayList online;
			Hashtable onlineinfo = var.public_onlineinfo;
			this.Application.Lock();
			//删除原房间
			((ArrayList) this.Application["byts_xajh_chat_online_" + info.RoomID]).Remove(info.UserName);
			//结束
			ArrayList words = (ArrayList) this.Application["byts_xajh_chat_words_" + info.RoomID];
			words.Add(aword);
			words.RemoveAt(0);
			this.Application["byts_xajh_chat_line_" + info.RoomID] = (int) this.Application["byts_xajh_chat_line_" + info.RoomID] + 1;
			aword = new string[9];
			aword[0] = "add";
			aword[1] = info.UserName;
			aword[2] = "";
			aword[3] = onlineinfo[info.UserName].ToString();
			aword[4] = "";
			aword[5] = "";
			aword[6] = var.public_addroom.Replace("(old)",byts_oldroom).Replace("(new)",byts_newroom);
			aword[7] = "进入";
			aword[8] = DateTime.Now.ToLongTimeString();
			words = (ArrayList) this.Application["byts_xajh_chat_words_" + roomid];
			words.Add(aword);
			words.RemoveAt(0);
			this.Application["byts_xajh_chat_line_" + roomid] = (int) this.Application["byts_xajh_chat_line_" + roomid] + 1;
			//加入新房间
			online = (ArrayList) this.Application["byts_xajh_chat_online_" + roomid];
			online.Add(info.UserName);
			//结束
			this.Application.UnLock();
			int all_line = (int) this.Application["byts_xajh_chat_line_" + roomid];
			int check_line = 30 - (all_line - info.MsgLine);
			if (check_line < 0)
			{
				check_line = 0;
			}
			string[] mywords;
			this.Response.Write ("<script language=javascript type=text/javascript>\r");
			for (int myline = check_line; myline < 30; myline ++)
			{
				mywords = (string[]) words[myline];
				if (!(mywords[0] == "only" && mywords[1] != info.UserName && mywords[2] != info.UserName))
				{
					this.Response.Write ("parent.h0.byts_getmsg(\"" + mywords[0] + "\",\"" + mywords[1] + "\",\"" + mywords[2] + "\",\"" + mywords[3] + "\",\"" + mywords[4] + "\",\"" + mywords[5] + "\",\"" + mywords[6] + "\",\"" + mywords[7] + "\",\"" + mywords[8] + "\");\r");
				}
			}
			string namelist = "\"" + onlineinfo[online[0]] + "\"";
			int j = online.Count;
			for (int i = 1; i < j; i ++)
			{
				namelist += ",\"" + onlineinfo[online[i]] + "\"";
			}
			info.RoomID = roomid;
			info.MsgLine = all_line;
			this.Session["info"] = info;
			this.Response.Write ("var byts_xajh_chat_namelist = new Array(" + namelist + ");\r" +
				"parent.byts_xajh_chat_namelist = byts_xajh_chat_namelist;\r" +
				"parent.h0.byts_getnamestring();\r" +
				"parent.byts_xajh_chat_roomid = " + roomid + ";\r" +
				"parent.byts_xajh_chat_roomname = \"" + roominfo.RoomName + "\";\r" +
				"parent.byts_xajh_chat_roomautoman = \"" + roominfo.AutoMan + "\";\r" +
				"parent.h0.byts_showietitle();\r" +
				"parent.h0.byts_load_list();\r" +
				"parent.h0.byts_showwelcome();\r" +
				"</script>");
			this.Response.End();
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -