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 china_voteview : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        SqlCommand smd = new SqlCommand("select top 1 * from vote where isfp='y'", conn);
        SqlDataReader sdr = smd.ExecuteReader();
        sdr.Read();
        if (sdr["votoall"].ToString() == "0")
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
        }
        else
        {
            if (Convert.ToInt32(sdr["votoall"].ToString()) < 150)
            {
                this.TextBox1.Width = Convert.ToInt32(sdr["d1"].ToString());
                this.TextBox2.Width = Convert.ToInt32(sdr["d2"].ToString());
                this.TextBox3.Width = Convert.ToInt32(sdr["d3"].ToString());
                this.TextBox4.Width = Convert.ToInt32(sdr["d4"].ToString());
                this.TextBox5.Width = Convert.ToInt32(sdr["d5"].ToString());
            }
            else
            {
                this.TextBox1.Width = Convert.ToInt32(sdr["d1"].ToString())/10;
                this.TextBox2.Width = Convert.ToInt32(sdr["d2"].ToString())/ 10;
                this.TextBox3.Width = Convert.ToInt32(sdr["d3"].ToString())/ 10;
                this.TextBox4.Width = Convert.ToInt32(sdr["d4"].ToString())/ 10;
                this.TextBox5.Width = Convert.ToInt32(sdr["d5"].ToString())/ 10;
            }

            this.b1.Text =Convert.ToString(Math.Round(Convert.ToDouble(sdr.GetInt32(7))/sdr.GetInt32(12)*100,2))+"%";
            this.b2.Text = Convert.ToString(Math.Round(Convert.ToDouble(sdr.GetInt32(8)) / sdr.GetInt32(12) * 100, 2)) + "%";
            this.b3.Text = Convert.ToString(Math.Round(Convert.ToDouble(sdr.GetInt32(9)) / sdr.GetInt32(12) * 100, 2)) + "%";
            this.b4.Text = Convert.ToString(Math.Round(Convert.ToDouble(sdr.GetInt32(10)) / sdr.GetInt32(12) * 100, 2)) + "%";
            this.b5.Text = Convert.ToString(Math.Round(Convert.ToDouble(sdr.GetInt32(11)) / sdr.GetInt32(12) * 100, 2)) + "%";
            this.title1.Text = sdr["title"].ToString();
            this.t1.Text = sdr["q1"].ToString();
            this.t2.Text = sdr["q2"].ToString();
            this.t3.Text = sdr["q3"].ToString();
            this.t4.Text = sdr["q4"].ToString();
            this.t5.Text = sdr["q5"].ToString();
            this.d1.Text = sdr["d1"].ToString();
            this.d2.Text = sdr["d2"].ToString();
            this.d3.Text = sdr["d3"].ToString();
            this.d4.Text = sdr["d4"].ToString();
            this.d5.Text = sdr["d5"].ToString();
            this.votoall.Text ="共计：  " +sdr["votoall"].ToString()+"票";
        }
        sdr.Close();
        conn.Close();
    }
}
