using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class include_Surveyonline : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Showsurvey();
        }
    }
    //绑定控件
    private void Showsurvey()
    {       
        RadioButtonList1.Items.Clear();
        SqlDataReader dr = Getsurvey();
        while (dr.Read())
        {
            lblTitle.Text = dr["Title"].ToString();
            RadioButtonList1.Items.Add(new ListItem(dr["Surveyitem"].ToString(), dr["SurveyitemID"].ToString()));
        }
    }
    //打开调查项目数据库
    public SqlDataReader Getsurvey()
    {
        INews shownews = new Mynews();
        SqlDataReader dr = shownews.SqlGetinfo("SELECT * FROM Survey AS CLA INNER JOIN Surveyitem AS CLB ON CLA.SurveyID=CLB.ParrentID WHERE CLA.ShowID=1");     
        return dr;
    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Showsurvey.aspx");
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (RadioButtonList1.SelectedItem == null)
        {
            return;
        }
        int nSurveyitemID = Int32.Parse(RadioButtonList1.SelectedValue.ToString());
        INews shownews = new Mynews();
        shownews.Executeinfo("UPDATE Surveyitem SET Hit=Hit+1 WHERE SurveyitemID=" + nSurveyitemID);
    }
}
