コード例 #1
0
 protected PredefinedLocalizedChoiceDto ReadPredefineLocalizedChoice(IDataReader reader, ref bool alreadyRead)
 {
     PredefinedLocalizedChoiceDto retval = new PredefinedLocalizedChoiceDto();
     retval.ElementId = reader.GetInt32(0);
     List<CountryLanguageDto> temp = GetCoutryLanguage(reader.GetInt32(1), String.Empty, String.Empty);
     if (temp.Count > 0)
         retval.PCountryLanguageDto = temp[0];
     List<PredefinedChoiceDto> tempChoices = GetPredefinedChoices(null, reader.GetInt32(2));
     if (tempChoices.Count > 0)
         retval.PChoiceDto = tempChoices[0];
     retval.ChoiceLabel = reader.GetString(3);
     retval.OtherText = GetString(reader, 4);
     retval.ErrorMessage = GetString(reader, 5);
     alreadyRead = reader.Read();
     return retval;
 }
コード例 #2
0
        public PredefinedLocalizedChoiceDto SaveLocalizedChoice(PredefinedLocalizedChoiceDto pChoiceDto)
        {
            PredefinedLocalizedChoiceDto retval = null;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "update_localized_predefined_choice";
                sp.CommandType = CommandType.StoredProcedure;
                _dbLayer.AddParameter(sp, "@element_id", ParameterDirection.Input, DbType.Int32, pChoiceDto.ElementId);
                _dbLayer.AddParameter(sp, "@choice_label", ParameterDirection.Input, DbType.String, pChoiceDto.ChoiceLabel);
                _dbLayer.AddParameter(sp, "@other_text", ParameterDirection.Input, DbType.String, pChoiceDto.OtherText);
                _dbLayer.AddParameter(sp, "@error_message", ParameterDirection.Input, DbType.String, pChoiceDto.ErrorMessage);
                _dbLayer.AddReturnParameter(sp);
                reader = sp.ExecuteReader();
                if (reader.Read())
                {
                    bool alreadyRead = true; ;
                    retval = ReadPredefineLocalizedChoice(reader, ref alreadyRead);
                }
                else
                {
                    int err = _dbLayer.GetReturnValue(sp);
                    Trace.WriteLine("PredefinedQuestionDao.SaveLocalizedChoice("+pChoiceDto+") returned " + err);
                }
            }
            catch (DbException e)
            {
                Trace.WriteLine("PredefinedQuestionDao.SaveLocalizedChoice("+pChoiceDto+"): " + 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;
        }
コード例 #3
0
 protected void InitializeVariables()
 {
     question = null;
     listOfChoices = null;
     otherChoice = null;
 }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
 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();
         }
     }
 }
コード例 #6
0
 public static PredefinedLocalizedChoiceDto SaveLocalizedChoice(PredefinedLocalizedChoiceDto pChoiceDto)
 {
     return FormRegistry.PredefinedQuestionDao.SaveLocalizedChoice(pChoiceDto);
 }
コード例 #7
0
 protected void LoadOther(PredefinedLocalizedChoiceDto otherChoice)
 {
     if (otherChoice != null &&
         otherChoice.PChoiceDto != null)
     {
         other_text_lbl.Text = otherChoice.OtherText;
         other_text_lbl_en.Text = otherChoice.PChoiceDto.OtherText;
         error_text_lbl.Text = otherChoice.ErrorMessage;
         error_text_lbl_en.Text = otherChoice.PChoiceDto.ErrorMessage;
     }
 }