Esempio n. 1
0
    protected void ImageButton8_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["qzone"] == null || Session["qzone"].ToString() == "")
        {
            //Page.ClientScript.RegisterStartupScript(Page.GetType(), "x", "DocDetailtop()", true);

            Response.Write("<script type=\"text/javascript\" language=\"javascript\">window.parent.location.href='" + component.ServerInfo.GetRootURI() + "/VoteProject/LoginQQ.aspx?LinkPage=" + Request.Url.ToString() + "';</script>");
            return;
        }
        else
        {

            QOpenClient qzone = (QOpenClient)Session["qzone"];

            leica_geosystemsSFVoteProjectRecord model = new leica_geosystemsSFVoteProjectRecord();
            model.VoteUserId = qzone.OAuthToken.OpenId;
            model.VoteUserName = qzone.GetCurrentUser().Nickname;
            model.WorksId = getid().ToString();
            leica_geosystemsSFVoteProjectRecordManager bll = new leica_geosystemsSFVoteProjectRecordManager();
            //leica_geosystemsSFVoteProjectSetUp setmodel = new leica_geosystemsSFVoteProjectSetUp();
            leica_geosystemsSFVoteProjectRecordManager rebll = new leica_geosystemsSFVoteProjectRecordManager();
            DataSet ds = new DataSet();
            StringBuilder strWhere = new StringBuilder();
            if (Session["qzone"] != null && Session["qzone"].ToString() != "")
            {

                strWhere.AppendFormat("VoteUserId like '%{0}%'", ((QOpenClient)Session["qzone"]).OAuthToken.OpenId);
            }
            ds = rebll.GetDistinctList(strWhere.ToString());
            leica_geosystemsSFVoteProjectSetUpManager setbll = new leica_geosystemsSFVoteProjectSetUpManager();
            DataSet setds = new DataSet();
            setds = setbll.GetList("");

            DataSet dsAPieceTime = new DataSet();
            StringBuilder strWhereAPieceTime = new StringBuilder();
            if (Session["qzone"] != null && Session["qzone"].ToString() != "")
            {

                strWhereAPieceTime.AppendFormat("leica_geosystemsSFVoteProjectRecord.VoteUserId ='{0}'", ((QOpenClient)Session["qzone"]).OAuthToken.OpenId);
                strWhereAPieceTime.AppendFormat(" and leica_geosystemsSFVoteProjectRecord.WorksId ='{0}'", getid());
            }
            dsAPieceTime = rebll.GetList(strWhereAPieceTime.ToString());

            //Response.Write(ds.Tables[0].Rows.Count);
            //Response.Write(setds.Tables[0].Rows[0]["TotalPiece"].ToString());
            //Response.Write(dsAPieceTime.Tables[0].Rows.Count);
            //Response.Write(int.Parse(setds.Tables[0].Rows[0]["APieceTime"].ToString()));
            //Response.Write(setds.Tables[0].Rows[0]["TotalPiece"].ToString());
            //Response.End();

            #region 第人可投多少票
            leica_geosystemsSFVoteProjectRecordManager rebllMax = new leica_geosystemsSFVoteProjectRecordManager();
            DataSet dsMax = new DataSet();
            StringBuilder strWhereMax = new StringBuilder();
            if (Session["qzone"] != null && Session["qzone"].ToString() != "")
            {

                strWhereMax.AppendFormat("VoteUserId like '%{0}%' and CONVERT(varchar(100), leica_geosystemsSFVoteProjectRecord.CreateTime, 23)='{1}'", ((QOpenClient)Session["qzone"]).OAuthToken.OpenId, DateTime.Now.ToString("yyyy-MM-dd"));
            }
            dsMax = rebllMax.GetList(strWhereMax.ToString());
            //Response.Write(setds.Tables[0].Rows[0]["MaxCount"].ToString()+"<br/>");
            //Response.Write(dsMax.Tables[0].Rows.Count);
            //Response.End();
            #endregion

            if (setds.Tables[0].Rows[0]["MaxCount"].ToString() != "")
            {
                if (dsMax.Tables[0].Rows.Count < int.Parse(setds.Tables[0].Rows[0]["MaxCount"].ToString()))
                {
                    bll.Add(model);
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功,每人第天限投" + setds.Tables[0].Rows[0]["MaxCount"].ToString() + "票!", "SFIVoteList.aspx");
                }
                else
                {
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票失败,每人第天限投" + setds.Tables[0].Rows[0]["MaxCount"].ToString() + "票!", "SFIVoteList.aspx");
                }
            }
            else
            {
                if (setds.Tables[0].Rows[0]["TotalPiece"].ToString() != "" && ((ds.Tables[0].Rows.Count < int.Parse(setds.Tables[0].Rows[0]["TotalPiece"].ToString())) || dsAPieceTime.Tables[0].Rows.Count != 0))
                {

                    //Response.Write(dsAPieceTime.Tables[0].Rows.Count);
                    //Response.Write(int.Parse(setds.Tables[0].Rows[0]["APieceTime"].ToString()));
                    //Response.End();
                    int shengyuz = int.Parse(setds.Tables[0].Rows[0]["TotalPiece"].ToString()) - ds.Tables[0].Rows.Count;
                    if (dsAPieceTime.Tables[0].Rows.Count < int.Parse(setds.Tables[0].Rows[0]["APieceTime"].ToString()))
                    {
                        bll.Add(model);
                        Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功,您还可以投" + shengyuz + "张不同作品!", "SFIVoteList.aspx");
                    }
                    else
                    {
                        Page.RegisterStartupScript("", "<script>alert('投票失败,每人每张作品最多可投" + setds.Tables[0].Rows[0]["APieceTime"].ToString() + "次');</script>");

                    }
                }
                else
                {
                    if (setds.Tables[0].Rows[0]["TotalPiece"].ToString() != "")
                    {
                        Page.RegisterStartupScript("", "<script>alert('投票失败,每人最多可以投" + setds.Tables[0].Rows[0]["TotalPiece"].ToString() + "张不同的作品');</script>");
                    }
                    else
                    {
                        if (dsAPieceTime.Tables[0].Rows.Count < int.Parse(setds.Tables[0].Rows[0]["APieceTime"].ToString()))
                        {
                            bll.Add(model);
                            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功,每人每张作品最多可投" + setds.Tables[0].Rows[0]["APieceTime"].ToString() + "次!", "SFIVoteList.aspx");
                        }
                        else
                        {
                            Page.RegisterStartupScript("", "<script>alert('投票失败,每人每张作品最多可投" + setds.Tables[0].Rows[0]["APieceTime"].ToString() + "次');</script>");

                        }
                    }

                }
            }
            //Response.Write("12121");
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        if (top1.FindControl("lizi7") != null)
        {
            //((HtmlGenericControl)topVote1.FindControl("lizi7")).Style.Add("background-image", "url(images/menu_bg1.jpg)");
        }
        if (top1.FindControl("izi7") != null)
        {
            ((HtmlAnchor)top1.FindControl("izi7")).Style.Add("color", "#ffffff");
        }

        if (!IsPostBack)
        {
            if (getid() != -1)
            {
                ShowInfo(getid());
                PicBind();
            }
            leica_geosystemsSFVoteProjectSetUpManager Setupbll = new leica_geosystemsSFVoteProjectSetUpManager();
            DataSet ds = Setupbll.GetList("");
            if (ds.Tables[0].Rows.Count == 0)
            {
                ImageButton8.Enabled = false;
                Label6.Visible = true;
                Label6.Text = "投票还没有开始!!!";
                ImageButton8.ImageUrl = "~/VoteProject/images/tovote_01.png";
            }
        }
    }