コード例 #1
0
        void AppendNeedCommentUI(HtmlTableCell cell, SurveyOptions option, CheckBox uiAssociatedBy)
        {
            var uiSpan = new HtmlGenericControl("div");

            uiSpan.Attributes["class"] = Css_NeedComment_Section;

            var uiId = string.Format("{0}{1}", Id_NeedComment_Prefix, option.Id);

            var tb = new TextBox
            {
                ID       = uiId,
                CssClass = Css_NeedComment_Input,
            };

            RequiredFieldValidator vldReq = new RequiredFieldValidator
            {
                ID = string.Format("req{0}", uiId),
                ControlToValidate  = tb.ID,
                Display            = ValidatorDisplay.Static,
                ErrorMessage       = "必填选项",
                EnableClientScript = true,
            };

            uiSpan.Controls.Add(tb);
            uiSpan.Controls.Add(vldReq);

            // Need to paste the associating client controls' ClientId to the newly created control.
            // ClientId doesn't work properly at this stage, have to do this in OnPreRender event.
            NeedCommentVMList.Add(new NeedCommentViewModel {
                Container = uiSpan, ControlToAssociat = uiAssociatedBy, ValidatorToAssociat = vldReq
            });

            cell.Controls.Add(uiSpan);
        }
コード例 #2
0
        public void GetSurveyInfo(string Id)
        {
            //浏览量+1
            surveyBaseBLL.PlusOne(Id, OperatType.PV);
            string stateText = "";
            var    readrows  = messageReadBLL.GetList(OperatorProvider.Provider.Current().UserId).Where(t => t.Category == surveyCategory && t.MessageId.Equals(Id)).FirstOrDefault();;

            if (readrows == null)
            {
                stateText = "未读";
            }
            else if (readrows.AppRead && readrows.SubmitMark)
            {
                stateText = "已读已完成";
            }
            else if (readrows.AppRead && !readrows.SubmitMark)
            {
                stateText = "已读未完成";
            }
            else
            {
                stateText = "已读未完成";
            }
            SurveyBaseEntity            surveyBaseEntity     = new SurveyBaseEntity();
            List <SurveyQuestionEntity> surveyQuestionEntity = new List <SurveyQuestionEntity>();
            List <SurveyOptionsEntity>  surveyOptionsEntity  = new List <SurveyOptionsEntity>();

            //答案选项
            SurveyAnswerBaseEntity          surveyAnswerBaseEntity   = new SurveyAnswerBaseEntity();
            List <SurveyAnswerDetailEntity> surveyAnswerDetailEntity = new List <SurveyAnswerDetailEntity>();

            SurveyBase surveyInfo = new SurveyBase();

            surveyBaseEntity     = surveyBaseBLL.GetEntity(Id);
            surveyQuestionEntity = surveyQuestionBLL.GetList(Id);//.OrderBy(t => t.SortCode).ToList();
            surveyOptionsEntity  = surveyOptionsBLL.GetList(Id);
            //答案选项
            surveyAnswerBaseEntity = surveyAnswerBaseBLL.GetList().Where(t => t.UserId == OperatorProvider.Provider.Current().UserId&& t.SurveyId == Id).FirstOrDefault();
            if (surveyAnswerBaseEntity != null && !string.IsNullOrWhiteSpace(surveyAnswerBaseEntity.Id))
            {
                surveyAnswerDetailEntity = surveyAnswerDetailBLL.GetList(surveyAnswerBaseEntity.Id);
            }

            //赋值
            surveyInfo.Id         = surveyBaseEntity.Id;
            surveyInfo.Category   = surveyBaseEntity.Category;
            surveyInfo.CreateDate = surveyBaseEntity.CreateDate;

            surveyInfo.Title              = surveyBaseEntity.Title;
            surveyInfo.TitleColor         = surveyBaseEntity.TitleColor;
            surveyInfo.OperateSDate       = surveyBaseEntity.OperateSDate;
            surveyInfo.OperateEDate       = surveyBaseEntity.OperateEDate;
            surveyInfo.JoinCount          = surveyBaseEntity.JoinCount;
            surveyInfo.PV                 = surveyBaseEntity.PV;
            surveyInfo.SurveyQuestionList = new List <SurveyQuestion>();
            for (int i = 0; i < surveyQuestionEntity.Count; i++)
            {
                SurveyQuestion surveyQuestion = new SurveyQuestion();
                surveyQuestion.QuestionId = surveyQuestionEntity[i].QuestionId;
                surveyQuestion.Category   = surveyQuestionEntity[i].Category;
                surveyQuestion.Title      = surveyQuestionEntity[i].Title;
                surveyQuestion.CreateDate = surveyQuestionEntity[i].CreateDate;
                surveyQuestion.Score      = surveyQuestionEntity[i].Score;
                surveyQuestion.SortCode   = surveyQuestionEntity[i].SortCode;
                surveyQuestion.SurveyId   = surveyQuestionEntity[i].SurveyId;
                if (surveyQuestion.Category == "7")
                {
                    surveyQuestion.Content = surveyAnswerDetailEntity.Where(t => t.QuestionId == surveyQuestion.QuestionId).FirstOrDefault().Content;
                }
                surveyQuestion.SurveyOptionsList = new List <SurveyOptions>();
                var surveyOptionsList = surveyOptionsEntity.Where(t => t.QuestionId == surveyQuestionEntity[i].QuestionId).ToList();
                if (surveyOptionsList.Count > 0)
                {
                    for (int k = 0; k < surveyOptionsList.Count; k++)
                    {
                        SurveyOptions surveyOptions = new SurveyOptions();
                        surveyOptions.OptionId   = surveyOptionsList[k].OptionId;
                        surveyOptions.SurveyId   = surveyOptionsList[k].SurveyId;
                        surveyOptions.QuestionId = surveyOptionsList[k].QuestionId;
                        surveyOptions.SortCode   = surveyOptionsList[k].SortCode;
                        surveyOptions.Content    = surveyOptionsList[k].Content;
                        surveyOptions.CreateDate = surveyOptionsList[k].CreateDate;
                        surveyOptions.Category   = surveyOptionsList[k].Category;
                        surveyOptions.IsAnswer   = false;
                        if (surveyQuestion.Category == "1" || surveyQuestion.Category == "2")
                        {
                            surveyOptions.IsAnswer = surveyAnswerDetailEntity.Where(t => t.OptionId == surveyOptions.OptionId).ToList().Count > 0 ? true : false;;
                        }
                        surveyQuestion.SurveyOptionsList.Add(surveyOptions);
                    }
                }
                surveyInfo.SurveyQuestionList.Add(surveyQuestion);
            }
            ViewBag.stateText  = stateText;
            ViewBag.SurveyBase = surveyInfo;
        }
コード例 #3
0
 public ActionResult Create(SurveyOptions surveyOptions)
 {
     unitOfWork.SurveyOptions.AddSurveyOption(surveyOptions);
     unitOfWork.SaveChanges();
     return(RedirectToAction("Index"));
 }