protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Sid <= 0) { function.WriteErrMsg("缺少问卷的ID参数!"); } M_Survey info = surveyBll.GetSurveyBySid(Sid); if (info == null) { function.WriteErrMsg("该问卷不存在!可能已被删除"); } if (info.EndTime < DateTime.Now) { function.WriteErrMsg("该问卷已过期!"); } if (!B_Survey.HasQuestion(Sid)) { function.WriteErrMsg("该问卷没有设定问卷问题!"); } MyBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { M_UserInfo mu = buser.GetLogin(); M_Survey info = surBll.GetSurveyBySid(Sid); if (Sid <= 0) { function.WriteErrMsg("缺少问卷投票的ID参数!", Request.UrlReferrer.ToString()); } if (info == null || info.IsNull) { function.WriteErrMsg("缺少问卷!!"); } if (!B_Survey.HasQuestion(Sid)) { function.WriteErrMsg("该投票没有设定投票问题!"); } if (info.NeedLogin) { B_User.CheckIsLogged(Request.RawUrl); } if (info.IsCheck) { regVcodeRegister.Visible = true; } if (!info.IsOpen) { function.WriteErrMsg("对不起,该问卷尚未启用!!", Request.UrlReferrer.ToString()); } if (info.StartTime > DateTime.Now || info.EndTime < DateTime.Now) { function.WriteErrMsg("对不起,每年填写或报名时间是" + info.StartTime.ToLongDateString() + "到" + info.EndTime.ToLongDateString()); } //判断是否已参与了该问卷 if (B_Survey.HasAnswerBySID(Sid, mu.UserID)) { function.WriteErrMsg("您已提交过该问卷!"); } CheckIP(info); Random_Hid.Value = GetRandomID().ToString(); DataTable tblAnswers = new DataTable(); if (Request.QueryString["UID"] != null && Request.QueryString["PTime"] != null) { int uid = DataConverter.CLng(Request.QueryString["UID"]); string time = Server.UrlDecode(Request.QueryString["PTime"]); tblAnswers = B_Answer.GetUserAnswers(Sid, uid, time); } if (tblAnswers.Rows.Count > 0) { btnSubmit.Visible = false; btnExport.Visible = true; } else { btnExport.Visible = false; btnSubmit.Visible = true; } this.SurveyName_L.Text = info.SurveyName; this.Description_L.Text = info.Description; this.CreateDate_L.Text = info.CreateDate.ToString("yyyy-MM-dd"); qtitle.Visible = !string.IsNullOrEmpty(info.Description); StringBuilder sb = new StringBuilder(); IList <M_Question> list = new List <M_Question>(); list = B_Survey.GetQueList(Sid); for (int i = 0; i < list.Count; i++) { if (list[i].IsNull) { sb.AppendLine("<li id='mao_" + i + "' name='mao_" + i + " '>"); IsNull_H.Value += "vote_" + i + ","; } else { sb.AppendLine("<li id='mao_" + i + "' name='mao_" + i + " '>"); } sb.AppendLine("<table id='tbl_" + i + "' style='width:100%;'>"); sb.AppendLine("<tr style='border-bottom:1px solid #ddd;padding-bottom:5px;'><th>" + (i + 1) + ". " + list[i].QuestionTitle + (list[i].IsNull ? "<span style='color:#f00;margin-left:10px;'>*</span>" : "") + "</th></tr>"); sb.AppendLine("<tr><td>" + list[i].QuestionContent + "</td></tr>"); List <string> optionlist = new List <string>(); JObject jobj = JsonConvert.DeserializeObject <JObject>(list[i].Qoption); string[] OptionValue = list[i].TypeID == 0 ? jobj["sel_op_body"].ToString().Split(',') : jobj["text_str_dp"].ToString().Split(','); string optiontype = list[i].TypeID == 0 ? jobj["sel_type_rad"].ToString() : jobj["text_type_rad"].ToString(); if (tblAnswers.Rows.Count > 0) { sb.AppendLine(SetAnswers(i, list[i].TypeID, list[i].QuestionID, tblAnswers, OptionValue)); } else { sb.AppendLine(SetOptions(i, optiontype, OptionValue)); } sb.AppendLine("</table></li>"); } IsNull_H.Value = IsNull_H.Value.Trim(','); ltlResultHtml.Text = sb.ToString(); } }