示例#1
0
        private void GetActStr(Questionnaire_Info model, int listCount, int i)
        {
            StringBuilder actStr = new StringBuilder();

            actStr.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"250\"><tr><form name=\"upform\"><td width=\"70\">");
            if (i > 0)
            {
                actStr.Append($"<select id=\"stepUp{model.Id}\" > ");
                for (int j = 1; j <= i; j++)
                {
                    actStr.Append("<option value=\"" + j + "\">" + j + "</option>");
                }
                actStr.Append($"</select><input type=\"button\" name=\"Submit2\" value=\"↑\" class=\"btn btn-default\" onclick=\"SetMove('{model.Id}','{model.SubjectId}','up')\"> ");
            }
            actStr.Append("</td></form><form name=\"downform\"><td  width=\"70\">");
            if (i < listCount - 1)
            {
                actStr.Append($"<select id=\"stepDown{model.Id}\" > ");
                for (int j = 1; j <= listCount - i - 1; j++)
                {
                    actStr.Append("<option value=\"" + j + "\">" + j + "</option>");
                }
                actStr.Append($"</select><input type=\"button\" name=\"Submit2\" value=\"↓\" class=\"btn btn-default\" onclick=\"SetMove('{model.Id}','{model.SubjectId}','down')\"> ");
            }
            actStr.Append("</td></form></tr></table>");
            model.actStr = actStr.ToString();
        }
示例#2
0
        public ActionResult Edit(int id = 0)
        {
            Questionnaire_Info model = null;

            if (id > 0)
            {
                model = Bll.BllQuestionnaire_Info.First(o => o.Id == id);
            }

            ViewBag.subjectId = RequestInt("subjectId");
            ViewBag.typeHtml  = Tools.Enums.Tools.GetOptionHtml(typeof(Tools.Enums.Site.InputType), (byte)(model?.Type ?? 0));
            return(View(model));
        }
示例#3
0
        public ActionResult Save(List <string> option = null, List <string> optionCheck = null)
        {
            int    id        = RequestInt("id");
            string title     = RequestString("title");
            string remark    = RequestString("remark");
            int    score     = RequestInt("score");
            byte   type      = RequestByte("type");
            int    subjectId = RequestInt("subjectId");
            bool   isshow    = RequestBool("isshow");

            if (option == null || option.Count == 0)
            {
                return(MessageBoxAndReturn("请填写至少一个选项!"));
            }
            if (type != (byte)Tools.Enums.Site.InputType.Text && (optionCheck == null || optionCheck.Count == 0))
            {
                return(MessageBoxAndReturn("请勾选一个正确答案!"));
            }

            //判断答案是否存在于选项中,并获取
            string answer    = string.Empty;
            var    hasAnswer = false;

            foreach (var item in optionCheck)
            {
                if (option.Contains(item))
                {
                    hasAnswer = true;
                    answer   += item + ",";
                }
            }
            if (!hasAnswer)
            {
                return(MessageBoxAndReturn("请勾选一个正确答案!"));
            }

            Questionnaire_Info model     = null;
            string             classHtml = string.Empty;

            if (id > 0)
            {
                model = Bll.BllQuestionnaire_Info.First(o => o.Id == id);
                if (model == null)
                {
                    return(MessageBoxAndReturn("题目不存在!"));
                }
                model.SubjectId = subjectId;
                model.Type      = type;
                model.Title     = title;
                model.Remark    = remark;
                model.Score     = score;
                model.Options   = string.Join(",", option);
                model.Answer    = answer.TrimEnd(',');
                model.IsShow    = isshow;

                if (Bll.BllQuestionnaire_Info.Update(model, o => o.Id == id) > 0)
                {
                    return(LayerAlertSuccessAndRefresh("修改成功"));
                }
                else
                {
                    return(LayerAlertSuccessAndRefresh("修改失败"));
                }
            }
            else
            {
                model           = new Questionnaire_Info();
                model.SubjectId = subjectId;
                model.Type      = type;
                model.Title     = title;
                model.Remark    = remark;
                model.Score     = score;
                model.Options   = string.Join(",", option);
                model.Answer    = answer.TrimEnd(',');
                model.IsShow    = isshow;
                model.Sequence  = Bll.BllSys_Class <Questionnaire_Info> .Instance().GetNextSequence("SubjectId=" + subjectId);

                if (Bll.BllQuestionnaire_Info.Insert(model) > 0)
                {
                    return(LayerAlertSuccessAndRefresh("添加成功"));
                }
                else
                {
                    return(LayerAlertSuccessAndRefresh("添加失败"));
                }
            }
        }