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 Models;
using LoveBLL;

namespace LoveWeb.Vote
{
    public partial class vote : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < DataList1.Items.Count; i++)
            {
                Qest q = new Qest();
              //  RadioButtonlist rb = (RadioButtonlist)DataList1.Items[i].FindControl("RadioButtonlist1");//（）内为rb的id
                 int  getvalue = Convert.ToInt32(((RadioButtonList)this.DataList1.Items[i].FindControl("RadioButtonList1")).SelectedValue.ToString());
                 q = VoteManager.qest(i + 1);
                if (getvalue%3==1)
                {
                   
                    q.Answer_1+=1;

                    VoteManager.InsertQuestion(q, getvalue, (i + 1));
                }
                else if (getvalue%3 == 2)
                {

                    q.Answer_2 += 1;

                    VoteManager.InsertQuestion(q, getvalue, (i + 1));
                }
                else
                {
                    q.Answer_3 += 1;

                    VoteManager.InsertQuestion(q, getvalue, (i + 1));
                }
            }

            Response.Redirect("VoteResult.aspx");
        }

     
    }
}
