📄 save.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.chat
{
/// <summary>
/// save 的摘要说明。
/// </summary>
public class save : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label username;
protected System.Web.UI.WebControls.Label gold;
protected System.Web.UI.WebControls.Label allvalue;
protected System.Web.UI.WebControls.Label monthvalue;
protected System.Web.UI.WebControls.Label money;
protected System.Web.UI.WebControls.Label wg;
protected System.Web.UI.WebControls.Label nl;
protected System.Web.UI.WebControls.Label tl;
protected System.Web.UI.WebControls.Label gj;
protected System.Web.UI.WebControls.Label fy;
protected System.Web.UI.WebControls.Label grade;
protected System.Web.UI.WebControls.Label figthgrade;
protected System.Web.UI.WebControls.Label a_wg;
protected System.Web.UI.WebControls.Label a_nl;
protected System.Web.UI.WebControls.Label a_tl;
protected System.Web.UI.WebControls.Label a_gj;
protected System.Web.UI.WebControls.Label a_fy;
protected System.Web.UI.WebControls.Label a_grade;
protected System.Web.UI.WebControls.Literal byts_errormsg;
protected System.Web.UI.WebControls.Label a_;
protected System.Web.UI.WebControls.Label a_iq;
protected System.Web.UI.WebControls.Label ds;
protected System.Web.UI.WebControls.Label iq;
protected System.Web.UI.WebControls.Label ww;
protected System.Web.UI.WebControls.Label ml;
protected System.Web.UI.WebControls.Label jq;
protected System.Web.UI.HtmlControls.HtmlGenericControl displaysave;
private void Page_Load(object sender, System.EventArgs e)
{
if (this.Session["info"] == null)
{
this.Server.Transfer ("../error.aspx?v=relogin");
}
x.UserInfo info = (x.UserInfo) this.Session["info"];
if (info.RoomID == "false")
{
this.Server.Transfer ("../error.aspx?v=outchat");
}
TimeSpan myspan = new TimeSpan(0, 0, 0, var.public_savespan);
TimeSpan v_span = DateTime.Now - info.LastSave;
if (v_span < myspan)
{
displaysave.InnerHtml = "";
this.byts_errormsg.Text = "为了减轻服务器负担,两次存档的时间间隔不得少于 " + var.public_savespan + " 秒!";
return;
}
int addmin = (int) Math.Floor(v_span.TotalSeconds) / 60;
int goldgrade = info.Gold;
OleDbConnection MyConn = new OleDbConnection(var.public_conn);
MyConn.Open();
OleDbCommand MyComm = new OleDbCommand(@"select [点券],[积分],[月积分],[银两],[武功],[内力],[体力],[攻击],[防御],[智力],[生命],[魅力],[精确],[宠物],[宠物武功],[宠物内力],[宠物体力],[宠物攻击],[宠物防御],[宠物生命] from [注册用户] where [id]=" + info.DataID,MyConn);
OleDbDataReader dr = MyComm.ExecuteReader();
if (dr.Read())
{
string sql = "update [注册用户] set ";
this.username.Text = info.UserName;
if (goldgrade == 0)
{
this.gold.Text = "(非会员)";
}
else
{
this.gold.Text = goldgrade + " 级";
}
string[] v_max = var.public_goldmax[goldgrade].Split('|');
string[] v_v_m = ((string[]) this.Application["byts_xajh_chat_saveinfo_" + info.RoomID])[goldgrade].Split('|');
int fg;
switch (var.public_maxfor)
{
case "等级":
fg = info.Grade;
break;
case "战斗等级":
fg = info.FGrade;
break;
default:
fg = 1;
break;
}
int value_add = addmin * int.Parse(v_v_m[16]);
int allvalue_new = (int)dr["积分"] + value_add;
int monthvalue_new = (int)dr["月积分"] + value_add;
int money_add = addmin * int.Parse(v_v_m[17]);
int money_new = (int)dr["银两"] + money_add;
int ds_add = addmin * int.Parse(v_v_m[0]);
int ds_new = (int)dr["点券"] + ds_add;
int ds_max = int.Parse(v_max[0]) * fg;
if (ds_new > ds_max)
{
ds_new = ds_max;
ds_add = ds_new - (int)dr["点券"];
}
int wg_add = addmin * int.Parse(v_v_m[1]);
int wg_new = (int)dr["武功"] + wg_add;
int wg_max = int.Parse(v_max[1]) * fg;
if (wg_new > wg_max)
{
wg_new = wg_max;
wg_add = wg_new - (int)dr["武功"];
}
int nl_add = addmin * int.Parse(v_v_m[2]);
int nl_new = (int)dr["内力"] + nl_add;
int nl_max = int.Parse(v_max[2]) * fg;
if (nl_new > nl_max)
{
nl_new = nl_max;
nl_add = nl_new - (int)dr["内力"];
}
int tl_add = addmin * int.Parse(v_v_m[3]);
int tl_new = (int)dr["体力"] + tl_add;
int tl_max = int.Parse(v_max[3]) * fg;
if (tl_new > tl_max)
{
tl_new = tl_max;
tl_add = tl_new - (int)dr["体力"];
}
int gj_add = addmin * int.Parse(v_v_m[4]);
int gj_new = (int)dr["攻击"] + gj_add;
int gj_max = int.Parse(v_max[4]) * fg;
if (gj_new > gj_max)
{
gj_new = gj_max;
gj_add = gj_new - (int)dr["攻击"];
}
int fy_add = addmin * int.Parse(v_v_m[5]);
int fy_new = (int)dr["防御"] + fy_add;
int fy_max = int.Parse(v_max[5]) * fg;
if (fy_new > fy_max)
{
fy_new = fy_max;
fy_add = fy_new - (int)dr["防御"];
}
int iq_add = addmin * int.Parse(v_v_m[6]);
int iq_new = (int)dr["智力"] + iq_add;
int iq_max = int.Parse(v_max[6]) * fg;
if (iq_new > iq_max)
{
iq_new = iq_max;
iq_add = iq_new - (int)dr["智力"];
}
int ww_add = addmin * int.Parse(v_v_m[7]);
int ww_new = (int)dr["生命"] + ww_add;
int ww_max = int.Parse(v_max[7]) * fg;
if (ww_new > ww_max)
{
ww_new = ww_max;
ww_add = ww_new - (int)dr["生命"];
}
int ml_add = addmin * int.Parse(v_v_m[8]);
int ml_new = (int)dr["魅力"] + ml_add;
int ml_max = int.Parse(v_max[8]) * fg;
if (ml_new > ml_max)
{
ml_new = ml_max;
ml_add = ml_new - (int)dr["魅力"];
}
int jq_add = addmin * int.Parse(v_v_m[9]);
int jq_new = (int)dr["精确"] + jq_add;
int jq_max = int.Parse(v_max[9]) * fg;
if (jq_new > jq_max)
{
jq_new = jq_max;
jq_add = jq_new - (int)dr["精确"];
}
int fightgrade_new = (int) Math.Floor(allvalue_new / var.public_fightgrade);
this.allvalue.Text = allvalue_new + " (+" + value_add + ")";
this.monthvalue.Text = monthvalue_new + " (+" + value_add + ")";
this.money.Text = money_new + " (+" + money_add + ")";
this.ds.Text = ds_new + "/" + ds_max + " (+" + ds_add + ")";
this.wg.Text = wg_new + "/" + wg_max + " (+" + wg_add + ")";
this.nl.Text = nl_new + "/" + nl_max + " (+" + nl_add + ")";
this.tl.Text = tl_new + "/" + tl_max + " (+" + tl_add + ")";
this.gj.Text = gj_new + "/" + gj_max + " (+" + gj_add + ")";
this.fy.Text = fy_new + "/" + fy_max + " (+" + fy_add + ")";
this.iq.Text = iq_new + "/" + iq_max + " (+" + iq_add + ")";
this.ww.Text = ww_new + "/" + ww_max + " (+" + ww_add + ")";
this.ml.Text = ml_new + "/" + ml_max + " (+" + ml_add + ")";
this.jq.Text = jq_new + "/" + jq_max + " (+" + jq_add + ")";
this.figthgrade.Text = fightgrade_new.ToString();
sql += "[战斗等级]=" + fightgrade_new + ",[积分]=" + allvalue_new + ",[月积分]=" + monthvalue_new + ",[银两]=" + money_new + ",[点券]=" + ds_new + ",[武功]=" + wg_new + ",[内力]=" + nl_new + ",[体力]=" + tl_new + ",[攻击]=" + gj_new + ",[防御]=" + fy_new + ",[智力]=" + iq_new + ",[生命]=" + ww_new + ",[魅力]=" + ml_new + ",[精确]=" + jq_new;
if (dr["宠物"].ToString() == "(无)")
{
this.a_.Text = "(无)";
this.a_wg.Text = "-";
this.a_nl.Text = "-";
this.a_tl.Text = "-";
this.a_gj.Text = "-";
this.a_fy.Text = "-";
this.a_iq.Text = "-";
this.a_grade.Text = "-";
}
else
{
int a_wg_add = addmin * int.Parse(v_v_m[10]);
int a_wg_new = (int)dr["宠物武功"] + a_wg_add;
int a_wg_max = int.Parse(v_max[10]) * fg;
if (a_wg_new > a_wg_max)
{
a_wg_new = a_wg_max;
a_wg_add = a_wg_new - (int)dr["宠物武功"];
}
int a_nl_add = addmin * int.Parse(v_v_m[11]);
int a_nl_new = (int)dr["宠物内力"] + a_nl_add;
int a_nl_max = int.Parse(v_max[11]) * fg;
if (a_nl_new > a_nl_max)
{
a_nl_new = a_nl_max;
a_nl_add = a_nl_new - (int)dr["宠物内力"];
}
int a_tl_add = addmin * int.Parse(v_v_m[12]);
int a_tl_new = (int)dr["宠物体力"] + a_tl_add;
int a_tl_max = int.Parse(v_max[12]) * fg;
if (a_tl_new > a_tl_max)
{
a_tl_new = a_tl_max;
a_tl_add = a_tl_new - (int)dr["宠物体力"];
}
int a_gj_add = addmin * int.Parse(v_v_m[13]);
int a_gj_new = (int)dr["宠物攻击"] + a_gj_add;
int a_gj_max = int.Parse(v_max[13]) * fg;
if (a_gj_new > a_gj_max)
{
a_gj_new = a_gj_max;
a_gj_add = a_gj_new - (int)dr["宠物攻击"];
}
int a_fy_add = addmin * int.Parse(v_v_m[14]);
int a_fy_new = (int)dr["宠物防御"] + a_fy_add;
int a_fy_max = int.Parse(v_max[14]) * fg;
if (a_fy_new > a_fy_max)
{
a_fy_new = a_fy_max;
a_fy_add = a_fy_new - (int)dr["宠物防御"];
}
int a_iq_add = addmin * int.Parse(v_v_m[15]);
int a_iq_new = (int)dr["宠物生命"] + a_iq_add;
int a_iq_max = int.Parse(v_max[15]) * fg;
if (a_iq_new > a_iq_max)
{
a_iq_new = a_iq_max;
a_iq_add = a_iq_new - (int)dr["宠物生命"];
}
this.a_.Text = dr["宠物"].ToString();
this.a_wg.Text = a_wg_new + "/" + a_wg_max + " (+" + a_wg_add + ")";
this.a_nl.Text = a_nl_new + "/" + a_nl_max + " (+" + a_nl_add + ")";
this.a_tl.Text = a_tl_new + "/" + a_tl_max + " (+" + a_tl_add + ")";
this.a_gj.Text = a_gj_new + "/" + a_gj_max + " (+" + a_gj_add + ")";
this.a_fy.Text = a_fy_new + "/" + a_fy_max + " (+" + a_fy_add + ")";
this.a_iq.Text = a_iq_new + "/" + a_iq_max + " (+" + a_iq_add + ")";
sql += ",[宠物武功]=" + a_wg_new + ",[宠物内力]=" + a_nl_new + ",[宠物体力]=" + a_tl_new + ",[宠物攻击]=" + a_gj_new + ",[宠物防御]=" + a_fy_new + ",[宠物生命]=" + a_iq_new;
}
dr.Close();
sql += " where [id]=" + info.DataID;
try
{
MyComm.CommandText = sql;
MyComm.ExecuteNonQuery();
}
catch
{
MyConn.Close();
MyConn.Dispose();
this.displaysave.InnerHtml = "";
this.byts_errormsg.Text = "数据库溢出!(数据库中不允许存在超过21亿的值)";
return;
}
MyConn.Close();
MyConn.Dispose();
info.LastSave = DateTime.Now;
if (info.FGrade != fightgrade_new)
{
info.FGrade = fightgrade_new;
xajh.chat.info upinfo = new xajh.chat.info();
this.Session["info"] = upinfo.Update("##的战斗等级已经提升至<font class=\\\"byts\\\">" + fightgrade_new + "</font>级。", "升级", info);
this.Response.Write ("<script language=javascript type=text/javascript>parent.byts_figthgrade=" + fightgrade_new + "</script>");
}
else
{
this.Session["info"] = info;
}
}
else
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.byts_errormsg.Text = "用户名未找到!";
}
}
#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.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -