📄 horse_bet.aspx.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>
/// horse_bet 的摘要说明。
/// </summary>
public class horse_bet : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid horselist;
protected System.Web.UI.WebControls.Button byts_submit;
protected System.Web.UI.WebControls.Panel hlist;
protected System.Web.UI.WebControls.Label gamemsg;
protected System.Web.UI.WebControls.Label byts_copyright;
protected System.Web.UI.WebControls.Label showtitle;
private void Page_Load(object sender, System.EventArgs e)
{
if (this.Session["info"] == null)
{
this.Server.Transfer ("../error.aspx?v=relogin");
}
if (!this.Page.IsPostBack)
{
this.byts_copyright.Text = "授权给:<font class=\"byts\">" + var.public_user + "</font> 序列号:<font class=\"byts\">" + var.public_sn + "</font><br />作者<font class=\"byts\"><a target=_blank href=http://9diy.net/go.aspx?type=aboutme>变异天使</a></font>保留所有权利";
this.showtitle.Text += "<font style=\"font-size:12px;\">(第<font class=\"byts\">" + var.public_horseID + "</font>场)</font>";
this.horselist.DataSource = var.public_horseinfo.DefaultView;
this.horselist.DataBind();
}
else
{
this.hlist.Visible = 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.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 butstr = "<br /><br /><input class=\"but\" type=\"button\" value=\" 返回 \" onclick=\"history.go(-1)\" /> <input class=\"but\" type=\"button\" value=\" 关闭 \" onclick=\"window.close()\" /><br /><br /><br /><br />";
if (var.public_canbet != "")
{
this.gamemsg.Text = var.public_canbet + butstr;
return;
}
x.UserInfo info = (x.UserInfo) this.Session["info"];
if (var.public_horselist.ContainsKey(info.UserName) == true)
{
this.gamemsg.Text = "本场你已经下过注了,请等到下一场!" + butstr;
return;
}
string allstr = "";
string showword = "";
int allv = 0;
try
{
foreach (DataRow dr in var.public_horseinfo.Rows)
{
int nv = int.Parse(this.Request.Form["v_" + dr["id"]]);
if (nv > 0)
{
allstr += "|" + dr["马匹名称"] + ":" + nv;
showword += "<font style=\\\"color:#008000\\\">" + dr["马匹名称"] + "</font>:<font class=\\\"byts\\\">" + nv + "</font>两、";
allv += nv;
}
}
}
catch
{
this.gamemsg.Text = "输入数据溢出!(数据不允许超过21亿)" + butstr;
return;
}
if (allv == 0)
{
this.gamemsg.Text = "没有给任何马下注!" + butstr;
}
else
{
x.CheckUse useinfo = var.public_bet;
if (useinfo.MinGrade != -1 && info.Grade < useinfo.MinGrade)
{
this.gamemsg.Text = "等级小于 " + useinfo.MinGrade + " 不能赌博!" + butstr;
return;
}
if (useinfo.MaxGrade != -1 && info.Grade > useinfo.MaxGrade)
{
this.gamemsg.Text = "等级大于 " + useinfo.MaxGrade + " 不能赌博!" + butstr;
return;
}
if (useinfo.MinFGrade != -1 && info.FGrade < useinfo.MinFGrade)
{
this.gamemsg.Text = "战斗等级小于 " + useinfo.MinFGrade + " 不能赌博!" + butstr;
return;
}
if (useinfo.MaxFGrade != -1 && info.FGrade > useinfo.MaxFGrade)
{
this.gamemsg.Text = "战斗等级大于 " + useinfo.MaxFGrade + " 不能赌博!" + butstr;
return;
}
if (useinfo.MinGGrade != -1 && info.Gold < useinfo.MinGGrade)
{
this.gamemsg.Text = "会员等级小于 " + useinfo.MinGGrade + " 不能赌博!" + butstr;
return;
}
if (useinfo.MaxGGrade != -1 && info.Gold > useinfo.MaxGGrade)
{
this.gamemsg.Text = "会员等级大于 " + useinfo.MaxGGrade + " 不能赌博!" + butstr;
return;
}
if (useinfo.CheckSex == "boy" && info.Sex != "boy")
{
this.gamemsg.Text = "性别必须为 男 才能赌博!" + butstr;
return;
}
if (useinfo.CheckSex == "girl" && info.Sex != "girl")
{
this.gamemsg.Text = "性别必须为 女 才能赌博!" + butstr;
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["银两"] < allv)
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.gamemsg.Text = "你的钱不够!" + butstr;
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>,而你的" + useinfo.Run_Name[i] + "不够!" + butstr;
return;
}
}
}
dr.Close();
MyComm.CommandText = @"update [注册用户] set [银两]=[银两]-" + allv + " where [id]=" + info.DataID;
MyComm.ExecuteNonQuery();
MyConn.Close();
MyConn.Dispose();
string[] aword = new string[9];
aword[0] = "ran";
aword[1] = info.UserName;
aword[2] = "";
aword[3] = "sys.gif";
aword[4] = "";
aword[5] = "";
aword[6] = "##来到赛马场下注,心里还在想:我就要成暴发户啦!『下注情况:" + showword.Substring(0, showword.Length - 1) + "』";
aword[7] = "下注";
aword[8] = DateTime.Now.ToLongTimeString();
this.Application.Lock();
ArrayList words = (ArrayList) this.Application["byts_xajh_chat_words_" + info.RoomID];
words.Add(aword);
words.RemoveAt(0);
this.Application["byts_xajh_chat_line_" + info.RoomID] = (int) this.Application["byts_xajh_chat_line_" + info.RoomID] + 1;
var.public_horselist.Add(info.UserName, info.DataID + "|" + info.UserName + allstr);
this.Application.UnLock();
this.gamemsg.Text = "下注成功,希望你能圆梦哦!" + butstr;
}
else
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.gamemsg.Text = "必须符合 " + useinfo.CheckIn + " 才能赌博!" + butstr;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -