类别:程序开发
日期:2020-08-12 浏览:2023 评论:0
前端页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zymyddcb.aspx.cs" Inherits="SysFrameWeb.View.ViewQuestionnaire.zymyddcb" %> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"> <meta name="format-detection" content="telephone=no"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <meta name="screen-orientation" content="portrait"> <meta name="x5-orientation" content="portrait"> <title>首页</title> <link rel="stylesheet" type="text/css" href="assets/css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="assets/css/index.css"> <script src="assets/js/jquery-2.1.4.min.js"></script> </head> <body> <div id="body"> <form runat="server"> <section class="hdinfo"> <div class="hd-title" id="titleName" runat="server">出院一周后患者随访</div> <asp:HiddenField ID="hidSID" runat="server" /> <div class="hd-dsc" style="margin-top: 10px;">请您协助完成以下随访调查,感谢您的配合!</div> </section> <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemCreated"> <ItemTemplate> <div class="section"> <div class="sec-title"> <div class="item-titlebd"></div> <div class="item-titlebg"><%#Eval("TypeName") %></div> <asp:HiddenField ID="stTypeID" runat="server" Value='<%#Eval("ID") %>' /> </div> <asp:Repeater ID="Repeater2" runat="server"> <ItemTemplate> <div class="sec-item"> <div class="item-title"><em class="colred">* </em><%#Eval("TitleName") %><span class="col92">(<%#Eval("lxName") %>)</span></div> <input type="hidden" name="thid" value="<%#Eval("ID") %>" /> <input type="hidden" name="dtid" /> <!--文本--> <textarea class="item-con-textarea" placeholder="请留下您的意见吧" style="<%#Eval("lx").ToString()=="4"?"display:block":"display:none;"%>" onblur="onradclick(<%#Eval("lx") %>,$(this));"></textarea> <!--单选 判断--> <ul class="item-con" style="<%#Eval("lx").ToString()=="0" || Eval("lx").ToString()=="2"?"display:block":"display:none;"%>"> <li class="radio" style="<%#Eval("OptionA").ToString()==""?"display:none":"display:block"%>"> <label> <input type="radio" name="m<%#Eval("ID") %>" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionA") %>"> <%#Eval("OptionA") %> </label> </li> <li class="radio" style="<%#Eval("OptionB").ToString()==""?"display:none":"display:block"%>"> <label> <input type="radio" name="m<%#Eval("ID") %>" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionB") %>"> <%#Eval("OptionB") %> </label> </li> <li class="radio" style="<%#Eval("OptionC").ToString()==""?"display:none":"display:block"%>"> <label> <input type="radio" name="m<%#Eval("ID") %>" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionC") %>"> <%#Eval("OptionC") %> </label> </li> <li class="radio" style="<%#Eval("OptionD").ToString()==""?"display:none":"display:block"%>"> <label> <input type="radio" name="m<%#Eval("ID") %>" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionD") %>"> <%#Eval("OptionD") %> </label> </li> </ul> <!--多选---> <ul class="item-con" style="<%#Eval("lx").ToString()=="1"?"display:block":"display:none;"%>"> <li class="checkbox" style="<%#Eval("OptionA").ToString()==""?"display:none":"display:block"%>"> <label> <input type="checkbox" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionA") %>"> <%#Eval("OptionA") %> </label> </li> <li class="checkbox" style="<%#Eval("OptionB").ToString()==""?"display:none":"display:block"%>"> <label> <input type="checkbox" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionB") %>"> <%#Eval("OptionB") %> </label> </li> <li class="checkbox" style="<%#Eval("OptionC").ToString()==""?"display:none":"display:block"%>"> <label> <input type="checkbox" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionC") %>"> <%#Eval("OptionC") %> </label> </li> <li class="checkbox" style="<%#Eval("OptionD").ToString()==""?"display:none":"display:block"%>"> <label> <input type="checkbox" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionD") %>"> <%#Eval("OptionD") %> </label> </li> <li class="checkbox" style="<%#Eval("OptionE").ToString()==""?"display:none":"display:block"%>"> <label> <input type="checkbox" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionE") %>"> <%#Eval("OptionE") %> </label> </li> <li class="checkbox" style="<%#Eval("OptionF").ToString()==""?"display:none":"display:block"%>"> <label> <input type="checkbox" onchange="onradclick(<%#Eval("lx") %>,$(this));" value="<%#Eval("OptionF") %>"> <%#Eval("OptionF") %> </label> </li> </ul> </div> </ItemTemplate> </asp:Repeater> </div> </ItemTemplate> </asp:Repeater> <div class="btn-group"> <input type="hidden" id="thzh" runat="server" /> <input type="hidden" id="dtzh" runat="server" /> <asp:Button ID="Button1" runat="server" Text="填好了,我要提交" OnClientClick="return onclicks() " OnClick="Unnamed_ServerClick" CssClass="btn btn-default"/> <%--<a class="btn btn-default" onclik="onclicks()" runat="server" onserverclick="Unnamed_ServerClick">填好了,我要提交</a>--%> </div> </form> </div> </body> </html> <script type="text/javascript"> function onclicks() { var m = ""; var n = ""; $("input[name='thid']").each(function () { m += $("#thzh").val() + $(this).val() + "|"; }); $("input[name='dtid']").each(function () { n += $("#dtzh").val() + $(this).val() + "|"; }); $("#thzh").val(m); $("#dtzh").val(n); } function onradclick(a, b) { if (a == 4) { b.parent().find("input[name='dtid']").val(b.val()); } else if (a == 0 || a == 2) { var msg = ""; b.parent().parent().parent().find("input[type='radio']:checked:checked").each(function () { //$(this).parent().parent().parent().parent().find("input[name='dtid']").val($(this).val()); msg += $(this).val(); }) b.parent().parent().parent().parent().find("input[name='dtid']").val(msg); } else if (a == 1) { var msg = ""; b.parent().parent().parent().find("input[type='checkbox']:checkbox:checked").each(function () { //$(this).parent().parent().parent().parent().find("input[name='dtid']").val($(this).val()); msg += $(this).val() + "$"; }) b.parent().parent().parent().parent().find("input[name='dtid']").val(msg); } } </script>
后台页面处理
using SysFrameDbUntity; using SysFrameModel; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using SysFrameCommon; namespace SysFrameWeb.View.ViewQuestionnaire { public partial class zymyddcb : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { hidSID.Value = "1"; AQ_SystemSet Model = new AQ_SystemSetB().GetEntity(d => d.Del == "0" && d.ID.ToString() == hidSID.Value && d.MultipleQuestion == 1); titleName.InnerText = Model.TestTitle; GetDataBind(Model.SingleQuestion.ToString()); } } protected void Repeater1_ItemCreated(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Repeater rptStudentInfo = e.Item.FindControl("Repeater2") as Repeater; HiddenField tb = e.Item.FindControl("stTypeID") as HiddenField; if (rptStudentInfo != null) { string sid = tb.Value; AQ_SystemSet Model = new AQ_SystemSetB().GetEntity(d => d.Del == "0" && d.ID.ToString() == hidSID.Value && d.MultipleQuestion == 1); string tid = Model.ExamTime; DataTable dt = new AQ_SafeQuestionB().GetDtQuestion(sid, tid); rptStudentInfo.DataSource = dt; rptStudentInfo.DataBind(); } } } public void GetDataBind(string ttid) { DataTable dt = new AQ_SafeTypeB().GetEntities(d => d.tt == ttid && d.Del == "0").ToDataTable(); Repeater1.DataSource = dt; Repeater1.DataBind(); } protected void Unnamed_ServerClick(object sender, EventArgs e) { string uid = "123"; string m = thzh.Value; string n = dtzh.Value; List<AQ_UserQuestion> aulist = new List<AQ_UserQuestion>(); string[] str = m.Split('|'); string[] strValue = n.Split('|'); for (int i = 0; i < str.Length - 1; i++) { AQ_UserQuestion au = new AQ_UserQuestion(); au.UserWechat = uid; au.CRUser = str[i].ToString(); au.STsetID = hidSID.Value; au.CRDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); au.STResult = strValue[i].ToString(); au.Del = "0"; aulist.Add(au); } if (aulist.Count > 0) { bool flag = new AQ_UserQuestionB().Insert(aulist); if (flag) { Response.Redirect("index.aspx"); } } } } }
本文标题:C# 一般考试题目页面问题的处理~
本文链接:https://vtzw.com/post/243.html
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。
发表评论 / 取消回复