using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace WebApplication2.Admin
{
	/// <summary>
	/// ModifAdvCount 的摘要说明。
	/// </summary>
	public partial class ModifAdvCount : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{
				if(this.Session["USERNAME"]==null||this.Session["Role"]==null||this.Session["USERNAME"].ToString()==""||this.Session["Role"].ToString()=="")
				{
					Response.Redirect("login.aspx");
				}
				else
				{
					string [] role=this.Session["Role"].ToString().Split('#');
					bool exists=false;
					for(int i=0;i<role.Length;i++)
					{
                        if (role[i].Equals("12") || role[i].Equals("0"))
						{
							exists=true;break;
						}
					}
					if(exists)
					{
					
						string id=Request.Params["id"].ToString();
						SB.ADOHelper help=new SB.ADOHelper();
						SqlDataReader rd=help.getReader("select IsPayment,Quantity,ShowQuantity,money from AdvCount where id='"+id+"'");
						if(rd.Read())
						{
							this.TextBox1.Text=rd["Quantity"].ToString();
							this.TextBox2.Text=rd["ShowQuantity"].ToString();
							this.TextBox3.Text=rd["money"].ToString();
							this.DropDownList1.SelectedIndex=Convert.ToInt32(rd["IsPayment"].ToString())-1;
						}
						rd.Close();
					
					}
					else
					{Response.Redirect("NoAuthor.aspx");}
				}
			

			}


			// 在此处放置用户代码以初始化页面
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

		protected void Button1_Click(object sender, System.EventArgs e)
		{
		
				string hitcount=this.TextBox1.Text;
				string appcount=this.TextBox2.Text;
				string moneycount=this.TextBox3.Text;
				string state=this.DropDownList1.SelectedValue;
				SB.ADOHelper help=new SB.ADOHelper();
				help.execSql("update AdvCount set IsPayment='"+state+"', Quantity='"+hitcount+"', ShowQuantity='"+appcount+"', money="+moneycount+" where id='"+Request.Params["id"].ToString()+"'");
				Response.Redirect("AdvCount.aspx");
			
	
			
			
		
		}

		protected void Button2_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("AdvCount.aspx");
		}
	}
}
