protected void ImageButton8_Click(object sender, ImageClickEventArgs e) { if (Session["VotePId"] == null || Session["VotePId"].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/LoginPrompt.aspx?LinkPage=" + Request.Url.ToString() + "';</script>"); return; } else { leica_geosystemsVoteProjectRecord model = new leica_geosystemsVoteProjectRecord(); model.VoteUserId = Session["VotePId"].ToString(); model.VoteUserName = Session["VotePName"].ToString(); model.WorksId = getid().ToString(); leica_geosystemsVoteProjectRecordManager bll = new leica_geosystemsVoteProjectRecordManager(); //leica_geosystemsVoteProjectSetUp setmodel = new leica_geosystemsVoteProjectSetUp(); leica_geosystemsVoteProjectRecordManager rebll = new leica_geosystemsVoteProjectRecordManager(); DataSet ds = new DataSet(); StringBuilder strWhere = new StringBuilder(); if (Session["VotePId"] != null && Session["VotePId"].ToString() != "") { strWhere.AppendFormat("VoteUserId like '%{0}%'", Session["VotePId"].ToString()); } ds = rebll.GetDistinctList(strWhere.ToString()); #region 第人可投多少票 leica_geosystemsVoteProjectRecordManager rebllMax = new leica_geosystemsVoteProjectRecordManager(); DataSet dsMax = new DataSet(); StringBuilder strWhereMax = new StringBuilder(); if (Session["VotePId"] != null && Session["VotePId"].ToString() != "") { strWhereMax.AppendFormat("VoteUserId={0}", Session["VotePId"].ToString()); } dsMax = rebllMax.GetList(strWhereMax.ToString()); #endregion leica_geosystemsVoteProjectSetUpManager setbll = new leica_geosystemsVoteProjectSetUpManager(); DataSet setds = new DataSet(); setds = setbll.GetList(""); //Response.Write(strWhereMax.ToString()); //Response.Write(int.Parse(setds.Tables[0].Rows[0]["MaxCount"].ToString())); //Response.End(); DataSet dsAPieceTime = new DataSet(); StringBuilder strWhereAPieceTime = new StringBuilder(); if (Session["VotePId"] != null && Session["VotePId"].ToString() != "") { strWhereAPieceTime.AppendFormat("leica_geosystemsVoteProjectRecord.VoteUserId ='{0}'", Session["VotePId"].ToString()); strWhereAPieceTime.AppendFormat(" and leica_geosystemsVoteProjectRecord.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(); //Response.Write(setds.Tables[0].Rows[0]["MaxCount"].ToString()); //Response.End(); if (setds.Tables[0].Rows[0]["MaxCount"].ToString() != "") { leica_geosystemsVoteProjectRecordManager reblls = new leica_geosystemsVoteProjectRecordManager(); DataSet dsAPieceTimes = new DataSet(); StringBuilder strWhereAPieceTimes = new StringBuilder(); if (Session["VotePId"] != null && Session["VotePId"].ToString() != "") { strWhereAPieceTimes.AppendFormat("leica_geosystemsVoteProjectRecord.VoteUserId ='{0}'", Session["VotePId"].ToString()); strWhereAPieceTimes.AppendFormat(" and leica_geosystemsVoteProjectRecord.WorksId ='{0}'", getid()); } else { strWhereAPieceTimes.AppendFormat("leica_geosystemsVoteProjectRecord.VoteUserId ='{0}'", "-1"); strWhereAPieceTimes.AppendFormat(" and leica_geosystemsVoteProjectRecord.WorksId ='{0}'", getid()); } dsAPieceTimes = rebll.GetList(strWhereAPieceTimes.ToString()); if (dsAPieceTimes.Tables[0].Rows.Count == 0) { //Response.Write(dsMax.Tables[0].Rows.Count); //Response.Write(int.Parse(setds.Tables[0].Rows[0]["MaxCount"].ToString())); //Response.End(); if (dsMax.Tables[0].Rows.Count < int.Parse(setds.Tables[0].Rows[0]["MaxCount"].ToString())) { bll.Add(model); if (dsMax.Tables[0].Rows.Count <= 10) { if ((dsMax.Tables[0].Rows.Count + 1) == 10) { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功!您已投完10票!", "IVoteList.aspx"); } else { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功!您至少还需要投" + (10 - (dsMax.Tables[0].Rows.Count + 1)) + "票!", "IVoteList.aspx"); } } else { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功!您已经投了" + dsMax.Tables[0].Rows.Count + "票!", "IVoteList.aspx"); } } else { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "感谢参与,您已投完10票!", "IVoteList.aspx"); } } else { Maticsoft.Common.MessageBox.ShowAndRedirect(this, "该作品您已投过票,无法再对该作品投票!", "IVoteList.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()) - (dsAPieceTime.Tables[0].Rows.Count + 1); if (dsAPieceTime.Tables[0].Rows.Count < int.Parse(setds.Tables[0].Rows[0]["APieceTime"].ToString())) { bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "投票成功,您还可以投" + shengyuz + "张不同作品!", "IVoteList.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() + "次!", "IVoteList.aspx"); } else { Page.RegisterStartupScript("", "<script>alert('投票失败,每人每张作品最多可投" + setds.Tables[0].Rows[0]["APieceTime"].ToString() + "次');</script>"); } } } } //Response.Write("12121"); } }
protected void Page_Load(object sender, EventArgs e) { Context.Response.Cache.SetCacheability(HttpCacheability.NoCache); if (topVote1.FindControl("lizi7") != null) { //((HtmlGenericControl)topVote1.FindControl("lizi7")).Style.Add("background-image", "url(images/menu_bg1.jpg)"); } if (topVote1.FindControl("izi7") != null) { ((HtmlAnchor)topVote1.FindControl("izi7")).Style.Add("color", "#ffffff"); } if (!IsPostBack) { if (getid() != -1) { ShowInfo(getid()); PicBind(); } leica_geosystemsVoteProjectSetUpManager Setupbll = new leica_geosystemsVoteProjectSetUpManager(); 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"; } leica_geosystemsVoteProjectRecordManager rebll = new leica_geosystemsVoteProjectRecordManager(); DataSet dsAPieceTime = new DataSet(); StringBuilder strWhereAPieceTime = new StringBuilder(); if (Session["VotePId"] != null && Session["VotePId"].ToString() != "") { strWhereAPieceTime.AppendFormat("leica_geosystemsVoteProjectRecord.VoteUserId ='{0}'", Session["VotePId"].ToString()); strWhereAPieceTime.AppendFormat(" and leica_geosystemsVoteProjectRecord.WorksId ='{0}'", getid()); } else { strWhereAPieceTime.AppendFormat("leica_geosystemsVoteProjectRecord.VoteUserId ='{0}'", "-1"); strWhereAPieceTime.AppendFormat(" and leica_geosystemsVoteProjectRecord.WorksId ='{0}'", getid()); } dsAPieceTime = rebll.GetList(strWhereAPieceTime.ToString()); if (dsAPieceTime.Tables[0].Rows.Count != 0) { //ImageButton8.Enabled = false; ImageButton8.Visible = false; Label5.Visible = true; toupiao.Visible = true; } //Response.Write(dsAPieceTime.Tables[0].Rows.Count); } }