📄 answer.aspx.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>
/// answer 的摘要说明。
/// </summary>
public class answer : 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 string[] qvalue;
private int id;
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");
}
string rid = this.Request.QueryString["id"];
if (rid == null)
{
this.setdisabled();
this.byts_errormsg.Text = "^没有指定要回答问题的标识号!";
return;
}
id = int.Parse(rid);
if (var.public_questionlist.ContainsKey(id) != true)
{
this.setdisabled();
this.byts_errormsg.Text = "^该问题已经被其他人抢答了!";
return;
}
qvalue = (string[]) var.public_questionlist[id];
if (!this.Page.IsPostBack)
{
this.q_title.Text = qvalue[0];
}
}
#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 answer = this.q_rightanswer.Text.Trim();
if (answer == "")
{
this.byts_errormsg.Text = "所回答问题的答案不能为空!";
return;
}
if (qvalue[2] == info.UserName)
{
this.setdisabled();
this.byts_errormsg.Text = "^不能回答自己提出的问题!";
return;
}
if (qvalue[1] != answer)
{
this.byts_errormsg.Text = "回答错误,继续想想哦!";
return;
}
this.setdisabled();
this.byts_errormsg.Text = "^恭喜你,回答正确!";
string[] aword = new string[9];
aword[0] = "ran";
aword[1] = info.UserName;
aword[2] = qvalue[2];
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "##正确回答了%%提出的“<font class=\\\"byts\\\">" + this.Server.HtmlEncode(qvalue[0].Replace("\r", "").Replace("\n", "").Replace("\\", "\\\\").Replace("/", "\\/").Replace("\"", "\\\"")) + "</font>”。";
aword[7] = "回答";
aword[8] = DateTime.Now.ToLongTimeString();
ArrayList roomlist = var.public_roomlist;
this.Application.Lock();
var.public_questionlist.Remove(id);
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;
}
this.Application.UnLock();
}
private void setdisabled()
{
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 + -