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

📄 ask.aspx.cs

📁 ASP.NET构建的笑傲江湖社区(C#,全源码提供)
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
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>
	/// ask 的摘要说明。
	/// </summary>
	public class ask : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox q_rightanswer;
		protected System.Web.UI.WebControls.Button byts_submit;
		protected System.Web.UI.WebControls.TextBox q_title;
		protected System.Web.UI.WebControls.Literal byts_errormsg;
		private x.UserInfo info;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.Session["info"] == null)
			{
				this.Server.Transfer ("../error.aspx?v=relogin");
			}
			info = (x.UserInfo) this.Session["info"];
			if (info.RoomID == "false")
			{
				this.Server.Transfer ("../error.aspx?v=outchat");
			}
			if (info.Grade < var.public_question)
			{
				this.setdisabled();
				this.byts_errormsg.Text = "^等级不足 " + var.public_question + " ,没有提问的权限!";
				return;
			}
		}

		#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.byts_submit.Click += new System.EventHandler(this.byts_submit_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void byts_submit_Click(object sender, System.EventArgs e)
		{
			string title = this.q_title.Text.Trim();
			string answer = this.q_rightanswer.Text.Trim();
			if (title == "")
			{
				this.byts_errormsg.Text = "所提问题的标题不能为空!";
				return;
			}
			if (answer == "")
			{
				this.byts_errormsg.Text = "所提问题的答案不能为空!";
				return;
			}
			if (title.Length > 50)
			{
				this.byts_errormsg.Text = "所提问题的标题长度不能超过50!";
				return;
			}
			foreach (string[] v in var.public_questionlist.Values)
			{
				if (v[0] == title)
				{
					this.byts_errormsg.Text = "当前已经存在一个和所提问题相同的问题!";
					return;
				}
			}
			
			string[] qvalue = new string[3];
			qvalue[0] = title;
			qvalue[1] = answer;
			qvalue[2] = info.UserName;
			string[] aword = new string[9];
			aword[0] = "ran";
			aword[1] = info.UserName;
			aword[2] = "";
			aword[3] = "sys.gif";
			aword[4] = "";
			aword[5] = "";
			aword[6] = "##出题一道:“<font class=\\\"byts\\\">" + this.Server.HtmlEncode(title.Replace("\r", "").Replace("\n", "").Replace("\\", "\\\\").Replace("/", "\\/").Replace("\"", "\\\"")) + "</font>”,知道的快抢答呀!(<a href=\\\"javascript:parent.h0.byts_answer(" + var.public_questionid + ")\\\">立即回答</a>)";
			aword[7] = "提问";
			aword[8] = DateTime.Now.ToLongTimeString();
			ArrayList roomlist = var.public_roomlist;
			this.Application.Lock();
			var.public_questionlist.Add(var.public_questionid, qvalue);
			for (int i = 0; i < roomlist.Count; i ++)
			{
				ArrayList words = (ArrayList) this.Application["byts_xajh_chat_words_" + roomlist[i]];
				words.Add(aword);
				words.RemoveAt(0);
				this.Application["byts_xajh_chat_line_" + roomlist[i]] = (int) this.Application["byts_xajh_chat_line_" + roomlist[i]] + 1;
			}
			var.public_questionid ++;
			this.Application.UnLock();
			this.setdisabled();
			this.byts_errormsg.Text = "^出题已经成功完成!";
		}

		private void setdisabled()
		{
			this.q_title.BackColor = System.Drawing.Color.FromName("#DCD8D0");
			this.q_title.Enabled = false;
			this.q_rightanswer.BackColor = System.Drawing.Color.FromName("#DCD8D0");
			this.q_rightanswer.Enabled = false;
		}
	}
}

⌨️ 快捷键说明

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