using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using web;
using System.Data.SqlClient;
using System.Data;
public partial class control_Award : System.Web.UI.UserControl
{
public string xxx = "";
public static DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (base.Session["userid"] == null)
{
base.Response.Redirect("login.aspx?returnurl=" + base.Request.ServerVariables["SCRIPT_NAME"]);
}
else if (!this.Page.IsPostBack)
{
this.ddchalist.DataSource = new DataProviders().ExecuteSqlDs("select character_idx,character_name+'['+convert(varchar,webchareset)+'锣]' as character_name from mhgame..tb_character where substring(character_name,1,1)!='@' and user_idx=" + base.Session["useridx"].ToString(), "ddchalist");
this.ddchalist.DataTextField = "character_name";
this.ddchalist.DataValueField = "character_idx";
this.ddchalist.DataBind();
for (int i = 0; i < this.ddchalist.Items.Count; i++)
{
this.ddchalist.Items[i].Text = new system().ConvertToBig5(this.ddchalist.Items[i].Text.ToString(), 950);
}
DataSet ds = new DataProviders().ExecuteSqlDs("select * from Award", "DataGrid1");
dt = ds.Tables[0];
this.DataGrid1.DataSource = dt;
this.DataGrid1.DataBind();
dpitem.DataSource = dt;
dpitem.DataValueField = "ID";
dpitem.DataTextField = "NAME";
dpitem.DataBind();
xxx = new DataProviders().ExecScalarOne(string.Format("select sum(gold) from Web_Log where playerid='{0}'", base.Session["userid"].ToString())).ToString();
if (xxx == "") xxx = "0";
}
}
protected void btnedit_Click(object sender, EventArgs e)
{
if (this.ddchalist.Items.Count == 0)
{
base.Response.Write(""); return;
}
int chaidxs = int.Parse(this.ddchalist.SelectedValue);
xxx = new DataProviders().ExecScalarOne(string.Format("select sum(gold) from Web_Log where playerid='{0}'", base.Session["userid"].ToString())).ToString();
if (xxx == "") xxx = "0";
int value = int.Parse(xxx);
int itemID = int.Parse(dpitem.SelectedItem.Value);
DataRow[] rr = dt.Select(string.Format("ID='{0}'", itemID));
if (rr == null || rr.Length < 1)
{
base.Response.Write("");
return;
}
int cost = int.Parse(rr[0]["Value"].ToString());
if (value < cost)
{
base.Response.Write("");
return;
}
int num;
SqlParameter[] parameters = new SqlParameter[]
{ new SqlParameter("@userid", SqlDbType.VarChar, 50), new SqlParameter("@useridx", SqlDbType.Int, 8),
new SqlParameter("@chaidx", SqlDbType.Int, 8), new SqlParameter("@itemid", SqlDbType.Int, 8),
new SqlParameter("@gold", SqlDbType.Int, 8),
new SqlParameter("@isbb", SqlDbType.Int, 8) };
parameters[0].Value = this.Session["userid"].ToString();
parameters[1].Value = this.Session["useridx"].ToString();
parameters[2].Value = chaidxs;
parameters[3].Value = itemID;
parameters[4].Value = 0 - cost;
parameters[5].Value = 1;
switch (new DataProviders().RunProcedure("getaward", parameters, out num))
{
case 0:
base.Response.Write("");
xxx = new DataProviders().ExecScalarOne(string.Format("select sum(gold) from Web_Log where playerid='{0}'", base.Session["userid"].ToString())).ToString();
if (xxx == "") xxx = "0";
return;
case 1:
base.Response.Write("");
return;
case 2:
base.Response.Write("");
return;
case 3:
base.Response.Write("");
return;
case 6:
base.Response.Write("");
return;
case 7:
base.Response.Write("");
return;
default: return;
}
base.Response.Write("");
return;
}
}