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

📄 song.aspx.cs

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

namespace xajh.chat
{
	/// <summary>
	/// song 的摘要说明。
	/// </summary>
	public class song : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Literal byts_errormsg;
		protected System.Web.UI.WebControls.RadioButtonList kind;
		protected System.Web.UI.WebControls.CheckBox loopplay;
		protected System.Web.UI.WebControls.DropDownList typelist;
		protected System.Web.UI.WebControls.TextBox givename;
		protected System.Web.UI.WebControls.Button play;
		protected System.Web.UI.WebControls.ListBox songlist;
		protected System.Web.UI.WebControls.TextBox giveword;
		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 (!this.Page.IsPostBack)
			{
				DirectoryInfo dirinfo = new DirectoryInfo(var.public_apppath + "song\\");
				DirectoryInfo[] myfolders = dirinfo.GetDirectories();
				bool first = true;
				foreach (DirectoryInfo myfolder in myfolders)
				{
					typelist.Items.Add(myfolder.Name);
					if (first == true)
					{
						DirectoryInfo fileinfo = new DirectoryInfo(var.public_apppath + "song\\" + myfolder.Name);
						FileInfo[] myfiles = fileinfo.GetFiles();
						foreach (FileInfo myfile in myfiles)
						{
							songlist.Items.Add(myfile.Name);
						}
						first = false;
					}
				}
			}
		}

		#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.typelist.SelectedIndexChanged += new System.EventHandler(this.typelist_SelectedIndexChanged);
			this.play.Click += new System.EventHandler(this.play_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void typelist_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.byts_errormsg.Text = "";
			this.songlist.Items.Clear();
			string mystr = typelist.SelectedItem.Value;
			mystr = mystr.Replace("..","");
			mystr = var.public_apppath + "song\\" + mystr;
			DirectoryInfo fileinfo = new DirectoryInfo(mystr);
			FileInfo[] myfiles = fileinfo.GetFiles();
			foreach (FileInfo myfile in myfiles)
			{
				this.songlist.Items.Add(myfile.Name);
			}
		}

		private void play_Click(object sender, System.EventArgs e)
		{
			string type_value = this.typelist.SelectedItem.Value.Trim();
			string song_value = this.songlist.SelectedItem.Value.Trim();
			string give_name = this.givename.Text.Trim();
			string give_word = this.giveword.Text.Trim();
			if (give_name == info.UserName)
			{
				this.byts_errormsg.Text = "不能给自己点歌!";
				return;
			}
			if (give_word == "" || give_word == null)
			{
				this.byts_errormsg.Text = "请指定赠语!";
				return;
			}

			x.CheckUse useinfo = var.public_webicq;
			if (useinfo.MinGrade != -1 && info.Grade < useinfo.MinGrade)
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('等级小于 " + useinfo.MinGrade + " 不能点歌!')</script>");
				return;
			}
			if (useinfo.MaxGrade != -1 && info.Grade > useinfo.MaxGrade)
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('等级大于 " + useinfo.MaxGrade + " 不能点歌!')</script>");
				return;
			}
			if (useinfo.MinFGrade != -1 && info.FGrade < useinfo.MinFGrade)
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('战斗等级小于 " + useinfo.MinFGrade + " 不能点歌!')</script>");
				return;
			}
			if (useinfo.MaxFGrade != -1 && info.FGrade > useinfo.MaxFGrade)
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('战斗等级大于 " + useinfo.MaxFGrade + " 不能点歌!')</script>");
				return;
			}
			if (useinfo.MinGGrade != -1 && info.Gold < useinfo.MinGGrade)
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('会员等级小于 " + useinfo.MinGGrade + " 不能点歌!')</script>");
				return;
			}
			if (useinfo.MaxGGrade != -1 && info.Gold > useinfo.MaxGGrade)
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('会员等级大于 " + useinfo.MaxGGrade + " 不能点歌!')</script>");
				return;
			}
			if (useinfo.CheckSex == "boy" && info.Sex != "boy")
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('性别必须为 男 才能点歌!')</script>");
				return;
			}
			if (useinfo.CheckSex == "girl" && info.Sex != "girl")
			{
				this.Response.Write ("<script language=javascript type=text/javascript>alert('性别必须为 女 才能点歌!')</script>");
				return;
			}
			if (useinfo.CheckIn != "(无)" || useinfo.sql != "")
			{
				string sql = @"select [点券],[银两],[存款],[武功],[智力],[内力],[体力],[攻击],[防御],[生命],[魅力],[精确] from [注册用户] where [id]=" + info.DataID;
				if (useinfo.CheckIn != "(无)")
				{
					sql += " and " + useinfo.CheckIn;
				}
				OleDbConnection MyConn = new OleDbConnection(var.public_conn);
				MyConn.Open();
				OleDbCommand MyComm = new OleDbCommand(sql, MyConn);
				OleDbDataReader dr = MyComm.ExecuteReader();
				if (dr.Read())
				{
					for (int i = 0; i < 3; i ++)
					{
						if (useinfo.Run_Name[i] != "(无)")
						{
							if ((int)dr[useinfo.Run_Name[i]] < useinfo.Run_Value[i])
							{
								dr.Close();
								MyConn.Close();
								MyConn.Dispose();
								this.Response.Write ("<script language=javascript type=text/javascript>alert('使用点歌要耗费" + useinfo.Run_Name[i] + " " + useinfo.Run_Value[i] + ",而你的" + useinfo.Run_Name[i] + "不够!')</script>");
								return;
							}
						}
					}
					if (useinfo.sql != "")
					{
						dr.Close();
						MyComm.CommandText = @"update [注册用户] set " + useinfo.sql.Substring(0, useinfo.sql.Length - 1) + " where [id]=" + info.DataID;
						MyComm.ExecuteNonQuery();
						MyConn.Close();
						MyConn.Dispose();
					}
					else
					{
						dr.Close();
						MyConn.Close();
						MyConn.Dispose();
					}
				}
				else
				{
					dr.Close();
					MyConn.Close();
					MyConn.Dispose();
					this.Response.Write ("<script language=javascript type=text/javascript>alert(\"必须符合 " + useinfo.CheckIn + " 才能点歌!\")</script>");
					return;
				}
			}

			string toroom = "";
			ArrayList roomlist = var.public_roomlist;
			for (int i = 0; i < roomlist.Count; i ++)
			{
				if (((ArrayList) this.Application["byts_xajh_chat_online_" + roomlist[i]]).IndexOf(give_name) != -1)
				{
					toroom = roomlist[i].ToString();
					break;
				}
			}
			if (toroom == "")
			{
				this.byts_errormsg.Text = "该聊友不在聊天室内,不能点歌!";
				return;
			}

			type_value = type_value.Replace("/", "");
			song_value = song_value.Replace("/", "");
			give_word = this.Server.HtmlEncode(give_word).Replace("\r", "$br;").Replace("\n", "").Replace("\\", "\\\\").Replace("/", "\\/").Replace("\"", "\\\"");
			string give_url = "../song/" + type_value + "/" + song_value;
			give_url = give_url.Replace("\r", "").Replace("\n", "").Replace("\\", "").Replace("\"", "").Replace("'", "");
			string[] aword = new string[9];
			aword[0] = "only";
			aword[1] = info.UserName;
			aword[2] = give_name;
			aword[3] = give_url;
			aword[4] = "";
			aword[5] = "";
			aword[6] = give_word;
			aword[7] = "song";
			aword[8] = DateTime.Now.ToLongTimeString();
			this.Application.Lock();
			ArrayList words = (ArrayList) this.Application["byts_xajh_chat_words_" + toroom];
			words.Add(aword);
			words.RemoveAt(0);
			this.Application["byts_xajh_chat_line_" + toroom] = (int) this.Application["byts_xajh_chat_line_" + toroom] + 1;
			this.Application.UnLock();
			this.Response.Write ("<script language=javascript type=text/javascript>\rparent.h0.byts_load_list();\ralert('恭喜,点歌已经成功发送!');\r</script>");
			this.Response.End();
		}

	}
}

⌨️ 快捷键说明

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