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 free.bbs
{
	/// <summary>
	/// Summary description for pingding.
	/// </summary>
	public class pingding : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox zhuti;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
		protected System.Data.SqlClient.SqlConnection myconn;
		protected System.Data.SqlClient.SqlCommand mycomm;
		SqlDataReader myread;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			myconn=new SqlConnection(Session["str_connection"].ToString());
			myconn.Open();
			//zhuti.Text=Session["zhuti"].ToString();
			try
			{
				if(Request.Cookies["free_huiyuan"].Value.ToString()!="free911")
				{
					try
					{
						string ans=Request.Params["ancestor_id"];
						mycomm=new SqlCommand("select neirong from ancestor where (ancestor_id="+Request.Params["ancestor_id"]+" and banzhu='"+Request.Cookies["free_huiyuan"].Value.ToString()+"')",myconn);
						myread=mycomm.ExecuteReader();
						try
						{
							myread.Read();
							string he=myread["neirong"].ToString().Trim();
							myread.Close();
				
						}
						catch
						{
							myread.Close();
							Response.Write("<script>alert('你无权评定该主题')</script>");
							Response.Write("<script>window.close()</script>");
					
						}
					}
			
					catch
					{
						Response.Write("<script>alert('你无权评定该主题')</script>");
						Response.Write("<script>window.close()</script>");

				
					}
				}
			}
			catch
			{
				Response.Write("<script>alert('你无权评定该主题')</script>");
				Response.Write("<script>window.close()</script>");
			}
			
			myconn.Close();
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button2_Click(object sender, System.EventArgs e)
		{
			Response.Write("<script>window.close()</script>");
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
		    string sqlstr;
			if(RadioButtonList1.SelectedValue=="1")
				sqlstr="update posts set  isceam=2,islock=0 where postid="+Request.Params["post_id"]+"";
			else if(RadioButtonList1.SelectedValue=="2")
				sqlstr="update posts set  islock=1 where postid="+Request.Params["post_id"]+"";
			else if(RadioButtonList1.SelectedValue=="3")
				sqlstr="update posts set  isfix=2,islock=0 where postid="+Request.Params["post_id"]+"";
			else
				sqlstr="update posts set  isfix=1,islock=0 where postid="+Request.Params["post_id"]+"";
			mycomm=new SqlCommand(sqlstr,myconn);
			
			mycomm.Connection.Open();		
			try 
			{
				mycomm.ExecuteNonQuery();
				Response.Write("<script>alert('评定成功')</script>");
				Response.Write("<script>window.close()</script>");
			}
			catch
			{
				Response.Write("<script>alert('评定失败')</script>");}
			mycomm.Connection.Close();
		}
	}
}
