private void SubmitVote() { SqlHelper sqlhelper = SqlFactory.GetSqlhelper(); AjaxResult result = new AjaxResult(); string session = Fun.GetSession("openid"); int primaryKey = int.Parse(HttpContext.Current.Request.Form["voteid"]); if (string.IsNullOrEmpty(session)) { result.ErrCode = -1; result.Message = "已超期,请重新进入页面"; } else if (sqlhelper.Count <VoteDetail>("where openid='" + session + "' and datediff(dd,votedate,getdate())=0", new object[0]) > 0) { result.ErrCode = -1; result.Message = "您今天已投过票,无法继续投票"; } else { VoteInfos infos = sqlhelper.SingleById <VoteInfos>(primaryKey); TimeSpan span = (TimeSpan)(DateTime.Now - infos.ValidStartDate); if (span.TotalDays < 0.0) { result.ErrCode = -1; result.Message = "该投票尚未开始"; } else { TimeSpan span2 = (TimeSpan)(DateTime.Now - infos.ValidEndDate); if (span2.TotalDays > 1.0) { result.ErrCode = -1; result.Message = "该投票已经结束"; } else { string[] strArray = HttpContext.Current.Request.Form["ids"].Split(new char[] { ',' }); for (int i = 0; i < strArray.Length; i++) { VotePersons persons = sqlhelper.SingleById <VotePersons>(strArray[i]); VoteDetail detail = new VoteDetail { VoteID = primaryKey, Person = persons.RealName, OpenID = session }; sqlhelper.Execute("insert into votedetail(voteid,person,openid)values(@0,@1,@2)", new object[] { primaryKey, persons.RealName, session }); } result.ErrCode = 0; result.Message = "提交成功"; //判断每人的中奖次数 if (Fun.HasBonus(session)) { result.Tag = "enable"; HttpContext.Current.Session["BonusEnable"] = "1"; } } } } HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); }
private void GetPersonDetail() { string name = HttpContext.Current.Request.QueryString["person"]; int voteid = int.Parse(HttpContext.Current.Request.QueryString["voteid"]); VotePersons persons = SqlFactory.GetSqlhelper().CreateWhere <VotePersons>().Where(o => (o.VoteID == voteid) && (o.RealName == name)).SingleOrDefault(); if (persons != null) { HttpContext.Current.Response.Write(persons.Description); } }
public ActionResult VotePersonAdd(VotePersons person) { DbUser user = base.Session["user"] as DbUser; person.VoteID = user.LimitVoteID; if (string.IsNullOrEmpty(person.RealName)) { return(base.Error("请输入姓名")); } SqlFactory.GetSqlhelper().Save <VotePersons>(person); return(base.Success()); }
public ActionResult VotePersonEdit(int id) { VotePersons model = SqlFactory.GetSqlhelper().SingleById <VotePersons>(id); return(base.View(model)); }