using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;

public partial class newvote : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Int32 vtid;
            string sql0 = "select top 1 * from vtitle order by vtid desc";
            DataRow dr = oper.dr(sql0);
            lblvt.Text = dr["vtname"].ToString();
            vtid = Convert.ToInt32(dr["vtid"].ToString());

            string sql1="select * from vdetail where vtid="+vtid;
            DataTable dt = oper.dt(sql1);
            rdbld.DataSource = dt;
            rdbld.DataTextField = "vdname";
            rdbld.DataValueField = "vdid";
            rdbld.DataBind();
        }
    }
    protected void btnvote_Click(object sender, EventArgs e)
    {
        if (rdbld.SelectedIndex < 0)
        {
            Response.Write("<script language='javascript'>alert('您没有选择项，请重新选择！');window.location.href=document.URL;</script>");
        }
        else
        {
            string sql2 = "update vdetail set vdnum=vdnum+1 where vdid=" + rdbld.SelectedValue;
            oper.opertb(sql2);
            Response.Write("<script language='javascript'>alert('感谢您的参与！');window.location.href=document.URL;</script>");
        }
    }
}
