コード例 #1
0
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            objvotes.ID          = Convert.ToInt32(this.GridView1.DataKeys[e.NewEditIndex].Value);
            objvotes.AgreeQty    = 0;
            objvotes.DisagreeQty = 0;
            votes.UpdateVoteAgreeQtyByID(objvotes);
            votes.UpdateVoteDisagreeQtyByID(objvotes);

            GridView1.DataSource = votes.SelectAllVote();
            GridView1.DataBind();
        }
コード例 #2
0
ファイル: Voting.aspx.cs プロジェクト: wangchuncheng211/OAS
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (Convert.ToString(Session["vote"]) != string.Empty)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('每人只有一次投票机会,谢谢!!');</script>");
                //Response.Write("<script>history.go(-1)</script>");
                return;
            }
            else
            {
                int    str         = (int)DataList1.DataKeys[e.Item.ItemIndex];
                string commandName = e.CommandName.ToString().Trim();
                if (commandName == "agree")
                {
                    int AgreeQty = 0;
                    //检索 原有票 +1
                    objvotes.ID = str;
                    DataTable dt = votes.SelectVoteByID(objvotes);
                    AgreeQty = Convert.ToInt32(dt.Rows[0]["agreeQty"]);
                    AgreeQty = AgreeQty + 1;
                    //更新投票
                    objvotes.AgreeQty = AgreeQty;
                    objvotes.ID       = str;
                    bool bl = votes.UpdateVoteAgreeQtyByID(objvotes);
                    if (bl)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('投票成功!');</script>");
                    }
                }
                else if (commandName == "disagree")
                {
                    int DisagreeQty = 0;
                    //检索 原有票 +1
                    objvotes.ID = str;
                    DataTable dt = votes.SelectVoteByID(objvotes);
                    DisagreeQty = Convert.ToInt32(dt.Rows[0]["disagreeQty"]);
                    DisagreeQty = DisagreeQty + 1;
                    //更新投票
                    objvotes.DisagreeQty = DisagreeQty;
                    objvotes.ID          = str;
                    bool bl = votes.UpdateVoteDisagreeQtyByID(objvotes);
                    if (bl)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('投票成功!');</script>");
                    }
                }

                DataList1.DataSource   = votes.SelectAllVote();
                DataList1.DataKeyField = "ID";
                DataList1.DataBind();
                //标记本浏览器已经投过票
                Session["vote"] = "vote";
            }
        }