Exemplo n.º 1
0
    protected void DataListvote_ItemCommand(object source, DataListCommandEventArgs e)
    {
        string Studentnum = Request.Cookies["StudentCookies"].Values["Snum"].ToString();
        if (e.CommandName == "down")
        {
        string Wurlstr=((HyperLink)e.Item.FindControl("Hyperurl")).NavigateUrl;
        LearnSite.Common.FileDown.DownLoad(Wurlstr);

        }

        if (e.CommandName == "vote")
        {
            if (Request.QueryString["Wid"] != null)
            {
                int myWid = Int32.Parse(Request.QueryString["Wid"].ToString());
                LearnSite.BLL.Works wsbll = new LearnSite.BLL.Works();
                int iv = wsbll.GetWegg(myWid);//从数据库中获取可投次数
                if (iv > 0)
                {
                    Labelmsg.Text = "你现在可以开始投票了!";
                    if (Session[Studentnum] != null)
                    {
                            int Wid = Int32.Parse(DataListvote.DataKeys[e.Item.ItemIndex].ToString());
                            LearnSite.BLL.Works ws = new LearnSite.BLL.Works();
                            ws.UpdateWvote(Wid);//别人的得票数加1
                            iv = iv - 1;//我的投票次数减1
                            int MyWid = Int32.Parse(Request.QueryString["Wid"]);
                            ws.UpdateWegg(MyWid);
                            System.Threading.Thread.Sleep(1000);
                            string Wname = ((LinkButton)e.Item.FindControl("Linkname")).Text;//8888888888888
                            Labelmsg.Text = "给" + Wname + "同学投票成功!";
                            ShowInfo();
                    }
                    else
                    {
                        Labelmsg.Text = "投票页面超时!";
                    }
                }
                else
                {
                    Labelmsg.Text = "你的投票次数已经用完!";
                }
            }
        }
    }