/// <summary>
        /// This method Deletes a category if the category is not used for any question
        /// </summary>
        /// <param name="oListCategory"> It takes List<Category> Object </param>
        /// <param name="iArrCheck"> It is an integer array to indicate the marked categories</param>
        /// <returns> It returns Result Object </returns>
        public Result CategoryDelete(List<Category> oListCategory, int[] iArrCheck)
        {
            //new CLogger("Start CategoryDelete CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start CategoryDelete CategoryDAO+DAO", ELogLevel.Debug);

            logger.Info("Start CategoryDelete CategoryDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sDelete = String.Empty;

            List<String> oListString = new List<String>();

            int i = 0;

            try
            {
                for (i = 0; i < iArrCheck.Length; i++)
                {
                    if (iArrCheck[i] == 1)
                    {
                        sDelete = "delete from EX_Category where CategoryID='" + oListCategory[i].CategoryID + "' and CategoryID not in (select QuestionCategoryID from EX_Question where QuestionCategoryID='" + oListCategory[i].CategoryID + "')";

                        oListString.Add(sDelete);
                    }
                }

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListCategory; // This is not necessary Object
                    oResult.ResultMessage = "Category Delete Success(If not deleted then,it is used)...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Category Delete Fail...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Category Delete Exception...";

                logger.Info("Exception CategoryDelete CategoryDAO+DAO", oEx);

                //new CLogger("Exception CategoryDelete CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception CategoryDelete CategoryDAO+DAO", ELogLevel.Debug, oEx);
            }

            //new CLogger("Out CategoryDelete CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out CategoryDelete CategoryDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End CategoryDelete CategoryDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This Methods provides to get current time from database
        /// </summary>
        /// <param name="sFormatNumber"> It takes format string to convert the sqlserver datetime </param>
        /// <returns> return result</returns>
        public Result GetCurrentTime(String sFormatNumber)
        {
            logger.Info("start GetCurrentTime Utility+GetCurrentTimeFromDataBase");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sSelect = String.Empty;

            Object oObject = null;

            try
            {
                if (!sFormatNumber.Equals(String.Empty))
                {
                    sSelect = "select convert(varchar, getdate(), " + sFormatNumber + ") as currentTime";

                    oObject=oDAOUtil.GetExecuteScalar(sSelect);

                    if (oObject != null)
                    {
                        oResult.ResultObject = oObject;
                        oResult.ResultMessage = "Get time from DataBase success...";
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "Get time from DataBase failed...";
                    }
                }
                else
                {
                    sSelect = "select getdate() as currentTime";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception at geting time from DataBase...";
                oResult.ResultException = oEx;

                logger.Info("Esception GetCurrentTime Utility+GetCurrentTimeFromDataBase",oEx);
            }

            logger.Info("End GetCurrentTime Utility+GetCurrentTimeFromDataBase");

            return oResult;
        }
        /// <summary>
        /// This method change the systemuser password
        /// </summary>
        /// <param name="oSystemUser"> It takes SystemUser Object </param>
        /// <param name="sNewPassword"> It takes String Object</param>
        /// <param name="sConfirmPassword"> It takes String Object</param>
        /// <returns> It returns Result Object </returns>
        public Result ChangePassword(SystemUser oSystemUser, String sNewPassword, String sConfirmPassword)
        {
            logger.Info("Start ChangePassword SystemUserDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sUpadte = String.Empty;

            List<String> oListString = new List<String>();

            try
            {
                sUpadte = "update EX_SystemUser set SystemUserPassword='******' where SystemUserID='" + oSystemUser.SystemUserID + "' and SystemUserPassword='******' and DeleteTime is NULL";

                oListString.Add(sUpadte);

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oSystemUser.SystemUserPassword = sNewPassword;

                    oResult.ResultObject = oSystemUser;
                    oResult.ResultMessage = "Your password have been changed successfully...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "SystemUser ChangePassword Fail...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "SystemUser ChangePassword Exception...";

                logger.Info("Exception ChangePassword SystemUserDAO+DAO", oEx);
            }

            logger.Info("End ChangePassword SystemUserDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method get total possible time for answering questions which are set up for an exam
        /// </summary>
        /// <param name="oExam"> It takes Exam Object </param>
        /// <returns> It returns Result Object </returns>
        public Result GetTotalLastSetupQuestionTime(Exam oExam)
        {
            logger.Info("Start GetTotalLastSetupQuestionTime QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sSelect = String.Empty;

            Object oObject = new Object();

            float fTotalTime = 0f;

            try
            {
                sSelect = "select sum(EX_Question.QuestionPossibleAnswerTime) from EX_Question inner join EX_QuestionGeneration on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "'";

                oObject = oDAOUtil.GetExecuteScalar(sSelect);

                if (oObject.ToString().Length > 0)
                {
                    fTotalTime = float.Parse(oObject.ToString());
                }

                oResult.ResultObject = fTotalTime;
                oResult.ResultMessage = "GetTotalLastSetupQuestionTime Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during GetTotalLastSetupQuestionTime...";

                logger.Info("Exception GetTotalLastSetupQuestionTime QuestionDAO+DAO", oEx);
            }

            logger.Info("End GetTotalLastSetupQuestionTime QuestionDAO+DAO");

            return oResult;
        }
        public Result LoadAllQuestionsOfAnExam(Exam oSelectedExam)
        {
            logger.Info("Start LoadAllQuestionsOfAnExam QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelect = String.Empty;

            List<QuestionSetup> oListQuestionSetup = new List<QuestionSetup>();

            try
            {
                sSelect="select distinct EX_QuestionGeneration.ExamID,"
                +" EX_QuestionGeneration.SetupQuestionMark,"
                +" EX_QuestionGeneration.GeneratorID,"
                +" EX_Question.QuestionID,"
                +" EX_Question.QuestionText,EX_Question.QuestionTypeID,"
                +" EX_Question.QuestionPossibleAnswerTime,"
                +" EX_Label.LabelID,"
                +" EX_Label.LabelName,"
                +" EX_Category.CategoryID,EX_Category.CategoryName"
                +" from EX_QuestionGeneration,EX_Question,EX_Category,EX_Label"
                +" where EX_Question.QuestionLabelID=EX_Label.LabelID"
                +" and EX_Question.QuestionCategoryID=EX_Category.CategoryID"
                +" and EX_Question.QuestionID=EX_QuestionGeneration.QuestionID"
                +" and EX_QuestionGeneration.ExamID='" + oSelectedExam.ExamID + "'"
                +" order by EX_Category.CategoryName,EX_Label.LabelName,EX_Question.QuestionTypeID asc";

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    QuestionSetup oPopulatedQuestionSetup = new QuestionSetup();

                    oPopulatedQuestionSetup.QuestionSetupExam.ExamID = new Guid(oSqlDataReader["ExamID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupSystemUser.SystemUserID = new Guid(oSqlDataReader["GeneratorID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString();
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionPossibleAnswerTime = float.Parse(oSqlDataReader["QuestionPossibleAnswerTime"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID = new Guid(oSqlDataReader["LabelID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelName = oSqlDataReader["LabelName"].ToString();
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["CategoryID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryName = oSqlDataReader["CategoryName"].ToString();

                    oListQuestionSetup.Add(oPopulatedQuestionSetup);
                }

                oSqlDataReader.Close();

                foreach (QuestionSetup oQuestionSetupInList in oListQuestionSetup)
                {
                    if (oQuestionSetupInList.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID == 0)
                    {
                        sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer,"
                        +" EX_Objective.ObjectiveAnswerIsValid from EX_Objective"
                        + " where EX_Objective.ObjectiveQuestionID = '" + oQuestionSetupInList.QuestionSetupQuestion.QuestionID + "'";

                        List<Choice> oListChoice = new List<Choice>();

                        oSqlDataReader = oDAOUtil.GetReader(sSelect);

                        while (oSqlDataReader.Read())
                        {
                            Choice oChoice = new Choice();

                            oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString();
                            oChoice.ChoiceIsValid = Convert.ToBoolean(oSqlDataReader["ObjectiveAnswerIsValid"].ToString());

                            oListChoice.Add(oChoice);
                        }

                        oSqlDataReader.Close();

                        oQuestionSetupInList.QuestionSetupQuestion.QuestionObjectiveType.ListOfChoices = oListChoice;
                    }

                }

                oResult.ResultObject = oListQuestionSetup;
                oResult.ResultMessage = "LoadAllQuestionsOfAnExam success...";
                oResult.ResultIsSuccess = true;

            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception occured during LoadAllQuestionsOfAnExam...";
                oResult.ResultException = oEx;

                logger.Info("Exception LoadAllQuestionsOfAnExam QuestionDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader != null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End LoadAllQuestionsOfAnExam QuestionDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This Method Load Question Categories With Type of an exam For A Candidate.
        /// For example: (Category: Math,IQ,English,etc...) (Only Two Type: Objective, Descriptive) 
        /// </summary>
        /// <param name="oCandidateForExam"> It takes CandidateForExam Object </param>
        /// <returns> It returns Result Object </returns>
        public Result LoadCategoriesWithType(CandidateForExam oCandidateForExam)
        {
            //new CLogger("Start LoadCategoriesWithType CandidateExamProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start LoadCategoriesWithType CandidateExamProcessDAO+DAO", ELogLevel.Debug);

            logger.Info("Start LoadCategoriesWithType CandidateExamProcessDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelect = String.Empty;

            List<CandidateMenu> oListCandidateMenu = new List<CandidateMenu>();

            try
            {
                sSelect = "select distinct EX_Category.CategoryID, EX_Category.CategoryName from"
                +" EX_Category inner join EX_Question on EX_Category.CategoryID=EX_Question.QuestionCategoryID"
                +" inner join EX_QuestionGeneration on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID"
                + " where EX_QuestionGeneration.ExamID='" + oCandidateForExam.CadidateCandidateExam.CandiadteExamExam.ExamID + "'"
                +" order by EX_Category.CategoryID asc";

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    CandidateMenu oCandidateMenu = new CandidateMenu();

                    oCandidateMenu.CandidateMenuCategory.CategoryID = int.Parse(oSqlDataReader["CategoryID"].ToString());
                    oCandidateMenu.CandidateMenuCategory.CategoryName = oSqlDataReader["CategoryName"].ToString();

                    oListCandidateMenu.Add(oCandidateMenu);
                }

                oSqlDataReader.Close();

                foreach (CandidateMenu oCandidateMenuInList in oListCandidateMenu)
                {
                    sSelect = "select distinct EX_QuestionType.TypeID, EX_QuestionType.TypeName"
                    +" from EX_QuestionType inner join EX_Question on EX_QuestionType.TypeID=EX_Question.QuestionTypeID"
                    + " inner join EX_QuestionGeneration on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID where EX_QuestionGeneration.ExamID='" + oCandidateForExam.CadidateCandidateExam.CandiadteExamExam.ExamID + "' and EX_Question.QuestionCategoryID ='" + oCandidateMenuInList.CandidateMenuCategory.CategoryID + "' order by EX_QuestionType.TypeID asc";

                    List<QuestionType> oListQuestionType = new List<QuestionType>();

                    oSqlDataReader = oDAOUtil.GetReader(sSelect);

                    while (oSqlDataReader.Read())
                    {
                        QuestionType oQuestionType = new QuestionType();

                        oQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["TypeID"].ToString());
                        oQuestionType.QuestionTypeName = oSqlDataReader["TypeName"].ToString();

                        oListQuestionType.Add(oQuestionType);
                    }

                    oSqlDataReader.Close();

                    foreach (QuestionType oQuestionTypeInList in oListQuestionType)
                    {
                        sSelect = "select count(EX_Question.QuestionID) as TotalQuestions from EX_Question inner join EX_QuestionGeneration on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID where EX_QuestionGeneration.ExamID='" + oCandidateForExam.CadidateCandidateExam.CandiadteExamExam.ExamID + "' and EX_Question.QuestionCategoryID ='" + oCandidateMenuInList.CandidateMenuCategory.CategoryID + "' and EX_Question.QuestionTypeID='" + oQuestionTypeInList.QuestionTypeID + "'";

                        oQuestionTypeInList.QuestionTypeTotalQuestions = int.Parse(oDAOUtil.GetExecuteScalar(sSelect).ToString());
                    }

                    oCandidateMenuInList.CandidateMenuCategoryQuestionType = oListQuestionType;
                }

                oResult.ResultObject = oListCandidateMenu;
                oResult.ResultMessage = "Candidate Menu Category with type Load Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception in Candidate Menu Category with type Load for Candidate...";
                oResult.ResultException = oEx;

                logger.Info("Exception LoadCategoriesWithType CandidateExamProcessDAO+DAO", oEx);

                //new CLogger("Exception LoadCategoriesWithType CandidateExamProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception LoadCategoriesWithType CandidateExamProcessDAO+DAO", ELogLevel.Debug, oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            //new CLogger("Out LoadCategoriesWithType CandidateExamProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out LoadCategoriesWithType CandidateExamProcessDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End LoadCategoriesWithType CandidateExamProcessDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method Save DescriptiveAnswer Marks For Candidates For A SystemUser Of An Exam
        /// </summary>
        /// <param name="sCandidateID"> It takes String Object </param>
        /// <param name="oListCandidateAnswerQuestion"> It takes List<CandidateAnswerQuestion> Object </param>
        /// <param name="oExam"> It takes Exam Object </param>
        /// <param name="oSystemUser"> It takes SystemUser Object </param>
        /// <returns> It returns Result Object </returns>
        public Result SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam(String sCandidateID, List<CandidateAnswerQuestion> oListCandidateAnswerQuestion, Exam oExam, SystemUser oSystemUser)
        {
            //new CLogger("Start SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", ELogLevel.Debug);

            logger.Info("Start SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sUpdate = String.Empty;

            List<String> oListString = new List<String>();

            try
            {
                foreach (CandidateAnswerQuestion oCandidateAnswerQuestionInList in oListCandidateAnswerQuestion)
                {
                    if (oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID == 1)
                    {
                        sUpdate = "update EX_CandidateExam set ObtainMark='" + oCandidateAnswerQuestionInList.ObtainMark + "' where ExamID='" + oExam.ExamID + "' and CandidateID='" + sCandidateID + "' and QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'";

                        oListString.Add(sUpdate);
                    }
                }

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListCandidateAnswerQuestion;
                    oResult.ResultMessage = "Descriptive answers are evaluated...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Descriptive answers are evaluation failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam Exception...";

                logger.Info("Exception SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", oEx);
                //new CLogger("Exception SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", ELogLevel.Debug, oEx);
            }

            //new CLogger("Out SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End SaveDescriptiveAnswerMarksForCandidatesForASystemUserOfAnExam EvaluateProcessDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method Load all levels
        /// </summary>
        /// <returns> It returns Result Object </returns>
        public Result LoadAllLevels()
        {
            logger.Info("Start LoadAllLevels LevelDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelect = String.Empty;

            List<Level> oListLevel = new List<Level>();

            try
            {
                sSelect = "select EX_Label.LabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite from"
                +" EX_Label order by EX_Label.LabelName";

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    Level oLevel = new Level();

                    oLevel.LevelID = new Guid(oSqlDataReader["LabelID"].ToString());
                    oLevel.LevelName = oSqlDataReader["LabelName"].ToString();
                    oLevel.LevelDescription = oSqlDataReader["LabelPrerequisite"].ToString();

                    oListLevel.Add(oLevel);
                }

                oSqlDataReader.Close();

                oResult.ResultObject = oListLevel;
                oResult.ResultMessage = "Load All Levels Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Load All Levels Exception...";

                logger.Info("Exception LoadAllLevels LevelDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader != null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End LoadAllLevels LevelDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This Method Load Questions according to category, type for an exam.
        /// </summary>
        /// <param name="oCategory"> It takes Category Object </param>
        /// <param name="oQuestionType"> It takes QuestionType Object </param>
        /// <param name="oCandidateForExam"> It takes CandidateForExam Object </param>
        /// <returns> It returns Result Object </returns>
        public Result LoadQuestionsForACandidateInExamByCategoryAndType(Category oCategory, QuestionType oQuestionType, CandidateForExam oCandidateForExam)
        {
            logger.Info("Start LoadQuestionsForACandidateInExamByCategoryAndType CandidateExamProcessDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelect = String.Empty;
            String sChoiceSelect = String.Empty;

            List<Question> oListQuestion = new List<Question>();
            List<CandidateAnswerQuestion> oListCandidateAnswerQuestion = new List<CandidateAnswerQuestion>();

            int i = 0;

            try
            {
                //sSelect = "select EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionCreatorID,EX_Question.QuestionDefaultMark,EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID where EX_QuestionGeneration.ExamID='" + oCandidate.CadidateCandidateExam.CandiadteExamExam.ExamID + "' order by EX_Question.QuestionCategoryID, EX_Question.QuestionTypeID asc";

                //sSelect = "select EX_Question.QuestionID,EX_Question.QuestionText,EX_Question.QuestionCreatorID,EX_QuestionGeneration.SetupQuestionMark,EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID"
                //+" from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID"
                //+" where EX_QuestionGeneration.ExamID='" + oCandidate.CadidateCandidateExam.CandiadteExamExam.ExamID + "' order by EX_Question.QuestionCategoryID, EX_Question.QuestionTypeID asc";

                sSelect = "select EX_Question.QuestionID,EX_Question.QuestionText,"
                +" EX_Question.QuestionCreatorID,EX_QuestionGeneration.SetupQuestionMark"
                +" ,EX_Question.QuestionCategoryID,EX_Question.QuestionTypeID"
                +" from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID"
                +" where EX_QuestionGeneration.ExamID='" + oCandidateForExam.CadidateCandidateExam.CandiadteExamExam.ExamID + "'"
                +" and EX_Question.QuestionCategoryID='" + oCategory.CategoryID + "'"
                +" and EX_Question.QuestionTypeID='" + oQuestionType.QuestionTypeID + "'";

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    Question oQuestion = new Question();

                    oQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString());
                    oQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString();
                    oQuestion.QuestionCreator.SystemUserID = new Guid(oSqlDataReader["QuestionCreatorID"].ToString());
                    oQuestion.QuestionDefaultMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString());
                    oQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["QuestionCategoryID"].ToString());
                    oQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString());

                    oListQuestion.Add(oQuestion);
                }

                oSqlDataReader.Close();

                foreach (Question oQuestionForChoice in oListQuestion)
                {
                    if (oQuestionForChoice.QuestionQuestionType.QuestionTypeID == 0)
                    {
                        sChoiceSelect = "select ObjectiveAnswer,ObjectiveAnswerIsValid from EX_Objective where ObjectiveQuestionID='" + oQuestionForChoice.QuestionID + "'";

                        List<Choice> oListChoice = new List<Choice>();

                        oSqlDataReader = oDAOUtil.GetReader(sChoiceSelect);

                        while (oSqlDataReader.Read())
                        {
                            //prepare the choices for a particular questtion......
                            //and populate oListQuestion
                            Choice oChoice = new Choice();

                            oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString();
                            //oChoice.ChoiceIsValid = Convert.ToBoolean(oSqlDataReader["ObjectiveAnswerIsValid"].ToString());
                            oChoice.ChoiceIsValid = false;

                            oListChoice.Add(oChoice);
                        }

                        oSqlDataReader.Close();

                        oQuestionForChoice.QuestionObjectiveType.ListOfChoices = oListChoice;
                    }
                }

                for (i = 0; i < oListQuestion.Count; i++)
                {
                    CandidateAnswerQuestion oCandidateAnswerQuestion = new CandidateAnswerQuestion();
                    oCandidateAnswerQuestion.QuestionForCandidateAnswer = oListQuestion[i];
                    oListCandidateAnswerQuestion.Add(oCandidateAnswerQuestion);
                }

                oResult.ResultObject = oListCandidateAnswerQuestion;
                oResult.ResultMessage = "Load Question for Exam Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception in Question Load for Exam...";
                oResult.ResultException = oEx;

                logger.Info("Exception LoadQuestionsForACandidateInExamByCategoryAndType CandidateExamProcessDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader != null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End LoadQuestionsForACandidateInExamByCategoryAndType CandidateExamProcessDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method show the questions according to category,type,questionlevel.
        /// And these questions are shown to setup them for an exam
        /// </summary>
        /// <param name="oQuestion"> It takes Question Object </param>
        /// <param name="oExam"> It takes Exam Object </param>
        /// <returns> It returns Result Object </returns>
        public Result QuestionListShowForSetupByQuestionLevel(Question oQuestion, Exam oExam)
        {
            logger.Info("Start QuestionListShowForSetupByQuestionLevel QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelect = String.Empty;
            String sChoiceSelect = String.Empty;

            List<QuestionSetup> oListQuestionSetup = new List<QuestionSetup>();

            try
            {
                //sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,"
                //    + " QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite"
                //    + " from EX_Question left join EX_Label on EX_Question.QuestionLabelID=EX_Label.LabelID where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID +
                //    "' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "'";

                if (oQuestion.QuestionCreator.SystemUserName.ToLower().Equals("administrator"))
                {
                    //sSelect = "select distinct EX_Question.QuestionID as EntryQuestionID,EX_QuestionGeneration.QuestionID as GeneratedQuestionID,EX_QuestionGeneration.SetupQuestionMark,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,QuestionTypeID,EX_Question.QuestionPossibleAnswerTime from EX_Question left join EX_QuestionGeneration on EX_Question.QuestionID=EX_QuestionGeneration.QuestionID where EX_Question.QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + "' and EX_Question.QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "'";

                    //sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," +
                    //"QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID from EX_Question where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID +
                    //"' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='"+oQuestion.QuestionLevel.LevelID+"'";

                    sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,"
                        + " QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite"
                        + " from EX_Question inner join EX_Label on EX_Question.QuestionLabelID=EX_Label.LabelID where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID +
                        "' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='" + oQuestion.QuestionLevel.LevelID + "'";
                }
                else
                {
                    //sSelect = "select distinct EX_Question.QuestionID as EntryQuestionID,EX_QuestionGeneration.QuestionID as GeneratedQuestionID,EX_QuestionGeneration.SetupQuestionMark,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,QuestionTypeID,EX_Question.QuestionPossibleAnswerTime from EX_Question left join EX_QuestionGeneration on EX_Question.QuestionID=EX_QuestionGeneration.QuestionID where EX_Question.QuestionCreatorID='" + oQuestion.QuestionCreator.SystemUserID + "' and EX_Question.QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID + "' and EX_Question.QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "'";

                    //sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID," +
                    //"QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID from EX_Question where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID +
                    //"' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='" + oQuestion.QuestionLevel.LevelID + "'";

                    sSelect = "select distinct QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,"
                        + " QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite"
                        + " from EX_Question inner join EX_Label on EX_Question.QuestionLabelID=EX_Label.LabelID where QuestionCategoryID='" + oQuestion.QuestionCategory.CategoryID +
                        "' and QuestionTypeID='" + oQuestion.QuestionQuestionType.QuestionTypeID + "' and QuestionLabelID='" + oQuestion.QuestionLevel.LevelID + "'";
                }

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    QuestionSetup oPopulatedQuestionSetup = new QuestionSetup();

                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString();
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCreator.SystemUserID = new Guid(oSqlDataReader["QuestionCreatorID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionDefaultMark = float.Parse(oSqlDataReader["QuestionDefaultMark"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["QuestionCategoryID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionPossibleAnswerTime = float.Parse(oSqlDataReader["QuestionPossibleAnswerTime"].ToString());

                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID = new Guid(oSqlDataReader["QuestionLabelID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelName = oSqlDataReader["LabelName"].ToString();
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelDescription = oSqlDataReader["LabelPrerequisite"].ToString();

                    oPopulatedQuestionSetup.QuestionSetupMark = oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionDefaultMark;
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionIsUsed = false;

                    //if (oSqlDataReader["GeneratedQuestionID"].ToString().Length > 0)
                    //{
                    //    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionIsUsed = true;
                    //}

                    //if (oSqlDataReader["SetupQuestionMark"].ToString().Length > 0)
                    //{
                    //    oPopulatedQuestionSetup.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString());
                    //}

                    oListQuestionSetup.Add(oPopulatedQuestionSetup);
                }

                oSqlDataReader.Close();

                if (oQuestion.QuestionQuestionType.QuestionTypeID == 0) //enum should be used here
                {
                    foreach (QuestionSetup oQuestionSetupInList in oListQuestionSetup)
                    {
                        sChoiceSelect = "select ObjectiveAnswer,ObjectiveAnswerIsValid from EX_Objective where ObjectiveQuestionID='" + oQuestionSetupInList.QuestionSetupQuestion.QuestionID + "'";

                        List<Choice> oListChoice = new List<Choice>();

                        oSqlDataReader = oDAOUtil.GetReader(sChoiceSelect);

                        while (oSqlDataReader.Read())
                        {
                            //prepare the choices for a particular questtion......
                            //and populate oListQuestion
                            Choice oChoice = new Choice();

                            oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString();
                            oChoice.ChoiceIsValid = Convert.ToBoolean(oSqlDataReader["ObjectiveAnswerIsValid"].ToString());

                            oListChoice.Add(oChoice);
                        }

                        oSqlDataReader.Close();

                        oQuestionSetupInList.QuestionSetupQuestion.QuestionObjectiveType.ListOfChoices = oListChoice;
                    }
                }

                foreach (QuestionSetup oQuestionSetupInList in oListQuestionSetup)
                {
                    sSelect = "select distinct EX_QuestionGeneration.QuestionID as GeneratedQuestionID,EX_QuestionGeneration.SetupQuestionMark from EX_QuestionGeneration where EX_QuestionGeneration.QuestionID='" + oQuestionSetupInList.QuestionSetupQuestion.QuestionID + "' and EX_QuestionGeneration.ExamID='" + oExam.ExamID + "'";

                    oSqlDataReader = oDAOUtil.GetReader(sSelect);

                    if (oSqlDataReader.HasRows)
                    {
                        oQuestionSetupInList.QuestionSetupQuestion.QuestionIsUsed = true;

                        while (oSqlDataReader.Read())
                        {
                            if (oSqlDataReader["SetupQuestionMark"].ToString().Length > 0)
                            {
                                oQuestionSetupInList.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString());
                            }
                        }
                    }

                    oSqlDataReader.Close();
                }

                oResult.ResultObject = oListQuestionSetup;
                oResult.ResultMessage = "QuestionListShowForSetupByQuestionLevel Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception occured during QuestionListShowForSetupByQuestionLevel...";
                oResult.ResultException = oEx;

                logger.Info("Exception QuestionListShowForSetupByQuestionLevel QuestionDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader != null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End QuestionListShowForSetupByQuestionLevel QuestionDAO+DAO");

            return oResult;
        }
        //r
        /// <summary>
        /// This method loads the categories to set them in session
        /// </summary>
        /// <returns> It returns Result Object </returns>
        public Result CategoryGetFromDatabaseForSetSession()
        {
            //new CLogger("Start CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", ELogLevel.Debug);

            logger.Info("Start CategoryGetFromDatabaseForSetSession CategoryDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sSelectCategory = String.Empty;
            String sCategoryName = String.Empty;

            SqlDataReader oSqlDataReader = null;

            List<Category> oListCategory = new List<Category>();

            int iCategoryID = 0;

            sSelectCategory = "select CategoryID,CategoryName from EX_Category";

            try
            {
                oSqlDataReader = oDAOUtil.GetReader(sSelectCategory);

                while (oSqlDataReader.Read())
                {
                    Category oCategory = new Category();

                    iCategoryID = int.Parse(oSqlDataReader["CategoryID"].ToString());
                    sCategoryName = oSqlDataReader["CategoryName"].ToString();

                    oCategory.CategoryID = iCategoryID;
                    oCategory.CategoryName = sCategoryName;

                    oListCategory.Add(oCategory);
                }

                oSqlDataReader.Close();

                oResult.ResultObject = oListCategory;
                oResult.ResultMessage = "Category Get success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Category Get...";

                logger.Info("Exception CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", oEx);

                //new CLogger("Exception CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", ELogLevel.Debug, oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            //new CLogger("Out CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out CategoryGetFromDatabaseForSetSession CategoryDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End CategoryGetFromDatabaseForSetSession CategoryDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method checks the systemuser login
        /// </summary>
        /// <param name="oSystemUser"> It takes SystemUser Object </param>
        /// <returns> It returns Result Object </returns>
        public Result SystemUserLogin(SystemUser oSystemUser)
        {
            logger.Info("Start SystemUserLogin SystemUserDAO+DAO");

            Result oResult = new Result();
            SqlDataReader oSqlDataReader = null;

            try
            {
                DAOUtil oDAOUtil = new DAOUtil();
                SystemUser oPopulatedSystemUser = new SystemUser();

                Boolean flag = false;

                String sSelect = "select SystemUserID,SystemUserName,SystemUserPassword,EmailAddress from EX_SystemUser where SystemUserName='******' and SystemUserPassword='******' and DeleteTime is NULL";
                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                if (oSqlDataReader.HasRows)
                {
                    while (oSqlDataReader.Read())
                    {
                        oPopulatedSystemUser.SystemUserID = new Guid(oSqlDataReader["SystemUserID"].ToString());
                        oPopulatedSystemUser.SystemUserName = oSqlDataReader["SystemUserName"].ToString();
                        oPopulatedSystemUser.SystemUserPassword = oSqlDataReader["SystemUserPassword"].ToString();
                        oPopulatedSystemUser.SystemUserEmail = oSqlDataReader["EmailAddress"].ToString();

                        flag = true;
                    }

                    oSqlDataReader.Close();

                    if (flag)
                    {
                        oResult.ResultObject = oPopulatedSystemUser;
                        oResult.ResultMessage = "Login Success...";
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "System User Login Fail...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "System User Not Found...";
                }

            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "SystemUserLogin Exception...";
                oResult.ResultException = oEx;

                logger.Info("Exception SystemUserLogin SystemUserDAO+DAO",oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End SystemUserLogin SystemUserDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method update the systemuser
        /// It updates systemuser name, if the name is not duplicated
        /// </summary>
        /// <param name="oListSystemUser"> It takes List<SystemUser> Object </param>
        /// <param name="iArrCheck"> It takes integer array which indicates the marked system user</param>
        /// <returns> It returns Result Object </returns>
        public Result UpdateSystemUser(List<SystemUser> oListSystemUser, int[] iArrCheck)
        {
            logger.Info("Start UpdateSystemUser SystemUserDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            //List<String> oListString = new List<String>();

            List<SqlCommand> oListSqlCommand = new List<SqlCommand>();

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

            //String sUpdate = String.Empty;

            int i = 0;

            try
            {
                for (i = 0; i < iArrCheck.Length; i++)
                {
                    if (iArrCheck[i] == 1)
                    {
                        //sUpdate = "if not exists(select SystemUserName from EX_SystemUser where SystemUserName='******') update EX_SystemUser set SystemUserName='******',SystemUserPassword='******',EmailAddress='" + oListSystemUser[i].SystemUserEmail + "' where SystemUserID='" + oListSystemUser[i].SystemUserID + "' and DeleteTime is NULL";

                        SqlCommand oSqlCommand = new SqlCommand("SP_SystemUserModification");
                        oSqlCommand.CommandType = CommandType.StoredProcedure;

                        oSqlCommand.Parameters.Add("@SystemUserID", SqlDbType.UniqueIdentifier);
                        oSqlCommand.Parameters["@SystemUserID"].Value = oListSystemUser[i].SystemUserID;

                        oSqlCommand.Parameters.Add("@SystemUserName", SqlDbType.VarChar);
                        oSqlCommand.Parameters["@SystemUserName"].Value = oListSystemUser[i].SystemUserName;

                        oSqlCommand.Parameters.Add("@SystemUserPassword", SqlDbType.VarChar);
                        oSqlCommand.Parameters["@SystemUserPassword"].Value = oListSystemUser[i].SystemUserPassword;

                        oSqlCommand.Parameters.Add("@EmailAddress", SqlDbType.VarChar);
                        oSqlCommand.Parameters["@EmailAddress"].Value = oListSystemUser[i].SystemUserEmail;

                        oListSqlCommand.Add(oSqlCommand);

                        //sUpdate = "update EX_SystemUser set"
                        //        + " SystemUserName="******" ( case when not exists(select SystemUserName from EX_SystemUser where SystemUserName='******')"
                        //        + " then  '" + oListSystemUser[i].SystemUserName + "' else '" + oListSystemUser[i].SystemUserName + "' end )"
                        //        + " ,SystemUserPassword='******'"
                        //        + ",EmailAddress= ( case  when not exists(select EmailAddress from EX_SystemUser where EmailAddress='" + oListSystemUser[i].SystemUserEmail + "')"
                        //        + " then '" + oListSystemUser[i].SystemUserEmail + "' else '" + oListSystemUser[i].SystemUserEmail + "' end )"
                        //        + " where SystemUserID='" + oListSystemUser[i].SystemUserID + "' and DeleteTime is NULL";

                        //oListString.Add(sUpdate);

                    }
                }

                oListInt = oDAOUtil.ExecuteNonQueryForStoredProcedure(oListSqlCommand);

                if (oListInt.Count > 0)
                {
                    oResult.ResultObject = oListSystemUser;
                    oResult.ResultMessage = "SystemUser Update Success(if email or name not update, then it is duplicate)...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "SystemUser Update Failed...";
                }

                //if (oDAOUtil.ExecuteNonQuery(oListString))
                //{
                //    oResult.ResultObject = oListSystemUser;
                //    oResult.ResultMessage = "SystemUser Update Success(if email or name not update, then it is duplicate)...";
                //    oResult.ResultIsSuccess = true;
                //}
                //else
                //{
                //    oResult.ResultIsSuccess = false;
                //    oResult.ResultMessage = "SystemUser Update Fail...";
                //}
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "SystemUser Update Exception...";

                logger.Info("Exception UpdateSystemUser SystemUserDAO+DAO", oEx);
            }

            logger.Info("End UpdateSystemUser SystemUserDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method inserts systemuser, if that systemuser name is not existed
        /// </summary>
        /// <param name="oSystemUser"> It takes SystemUser Object </param>
        /// <returns> It returns Result Object </returns>
        public Result SystemUserEntry(SystemUser oSystemUser)
        {
            logger.Info("Start SystemUserEntry SystemUserDAO+DAO");

            Result oResult = new Result();

            List<SqlCommand> oListSqlCommand = new List<SqlCommand>();
            List<int> oListInt = new List<int>();

            try
            {
                DAOUtil oDAOUtil = new DAOUtil();

                //Boolean flag = true;

                //String sSelect = "select SystemUserName from EX_SystemUser where (SystemUserName='******' or EmailAddress='" + oSystemUser.SystemUserEmail + "') and DeleteTime is NULL";
                //String sInsert = String.Empty;
                //List<String> oListOfString = new List<String>();

                //oSqlDataReader = oDAOUtil.GetReader(sSelect);

                //if (oSqlDataReader.HasRows)
                //{
                //    flag = false;
                //}

                //oSqlDataReader.Close();

                //if (flag)
                //{
                //    oSystemUser.SystemUserID = Guid.NewGuid();

                //    sInsert = "if not exists(select SystemUserName from EX_SystemUser where (SystemUserName='******' or EmailAddress='" + oSystemUser.SystemUserEmail + "')"
                //    +" and DeleteTime is NULL)"
                //    +" insert into EX_SystemUser(SystemUserID,SystemUserName,SystemUserPassword,EmailAddress)"
                //    +" values('" + oSystemUser.SystemUserID + "','" + oSystemUser.SystemUserName + "','" + oSystemUser.SystemUserPassword + "','" + oSystemUser.SystemUserEmail + "')";
                //    oListOfString.Add(sInsert);

                //    if (oDAOUtil.ExecuteNonQuery(oListOfString))
                //    {
                //        oResult.ResultObject = oSystemUser;
                //        oResult.ResultMessage = "System User Entry Success...";
                //        oResult.ResultIsSuccess = true;
                //    }
                //    else
                //    {
                //        oResult.ResultIsSuccess = false;
                //        oResult.ResultMessage = "System User Entry Failed...";
                //    }
                //}
                //else
                //{
                //    oResult.ResultIsSuccess = false;
                //    oResult.ResultMessage = "System User is already Existed...";
                //}

                SqlCommand oSqlCommand = new SqlCommand("SP_SystemUserEntry");
                oSqlCommand.CommandType = CommandType.StoredProcedure;

                oSystemUser.SystemUserID = Guid.NewGuid();

                oSqlCommand.Parameters.Add("@SystemUserID", SqlDbType.UniqueIdentifier);
                oSqlCommand.Parameters["@SystemUserID"].Value = oSystemUser.SystemUserID;

                oSqlCommand.Parameters.Add("@SystemUserName", SqlDbType.VarChar);
                oSqlCommand.Parameters["@SystemUserName"].Value = oSystemUser.SystemUserName;

                oSqlCommand.Parameters.Add("@SystemUserPassword", SqlDbType.VarChar);
                oSqlCommand.Parameters["@SystemUserPassword"].Value = oSystemUser.SystemUserPassword;

                oSqlCommand.Parameters.Add("@EmailAddress", SqlDbType.VarChar);
                oSqlCommand.Parameters["@EmailAddress"].Value = oSystemUser.SystemUserEmail;

                oListSqlCommand.Add(oSqlCommand);

                oListInt = oDAOUtil.ExecuteNonQueryForStoredProcedure(oListSqlCommand);

                if (oListInt.Count > 0)
                {
                    if (oListInt[0] > 0)
                    {
                        oResult.ResultObject = oSystemUser;
                        oResult.ResultMessage = "System User Entry Success...";
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "System User Name or Email is already Existed...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "SystemUser Entry Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "System User Entry Exception...";

                logger.Info("Exception SystemUserEntry SystemUserDAO+DAO", oEx);
            }

            logger.Info("End SystemUserEntry SystemUserDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method update the systemuser delete time, indicating that, the systemuser is deleted.
        /// </summary>
        /// <param name="oListSystemUser"> It takes List<SystemUser> Object </param>
        /// <param name="iArrCheck"> It takes integer array which indicates the marked system user</param>
        /// <returns> It returns Result Object </returns>
        public Result SystemUserDelete(List<SystemUser> oListSystemUser, int[] iArrCheck)
        {
            logger.Info("Start SystemUserDelete SystemUserDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<SystemUser> oListSystemUser1 = new List<SystemUser>();

            List<String> oListString = new List<String>();

            String sUpdate = String.Empty;

            int i = 0;

            try
            {
                for (i = 0; i < iArrCheck.Length; i++)
                {
                    if (iArrCheck[i] == 1)
                    {
                        sUpdate = "update EX_SystemUser set DeleteTime='" + DateTime.Now + "' where SystemUserID='" + oListSystemUser[i].SystemUserID + "'";
                        oListString.Add(sUpdate);
                        oListSystemUser1.Add(null);
                    }
                    else
                    {
                        oListSystemUser1.Add(oListSystemUser[i]);
                    }
                }

                oListSystemUser1.RemoveAll(delegate(SystemUser oSystemUser) { if (oSystemUser != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListSystemUser1;
                    oResult.ResultMessage = "System User Delete Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "System User Delete Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during System User Delete...";

                logger.Info("Exception SystemUserDelete SystemUserDAO+DAO", oEx);
            }

            logger.Info("End SystemUserDelete SystemUserDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method Save ObjectiveAnswer Marks For All Candidate Of An Exam
        /// </summary>
        /// <param name="oListCandidateForExamForGrid"> It takes List<CandidateForExam> Object </param>
        /// <param name="oExam"> It takes Exam Object </param>
        /// <param name="oSystemUser"> It takes SystemUser Object </param>
        /// <returns> It returns Result Object </returns>
        public Result SaveObjectiveAnswerMarksForAllCandidateOfAnExam(List<CandidateForExam> oListCandidateForExamForEvaluate, SystemUser oSystemUser, Exam oExam)
        {
            //new CLogger("Start SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", ELogLevel.Debug);

            logger.Info("Start SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sUpdate = String.Empty;

            List<String> oListString = new List<String>();

            try
            {
                foreach (CandidateForExam oCandidateForExamInList in oListCandidateForExamForEvaluate)
                {
                    foreach (CandidateAnswerQuestion oCandidateAnswerQuestionInList in oCandidateForExamInList.CadidateCandidateExam.CandidateAnsweredQuestions)
                    {
                        if (oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID == 0)
                        {
                            sUpdate = "update EX_CandidateExam set ObtainMark='" + oCandidateAnswerQuestionInList.ObtainMark + "' where ExamID='" + oExam.ExamID + "' and CandidateID='" + oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID + "' and QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'";

                            oListString.Add(sUpdate);
                        }
                    }
                }

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListCandidateForExamForEvaluate;
                    oResult.ResultMessage = "Objective answers are saved for all candidate of this exam...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Saving objective answers for all candidate of this exam Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception at saving objective answers for all candidate of this exam...";

                logger.Info("Exception SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", oEx);

                //new CLogger("Exception SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", ELogLevel.Debug, oEx);
            }

            //new CLogger("Out SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End SaveObjectiveAnswerMarksForAllCandidateOfAnExam EvaluateProcessDAO+DAO");

            return oResult;
        }
        //r
        /// <summary>
        /// This method inserts a Question
        /// </summary>
        /// <param name="oQuestion"> It takes Question Object </param>
        /// <returns> It returns Result Object </returns>
        public Result QuestionEntry(Question oQuestion)
        {
            logger.Info("Start QuestionEntry QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sInsert = String.Empty;
            List<String> oListInsert = new List<String>();

            int i=0;
            int iBit = 0;

            try
            {
                oQuestion.QuestionID = Guid.NewGuid();

                sInsert = "insert into EX_Question(QuestionID,QuestionText,QuestionCreatorID,QuestionDefaultMark,QuestionCategoryID,QuestionTypeID,QuestionPossibleAnswerTime,QuestionLabelID) values('" + oQuestion.QuestionID + "','" + oQuestion.QuestionText + "','" + oQuestion.QuestionCreator.SystemUserID + "','" + oQuestion.QuestionDefaultMark + "','" + oQuestion.QuestionCategory.CategoryID + "','" + oQuestion.QuestionQuestionType.QuestionTypeID + "','" + oQuestion.QuestionPossibleAnswerTime+"','"+oQuestion.QuestionLevel.LevelID + "')";
                oListInsert.Add(sInsert);

                if (oQuestion.QuestionQuestionType.QuestionTypeID == 0)
                {
                    for (i = 0; i < oQuestion.QuestionObjectiveType.ListOfChoices.Count; i++)
                    {
                        iBit = 0;

                        if (oQuestion.QuestionObjectiveType.ListOfChoices[i].ChoiceIsValid)
                        {
                            iBit = 1;
                        }

                        sInsert = "insert into EX_Objective(ObjectiveQuestionID,ObjectiveAnswer,ObjectiveAnswerIsValid) values('" + oQuestion.QuestionID + "','" + oQuestion.QuestionObjectiveType.ListOfChoices[i].ChoiceName + "','" + iBit + "')";
                        oListInsert.Add(sInsert);
                    }
                }

                if (oDAOUtil.ExecuteNonQuery(oListInsert))
                {
                    oResult.ResultObject = oQuestion;
                    oResult.ResultMessage = "Question Entry Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Question Entry Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception occured during Question Entry...";
                oResult.ResultException = oEx;

                logger.Info("Exception QuestionEntry QuestionDAO+DAO", oEx);
            }

            logger.Info("End QuestionEntry QuestionDAO+DAO");

            return oResult;
        }
Esempio n. 18
0
        /// <summary>
        /// This method inserts a Level
        /// </summary>
        /// <param name="oLevel"> It takes Level Object </param>
        /// <returns> It returns Result Object </returns>
        public Result LevelEntry(Level oLevel)
        {
            logger.Info("Start LevelEntry LevelDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sInsert = String.Empty;

            //List<String> oListString = new List<String>();

            List<SqlCommand> oListSqlCommand = new List<SqlCommand>();
            List<int> oListInt = new List<int>();

            try
            {
                sInsert = "if not exists(select LabelName from EX_Label where LabelName='" + oLevel.LevelName + "') insert into EX_Label(LabelID,LabelName,LabelPrerequisite)"
                +" values('"+oLevel.LevelID+"','"+oLevel.LevelName+"','"+oLevel.LevelDescription+"')";

                //oListString.Add(sInsert);

                //if (oDAOUtil.ExecuteNonQuery(oListString))
                //{
                //    oResult.ResultObject = oLevel;
                //    oResult.ResultMessage = "Level Entry Success(if not inserted, then level name is existed)...";
                //    oResult.ResultIsSuccess = true;
                //}
                //else
                //{
                //    oResult.ResultIsSuccess = false;
                //    oResult.ResultMessage = "Level Entry failed...";
                //}

                SqlCommand oSqlCommand = new SqlCommand(sInsert);
                oSqlCommand.CommandType = CommandType.Text;

                oListSqlCommand.Add(oSqlCommand);

                oListInt = oDAOUtil.ExecuteNonQueryForStoredProcedure(oListSqlCommand);

                if (oListInt.Count > 0)
                {
                    if (oListInt[0] > 0)
                    {
                        oResult.ResultObject = oLevel;
                        oResult.ResultMessage = "Level Entry Success...";
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "Level name is existed...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Level Entry failed...";
                }

            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Level Entry...";

                logger.Info("Exception LevelEntry LevelDAO+DAO", oEx);
            }

            logger.Info("End LevelEntry LevelDAO+DAO");

            return oResult;
        }
        //r
        /// <summary>
        /// This method deletes questions
        /// </summary>
        /// <param name="oListQuestion"> It takes List<Question> Object </param>
        /// <param name="iarrChecked"> It takes integer array indicates the marked questions </param>
        /// <returns> It returns Result Object </returns>
        public Result DeleteQuestionList(List<Question> oListQuestion, int[] iarrChecked)
        {
            logger.Info("Start DeleteQuestionList QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<String> oListString = new List<String>();
            String sDelete = String.Empty;

            List<Question> oListQuestion1 = new List<Question>();

            int i = 0;

            try
            {
                for (i = 0; i < iarrChecked.Length; i++)
                {
                    if (iarrChecked[i] == 1 && !oListQuestion[i].QuestionIsUsed)
                    {
                        // Before delete, check that, is it used at the time of SETUP Question.
                        // If it is used, then u cannot delete it.

                        if (oListQuestion[i].QuestionQuestionType.QuestionTypeID==1)
                        {
                            sDelete = "delete from EX_Question where QuestionID='" + oListQuestion[i].QuestionID + "'";
                            oListQuestion1.Add(null);
                            oListString.Add(sDelete);

                        }
                        else
                        {
                            //first delete from EX_Objective, then from EX_Question
                            sDelete = "delete from EX_Objective where ObjectiveQuestionID='" + oListQuestion[i].QuestionID+"'";
                            oListString.Add(sDelete);
                            //sDelete = "delete from EX_Question where QuestionID='" + oListQuestion[i].QuestionID + "' and QuestionTypeName='" + oListQuestion[i].QuestionObjectiveType.TypeName + "'";
                            sDelete = "delete from EX_Question where QuestionID='" + oListQuestion[i].QuestionID + "'";
                            oListQuestion1.Add(null);
                            oListString.Add(sDelete);
                        }

                    }
                    else
                    {
                        oListQuestion1.Add(oListQuestion[i]);
                    }
                }

                oListQuestion1.RemoveAll(delegate(Question oQuestion) { if (oQuestion != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListQuestion1;

                    if (oListQuestion1.Count < oListQuestion.Count)
                    {
                        oResult.ResultMessage = "Question Delete Success...";
                    }
                    else if(oListQuestion1.Count==oListQuestion.Count)
                    {
                        oResult.ResultMessage = "Your selected questions are used...";
                    }

                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Question Delete Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Question Delete...";

                logger.Info("Exception DeleteQuestionList QuestionDAO+DAO", oEx);
            }

            logger.Info("End DeleteQuestionList QuestionDAO+DAO");

            return oResult;
        }
        //r
        /// <summary>
        /// This method insert a category if it is not existed
        /// </summary>
        /// <param name="oCategory"> It takes Category Object </param>
        /// <returns> It returns Result Object </returns>
        public Result CategoryEntry(Category oCategory)
        {
            //new CLogger("Start CategoryEntry CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start CategoryEntry CategoryDAO+DAO", ELogLevel.Debug);

            logger.Info("Start CategoryEntry CategoryDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelectCategory = String.Empty;
            String sInsertCategory = String.Empty;

            List<String> sListCategory = new List<String>();

            bool flag = true;

            sSelectCategory = "select CategoryName from EX_Category where CategoryName='" + oCategory.CategoryName + "'";

            try
            {
                oSqlDataReader = oDAOUtil.GetReader(sSelectCategory);

                if (oSqlDataReader.HasRows)
                {
                    flag = false;
                }

                oSqlDataReader.Close();

                if (flag)
                {
                    sInsertCategory = "insert into EX_Category(CategoryName) values('" + oCategory.CategoryName + "')";

                    sListCategory.Add(sInsertCategory);

                    if (oDAOUtil.ExecuteNonQuery(sListCategory))
                    {
                        oResult.ResultObject = oCategory;
                        oResult.ResultMessage = "Category Entry Success...";
                        oResult.ResultIsSuccess = true;

                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "Category Entry Failed...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Category is already Existed";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception occured during Category Entry...";
                oResult.ResultException = oEx;

                logger.Info("Exception CategoryEntry CategoryDAO+DAO", oEx);

                //new CLogger("Exception CategoryEntry CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception CategoryEntry CategoryDAO+DAO", ELogLevel.Debug, oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            //new CLogger("Out CategoryEntry CategoryDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out CategoryEntry CategoryDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End CategoryEntry CategoryDAO+DAO");

            return oResult;
        }
        //r
        /// <summary>
        /// This method setup the selected questions for an exam 
        /// </summary>
        /// <param name="oListQuestionSetup"> It takes List<QuestionSetup> Object </param>
        /// <param name="iarrChecked"> It takes integer array to indicates the marked questions </param>
        /// <returns> It returns Result Object </returns>
        public Result QuestionSetup(List<QuestionSetup> oListQuestionSetup, int[] iarrChecked)
        {
            logger.Info("Start QuestionSetup QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sSelect = String.Empty;
            String sInsert = String.Empty;
            String sUpdate = String.Empty;

            List<String> oListStringInsertUpdate = new List<String>();

            List<QuestionSetup> oListSuccessQuestionSetup = new List<QuestionSetup>();

            SqlDataReader oSqlDataReader = null;

            int i = 0;

            try
            {
                foreach (QuestionSetup oQuestionSetup in oListQuestionSetup)
                {
                    if (iarrChecked[i] == 1)
                    {
                        Boolean flag = true;

                        sSelect = "select ExamID,QuestionID from EX_QuestionGeneration where ExamID='" + oQuestionSetup.QuestionSetupExam.ExamID + "' and QuestionID='" + oQuestionSetup.QuestionSetupQuestion.QuestionID + "'";

                        oSqlDataReader = oDAOUtil.GetReader(sSelect);
                        if (oSqlDataReader.HasRows)
                        {
                            flag = false;
                        }
                        oSqlDataReader.Close();

                        if (flag)
                        {
                            sInsert = "insert into EX_QuestionGeneration(ExamID,QuestionID,SetupQuestionMark,GeneratorID,GenerationTime) values('" + oQuestionSetup.QuestionSetupExam.ExamID + "','" + oQuestionSetup.QuestionSetupQuestion.QuestionID + "','" + oQuestionSetup.QuestionSetupMark + "','" + oQuestionSetup.QuestionSetupSystemUser.SystemUserID + "','" + oQuestionSetup.QuestionSetupGenerationTime + "')";
                            oListStringInsertUpdate.Add(sInsert);

                            oListSuccessQuestionSetup.Add(oQuestionSetup);
                        }

                    }
                    i++;
                }

                if (oListStringInsertUpdate.Count > 0) // any question is setup
                {
                    if (oDAOUtil.ExecuteNonQuery(oListStringInsertUpdate))
                    {
                        oResult.ResultMessage = "Question Setup Success...";
                        oResult.ResultObject = oListSuccessQuestionSetup;
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "Question Setup Failed...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Questions are all ready been Setup...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Question Setup...";

                logger.Info("Exception QuestionSetup QuestionDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End QuestionSetup QuestionDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method show all systemusers
        /// </summary>
        /// <returns> It returns Result Object </returns>
        public Result ShowAllSystemUsers()
        {
            logger.Info("Start ShowAllSystemUsers SystemUserDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            List<SystemUser> oListSystemUser = new List<SystemUser>();

            String sSelect = String.Empty;

            DateTime oDateTime = DateTime.MinValue;

            try
            {
                sSelect = "select SystemUserID,SystemUserName,SystemUserPassword,DeleteTime,EmailAddress from EX_SystemUser where DeleteTime is NULL order by SystemUserName asc";

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    SystemUser oSystemUser = new SystemUser();

                    oSystemUser.SystemUserID = new Guid(oSqlDataReader["SystemUserID"].ToString());
                    oSystemUser.SystemUserName = oSqlDataReader["SystemUserName"].ToString();
                    oSystemUser.SystemUserPassword = oSqlDataReader["SystemUserPassword"].ToString();
                    oSystemUser.SystemUserEmail = oSqlDataReader["EmailAddress"].ToString();

                    if (DateTime.TryParse(oSqlDataReader["DeleteTime"].ToString(), out oDateTime))
                    {
                        oSystemUser.DeleteTime = DateTime.Parse(oSqlDataReader["DeleteTime"].ToString());
                    }

                    oListSystemUser.Add(oSystemUser);
                }

                oSqlDataReader.Close();

                oResult.ResultObject = oListSystemUser;
                oResult.ResultMessage = "System User Load Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "System User Show Exception...";

                logger.Info("Exception ShowAllSystemUsers SystemUserDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End ShowAllSystemUsers SystemUserDAO+DAO");

            return oResult;
        }
Esempio n. 23
0
        /// <summary>
        /// This method updates level information
        /// </summary>
        /// <param name="oLevel"> It takes Level Object </param>
        /// <returns> It returns Result Object </returns>
        public Result LevelUpdate(Level oLevel)
        {
            logger.Info("Start LevelUpdate LevelDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            //String sUpdate = String.Empty;

            //List<String> oListString = new List<String>();

            List<SqlCommand> oListSqlCommand = new List<SqlCommand>();
            List<int> oListInt = new List<int>();

            try
            {
                //sUpdate = "if not exists(select LabelName from EX_Label where LabelName='" + oLevel.LevelName + "')"
                //+ " update EX_Label set LabelName='" + oLevel.LevelName
                //+ "',LabelPrerequisite='" + oLevel.LevelDescription
                //+ "' where LabelID='" + oLevel.LevelID + "'";

                //sUpdate = "update EX_Label set"
                //    + " LabelName="
                //    + " ( case when not exists"
                //    + " (select LabelName from EX_Label where LabelName='" + oLevel.LevelName + "')"
                //    + " then '" + oLevel.LevelName + "'"
                //    + " end ),"
                //    + " LabelPrerequisite='" + oLevel.LevelDescription
                //    + "' where LabelID='" + oLevel.LevelID + "'";

                //oListString.Add(sUpdate);

                //if (oDAOUtil.ExecuteNonQuery(oListString))
                //{
                //    oResult.ResultObject = oLevel;
                //    oResult.ResultMessage = "Level Update Success(if not updated, then level name is existed)...";
                //    oResult.ResultIsSuccess = true;
                //}
                //else
                //{
                //    oResult.ResultIsSuccess = false;
                //    oResult.ResultMessage = "Level Update failed...";
                //}

                SqlCommand oSqlCommand = new SqlCommand("SP_LevelUpdate");
                oSqlCommand.CommandType = CommandType.StoredProcedure;

                oSqlCommand.Parameters.Add("@LabelID", SqlDbType.UniqueIdentifier);
                oSqlCommand.Parameters["@LabelID"].Value = oLevel.LevelID;

                oSqlCommand.Parameters.Add("@LabelName", SqlDbType.VarChar);
                oSqlCommand.Parameters["@LabelName"].Value = oLevel.LevelName;

                oSqlCommand.Parameters.Add("@LabelPrerequisite", SqlDbType.VarChar);
                oSqlCommand.Parameters["@LabelPrerequisite"].Value = oLevel.LevelDescription;

                oListSqlCommand.Add(oSqlCommand);

                oListInt = oDAOUtil.ExecuteNonQueryForStoredProcedure(oListSqlCommand);

                if (oListInt.Count > 0)
                {
                    if (oListInt[0] > 0)
                    {
                        oResult.ResultObject = oLevel;
                        oResult.ResultMessage = "Level Update Success...";
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "Level name is existed...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Level Update failed...";
                }

            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Level Update Exception...";

                logger.Info("Exception LevelUpdate LevelDAO+DAO", oEx);
            }

            logger.Info("End LevelUpdate LevelDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method sums the question categoty & question type wise obtain mark & total mark.
        /// </summary>
        /// <param name="oExam"> It takes Exam Object </param>
        /// <param name="oListCandidateMenu"> It takes List<CandidateMenu> Object </param>
        /// <returns> It returns Result Object </returns>
        public Result GetCandidateAVGMarksForTypeAndCategory(Exam oExam, List<CandidateMenu> oListCandidateMenu)
        {
            logger.Info("Start GetCandidateTotalMarksForTypeAndCategory ResultViewDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sSelect = String.Empty;

            SqlDataReader oSqlDataReader = null;

            //CandidateResultsView oCandidateResultsView = new CandidateResultsView();

            //oCandidateResultsView.ListCandidates = new List<Candidate>();
            //oCandidateResultsView.ListOfListCandidateResults = new List<List<CandidateMenu>>();
            List<Candidate> oListCandidate = new List<Candidate>();

            Object oObject = new Object();

            try
            {

                DataTable dt = new DataTable();

                DataColumn dcolName = new DataColumn("Name", typeof(System.String));
                dt.Columns.Add(dcolName);

                float fTotalMarksForColumn = 0f;

                foreach (CandidateMenu oCandidateMenuInList in oListCandidateMenu) //columns
                {
                    foreach (QuestionType oQuestionTypeInList in oCandidateMenuInList.CandidateMenuCategoryQuestionType) //columns
                    {
                        float fMarkForAColumn = 0f;

                        object oObjectForMarkForAColumn = new object();

                        sSelect = " select sum(EX_QuestionGeneration.SetupQuestionMark) as TotalSetupMarkOfTypeOfCategory"
                                + " from EX_QuestionGeneration inner join EX_Question on EX_QuestionGeneration.QuestionID=EX_Question.QuestionID"
                                + " inner join EX_QuestionType on EX_QuestionType.TypeID = EX_Question.QuestionTypeID"
                                + " where EX_QuestionGeneration.ExamID='"+oExam.ExamID+"'"
                                + " and EX_Question.QuestionCategoryID='" + oCandidateMenuInList.CandidateMenuCategory.CategoryID + "'"
                                + " and EX_QuestionType.TypeID='" + oQuestionTypeInList.QuestionTypeID + "'";

                        oObjectForMarkForAColumn = oDAOUtil.GetExecuteScalar(sSelect);

                        if (oObjectForMarkForAColumn.ToString().Length <= 0)
                        {
                            fMarkForAColumn = 0f;
                        }
                        else
                        {
                            fMarkForAColumn = float.Parse(oObjectForMarkForAColumn.ToString());
                        }

                        fTotalMarksForColumn = fTotalMarksForColumn + fMarkForAColumn;

                        DataColumn dcolCategory = new DataColumn(oCandidateMenuInList.CandidateMenuCategory.CategoryName + "(" + oQuestionTypeInList.QuestionTypeName + ") = " + fMarkForAColumn.ToString(), typeof(System.Double));
                        dt.Columns.Add(dcolCategory);
                    }
                }

                DataColumn dcolTotal = new DataColumn("Total = " + fTotalMarksForColumn.ToString(), typeof(System.Double));
                dt.Columns.Add(dcolTotal);

                sSelect = "select distinct EX_CandidateExam.CandidateID,EX_Candidate.Name from"
                +" EX_Candidate inner join EX_CandidateExam on "
                +" EX_Candidate.CompositeCandidateID=EX_CandidateExam.CandidateID"
                +" where EX_CandidateExam.ExamID='"+oExam.ExamID+"'";

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    Candidate oCandidate = new Candidate();

                    oCandidate.CandidateCompositeID = oSqlDataReader["CandidateID"].ToString();
                    oCandidate.CandidateName = oSqlDataReader["Name"].ToString();

                    oListCandidate.Add(oCandidate);
                }

                oSqlDataReader.Close();

                //int iCandidateCount = 0;

                foreach (Candidate oCandidateInList in oListCandidate)
                {
                    DataRow drow = dt.NewRow();

                    int iColumnIndex = 0;

                    //********orginal*****//
                    //drow["Name"] = oCandidateInList.CandidateName;
                    drow[iColumnIndex++] = oCandidateInList.CandidateName;
                    //*******end orginal**********//

                    float fTotalMarks = 0f;

                    //List<CandidateMenu> oListCandidateMenuForView = new List<CandidateMenu>();

                    //for (int i = 0; i < oListCandidateMenu.Count; i++)
                    //{
                    //    oListCandidateMenuForView.Add(oListCandidateMenu[i]);
                    //}

                    //oCandidateResultsView.ListOfListCandidateResults.Add(oListCandidateMenuForView);

                    foreach (CandidateMenu oCandidateMenuInList in oListCandidateMenu)
                    {
                        //int iTypeCount = 0;

                        foreach (QuestionType oQuestionTypeInList in oCandidateMenuInList.CandidateMenuCategoryQuestionType)
                        {
                            //sSelect = "select sum(EX_CandidateExam.ObtainMark) as AvgTypeMark, EX_QuestionType.TypeID,EX_QuestionType.TypeName from EX_QuestionType inner join EX_Question on EX_QuestionType.TypeID = EX_Question.QuestionTypeID inner join EX_QuestionGeneration on EX_Question.QuestionID= EX_QuestionGeneration.QuestionID inner join EX_CandidateExam on EX_QuestionGeneration.QuestionID = EX_CandidateExam.QuestionID group by EX_CandidateExam.ExamID,EX_CandidateExam.CandidateID,EX_Question.QuestionCategoryID,EX_QuestionType.TypeID,EX_QuestionType.TypeName
                            //having EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.CandidateID='" + oCandidateInList.CandidateCompositeID + "'
                            //and EX_Question.QuestionCategoryID='" + oCandidateMenuInList.CandidateMenuCategory.CategoryID + "' and EX_QuestionType.TypeID='" + oQuestionTypeInList.QuestionTypeID+ "'";

                            sSelect = "select sum(EX_CandidateExam.ObtainMark) as AvgTypeMark, EX_QuestionType.TypeID,EX_QuestionType.TypeName"
                            +" from EX_CandidateExam inner join EX_Question on EX_CandidateExam.QuestionID=EX_Question.QuestionID"
                            +" inner join EX_QuestionType on EX_QuestionType.TypeID = EX_Question.QuestionTypeID"
                            + " where EX_CandidateExam.ExamID='" + oExam.ExamID + "' and"
                            + " EX_CandidateExam.CandidateID='" + oCandidateInList.CandidateCompositeID + "'"
                            +" and EX_Question.QuestionCategoryID='" + oCandidateMenuInList.CandidateMenuCategory.CategoryID + "'"
                            + " and EX_QuestionType.TypeID='" + oQuestionTypeInList.QuestionTypeID + "'"
                            +" group by EX_CandidateExam.ExamID,EX_CandidateExam.CandidateID,EX_Question.QuestionCategoryID,"
                            +" EX_QuestionType.TypeID,EX_QuestionType.TypeName";

                            oObject = oDAOUtil.GetExecuteScalar(sSelect);

                            if (oObject.ToString().Length <= 0)
                            {
                                //oQuestionTypeInList.AVGQuestionTypeMark = 0f;

                                //********orginal*****//
                                //drow[oCandidateMenuInList.CandidateMenuCategory.CategoryName + "(" + oQuestionTypeInList.QuestionTypeName + ")"] = 0f;
                                drow[iColumnIndex++] = 0f;
                                //*******end orginal**********//

                                fTotalMarks = fTotalMarks + 0f;

                                //oCandidateMenuInList.CandidateMenuCategoryQuestionType[iTypeCount].AVGQuestionTypeMark = 0f;

                            }
                            else
                            {
                                //oQuestionTypeInList.AVGQuestionTypeMark = float.Parse(oObject.ToString());
                                //oCandidateMenuInList.CandidateMenuCategoryQuestionType[iTypeCount].AVGQuestionTypeMark = float.Parse(oObject.ToString());

                                //********orginal*****//
                                //drow[oCandidateMenuInList.CandidateMenuCategory.CategoryName + "(" + oQuestionTypeInList.QuestionTypeName + ")"] = float.Parse(oObject.ToString());
                                drow[iColumnIndex++] = float.Parse(oObject.ToString());
                                //*******end orginal**********//

                                fTotalMarks = fTotalMarks + float.Parse(oObject.ToString());
                            }

                            //iTypeCount=iTypeCount+1;
                        }
                    }

                    //iCandidateCount = iCandidateCount + 1;
                    //oCandidateResultsView.ListOfListCandidateResults.Add(oListCandidateMenu);

                    //********orginal*****//
                    //drow["Total"] = fTotalMarks;
                    drow[iColumnIndex++] = fTotalMarks;
                    //*******end orginal**********//

                    dt.Rows.Add(drow);
                }

                oResult.ResultObject = dt;
                oResult.ResultMessage = "GetCandidateAVGMarksForTypeAndCategory Success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "GetCandidateAVGMarksForTypeAndCategory Exception...";

                logger.Info("Exception GetCandidateAVGMarksForTypeAndCategory ResultViewDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End GetCandidateAVGMarksForTypeAndCategory ResultViewDAO+DAO");

            return oResult;
        }
Esempio n. 25
0
        /// <summary>
        /// This method deletes a level if that level is not
        /// used for any question
        /// </summary>
        /// <param name="oLevel"> It takes Level Object </param>
        /// <returns> It returns Result Object </returns>
        public Result Delete(Level oLevel)
        {
            logger.Info("Start Delete LevelDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sDelete= String.Empty;

            //List<String> oListString = new List<String>();

            List<SqlCommand> oListSqlCommand = new List<SqlCommand>();
            List<int> oListInt = new List<int>();

            try
            {
                sDelete = "delete from EX_Label where EX_Label.LabelID='" + oLevel.LevelID + "' and EX_Label.LabelID not in (select EX_Question.QuestionLabelID from EX_Question where EX_Question.QuestionLabelID='" + oLevel.LevelID + "')";

                //oListString.Add(sDelete);

                //if (oDAOUtil.ExecuteNonQuery(oListString))
                //{
                //    oResult.ResultObject = oLevel;
                //    oResult.ResultMessage = "Level Delete Success(if not deleted, then it is used)...";
                //    oResult.ResultIsSuccess = true;
                //}
                //else
                //{
                //    oResult.ResultIsSuccess = false;
                //    oResult.ResultMessage = "Level Delete failed...";
                //}

                SqlCommand oSqlCommand = new SqlCommand(sDelete);
                oSqlCommand.CommandType = CommandType.Text;

                oListSqlCommand.Add(oSqlCommand);

                oListInt = oDAOUtil.ExecuteNonQueryForStoredProcedure(oListSqlCommand);

                if (oListInt.Count > 0)
                {
                    if (oListInt[0] > 0)
                    {
                        oResult.ResultObject = oLevel;
                        oResult.ResultMessage = "Level Delete Success...";
                        oResult.ResultIsSuccess = true;
                    }
                    else
                    {
                        oResult.ResultIsSuccess = false;
                        oResult.ResultMessage = "Level name is used...";
                    }
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Level Delete failed...";
                }

            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Level Delete Exception...";

                logger.Info("Exception Delete LevelDAO+DAO", oEx);
            }

            logger.Info("End Delete LevelDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method show the questions according to question level.
        /// And these questions are already been setup.
        /// </summary>
        /// <param name="oQuestionSetup"> It takes QuestionSetup Object </param>
        /// <returns> It returns Result Object </returns>
        public Result QuestionSetupListShowByQuestionLevel(QuestionSetup oQuestionSetup)
        {
            logger.Info("Start QuestionSetupListShowByQuestionLevel QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sSelect = String.Empty;

            List<QuestionSetup> oListQuestionSetup = new List<QuestionSetup>();

            SqlDataReader oSqlDataReader = null;

            try
            {
                if (oQuestionSetup.QuestionSetupQuestion.QuestionCreator.SystemUserName.Equals("administrator"))
                {
                    sSelect = "select EX_QuestionGeneration.ExamID,EX_QuestionGeneration.QuestionID,EX_QuestionGeneration.SetupQuestionMark,EX_QuestionGeneration.GeneratorID,"
                    +" EX_Question.QuestionText,EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID,EX_Question.QuestionPossibleAnswerTime,"
                    +" EX_Question.QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite"
                    +" from EX_Label inner join EX_Question on EX_Label.LabelID=EX_Question.QuestionLabelID inner join"
                    + " EX_QuestionGeneration on EX_Question.QuestionID=EX_QuestionGeneration.QuestionID"
                    +" where EX_QuestionGeneration.ExamID='" + oQuestionSetup.QuestionSetupExam.ExamID + "' and EX_Question.QuestionTypeID='" + oQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID + "'"
                    +" and EX_Question.QuestionCategoryID='" + oQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID + "'"
                    +" and EX_Question.QuestionLabelID='" + oQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID+"'";
                }
                else
                {
                    sSelect = "select EX_QuestionGeneration.ExamID,EX_QuestionGeneration.QuestionID,EX_QuestionGeneration.SetupQuestionMark,EX_QuestionGeneration.GeneratorID,"
                        + " EX_Question.QuestionText,EX_Question.QuestionTypeID,EX_Question.QuestionCategoryID,EX_Question.QuestionPossibleAnswerTime,"
                        + " EX_Question.QuestionLabelID,EX_Label.LabelName,EX_Label.LabelPrerequisite"
                        + " from EX_Label inner join EX_Question on EX_Label.LabelID=EX_Question.QuestionLabelID inner join"
                        + " EX_QuestionGeneration on EX_Question.QuestionID=EX_QuestionGeneration.QuestionID"
                        +" where EX_QuestionGeneration.ExamID='" + oQuestionSetup.QuestionSetupExam.ExamID + "' and EX_QuestionGeneration.GeneratorID='" + oQuestionSetup.QuestionSetupQuestion.QuestionCreator.SystemUserID + "'"
                        +" and EX_Question.QuestionTypeID='" + oQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID + "' and EX_Question.QuestionCategoryID='" + oQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID + "'"
                        + " and EX_Question.QuestionLabelID='" + oQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID+"'";
                }

                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                while (oSqlDataReader.Read())
                {
                    QuestionSetup oPopulatedQuestionSetup = new QuestionSetup();

                    oPopulatedQuestionSetup.QuestionSetupExam.ExamID = new Guid(oSqlDataReader["ExamID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionID = new Guid(oSqlDataReader["QuestionID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupMark = float.Parse(oSqlDataReader["SetupQuestionMark"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupSystemUser.SystemUserID = new Guid(oSqlDataReader["GeneratorID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionText = oSqlDataReader["QuestionText"].ToString();
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionQuestionType.QuestionTypeID = int.Parse(oSqlDataReader["QuestionTypeID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionCategory.CategoryID = int.Parse(oSqlDataReader["QuestionCategoryID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionPossibleAnswerTime = float.Parse(oSqlDataReader["QuestionPossibleAnswerTime"].ToString());

                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelID = new Guid(oSqlDataReader["QuestionLabelID"].ToString());
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelName = oSqlDataReader["LabelName"].ToString();
                    oPopulatedQuestionSetup.QuestionSetupQuestion.QuestionLevel.LevelDescription = oSqlDataReader["LabelPrerequisite"].ToString();

                    oListQuestionSetup.Add(oPopulatedQuestionSetup);
                }

                oSqlDataReader.Close();

                oResult.ResultObject = oListQuestionSetup;
                oResult.ResultMessage = "QuestionSetupListShowByQuestionLevel success...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during QuestionSetup ListShow ByQuestionLevel...";

                logger.Info("Exception QuestionSetupListShowByQuestionLevel QuestionDAO+DAO", oEx);
            }
            finally
            {
                if (oSqlDataReader != null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            logger.Info("End QuestionSetupListShowByQuestionLevel QuestionDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This Method save all answers of questions for an exam.
        /// This method is called when a candidate finish an exam
        /// </summary>
        /// <param name="oCandidateForExam"> It takes CandidateForExam Object </param>
        /// <returns> It returns Result Object </returns>
        public Result SaveCandidateAnswers(CandidateForExam oCandidateForExam)
        {
            //new CLogger("Start SaveCandidateAnswers CandidateExamProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start SaveCandidateAnswers CandidateExamProcessDAO+DAO", ELogLevel.Debug);

            logger.Info("Start SaveCandidateAnswers CandidateExamProcessDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            String sInsert = String.Empty;
            String sDesOrObj = String.Empty;

            List<String> oListString = new List<String>();

            try
            {
                foreach (CandidateAnswerQuestion oCandidateAnswerQuestion in oCandidateForExam.CadidateCandidateExam.CandidateAnsweredQuestions)
                {
                    if (oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID == 0)
                    {
                        sDesOrObj = "Objective@";

                        foreach (Choice oChoice in oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionObjectiveType.ListOfChoices)
                        {
                            sDesOrObj = sDesOrObj + oChoice.ChoiceIsValid.ToString()+":";
                        }
                    }
                    else
                    {
                        sDesOrObj = "Descriptive@"+oCandidateAnswerQuestion.DescriptiveQuestionAnswerText+":";
                    }

                    sInsert = "insert into EX_CandidateExam(ExamID,QuestionID,CandidateID,AnswerStringOrBits,AnswerAttachmentPath) values('" + oCandidateForExam.CadidateCandidateExam.CandiadteExamExam.ExamID + "','" + oCandidateAnswerQuestion.QuestionForCandidateAnswer.QuestionID + "','" + oCandidateForExam.CandidateForExamCandidate.CandidateCompositeID + "','" + sDesOrObj + "','" + oCandidateAnswerQuestion.sAnswerAttachFilePath + "')";
                    oListString.Add(sInsert);
                }

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultIsSuccess = true;
                    oResult.ResultObject = oCandidateForExam;
                    oResult.ResultMessage = "Candidate Answer Save Success...";
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Candidate Answer Save Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception in Candidate Answer Save...";
                oResult.ResultException = oEx;

                logger.Info("Exception SaveCandidateAnswers CandidateExamProcessDAO+DAO", oEx);

                //new CLogger("Exception SaveCandidateAnswers CandidateExamProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception SaveCandidateAnswers CandidateExamProcessDAO+DAO", ELogLevel.Debug, oEx);
            }

            //new CLogger("Out SaveCandidateAnswers CandidateExamProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out SaveCandidateAnswers CandidateExamProcessDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End SaveCandidateAnswers CandidateExamProcessDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method remove the selected questions for an exam 
        /// </summary>
        /// <param name="oListQuestionSetup"> It takes List<QuestionSetup> Object </param>
        /// <param name="iarrChecked"> It takes integer array to indicates the marked questions </param>
        /// <returns> It returns Result Object </returns>
        public Result QuestionSetupRemove(List<QuestionSetup> oListQuestionSetup, int[] iarrChecked)
        {
            logger.Info("Start QuestionSetupRemove QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<String> oListString = new List<String>();
            String sDelete = String.Empty;

            List<QuestionSetup> oListQuestionSetup1 = new List<QuestionSetup>();

            try
            {
                int i = 0;

                for (i = 0; i < iarrChecked.Length; i++)
                {
                    if (iarrChecked[i] == 1)
                    {
                        sDelete = "delete from EX_QuestionGeneration where ExamID='" + oListQuestionSetup[i].QuestionSetupExam.ExamID + "' and QuestionID='" + oListQuestionSetup[i].QuestionSetupQuestion.QuestionID + "' and GeneratorID='" + oListQuestionSetup[i].QuestionSetupSystemUser.SystemUserID + "'";
                        oListQuestionSetup1.Add(null);
                        oListString.Add(sDelete);
                    }
                    else
                    {
                        oListQuestionSetup1.Add(oListQuestionSetup[i]);
                    }
                }

                oListQuestionSetup1.RemoveAll(delegate(QuestionSetup oQuestionSetup) { if (oQuestionSetup != null) { return false; } return true; });

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oListQuestionSetup1;
                    oResult.ResultMessage = "Question Setup Remove Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Question Setup Remove Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultMessage = "Exception occured during Question Setup Remove...";
                oResult.ResultException = oEx;

                logger.Info("Exception QuestionSetupRemove QuestionDAO+DAO", oEx);
            }

            logger.Info("End QuestionSetupRemove QuestionDAO+DAO");

            return oResult;
        }
        //r
        /// <summary>
        /// This method Update a Question
        /// </summary>
        /// <param name="oQuestion"> It takes Question Object </param>
        /// <returns> It returns Result Object </returns>
        public Result UpdateQuestion(Question oQuestion)
        {
            logger.Info("Start UpdateQuestion QuestionDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            List<String> oListString = new List<String>();
            String sString = String.Empty;

            int iBit = 0;

            try
            {
                sString = "update EX_Question set QuestionDefaultMark='" + oQuestion.QuestionDefaultMark + "',QuestionPossibleAnswerTime='"+oQuestion.QuestionPossibleAnswerTime +"' where QuestionID='" + oQuestion.QuestionID + "'";
                oListString.Add(sString);

                //if (!oQuestion.QuestionIsDescriptive)
                if (oQuestion.QuestionQuestionType.QuestionTypeID==0)
                {
                    sString = "delete from EX_Objective where ObjectiveQuestionID='" + oQuestion.QuestionID + "'";
                    oListString.Add(sString);

                    foreach (Choice oChoice in oQuestion.QuestionObjectiveType.ListOfChoices)
                    {
                        iBit = 0;

                        if (oChoice.ChoiceIsValid)
                        {
                            iBit = 1;
                        }

                        sString = "insert into EX_Objective(ObjectiveQuestionID,ObjectiveAnswer,ObjectiveAnswerIsValid) values('" + oQuestion.QuestionID + "','" + oChoice.ChoiceName + "','" + iBit + "')";
                        oListString.Add(sString);
                    }
                }

                if (oDAOUtil.ExecuteNonQuery(oListString))
                {
                    oResult.ResultObject = oQuestion;
                    oResult.ResultMessage = "Question Update Success...";
                    oResult.ResultIsSuccess = true;
                }
                else
                {
                    oResult.ResultIsSuccess = false;
                    oResult.ResultMessage = "Question Update Failed...";
                }
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured during Question Update...";

                logger.Info("Exception UpdateQuestion QuestionDAO+DAO", oEx);
            }

            logger.Info("End UpdateQuestion QuestionDAO+DAO");

            return oResult;
        }
        /// <summary>
        /// This method evaluate objective answers for all candidate of an exam.
        /// Only the administrator can call this method.
        /// It evaluates automatically
        /// </summary>
        /// <param name="oListCandidateForExamForGrid"> It takes List<CandidateForExam> Object </param>
        /// <param name="oExam"> It takes Exam Object </param>
        /// <param name="oSystemUser"> It takes SystemUser Object </param>
        /// <returns> It returns Result Object </returns>
        public Result EvaluateObjectiveAnswersForAllCandidateOfAnExma(List<CandidateForExam> oListCandidateForExamForGrid, SystemUser oSystemUser, Exam oExam)
        {
            //new CLogger("Start EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Start EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", ELogLevel.Debug);

            logger.Info("Start EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO");

            Result oResult = new Result();
            DAOUtil oDAOUtil = new DAOUtil();

            SqlDataReader oSqlDataReader = null;

            String sSelect = String.Empty;

            try
            {
                foreach (CandidateForExam oCandidateForExamInList in oListCandidateForExamForGrid)
                {
                    List<CandidateAnswerQuestion> oListCandidateAnswerQuestion = new List<CandidateAnswerQuestion>();

                    oResult = LoadQuestionsForACandidateWhichSetupByAParticularUser(oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID, oExam, oSystemUser, true);

                    if (oResult.ResultIsSuccess)
                    {
                        oListCandidateAnswerQuestion = (List<CandidateAnswerQuestion>)oResult.ResultObject;

                        foreach (CandidateAnswerQuestion oCandidateAnswerQuestionInList in oListCandidateAnswerQuestion)
                        {
                            if (oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionQuestionType.QuestionTypeID == 0)
                            {
                                if (oSystemUser.SystemUserName.ToLower().Equals("administrator"))
                                {
                                    //sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer,EX_Objective.ObjectiveAnswerIsValid from EX_Objective inner join EX_Question on EX_Objective.ObjectiveQuestionID = EX_Question.QuestionID inner join EX_QuestionGeneration on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID inner join EX_CandidateExam on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID where EX_CandidateExam.QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "' and EX_CandidateExam.CandidateID='" + oCandidateInList.CandidateCompositeID + "' and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "' and EX_QuestionGeneration.GeneratorID='" + oSystemUser.SystemUserID + "')";
                                    //sSelect = "select distinct EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer,"
                                    //+" EX_Objective.ObjectiveAnswerIsValid from EX_Objective inner join EX_Question"
                                    //+" on EX_Objective.ObjectiveQuestionID = EX_Question.QuestionID inner join EX_QuestionGeneration"
                                    //+" on EX_Question.QuestionID = EX_QuestionGeneration.QuestionID inner join EX_CandidateExam"
                                    //+" on EX_CandidateExam.QuestionID=EX_QuestionGeneration.QuestionID"
                                    //+" where EX_CandidateExam.QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'"
                                    //+" and EX_CandidateExam.CandidateID='" + oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID + "'"
                                    //+" and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID"
                                    //+" in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration"
                                    //+" where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "')";

                                    sSelect = "select EX_Objective.ObjectiveQuestionID,EX_Objective.ObjectiveAnswer,"
                                    + " EX_Objective.ObjectiveAnswerIsValid from EX_Objective inner join EX_CandidateExam"
                                    + " on EX_CandidateExam.QuestionID=EX_Objective.ObjectiveQuestionID"
                                    + " where EX_CandidateExam.QuestionID='" + oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionID + "'"
                                    + " and EX_CandidateExam.CandidateID='" + oCandidateForExamInList.CandidateForExamCandidate.CandidateCompositeID + "'"
                                    + " and EX_CandidateExam.ExamID='" + oExam.ExamID + "' and EX_CandidateExam.QuestionID"
                                    + " in (select EX_QuestionGeneration.QuestionID from EX_QuestionGeneration"
                                    + " where EX_QuestionGeneration.ExamID='" + oExam.ExamID + "')";
                                }

                                String sCheckValid = String.Empty;
                                String sCheckName = String.Empty;

                                List<Choice> oListChoices = new List<Choice>();

                                oSqlDataReader = oDAOUtil.GetReader(sSelect);

                                while (oSqlDataReader.Read())
                                {
                                    Choice oChoice = new Choice();

                                    oChoice.ChoiceIsValid = Boolean.Parse(oSqlDataReader["ObjectiveAnswerIsValid"].ToString());
                                    oChoice.ChoiceName = oSqlDataReader["ObjectiveAnswer"].ToString();

                                    oListChoices.Add(oChoice);
                                }

                                oSqlDataReader.Close();

                                oCandidateAnswerQuestionInList.QuestionForCandidateAnswer.QuestionObjectiveType.ListOfChoices = oListChoices;
                            }
                        }

                        oCandidateForExamInList.CadidateCandidateExam.CandidateAnsweredQuestions = oListCandidateAnswerQuestion;
                    }
                }

                oResult.ResultObject = oListCandidateForExamForGrid;
                oResult.ResultMessage = "Objective answers are evaluated for all candidate of this exam...";
                oResult.ResultIsSuccess = true;
            }
            catch (Exception oEx)
            {
                oResult.ResultIsSuccess = false;
                oResult.ResultException = oEx;
                oResult.ResultMessage = "Exception occured at evaluation of objective answers for all candidate of this exam...";

                logger.Info("Exception EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", oEx);

                //new CLogger("Exception EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Exception EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", ELogLevel.Debug, oEx);
            }
            finally
            {
                if (oSqlDataReader!=null && !oSqlDataReader.IsClosed)
                {
                    oSqlDataReader.Close();
                }
            }

            //new CLogger("Out EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", FileNameManagerInDLL.sLogFileName, 1).WriteLog("Out EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO", ELogLevel.Debug); ;

            logger.Info("End EvaluateObjectiveAnswersForAllCandidateOfAnExma EvaluateProcessDAO+DAO");

            return oResult;
        }