//保存
        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);
        }
Example #2
0
        //---------------------Tools
        //根据配置,添加多选或单选等
        private string AddSelTlp(M_QuestOption option, string tlp)
        {
            string result = "";

            foreach (string val in option.sel_op_body.Split(','))
            {
                //如何决定每行的数量,用width?
                result += string.Format(tlp, val);
            }
            return(result);
        }
Example #3
0
        public string GetTypeStr()
        {
            M_QuestOption option = JsonConvert.DeserializeObject <M_QuestOption>(Eval("QOption").ToString());

            switch (DataConverter.CLng(Eval("TypeID")))
            {
            case 0:
                return(option.Sel_Type_Rad_Str);

            case 1:
                return(option.Text_Str_DP_Str);

            default:
                return("未知");
            }
        }
Example #4
0
        public string GetResult()
        {
            int           qid         = Convert.ToInt32(Eval("Qid"));
            string        textTlp     = "<input type='text' class='{0} form-control text_300 result_text' name='result_" + qid + "' />";
            string        areaTlp     = "<textarea class='{0} form-control result_area'  name='result_" + qid + "'/>";
            string        radTlp      = "<label><input type='radio'  name='result_" + qid + "' value='{0}' />{0}</label>";
            string        checkboxTlp = "<label><input type='checkbox'  name='result_" + qid + "' value='{0}'/>{0}</label>";
            string        optionTlp   = "<option value='{0}'>{0}</option>";
            string        result      = "";
            M_QuestOption option      = JsonConvert.DeserializeObject <M_QuestOption>(Eval("Qoption", ""));

            switch (DataConverter.CLng(Eval("TypeID")))
            {
            case 0:
                switch (option.sel_type_rad)
                {
                case "radio":
                    result = AddSelTlp(option, radTlp);
                    break;

                case "checkbox":
                    result = AddSelTlp(option, checkboxTlp);
                    break;

                case "select":
                    result = "<select  name='result_" + qid + "'>" + AddSelTlp(option, optionTlp) + "</select>";
                    break;
                }
                result = "<div class='result_div num_" + option.sel_num_dp + "'>" + result + "</div>";
                break;

            case 1:
                switch (option.text_type_rad)
                {
                case "text":
                    result = textTlp;
                    break;

                case "textarea":
                    result = areaTlp;
                    break;
                }
                result = string.Format(result, option.text_str_dp);
                break;
            }
            return(result);
        }
Example #5
0
        //---------------------Front Page
        public string GetRules()
        {
            string result = "";

            result += (Eval("IsNull", "") == "1") ? "必填," : "";
            M_QuestOption option = JsonConvert.DeserializeObject <M_QuestOption>(Eval("Qoption", ""));

            switch (DataConverter.CLng(Eval("TypeID")))
            {
            case 0:    //选择
                result += option.Sel_Type_Rad_Str + ",";
                break;

            case 1:    //填空
                //必填, 至少1字, 只允许填写数字)
                if (option.text_str_dp != "none")
                {
                    result += "只允许" + option.Text_Str_DP_Str + ",";
                }
                break;
            }
            return(result.TrimEnd(','));
        }