예제 #1
0
        private void GetData(int scheduleId)
        {
            var dtScheduleQuestions = ScheduleQuestionDataManager.GetBySchedule(scheduleId, SessionVariables.RequestProfile);

            gvScheduleQuestions.DataSource = dtScheduleQuestions;
            gvScheduleQuestions.DataBind();
        }
예제 #2
0
        public static void SyncQuestions(int scheduleId, RequestProfile requestProfile)
        {
            // Get all ScheduleId related records from ScheduleQuestion
            var dtScheduleQuestion = ScheduleQuestionDataManager.GetBySchedule(scheduleId, requestProfile);

            // Get all Question Records
            var questionData = QuestionDataManager.GetList(requestProfile);

            // filter question records using Question Category 'EOD Questions'
            questionData.DefaultView.RowFilter = "QuestionCategory = 'EOD Questions'";
            questionData = questionData.DefaultView.ToTable();

            var scheduleQuestionData = new ScheduleQuestionDataModel();

            // for loop for entering default answers for all questions
            for (var i = 0; i < questionData.Rows.Count; i++)
            {
                var questionid = int.Parse(questionData.Rows[i][QuestionDataModel.DataColumns.QuestionId].ToString());

                var filterExpression = QuestionDataModel.DataColumns.QuestionId + " = " + questionid;

                // find if record for this question id exists in ScheduleQuestion for the particular ScheduleId
                var rows = dtScheduleQuestion.Select(filterExpression);

                // insert if no record found
                if (rows.Length == 0)
                {
                    scheduleQuestionData = new ScheduleQuestionDataModel();

                    scheduleQuestionData.ScheduleId = scheduleId;
                    scheduleQuestionData.QuestionId = int.Parse(questionid.ToString());
                    scheduleQuestionData.Answer     = "No";

                    ScheduleQuestionDataManager.Create(scheduleQuestionData, requestProfile);
                }
            }
            // refresh data table with newly added records
            dtScheduleQuestion = ScheduleQuestionDataManager.GetBySchedule(scheduleId, requestProfile);

            // for removing invalid category schedule questions
            for (var i = 0; i < dtScheduleQuestion.Rows.Count; i++)
            {
                var questionid = int.Parse(dtScheduleQuestion.Rows[i][ScheduleQuestionDataModel.DataColumns.QuestionId].ToString());

                var filterExpression = ScheduleQuestionDataModel.DataColumns.QuestionId + " = " + questionid;

                // find if record for this question id exists in ScheduleQuestion for the particular ScheduleId
                var rows = questionData.Select(filterExpression);

                // insert if no record found, so it is invalid
                if (rows.Length == 0)
                {
                    scheduleQuestionData = new ScheduleQuestionDataModel();
                    scheduleQuestionData.ScheduleQuestionId = int.Parse(dtScheduleQuestion.Rows[i][ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId].ToString());
                    ScheduleQuestionDataManager.Delete(scheduleQuestionData, requestProfile);
                }
            }
        }
예제 #3
0
        private DataTable GetScheduleQuestionData(int scheduleId)
        {
            var dt = ScheduleQuestionDataManager.GetBySchedule(scheduleId, SessionVariables.RequestProfile);
            var scheduleQuestiondt = ScheduleQuestionDataManager.GetList(SessionVariables.RequestProfile);
            var resultdt           = scheduleQuestiondt.Clone();

            foreach (DataRow row in dt.Rows)
            {
                var rows = scheduleQuestiondt.Select("ScheduleQuestionId = " + row[ScheduleQuestionDataModel.DataColumns.ScheduleQuestionId]);
                resultdt.ImportRow(rows[0]);
            }

            return(resultdt);
        }