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

📄 game2.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.games
{
	/// <summary>
	/// game2 的摘要说明。
	/// </summary>
	public class game2 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label gamemsg;
		protected System.Web.UI.WebControls.TextBox gamemoney;
		protected System.Web.UI.WebControls.Button byts_submit;
		protected System.Web.UI.WebControls.Image img1;
		protected System.Web.UI.WebControls.Image img2;
		protected System.Web.UI.WebControls.Image img3;
		protected System.Web.UI.WebControls.Image img4;
		protected System.Web.UI.WebControls.Image img5;
		protected System.Web.UI.WebControls.Image img6;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.Session["info"] == null)
			{
				this.Server.Transfer ("../error.aspx?v=relogin");
			}
		}

		#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)
		{
			x.UserInfo info = (x.UserInfo) this.Session["info"];
			string addmoney = this.gamemoney.Text.Trim();
			if (addmoney == "")
			{
				this.gamemsg.Text = "请输入下注金额!";
				this.reset();
			}
			else
			{
				for (int i = 0; i < addmoney.Length; i ++)
				{
					if (char.IsNumber(addmoney, i) != true)
					{
						this.gamemsg.Text = "下注金额必须为数字!";
						this.reset();
						return;
					}
				}
				int upv;
				try
				{
					upv = int.Parse(addmoney);
				}
				catch
				{
					this.gamemsg.Text = "输入数据溢出!(数据不允许超过21亿)";
					this.reset();
					return;
				}
				if (upv <= 0)
				{
					this.gamemsg.Text = "操作数额不能等于或者小于 0 !";
					this.reset();
					return;
				}
				x.CheckUse useinfo = var.public_bet;
				if (useinfo.MinGrade != -1 && info.Grade < useinfo.MinGrade)
				{
					this.gamemsg.Text = "等级小于 " + useinfo.MinGrade + " 不能赌博!";
					this.reset();
					return;
				}
				if (useinfo.MaxGrade != -1 && info.Grade > useinfo.MaxGrade)
				{
					this.gamemsg.Text = "等级大于 " + useinfo.MaxGrade + " 不能赌博!";
					this.reset();
					return;
				}
				if (useinfo.MinFGrade != -1 && info.FGrade < useinfo.MinFGrade)
				{
					this.gamemsg.Text = "战斗等级小于 " + useinfo.MinFGrade + " 不能赌博!";
					this.reset();
					return;
				}
				if (useinfo.MaxFGrade != -1 && info.FGrade > useinfo.MaxFGrade)
				{
					this.gamemsg.Text = "战斗等级大于 " + useinfo.MaxFGrade + " 不能赌博!";
					this.reset();
					return;
				}
				if (useinfo.MinGGrade != -1 && info.Gold < useinfo.MinGGrade)
				{
					this.gamemsg.Text = "会员等级小于 " + useinfo.MinGGrade + " 不能赌博!";
					this.reset();
					return;
				}
				if (useinfo.MaxGGrade != -1 && info.Gold > useinfo.MaxGGrade)
				{
					this.gamemsg.Text = "会员等级大于 " + useinfo.MaxGGrade + " 不能赌博!";
					this.reset();
					return;
				}
				if (useinfo.CheckSex == "boy" && info.Sex != "boy")
				{
					this.gamemsg.Text = "性别必须为 男 才能赌博!";
					this.reset();
					return;
				}
				if (useinfo.CheckSex == "girl" && info.Sex != "girl")
				{
					this.gamemsg.Text = "性别必须为 女 才能赌博!";
					this.reset();
					return;
				}
				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())
				{
					if ((int)dr["银两"] < upv)
					{
						dr.Close();
						MyConn.Close();
						MyConn.Dispose();
						this.gamemsg.Text = "你的钱不够!";
						this.reset();
						return;
					}
					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.gamemsg.Text = "赌博需要耗用" + useinfo.Run_Name[i] + "<font class=\"byts\">" + useinfo.Run_Value[i] + "</font>,<br />而你的" + useinfo.Run_Name[i] + "不够!";
								this.reset();
								return;
							}
						}
					}
					dr.Close();
					System.Random MyRan = new System.Random();
					int co1 = MyRan.Next(1, 7);
					int co2 = MyRan.Next(1, 7);
					int co3 = MyRan.Next(1, 7);
					int my1 = MyRan.Next(1, 7);
					int my2 = MyRan.Next(1, 7);
					int my3 = MyRan.Next(1, 7);
					this.img1.ImageUrl = "../xajhimg/bet/game2/" + co1 + ".gif";
					this.img2.ImageUrl = "../xajhimg/bet/game2/" + co2 + ".gif";
					this.img3.ImageUrl = "../xajhimg/bet/game2/" + co3 + ".gif";
					this.img4.ImageUrl = "../xajhimg/bet/game2/" + my1 + ".gif";
					this.img5.ImageUrl = "../xajhimg/bet/game2/" + my2 + ".gif";
					this.img6.ImageUrl = "../xajhimg/bet/game2/" + my3 + ".gif";
					int co_all = co1 + co2 + co3;
					int my_all = my1 + my2 + my3;
					string dostr = "";
					if (co_all > my_all)
					{
						this.gamemsg.Text = "电脑比你大!<br />(输<font class=\"byts\">" + upv + "</font>两)";
						dostr = "-";
					}
					else if (co_all < my_all)
					{
						this.gamemsg.Text = "你比电脑大!<br />(赢<font class=\"byts\">" + upv + "</font>两)";
						dostr = "+";
					}
					else
					{
						this.gamemsg.Text = "你和电脑打了平手!";
					}
					if (useinfo.sql != "")
					{
						if (dostr != "")
						{
							MyComm.CommandText = @"update [注册用户] set " + useinfo.sql + "[银两]=[银两]" + dostr + upv + " where [id]=" + info.DataID;
							MyComm.ExecuteNonQuery();
						}
						else
						{
							MyComm.CommandText = @"update [注册用户] set " + useinfo.sql.Substring(0, useinfo.sql.Length - 1) + " where [id]=" + info.DataID;
							MyComm.ExecuteNonQuery();
						}
					}
					else
					{
						if (dostr != "")
						{
							MyComm.CommandText = @"update [注册用户] set [银两]=[银两]" + dostr + upv + " where [id]=" + info.DataID;
							MyComm.ExecuteNonQuery();
						}
					}
					MyConn.Close();
					MyConn.Dispose();
				}
				else
				{
					dr.Close();
					MyConn.Close();
					MyConn.Dispose();
					this.gamemsg.Text = "必须符合 " + useinfo.CheckIn + " 才能赌博!";
					this.reset();
				}
			}
		}
		private void reset()
		{
			this.img1.ImageUrl = @"..\xajhimg\bet\game2\0.gif";
			this.img2.ImageUrl = @"..\xajhimg\bet\game2\0.gif";
			this.img3.ImageUrl = @"..\xajhimg\bet\game2\0.gif";
			this.img4.ImageUrl = @"..\xajhimg\bet\game2\0.gif";
			this.img5.ImageUrl = @"..\xajhimg\bet\game2\0.gif";
			this.img6.ImageUrl = @"..\xajhimg\bet\game2\0.gif";
		}
	}
}

⌨️ 快捷键说明

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