private void MyBind() { DataTable dtable = new DataTable(); EGV.DataSource = B_Survey.GetSurveyList(); EGV.DataBind(); }
//保存 protected void Button_Click(object sender, EventArgs e) { M_Question qinfo = new M_Question(); M_QuestOption option = new M_QuestOption(); option.FillByForm(Request); if (Qid > 0) { qinfo = B_Survey.GetQuestion(Qid); } qinfo.QuestionTitle = this.TxtQTitle.Text.Trim(); qinfo.TypeID = Convert.ToInt32(Request.Form["type_rad"]); qinfo.IsNull = Convert.ToBoolean(Convert.ToInt32(NotNull.SelectedValue)); qinfo.QuestionContent = Content_T.Text; qinfo.Qoption = JsonConvert.SerializeObject(option); if (Qid > 0) { B_Survey.UpdateQuestion(qinfo); } else { qinfo.SurveyID = Sid; qinfo.OrderID = B_Survey.GetMaxOrderID(Sid) + 1; int qid = B_Survey.AddQuestion(qinfo); } function.WriteSuccessMsg("操作成功", "SurveyItemList.aspx?SID=" + Sid); }
protected void Button2_Click(object sender, EventArgs e) { M_Survey info = surBll.GetSurveyBySid(Sid); if (info.IsNull) { function.WriteErrMsg("该问卷不存在!可能已被删除"); } else { DateTime SubmitDate = DateTime.Now; string SIP = Request.UserHostAddress; int UserID = GetUserID(info); if (info.IsCheck && !CheckVCode(SendVcode.Text.Trim())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('验证码不正确!!');", true); return; } CheckInsert(); if (B_Survey.AddAnswerRecord(Sid, UserID, SIP, SubmitDate, -1)) { ClientScript.RegisterStartupScript(typeof(string), "script", "<script> alert('保存成功!');</script>"); } } }
public string GetScore(string qid, string qtypeid) { string result = ""; if (Convert.ToInt32(qtypeid) != 1) { result = ""; } else { M_Question QueMod = new M_Question(); QueMod = B_Survey.GetQuestion(Convert.ToInt32(qid)); B_Survey surBll = new B_Survey(); if (!CheckScore(QueMod.QuestionContent)) { result = ""; } else { //result = "<td colspan='3'>"; //result += surBll.GetScore(Convert.ToInt32(qid), Convert.ToInt32(qtypeid)) + "<div><iframe width='400' height='350' id='TbLocation' src='/Plugins/Chart/pie-basic.aspx?Bases=400|400||"; //result += "%u4F4D&Datas=" + Server.UrlEncode(surBll.CreateIframe(Convert.ToInt32(qid))) + "' frameborder='0' scrolling='no'></iframe><div><td>"; } } return(result); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Sid <= 0) { function.WriteErrMsg("缺少问卷投票的ID参数!", "../Plus/SurveyManage.aspx"); return; } M_Survey info = surBll.GetSurveyBySid(Sid); if (info.IsNull) { function.WriteErrMsg("该问卷投票不存在!可能已被删除", "../Plus/SurveyManage.aspx"); return; } //this.lblSurveyName.Text = info.SurveyName; //this.lblDesp.Text = info.Description; //if (!string.IsNullOrEmpty(info.Description)) //{ // this.lblDesp.Text = "问卷描述:" + info.Description; //} MyBind(); IList <M_Question> list = new List <M_Question>(); list = B_Survey.GetQueList(Sid); rptReuslt.DataSource = list; rptReuslt.DataBind(); Call.SetBreadCrumb(Master, "<li><a href='SurveyManage.aspx'>问卷投票</a></li><li><a href='Survey.aspx?SID=" + info.SurveyID + "'>" + info.SurveyName + "</a></li><li class='active'>问卷投票结果</li>"); } }
// 获取验证文本的具体类型 public string GetVType(int qid) { string[] types = { "邮箱", "手机号码", "固定电话", "身份证号", "准考证号" }; M_Question info = B_Survey.GetQuestion(qid); string tpIndex = info.QuestionContent.Split('|')[1]; return(types[DataConverter.CLng(tpIndex)]); }
private void MyBind() { DataTable dtable = B_Survey.GetQuestionList(Sid); this.EGV.DataSource = dtable; this.EGV.DataKeyNames = new string[] { "QID" }; this.EGV.DataBind(); }
protected void rptResult_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } M_Question rowv = (M_Question)e.Item.DataItem; if (rowv.TypeID >= 3) { ((HtmlGenericControl)e.Item.FindControl("divTable")).Style["display"] = "none"; (e.Item.FindControl("ltlTitle") as Literal).Text = rowv.QuestionTitle; return; } GridView gview = e.Item.FindControl("gviewOption") as GridView; string options = rowv.QuestionContent;//内容 List <string> lstopts = new List <string>(); for (int i = 0; i < options.Split('|').Length; i++) { lstopts.Add(options.Split('|')[i].Split(':')[0]); } int sum = 0; string ratios = ""; string names = ""; gview.RowDataBound += delegate(object s, GridViewRowEventArgs ex) { int total = 0; string rate = ""; int papers = B_Survey.GetUsersCnt(rowv.SurveyID); if (ex.Row.RowType == DataControlRowType.DataRow) { total = B_Survey.GetAnsOptionCount(rowv.QuestionID, ex.Row.DataItem.ToString()); (ex.Row.FindControl("ltlTotal") as Literal).Text = total.ToString(); sum += total; if (papers == 0) { rate = "未填写"; } else { rate = ((float)total / papers).ToString("P"); } (ex.Row.FindControl("ltlRate") as Literal).Text = rate; names += CutContent(ex.Row.DataItem.ToString(), 4) + ","; ratios += total + ","; } if (ex.Row.RowType == DataControlRowType.Footer) { (ex.Row.FindControl("ltlSum") as Literal).Text = papers.ToString(); } }; gview.DataSource = lstopts; gview.DataBind(); }
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)); }
public void MyBind() { M_Survey info = surveyBll.GetSurveyBySid(Sid); STitle_T.InnerText = info.SurveyName; DataTable dt = B_Survey.GetQuestionList(Sid); RPT.DataSource = dt; RPT.DataBind(); //list = B_Survey.GetQueList(Sid); }
protected void Order_B_Click(object sender, EventArgs e) { DataTable dt = JsonConvert.DeserializeObject <DataTable>(Order_Hid.Value); foreach (DataRow dr in dt.Rows) { M_Question surmod = B_Survey.GetQuestion(DataConverter.CLng(dr["id"])); surmod.OrderID = DataConverter.CLng(dr["oid"]); B_Survey.UpdateQuestion(surmod); } MyBind(); }
protected void MyBind() { M_Question qinfo = B_Survey.GetQuestion(Qid); if (qinfo != null) { NotNull.SelectedValue = qinfo.IsNull ? "1" : "0"; TxtQTitle.Text = qinfo.QuestionTitle; Content_T.Text = qinfo.QuestionContent; Option_Hid.Value = qinfo.Qoption; function.Script(this, "SetRadVal('type_rad'," + qinfo.TypeID + ");"); } }
protected void Page_Load(object sender, EventArgs e) { ////判断是否被屏蔽 //string ip = Request.UserHostAddress; //if (IsIPShielded(ip)) //{ // function.WriteErrMsg("你的IP已被列入黑名单, 禁止访问此页面!", "../Plus/SurveyManage.aspx"); // return; //} if (!this.Page.IsPostBack) { //B_Admin badmin = new B_Admin(); // int SID = string.IsNullOrEmpty(Request.QueryString["SID"]) ? 0 : DataConverter.CLng(Request.QueryString["SID"]); if (SID <= 0) { function.WriteErrMsg("缺少问卷投票的ID参数!"); } else { M_Survey info = new B_Survey().GetSurveyBySid(SID); if (info.IsNull) { function.WriteErrMsg("该问卷投票不存在!可能已被删除"); } else { if (info.IsShow == 0) { function.WriteErrMsg("该问卷结果前台显示未启用!!"); } this.ltlSurveyName.Text = info.SurveyName; this.ltlDate.Text = DateTime.Now.AddSeconds(-30).ToString("yyyy-MM-dd hh:mm:ss"); IList <M_Question> list = new List <M_Question>(); list = B_Survey.GetQueList(SID); rptResult.DataSource = list; rptResult.DataBind(); } } } }
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 Lnk_Click(object sender, GridViewCommandEventArgs e) { int Id = DataConverter.CLng(e.CommandArgument); if (e.CommandName == "Edit") { Response.Redirect("SurveyItem.aspx?SID=" + Sid + "&QID=" + Id); } if (e.CommandName == "MovePre") { M_Question info = B_Survey.GetQuestion(Id); if (info.OrderID != B_Survey.GetMinOrderID(info.SurveyID)) { M_Question Pre = B_Survey.GetQuestion(B_Survey.PreQusID(info.SurveyID, info.OrderID)); int CurrOrder = info.OrderID; info.OrderID = Pre.OrderID; Pre.OrderID = CurrOrder; B_Survey.UpdateQuestion(info); B_Survey.UpdateQuestion(Pre); } } if (e.CommandName == "MoveNext") { M_Question info = B_Survey.GetQuestion(Id); if (info.OrderID != B_Survey.GetMaxOrderID(info.SurveyID)) { M_Question Pre = B_Survey.GetQuestion(B_Survey.NexQusID(info.SurveyID, info.OrderID)); int CurrOrder = info.OrderID; info.OrderID = Pre.OrderID; Pre.OrderID = CurrOrder; B_Survey.UpdateQuestion(info); B_Survey.UpdateQuestion(Pre); } } MyBind(); }
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); // } // } //} }
protected void BatDel_Btn_Click(object sender, EventArgs e) { B_Survey.DelQuestion(Request.Form["idchk"]); MyBind(); }
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 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(); } }