Exemplo n.º 1
0
        private void createCheckBoxes()
        {
            SurveyLogicControl surveyLogicControl = new SurveyLogicControl();

            /* Bank check box list */
            List <QuestionAnswerOptions> bankQuestionAnswerOptionsList =
                surveyLogicControl.getListOfQuestionAnswerOptionByQuestionId(AppConstants.questionBank);

            for (var i = 0; i < bankQuestionAnswerOptionsList.Count; i++)
            {
                ListItem item = new ListItem(bankQuestionAnswerOptionsList[i].AnswerDescription,
                                             bankQuestionAnswerOptionsList[i].SurveyAnswerOptionId.ToString());
                BankCheckBoxList.Items.Add(item);
            }

            /* Bank Services check box list */
            List <QuestionAnswerOptions> bankServiceQuestionAnswerOptionsList =
                surveyLogicControl.getListOfQuestionAnswerOptionByQuestionId(AppConstants.questionBankServices);

            for (var i = 0; i < bankServiceQuestionAnswerOptionsList.Count; i++)
            {
                ListItem item = new ListItem(bankServiceQuestionAnswerOptionsList[i].AnswerDescription,
                                             bankServiceQuestionAnswerOptionsList[i].SurveyAnswerOptionId.ToString());
                ServicesCheckBoxList.Items.Add(item);
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ErrorMessageLabel.Text      = "";
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Black;
                SurveyLogicControl surveyLogicControl = new SurveyLogicControl();
                Question           question           = new Question();
                int currentQuestionSequence           = 0;

                if (string.IsNullOrEmpty(SessionControlUtil.getUserIPAddress()))
                {
                    string userIPAddress = AppUtil.getUserIPAddress();

                    if (!string.IsNullOrEmpty(userIPAddress))
                    {
                        Respondent respondent = new Respondent();
                        respondent.IpAddress = userIPAddress;
                        int userID = surveyLogicControl.insertRespondent(respondent);
                        SessionControlUtil.setUserID(userID);
                        SessionControlUtil.setUserIPAddress(userIPAddress);
                    }

                    // First time.
                    // Get the first question and set the session attributes control
                    question = surveyLogicControl.getNextQuestionBySequence(currentQuestionSequence);
                    SessionControlUtil.setCurrentQuestion(question);
                    SessionControlUtil.setCurrentQuestionSequence(question.QuestionSequence);
                    SessionControlUtil.incrementCurrentQuestionLevel();
                    HttpContext.Current.Session[AppConstants.sessionQuestionsAnswerList] = new List <SurveyQuestionAnswer>();
                }
                else
                {
                    question = SessionControlUtil.getCurrentQuestion();
                }

                this.displayQuestion(question);
            }
            catch (Exception ex)
            {
                /* IMPORTANT !!
                 * // No matter what was the error, user can not start, continue or
                 * // finalize the pageSurvey. So:
                 * // - A log (simulation) with the exception was done on the place that have occurred
                 * // - The exception comes till the final layer, shows a generic error to the user
                 * // - Insert more information on the log (simulation)
                 * */
                ErrorMessageLabel.Text      = AppConstants.errorSystemError;
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Red;

                //Error log simulated
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
            }
        }
Exemplo n.º 3
0
        protected void NextButton_Click(object sender, EventArgs e)
        {
            // Get the answer from last question and store on session
            // after pageload and all ui elements re-built dynamically and viewstate copied over
            this.setSurveyQuestionAnswer();

            //Get the next question
            int                currentQuestionSequence = SessionControlUtil.getCurrentQuestionSequence();
            Question           question           = null;
            SurveyLogicControl surveyLogicControl = new SurveyLogicControl();

            // Verify the level and additional questions to show before continuing
            // the sequence of the main questions
            if (SessionControlUtil.getCurrentQuestionsLevel() > 1)
            {
                int nextQuestionId = SessionControlUtil.getNexQuestionIdFromAdditionalQuestionCurrentLevelList();
                question = surveyLogicControl.getQuestionAndAnswersByIQuestionID(nextQuestionId);
            }
            else
            {
                question = surveyLogicControl.getNextQuestionBySequence(currentQuestionSequence);

                //If there is not more questions the method surveyLogicControl.getNextQuestionBySequence
                // will return zero that means there are no more questions on sequence.
                if (question.QuestionSequence == 0)
                {
                    // Get the list of questions answered from session
                    List <SurveyQuestionAnswer> surveyQuestionAnswerList = new List <SurveyQuestionAnswer>();
                    surveyQuestionAnswerList = SessionControlUtil.getSurveyQuestionAnswerList();

                    // Call the logic control to record the complete pageSurvey in the database
                    surveyLogicControl.insertAnsweredSurvey(surveyQuestionAnswerList);

                    Response.Redirect(AppConstants.pageSurveyComplete);
                }
                else
                {
                    SessionControlUtil.setCurrentQuestionSequence(question.QuestionSequence);
                }
            }

            // Store the next question to be showed on the session
            // as current question.
            SessionControlUtil.setCurrentQuestion(question);


            // Redirect back to pageSurvey.aspx to continue the pageSurvey
            // on next question.
            Response.Redirect(AppConstants.pageSurvey);
        }
Exemplo n.º 4
0
        protected void SearchButton_Click(object sender, EventArgs e)
        {
            SurveyLogicControl surveyLogicControl = new SurveyLogicControl();

            List <int> answerOptionIdList = new List <int>();


            foreach (ListItem item in BankCheckBoxList.Items)
            {
                if (item.Selected == true)
                {
                    answerOptionIdList.Add(AppUtil.convertStringToInt(item.Value));
                }
            }


            foreach (ListItem item in ServicesCheckBoxList.Items)
            {
                if (item.Selected == true)
                {
                    answerOptionIdList.Add(AppUtil.convertStringToInt(item.Value));
                }
            }
            try
            {
                SearchGridView.DataSource =
                    surveyLogicControl.searchSurveyByAnswerIDLastNameOrGivenNames(answerOptionIdList, LastNameTextBox.Text, GivenNamesTextBox.Text);
                SearchGridView.DataBind();

                if (SearchGridView.Rows.Count == 0)
                {
                    ErrorMessageLabel.Text      = AppConstants.errorNoRecordsFound;
                    ErrorMessageLabel.ForeColor = System.Drawing.Color.Blue;
                }
            }
            catch (AppControlException ex)
            {
                ErrorMessageLabel.Text      = ex.Message;
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Red;
            }
            this.clearSearchFields();
        }
Exemplo n.º 5
0
        protected void ConfirmRegistrationButton_Click(object sender, EventArgs e)
        {
            try
            {
                int userId = SessionControlUtil.getUserID();

                Respondent respondent = new Respondent();
                respondent.RespondentId = userId;
                respondent.GivenNames   = GivenNameTextBox.Text;
                respondent.LastName     = LastNameTextBox.Text;
                respondent.PhoneNumber  = PhoneNumberTextBox.Text;

                if (DateOfBirthCustomValidator.IsValid)
                {
                    DateTime dateOfBirth = DateTime.Parse(DateOfBirthTextBox.Text);
                    respondent.DateOfBirth = dateOfBirth;
                }
                else
                {
                    return;
                }

                SurveyLogicControl surveyLogicControl = new SurveyLogicControl();
                surveyLogicControl.updateRespondent(respondent);
                Response.Redirect(AppConstants.pageRegisterComplete);
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text      = AppConstants.errorSystemError;
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Red;

                //Error log simulated
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                throw;
            }
        }
Exemplo n.º 6
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            try
            {
                int    staffId       = AppUtil.convertStringToInt(UserIdTextBox.Text);
                String staffPassword = PasswordTextBox.Text;

                SurveyLogicControl surveyLogicControl = new SurveyLogicControl();
                if (surveyLogicControl.staffLoginValidation(staffId, staffPassword))
                {
                    SessionControlUtil.setUserID(staffId);
                    Response.Redirect(AppConstants.pageSearch, false);
                }
                else
                {
                    ErrorMessageLabel.ForeColor = System.Drawing.Color.Red;
                    ErrorMessageLabel.Text      = AppConstants.errorInvalidLogin;
                }
            }
            catch (Exception ex)
            {
                /* IMPORTANT !!
                 * // No matter what was the error, user can not start, continue or
                 * // finalize the pageSurvey. So:
                 * // - A log (simulation) with the exception was done on the place that have occurred
                 * // - The exception comes till the final layer, shows a generic error to the user
                 * // - Insert more information on the log (simulation)
                 * */
                ErrorMessageLabel.Text      = AppConstants.errorSystemError;
                ErrorMessageLabel.ForeColor = System.Drawing.Color.Red;

                //Error log simulated
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
            }
        }