Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveQuestion        saveQuestion    = null;
            string              quesModeID      = string.Empty;
            string              questionID      = string.Empty;
            MasterDataFunctions mDataFunc       = null;
            QBQuestions         qbQuestions     = null;
            List <QBQuestions>  qbQuestionsColl = null;
            QBInfo              qbInfo          = null;
            string              qbID            = string.Empty;

            try
            {
                mDataFunc       = new MasterDataFunctions();
                saveQuestion    = new SaveQuestion();
                qbQuestionsColl = new List <QBQuestions>();
                if (cbQB.SelectedItem != null)
                {
                    qbID = ((KeyValuePair <string, string>)cbQB.SelectedItem).Key;
                }

                htQBOrder.Clear();
                for (int i = 0; i < dgvQB.Rows.Count - 1; i++)
                {
                    htQBOrder.Add(dgvQB.Rows[i].Cells[0].Value, dgvQB.Rows[i].Cells[3].Value);
                }

                foreach (QuestionRelation qr in selectedQuestionRelation)
                {
                    qbQuestions = new QBQuestions();
                    qbQuestions.Question_Rel_ID = qr.ID;
                    qbQuestions.Order           = htQBOrder[qr.ID].ToString();
                    qbQuestions.EntityState     = QbQuestionsEntityState;
                    qbQuestionsColl.Add(qbQuestions);
                }

                qbInfo         = new QBInfo();
                qbInfo.ID      = string.IsNullOrWhiteSpace(qbID) ? string.Empty : qbID;
                qbInfo.QBName  = txtQBName.Text;
                qbInfo.Remarks = txtQBRemarks.Text;
                qbInfo.QBQuestionsEntityState = isQBQuestionChanged ? EntityOperationalState.Update : EntityOperationalState.None;
                qbInfo.EntityState            = QbQuestionsEntityState;
                qbInfo.QBQuestions            = qbQuestionsColl;

                isQBQuestionChanged = false;

                mDataFunc.AddQuestionBank(qbInfo);
                MessageBox.Show("Question Bank saved.");
                ResetAll();
                LoadQBCombo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveQuestion saveQuestion = null;
            string       quesGroupID  = string.Empty;
            string       quesTopicID  = string.Empty;
            string       quesModeID   = string.Empty;

            string questionID             = string.Empty;
            MasterDataFunctions mDataFunc = null;

            try
            {
                mDataFunc    = new MasterDataFunctions();
                saveQuestion = new SaveQuestion();
                quesGroupID  = ((KeyValuePair <string, string>)cbGroupType.SelectedItem).Key;
                quesTopicID  = ((KeyValuePair <string, string>)cbTopicType.SelectedItem).Key;
                quesModeID   = ((KeyValuePair <string, string>)cbQuestionMode.SelectedItem).Key;

                if (EditedQuestion != null)
                {
                    saveQuestion.ID = EditedQuestion.ID;
                }

                saveQuestion.Questionn    = txtQuestion.Text;
                saveQuestion.ComplexLevel = cbComplexlevel.Text;
                saveQuestion.Point        = txtPoint.Text;
                saveQuestion.EntityState  = QuestionOperatonState;

                questionID = mDataFunc.SaveQuestion(saveQuestion);
                saveQuestion.QuestionID = questionID;

                if (QuestionOperatonState == EntityOperationalState.New)
                {
                    SaveQuestionTypeForQuestion(saveQuestion);
                }

                ResetAll();
                LoadQuestionsGrid();
                EditedQuestion = null;

                MessageBox.Show("Question saved.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #3
0
        private void SaveQuestionTypeForQuestion(SaveQuestion saveQuestion)
        {
            string modeID      = string.Empty;
            string groupTypeID = string.Empty;
            string topicTypeID = string.Empty;
            MasterDataFunctions      mDataFunc        = null;
            SaveQuestionType         saveQuestionType = null;
            SaveQuestionTypes        questionType     = null;
            List <SaveQuestionTypes> questionTypeColl = null;

            try
            {
                groupTypeID = ((KeyValuePair <string, string>)cbGroupType.SelectedItem).Key;
                topicTypeID = ((KeyValuePair <string, string>)cbTopicType.SelectedItem).Key;
                modeID      = ((KeyValuePair <string, string>)cbQuestionMode.SelectedItem).Key;

                mDataFunc        = new MasterDataFunctions();
                saveQuestionType = new SaveQuestionType();
                questionType     = new SaveQuestionTypes();
                questionTypeColl = new List <SaveQuestionTypes>();

                questionType.Type = QuestionTypes.Topic;
                questionType.ID   = topicTypeID;
                questionTypeColl.Add(questionType);
                questionType      = new SaveQuestionTypes();
                questionType.Type = QuestionTypes.Mode;
                questionType.ID   = modeID;
                questionTypeColl.Add(questionType);

                saveQuestionType.QuestionID    = saveQuestion.QuestionID;
                saveQuestionType.Code          = string.Empty;
                saveQuestionType.Description   = string.Empty;
                saveQuestionType.Type          = QuestionTypes.Question;
                saveQuestionType.QuestionTypes = questionTypeColl;

                mDataFunc.SaveQuestionTypeRelation(saveQuestionType);
            }
            catch
            {
                throw;
            }
        }
        public string SaveQuestion(oEEntiti SaveQuestion)
        {
            DataTable    dtQuestion   = null;
            DataRow      drNew        = null;
            SaveQuestion saveQuestion = null;
            string       questionID   = string.Empty;

            try
            {
                saveQuestion = SaveQuestion as SaveQuestion;
                LoadXML();
                dtQuestion = oeEntity.Tables[EntityConstents.TBL_QUESTIONS];

                if (saveQuestion.EntityState == EntityOperationalState.New)
                {
                    drNew      = dtQuestion.NewRow();
                    questionID = Guid.NewGuid().ToString();
                    drNew[EntityConstents.COL_QUESTIONS_ID] = questionID;
                    dtQuestion.Rows.Add(drNew);
                }
                else
                {
                    questionID = saveQuestion.ID;
                    drNew      = dtQuestion.AsEnumerable().Where(ans => ans.Field <string>("ID") == saveQuestion.ID).SingleOrDefault();
                }

                if (drNew != null)
                {
                    drNew[EntityConstents.COL_QUESTIONS_QUESTION] = saveQuestion.Questionn;
                    drNew[EntityConstents.COL_QUESTIONS_LEVEL]    = saveQuestion.ComplexLevel;
                    drNew[EntityConstents.COL_QUESTIONS_POINT]    = saveQuestion.Point;

                    saveXML(oeEntity);
                }
            }
            catch
            {
                throw;
            }
            return(questionID);
        }