// Debug: Currently not used
//    private void TextBox_TextChanged(object sender, System.EventArgs e)
//    {
//      TextFormat format;
//      TextBoxEx textBox;
//
//      if (sender.GetType().Name == "TextBoxEx")
//      {
//        textBox = sender as TextBoxEx;
//        format = (textBox.Tag as RespondentInfo).Formatting;
//
//        int selStart = textBox.SelectionStart;
//        textBox.Text = textBox.Text.ToUpper();
//        textBox.SelectionStart = selStart;
//      }
//    }


        /// <summary>
        /// This event is fired when the user leaves a textbox.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBox_LostFocus(object sender, System.EventArgs e)
        {
            TextBoxEx      textBox  = sender as TextBoxEx;
            RespondentInfo respInfo = textBox.Tag as RespondentInfo;
            TextFormat     format   = respInfo.Formatting;

            switch (format)
            {
            case TextFormat.NumericOnly:
                // Do nothing, because this was handled in the KeyPress event
                break;

            case TextFormat.LowerCase:
                textBox.Text = textBox.Text.ToLower().Trim();
                break;

            case TextFormat.UpperCase:
                textBox.Text = textBox.Text.ToUpper().Trim();
                break;

            case TextFormat.ProperCase:
                textBox.Text = Tools.ProperCase(textBox.Text).Trim();
                break;

            case TextFormat.None:
                textBox.Text = textBox.Text.Trim();
                break;

            default:
                Debug.Fail("Unknown formatting code: " + format.ToString(), "frmRespondent.TextBox_LostFocus");
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 提交问卷
        /// </summary>
        /// <param name="resultVO"></param>
        /// <returns></returns>
        public ResultVO SubmitSurvey(SurveyResultVO resultVO)
        {
            ResultVO result = new ResultVO()
            {
                Result = 0
            };

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    RespondentInfo respondent = new RespondentInfo()
                    {
                        RespondentName = resultVO.Username,
                        MobilePhone    = resultVO.Mobile,
                        Age            = resultVO.Age,
                        Gender         = resultVO.Gender == 0 ? null : (resultVO.Gender == 1 ? "男" : "女"),
                        EduBackground  = string.IsNullOrEmpty(GetEduString(resultVO.Edu)) ? null : GetEduString(resultVO.Edu),
                        Location       = resultVO.Location,
                        MaritalStatus  = string.IsNullOrEmpty(GetMaritalString(resultVO.Marital)) ? null : GetMaritalString(resultVO.Marital),
                        Referrer       = resultVO.Refer,
                        Suggestion     = resultVO.Suggestion,
                        CreateTime     = CurrentServerTime,
                        Deleted        = false,
                        Occupation     = string.IsNullOrEmpty(GetPosString(resultVO.Position)) ? null : GetPosString(resultVO.Position)
                    };

                    var insertedResp = _respondentInfoRepository.Insert(respondent);
                    _unitOfWork.Commit();

                    var tmpOpt = resultVO.Options.Split(',').ToList().FindAll(o => o.Contains("#"));
                    tmpOpt.ForEach(o =>
                    {
                        var questionId  = Convert.ToInt32(o.Split('#')[0]);
                        var questionAns = o.Split('#')[1];

                        SurveyResult surveyResult = new SurveyResult()
                        {
                            SurveyId        = resultVO.SurveyId,
                            RespondentId    = insertedResp.RespondentId,
                            QuestionId      = questionId,
                            SelectedOptions = questionAns,
                            CreateTime      = CurrentServerTime
                        };

                        _surveyResultRepository.Insert(surveyResult);
                        _unitOfWork.Commit();
                    });

                    trans.Complete();
                    result.Result = 1;
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }

            return(result);
        }
Esempio n. 3
0
        public RespondentInfo Put(int id, [FromBody] UpdateRespondentRequest value)
        {
            var existingRespondent = _respondentsRepository.Get(id);

            existingRespondent.Name           = value.Name ?? existingRespondent.Name;
            existingRespondent.Email          = value.Email ?? existingRespondent.Email;
            existingRespondent.HashedPassword = _hashingService.HashString(value.NewPassword) ?? existingRespondent.HashedPassword;

            _respondentsRepository.Update(existingRespondent);

            return(RespondentInfo.FromEntity(existingRespondent));
        }
Esempio n. 4
0
 public RespondentInfo Post([FromBody] NewRespondentRequest value)
 => RespondentInfo.FromEntity(_respondentsRepository.Add(value.ToEntity(_hashingService)));
Esempio n. 5
0
 public RespondentInfo Get(int id) => RespondentInfo.FromEntity(_respondentsRepository.Get(id));
Esempio n. 6
0
        /// <summary>
        ///  Shows each respondent's answer to each question in a survey
        /// </summary>
        /// <param name="ResponseResultList">A list of responses from each person who responded to the survey</param>
        /// <param name="RespondentList">A list of respondents who answered the survey</param>
        /// <param name="SurveyQuestions">Contains a list of questions and a list of answers for each question/param>
        public void Flatten(GetResponsesResult[] ResponseResultList, RespondentInfo[] RespondentList, SurveyQuestionView SurveyQuestions)
        {
            List <ResponseWithAnswer> rwaList = new List <ResponseWithAnswer>();

            foreach (GetResponsesResult response in ResponseResultList)
            {
                List <RespondentInfo> rList = RespondentList.Where(e => e.RespondentID == response.RespondentID).ToList <RespondentInfo>();
                if (rList != null)
                {
                    RespondentInfo respondant = rList[0];
                    foreach (QuestionInfo qInfo in response.QuestionList)
                    {
                        List <QuestionInfo> question         = SurveyQuestions.QuestionList.Where(e => e.QuestionID == qInfo.QuestionID).ToList <QuestionInfo>();
                        QuestionInfo        responseQuestion = question[0];
                        qInfo.QuestionType = responseQuestion.QuestionType;

                        foreach (AnswerInfo aInfo in qInfo.QuestionAnswerList)
                        {
                            ResponseWithAnswer rwa = new ResponseWithAnswer();

                            AnswerInfo         qi       = new AnswerInfo();
                            QuestionFamilyEnum qaFamily = responseQuestion.QuestionType.Family;
                            switch (qaFamily)
                            {
                            case QuestionFamilyEnum.SingleChoice:
                                rwa.Answer = ProcessAnswer(responseQuestion, aInfo);
                                break;

                            case QuestionFamilyEnum.MultipleChoice:
                                rwa.Answer = ProcessAnswer(responseQuestion, aInfo);
                                break;

                            case QuestionFamilyEnum.Matrix:
                                rwa.Row    = ProcessRow(responseQuestion, aInfo);
                                rwa.Answer = ProcessAnswer(responseQuestion, aInfo);
                                break;

                            case QuestionFamilyEnum.OpenEnded:
                                rwa.Answer = aInfo.Text;
                                break;

                            case QuestionFamilyEnum.DateTime:
                                rwa.Row    = ProcessRow(responseQuestion, aInfo);
                                rwa.Answer = aInfo.Text;
                                break;

                            case QuestionFamilyEnum.Demographic:
                                rwa.Row    = ProcessRow(responseQuestion, aInfo);
                                rwa.Answer = aInfo.Text;
                                break;

                            case QuestionFamilyEnum.NotSet:
                                break;

                            case QuestionFamilyEnum.Presentation:
                                break;

                            case QuestionFamilyEnum.CustomVariable:
                                break;

                            default: rwa.Answer = "Answer choice cannot be found in answer bank for this question";
                                break;
                            }

                            rwa.Question        = responseQuestion.Heading;
                            rwa.QuestionID      = responseQuestion.QuestionID;
                            rwa.QuestionSubtype = responseQuestion.QuestionType.Subtype;
                            rwa.QuestionType    = qaFamily;


                            rwa.User         = respondant.Email;
                            rwa.RespondentID = respondant.RespondentID;
                            rwa.RecipientID  = respondant.RecipientID;
                            rwaList.Add(rwa);
                        }
                    }
                }
            }

            ResponseAnswerList = rwaList;
        }