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

📄 game3.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>
	/// game3 的摘要说明。
	/// </summary>
	public class game3 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label gamemsg;
		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.TextBox gamemoney;
		protected System.Web.UI.WebControls.Button byts_submit;
		protected System.Web.UI.WebControls.RadioButtonList gameselect;
	
		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"];
			int selectint = this.gameselect.SelectedIndex;
			string addmoney = this.gamemoney.Text.Trim();
			if (selectint == -1)
			{
				this.gamemsg.Text = "请作出选择!";
				this.reset();
			}
			else 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 (info.Grade < useinfo.MinGrade)
				{
					this.gamemsg.Text = "等级不足<font class=\"byts\">" + useinfo.MinGrade + "</font>,<br />不能赌博!";
					this.reset();
					return;
				}
				if (info.FGrade < useinfo.MinFGrade)
				{
					this.gamemsg.Text = "战斗等级不足<font class=\"byts\">" + useinfo.MinFGrade + "</font>,<br />不能赌博!";
					this.reset();
					return;
				}
				if (info.Gold < useinfo.MinGGrade)
				{
					this.gamemsg.Text = "会员等级不足<font class=\"byts\">" + useinfo.MinGGrade + "</font>,<br />不能赌博!";
					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();
						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();
								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 n1 = MyRan.Next(1, 7);
					int n2 = MyRan.Next(1, 7);
					int n3 = MyRan.Next(1, 7);
					int n_all = n1 + n2 + n3;
					this.img1.ImageUrl = "../xajhimg/bet/game2/" + n1 + ".gif";
					this.img2.ImageUrl = "../xajhimg/bet/game2/" + n2 + ".gif";
					this.img3.ImageUrl = "../xajhimg/bet/game2/" + n3 + ".gif";
					string dostr;
					if (n_all > 10)
					{
						if (selectint == 0)
						{
							dostr = "+";
							this.gamemsg.Text = "开大!<br />(赢<font class=\"byts\">" + upv + "</font>两)";
						}
						else
						{
							dostr = "-";
							this.gamemsg.Text = "开大!<br />(输<font class=\"byts\">" + upv + "</font>两)";
						}
					}
					else
					{
						if (selectint == 0)
						{
							dostr = "-";
							this.gamemsg.Text = "开小!<br />(输<font class=\"byts\">" + upv + "</font>两)";
						}
						else
						{
							dostr = "+";
							this.gamemsg.Text = "开小!<br />(赢<font class=\"byts\">" + upv + "</font>两)";
						}
					}
					MyComm.CommandText = @"update [注册用户] set " + useinfo.sql + "[银两]=[银两]" + dostr + upv + " where [id]=" + info.DataID;
					MyComm.ExecuteNonQuery();
					MyConn.Close();
				}
				else
				{
					dr.Close();
					MyConn.Close();
					this.gamemsg.Text = "用户名未找到!";
					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";
		}
	}
}

⌨️ 快捷键说明

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