示例#1
0
        public PredefinedLocalizedQuestionDto SaveLocalizedQuestion(PredefinedLocalizedQuestionDto pQuestionDto)
        {
            PredefinedLocalizedQuestionDto retval = null;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "update_localized_predefined_question";
                sp.CommandType = CommandType.StoredProcedure;
                _dbLayer.AddParameter(sp, "@element_id", ParameterDirection.Input, DbType.Int32, pQuestionDto.ElementId);
                _dbLayer.AddParameter(sp, "@question_text", ParameterDirection.Input, DbType.String, pQuestionDto.QuestionText);
                _dbLayer.AddParameter(sp, "@status_active", ParameterDirection.Input, DbType.Int16, pQuestionDto.StatusActive);
                _dbLayer.AddReturnParameter(sp);
                reader = sp.ExecuteReader();
                if (reader.Read())
                {
                    retval = ReadPredefineLocalizedQuestion(reader);
                }
                else
                {
                    int err = _dbLayer.GetReturnValue(sp);
                    Trace.WriteLine("PredefinedQuestionDao.SaveLocalizedQuestion("+pQuestionDto+") returned " + err);
                }
            }
            catch (DbException e)
            {
                Trace.WriteLine("PredefinedQuestionDao.SaveLocalizedQuestion(" + pQuestionDto + "): " + e.Message);
                retval = null;
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
                if (sp != null)
                    sp.Dispose();
                if (connection != null)
                {
                    _dbLayer.ReturnConnection(connection);
                }
                else
                {
                    _dbLayer.ReturnConnection(connection, true);
                }
            }
            return retval;
        }
示例#2
0
 protected PredefinedLocalizedQuestionDto ReadPredefineLocalizedQuestion(IDataReader reader)
 {
     PredefinedLocalizedQuestionDto retval = new PredefinedLocalizedQuestionDto();
     retval.ElementId = reader.GetInt32(0);
     List<CountryLanguageDto> temp = GetCoutryLanguage(reader.GetInt32(1), String.Empty, String.Empty);
     if (temp.Count > 0)
         retval.PCountryLanguageDto = temp[0];
     retval.PQuestionDto = GetQuestionById(reader.GetInt32(2));
     retval.QuestionText = reader.GetString(3);
     retval.StatusActive = reader.GetInt16(4);
     return retval;
 }
示例#3
0
 protected PredefinedLocalizedQuestionDto ReadPredefineLocalizedQuestionByInternalQuestionId(IDataReader reader)
 {
     PredefinedLocalizedQuestionDto retval = new PredefinedLocalizedQuestionDto();
     retval.ElementId = reader.GetInt32(0);
     retval.QuestionText = reader.GetString(1);
     return retval;
 }
 protected void InitializeVariables()
 {
     question = null;
     listOfChoices = null;
     otherChoice = null;
 }
        protected void Save_Click(object sender, EventArgs e)
        {
            InitializeErrorsPanels();
            bool validated = true;
            GetCurrentChoices();
            GetCurrentQuestion();
            GetCurrentOtherChoice();
            validated = validated & ValidateQuestion();
            validated = validated & ValidateListOfChoices();
            validated = validated & ValidateOtherChoice();

            if (validated)
            {
                try
                {
                    //if everything is validated correctly we can save updates for localization
                    question = PredefinedQuestionFacade.SaveLocalizedQuestion(question);
                    foreach (PredefinedLocalizedChoiceDto choice in listOfChoices)
                    {
                        PredefinedLocalizedChoiceDto nChoice = PredefinedQuestionFacade.SaveLocalizedChoice(choice);
                    }
                    if (otherChoice != null)
                    {
                        otherChoice = PredefinedQuestionFacade.SaveLocalizedChoice(otherChoice);
                    }
                    ResetAllFields();
                    localizations_dropdown.SelectedIndex = 0;
                }
                catch (Exception)
                {
                    errorSavingDatabasePanel.Visible = true;
                }
            }
        }
 protected void LocalizationDropdown_SelectedIndexChanged(object sender, EventArgs e)
 {
     ResetAllFields();
     if (question_dropdown.SelectedIndex > 0 &&
         localizations_dropdown.SelectedIndex > 0)
     {
         int localizeId = int.Parse(localizations_dropdown.SelectedValue);
         int questionId = int.Parse(question_dropdown.SelectedValue);
         
         question = PredefinedQuestionFacade.GetPredefinedLocalizedQuestionByQuestionIdAndLocalizeId(questionId, localizeId);
         if (question != null)
         {
             questionPanel.Visible = true;
             save_question.Visible = true;
         }
         LoadQuestion();
         List<PredefinedLocalizedChoiceDto> tempList = PredefinedQuestionFacade.GetPredefinedLocalizedChoicesByPredefinedQuestionIdAndLocalizeId(questionId, localizeId);
         if (tempList != null && tempList.Count >0)
         {
             foreach (PredefinedLocalizedChoiceDto choice in tempList)
             {
                 //if choice is other choice
                 if (choice.PChoiceDto != null &&
                     choice.PChoiceDto.SortSequence == 999 &&
                     !String.IsNullOrEmpty(choice.PChoiceDto.OtherText) &&
                     !String.IsNullOrEmpty(choice.PChoiceDto.ErrorMessage))
                 {
                     otherChoice = choice;
                     otherChoicePanel.Visible = true;                            
                     LoadOther();
                 }
                 else //else is normal choice
                 {
                     if (listOfChoices == null)
                         listOfChoices = new List<PredefinedLocalizedChoiceDto>();
                     listOfChoices.Add(choice);
                     listOfChoicesPanel.Visible = true;
                     bulkPanel.Visible = true;
                 }
             }
             LoadListOfChoices();
         }
     }
 }
 public static PredefinedLocalizedQuestionDto SaveLocalizedQuestion(PredefinedLocalizedQuestionDto pQuestionDto)
 {
     return FormRegistry.PredefinedQuestionDao.SaveLocalizedQuestion(pQuestionDto);
 }
 protected void LoadQuestionContent(PredefinedLocalizedQuestionDto question)
 {
     if (question != null &&
         question.PQuestionDto != null)
     {
         question_text.Text = question.QuestionText;
         question_text_en.Text = question.PQuestionDto.QuestionText;
     }
 }