/// <summary> /// ��֤���� /// </summary> /// <param name="json"></param> private void ValidateVote(LabMS.Model.VoteRecordJson json) { ExtendBLL.Vote vote = new ExtendBLL.Vote(); LabMS.Model.Vote voteInfo = vote.GetModel(json.VoteID); if (voteInfo == null) { throw new Exception("���������Ѿ�ʧЧ"); } bool exists = false; switch (voteInfo.VoteLimit) { case 0: break; case 1: // ÿIPһ�� exists = Exist(" [IP]='" + json.IP + "' and [VoteID]=" + json.VoteID); if (exists) { throw new Exception("�Բ���ÿ��IPֻ�ܲ���һ������!"); } break; case 2: exists = Exist(" [UserID]=" + json.UserID + " and [VoteID]=" + json.VoteID + " and [UserType] = " + json.UserType); if (exists) { throw new Exception("�Բ������Ѿ��������������������!"); } break; default: break; } }
public void ProcessRequest(HttpContext context) { try { string idJson = System.Web.HttpContext.Current.Server.UrlDecode(context.Request.Form.ToString()); LabMS.Model.VoteJson voteJson = (LabMS.Model.VoteJson)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(idJson, typeof(LabMS.Model.VoteJson)); // Get Vote ExtendBLL.Vote vote = new ExtendBLL.Vote(); voteJson = vote.GetJsonModel(voteJson.ID); if (voteJson == null) { context.Response.ContentType = "application/json"; context.Response.Write("{error: true}"); } String json = Newtonsoft.Json.JavaScriptConvert.SerializeObject(voteJson); context.Response.ContentType = "application/json"; context.Response.Write(json); } catch { context.Response.ContentType = "application/json"; context.Response.Write("{error: true}"); } }
public void ProcessRequest(HttpContext context) { try { HttpRequest request = context.Request; // string s = System.Web.HttpContext.Current.Server.UrlEncode("http://h.com/+"); string strJSON = System.Web.HttpContext.Current.Server.UrlDecode(request.Form.ToString()); LabMS.Model.VoteJson voteJson = (LabMS.Model.VoteJson)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strJSON, typeof(LabMS.Model.VoteJson)); #region Insert ExtendBLL.Vote vote = new ExtendBLL.Vote(); vote.Insert(voteJson); #endregion context.Response.ContentType = "application/json"; context.Response.Write("{success: true}"); } catch (Exception ex) { context.Response.ContentType = "application/json"; context.Response.Write("{success: false, msg: '" + ex.Message + "'}"); } }
protected void BtnDelete_Click(object sender, EventArgs e) { CheckBox cb; int voteID; ExtendBLL.Vote vote = new ExtendBLL.Vote(); for (int i = GridViewVoteList.Rows.Count - 1; i > -1; i--) { cb = (CheckBox)GridViewVoteList.Rows[i].FindControl("CBSelect"); if (cb.Checked) { voteID = int.Parse(GridViewVoteList.DataKeys[i].Value.ToString()); vote.DeleteFullInfo(voteID); } } BindData(); WriteBackScript("alert('�ѳɹ�ɾ�������Դ')"); }