using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using web; using System.Data; public partial class control_ybtogold : System.Web.UI.UserControl { private void btnchange_Click(object sender, EventArgs e) { int useridx = int.Parse(base.Session["useridx"].ToString()); int gold = Math.Abs(int.Parse(this.tbgold.Text.ToString())); int goldtomoney = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ybtogoldRate"].ToString()); string str = goldtomoney2(useridx, gold, goldtomoney); base.Response.Write(""); } public string goldtomoney2(int useridx, int gold, int goldtomoney) { int num; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@useridx", SqlDbType.Int, 8), new SqlParameter("@gold", SqlDbType.Int, 8), new SqlParameter("@goldtomoney", SqlDbType.Int, 8) }; parameters[0].Value = useridx; parameters[1].Value = gold; parameters[2].Value = goldtomoney; switch (new DataProviders().RunProcedure("Web_YBToGold", parameters, out num)) { case 0: return "元寶兌換金幣成功,請查看 賬戶登錄欄。"; case 1: return "你的元寶數量不夠!"; } return "系統級錯誤,請聯繫管理員!"; } private void InitializeComponent() { this.btnchange.Click += new EventHandler(this.btnchange_Click); base.Load += new EventHandler(this.Page_Load); } protected override void OnInit(EventArgs e) { this.InitializeComponent(); base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (base.Session["userid"] == null) { base.Response.Redirect("login.aspx?returnurl=" + base.Request.ServerVariables["SCRIPT_NAME"]); } } }