protected void btnSubmit_Click(object sender, EventArgs e) { M_Survey info = surBll.GetSurveyBySid(Sid); if (info.IsNull) { function.WriteErrMsg("该问卷不存在!可能已被删除"); } DateTime SubmitDate = DateTime.Now; string SIP = IPScaner.GetUserIP(); //----如该问卷是不用登录的,则以随机码作为用户名 int UserID = GetUserID(info); if (info.IsCheck && !CheckVCode(SendVcode.Text.Trim())) { function.Script(this, "alert('验证码不正确');"); return; } IList <M_Question> list = B_Survey.GetQueList(Sid); for (int i = 0; i < list.Count; i++) { M_Answer ans = new M_Answer(); string re = Request.Form["vote_" + i]; string[] OptionValue = list[i].QuestionContent.Split(new char[] { '|' }); if (list[i].TypeID == 2) { string[] ReArr = re.Split(new char[] { ',' }); for (int s = 0; s < ReArr.Length; s++) { ans.AnswerID = 0; ans.AnswerContent = ReArr[s]; ans.QuestionID = list[i].QuestionID; ans.SurveyID = Sid; ans.SubmitIP = SIP; ans.SubmitDate = SubmitDate; ans.UserID = UserID; B_Survey.AddAnswer(ans); } } else { ans.AnswerID = 0; ans.AnswerContent = re; ans.QuestionID = list[i].QuestionID; ans.SurveyID = Sid; ans.SubmitIP = SIP; ans.SubmitDate = SubmitDate; ans.UserID = UserID; B_Survey.AddAnswer(ans); } } B_Survey.AddAnswerRecord(Sid, UserID, SIP, SubmitDate, 1); string url = "VoteResult.aspx?SID=" + Sid; function.WriteSuccessMsg("提交成功!感谢您的参与!", Page.ResolveClientUrl(url)); }
protected void CheckInsert() { M_Survey info = surBll.GetSurveyBySid(Sid); //判断是否登录 DateTime SubmitDate = DateTime.Now; string SIP = Request.UserHostAddress; int UserID = GetUserID(info); //判断是否已参与了该问卷 if (B_Survey.HasAnswerBySID(Sid, UserID)) { function.WriteErrMsg("您已提交过该问卷!"); } if (info.IPRepeat > 0) { if (B_Survey.HasAnswerCountIP(Sid, SIP) >= info.IPRepeat) { function.WriteErrMsg("于IP:" + SIP + " 提交的问卷次数已达到限定次数:" + info.IPRepeat.ToString() + "次!"); } } IList <M_Question> list = new List <M_Question>(); list = B_Survey.GetQueList(Sid); for (int i = 0; i < list.Count; i++) { M_Answer ans = new M_Answer(); string re = Request.Form["vote_" + i]; string[] OptionValue = list[i].QuestionContent.Split(new char[] { '|' }); if (string.IsNullOrEmpty(re)) { re = ""; } if (list[i].TypeID == 1) { if (list[i].IsNull && string.IsNullOrEmpty(Request.Form["vote_" + i])) { function.WriteErrMsg(list[i].QuestionTitle + ":为必填选项"); } //ans.AnswerID = 0; ans.AnswerContent = DataConvert.CStr(re); ans.AnswerScore = surBll.GetScoreByContent(list[i].QuestionContent, re); ans.QuestionID = list[i].QuestionID; ans.SurveyID = Sid; ans.SubmitIP = SIP; ans.SubmitDate = SubmitDate; ans.UserID = UserID; B_Survey.AddAnswer(ans); } else { string[] ReArr = re.Split(new char[] { ',' }); for (int s = 0; s < ReArr.Length; s++) { //ans.AnswerID = 0; ans.AnswerContent = DataConvert.CStr(ReArr[s]); ans.QuestionID = list[i].QuestionID; ans.SurveyID = Sid; ans.SubmitIP = SIP; ans.SubmitDate = SubmitDate; ans.UserID = UserID; B_Survey.AddAnswer(ans); } } } }
protected void Button1_Click(object sender, EventArgs e) { M_Survey info = surveyBll.GetSurveyBySid(Sid); M_UserInfo mu = buser.GetLogin(); string SIP = EnviorHelper.GetUserIP(); if (info.NeedLogin && mu == null || mu.UserID < 1) { function.WriteErrMsg("该问卷需登录才能参与问卷,请先登录!"); } if (B_Survey.HasAnswerBySID(Sid, mu.UserID)) { function.WriteErrMsg("您已提交过该问卷!"); } if (info.IPRepeat > 0 && B_Survey.HasAnswerCountIP(Sid, SIP) >= info.IPRepeat) { function.WriteErrMsg("于IP:" + SIP + " 提交的问卷次数已达到限定次数:" + info.IPRepeat.ToString() + "次!"); } //-------------------------- IList <M_Question> list = B_Survey.GetQueList(Sid); for (int i = 0; i < list.Count; i++) { M_Answer anMod = new M_Answer(); anMod.AnswerContent = Request.Form["result_" + list[i].QuestionID]; anMod.QuestionID = list[i].QuestionID; anMod.SurveyID = Sid; anMod.SubmitIP = SIP; anMod.UserID = mu.UserID; B_Survey.AddAnswer(anMod); } if (B_Survey.AddAnswerRecord(Sid, mu.UserID, SIP, DateTime.Now, 0)) { function.WriteSuccessMsg("提交成功!感谢您的参与!"); } //for (int i = 0; i < list.Count; i++) //{ // M_Answer ans = new M_Answer(); // string re = Request.Form["txt_" + i]; // string[] OptionValue = list[i].QuestionContent.Split(new char[] { '|' }); // if (string.IsNullOrEmpty(re)) // { // re = OptionValue[0]; // } // if (list[i].TypeID == 1) // { // ans.AnswerID = 0; // ans.AnswerContent = re; // ans.QuestionID = list[i].QuestionID; // ans.SurveyID = Sid; // ans.SubmitIP = SIP; // ans.UserID = mu.UserID; // B_Survey.AddAnswer(ans); // } // else // { // string[] ReArr = re.Split(new char[] { ',' }); // for (int s = 0; s < ReArr.Length; s++) // { // ans.AnswerID = 0; // ans.AnswerContent = ReArr[s]; // ans.QuestionID = list[i].QuestionID; // ans.SurveyID = Sid; // ans.SubmitIP = SIP; // ans.UserID = mu.UserID; // B_Survey.AddAnswer(ans); // } // } //} }