/// <summary> /// Get the current DB data and fill /// the fields with them /// </summary> private void BindFields() { DateFormatLabel.Text = (DateTime.Now).ToShortDateString(); // Retrieve the survey data SurveyData surveyData = new Surveys().GetSurveyById(SurveyId, ""); SurveyData.SurveysRow survey = surveyData.Surveys[0]; // Assigns the retrieved data to the correct fields TitleTextBox.Text = survey.Title; ActiveCheckBox.Checked = survey.Activated; ArchiveCheckBox.Checked = survey.Archive; ScoredCheckbox.Checked = survey.Scored; QuestionNumberingCheckbox.Checked = survey.QuestionNumberingDisabled; OpeningDateTextBox.Text = survey.IsOpenDateNull() ? null : survey.OpenDate.ToShortDateString(); CloseDateTextbox.Text = survey.IsCloseDateNull() ? null : survey.CloseDate.ToShortDateString(); EnableNavigationCheckbox.Checked = survey.NavigationEnabled; EmailFromTextbox.Text = survey.EmailFrom; EmailToTextBox.Text = survey.EmailTo; EmailSubjectTextbox.Text = survey.EmailSubject; ViewState["ThanksMessage"] = survey.ThankYouMessage; DefaultSurveyCheckBox.Checked = survey.DefaultSurvey; EntryNotificationDropdownlist.DataSource = new Surveys().GetSurveyNotificationModes(); EntryNotificationDropdownlist.DataTextField = "description"; EntryNotificationDropdownlist.DataValueField = "NotificationModeId"; EntryNotificationDropdownlist.DataBind(); ((PageBase)Page).TranslateListControl(EntryNotificationDropdownlist); EntryNotificationDropdownlist.SelectedValue = survey.NotificationModeID.ToString(); if ((NotificationMode)survey.NotificationModeID != NotificationMode.None) { NotificationPlaceHolder.Visible = true; } else { NotificationPlaceHolder.Visible = false; } ProgressDisplayDropDownList.DataSource = new Surveys().GetSurveyProgressModes(); ProgressDisplayDropDownList.DataTextField = "description"; ProgressDisplayDropDownList.DataValueField = "ProgressDisplayModeId"; ProgressDisplayDropDownList.DataBind(); ((PageBase)Page).TranslateListControl(ProgressDisplayDropDownList); ProgressDisplayDropDownList.SelectedValue = survey.ProgressDisplayModeID.ToString(); ResumeModeDropdownlist.DataSource = new Surveys().GetSurveyResumeModes(); ResumeModeDropdownlist.DataTextField = "description"; ResumeModeDropdownlist.DataValueField = "ResumeModeId"; ResumeModeDropdownlist.DataBind(); ((PageBase)Page).TranslateListControl(ResumeModeDropdownlist); ResumeModeDropdownlist.SelectedValue = survey.ResumeModeID.ToString(); }
private void CreateSurveyButton_Click(object sender, System.EventArgs e) { // Creates a new entity and assign // the new values SurveyData surveyData = new SurveyData(); SurveyData.SurveysRow surveyRow = surveyData.Surveys.NewSurveysRow(); if (TitleTextBox.Text.Length == 0) { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingSurveyTitleMessage")); MessageLabel.Visible = true; return; } surveyRow.Title = TitleTextBox.Text; surveyRow.Activated = false; surveyRow.Archive = false; surveyRow.AccessPassword = string.Empty; surveyRow.SurveyDisplayTimes = 0; surveyRow.ResultsDisplayTimes = 0; surveyRow.SetOpenDateNull(); surveyRow.SetCloseDateNull(); surveyRow.CreationDate = DateTime.Now; surveyRow.IPExpires = 1440; surveyRow.CookieExpires = 1440; surveyRow.OnlyInvited = false; surveyRow.Scored = false; surveyRow.QuestionNumberingDisabled = false; surveyRow.FolderId = ((PageBase)Page).SelectedFolderId; surveyRow.ProgressDisplayModeID = (int)ProgressDisplayMode.PagerNumbers; surveyRow.ResumeModeID = (int)ResumeMode.NotAllowed; surveyData.Surveys.AddSurveysRow(surveyRow); try { // Add the survey in the DB new Survey().AddSurvey(surveyData); AssignSurveyToUser(surveyData.Surveys[0].SurveyId); ((PageBase)Page).SurveyId = surveyData.Surveys[0].SurveyId; ((Wap)Page.Master).isTreeStale = true; //This messes up the tree astructure etc so Stay where you are UINavigator.NavigateToSurveyBuilder(surveyRow.SurveyId, 4); } catch (SurveyExistsFoundException ex) { string x = ex.Message; ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyExistsInFolder")); MessageLabel.Visible = true; } }
/// <summary> /// Get the current DB data and fill /// the fields with them /// </summary> private void BindFields() { // Retrieve the survey data SurveyData surveyData = new Surveys().GetSurveyById(SurveyId, LanguagesDropdownlist.SelectedValue); SurveyData.SurveysRow survey = surveyData.Surveys[0]; RedirectionURLTextBox.Text = survey.RedirectionURL; //ThankYouFreeTextBox.Text = survey.ThankYouMessage; ThankYouCKEditor.Text = survey.ThankYouMessage; SurveyMessageConditons.BindData(); }
/// <summary> /// Get the current DB data and fill /// the fields with them /// </summary> private void BindFields() { // Retrieve the survey data SurveyData surveyData = new Surveys().GetSurveyById(SurveyId, ""); SurveyData.SurveysRow survey = surveyData.Surveys[0]; // Assigns the retrieved data to the correct fields TitleTextBox.Text = survey.Title; ViewState["ThanksMessage"] = survey.ThankYouMessage; DataSet surveygroupData = new Surveys().GetSurveyGroup(SurveyId); if (surveygroupData != null && surveygroupData.Tables.Count > 0 && surveygroupData.Tables[0].Rows.Count > 0) { // Assigns the retrieved data to the correct fields GroupIdTextBox.Text = (String)surveygroupData.Tables[0].Rows[0]["GroupId"]; } }
/// <summary> /// Apply the survey data changes to the DB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ApplyChangesButton_Click(object sender, System.EventArgs e) { if (OpeningDateTextBox.Text.Length != 0 && !Information.IsDate(OpeningDateTextBox.Text)) { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidOpeningDate")); MessageLabel.Visible = true; return; } if (CloseDateTextbox.Text.Length != 0 && !Information.IsDate(CloseDateTextbox.Text)) { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidClosingDate")); MessageLabel.Visible = true; return; } if (((NotificationMode)int.Parse(EntryNotificationDropdownlist.SelectedValue)) != NotificationMode.None) { if (EmailFromTextbox.Text.Length == 0 || !((PageBase)Page).isEmail(EmailFromTextbox.Text)) { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidFromEmail")); MessageLabel.Visible = true; return; } if (EmailToTextBox.Text.Length == 0 || !((PageBase)Page).isEmail(EmailToTextBox.Text)) { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("InvalidToEmail")); MessageLabel.Visible = true; return; } NotificationPlaceHolder.Visible = true; } else { EmailFromTextbox.Text = string.Empty; EmailToTextBox.Text = string.Empty; EmailSubjectTextbox.Text = string.Empty; NotificationPlaceHolder.Visible = false; } try { // Creates a new entity and assign // the updated values SurveyData surveyData = new SurveyData(); SurveyData.SurveysRow surveyRow = surveyData.Surveys.NewSurveysRow(); surveyRow.SurveyId = SurveyId; surveyRow.Title = TitleTextBox.Text; surveyRow.Activated = ActiveCheckBox.Checked; surveyRow.Archive = ArchiveCheckBox.Checked; surveyRow.Scored = ScoredCheckbox.Checked; surveyRow.QuestionNumberingDisabled = QuestionNumberingCheckbox.Checked; surveyRow.NavigationEnabled = EnableNavigationCheckbox.Checked; surveyRow.ResumeModeID = int.Parse(ResumeModeDropdownlist.SelectedValue); surveyRow.ProgressDisplayModeID = int.Parse(ProgressDisplayDropDownList.SelectedValue); surveyRow.NotificationModeID = int.Parse(EntryNotificationDropdownlist.SelectedValue); surveyRow.DefaultSurvey = DefaultSurveyCheckBox.Checked; surveyRow.ThankYouMessage = ViewState["ThanksMessage"] == null ? null : ViewState["ThanksMessage"].ToString(); if (((NotificationMode)surveyRow.NotificationModeID) != NotificationMode.None) { surveyRow.EmailFrom = EmailFromTextbox.Text; surveyRow.EmailTo = EmailToTextBox.Text; surveyRow.EmailSubject = EmailSubjectTextbox.Text; } if (OpeningDateTextBox.Text.Length != 0) { surveyRow.OpenDate = DateTime.Parse(OpeningDateTextBox.Text); } if (CloseDateTextbox.Text.Length != 0) { surveyRow.CloseDate = DateTime.Parse(CloseDateTextbox.Text); } surveyData.Surveys.AddSurveysRow(surveyRow); // Update the DB new Survey().UpdateSurvey(surveyData, ""); ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyUpdatedMessage")); MessageLabel.Visible = true; ((Wap)this.Page.Master.Master).isTreeStale = true; ((Wap)this.Page.Master.Master).RebuildTree(); // Let the subscribers know that something changed OnOptionChanged(); } catch (SurveyExistsFoundException ex) { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("SurveyExistsInFolder")); MessageLabel.Visible = true; } }
/// <summary> /// Retrieve all survey data from the db /// </summary> protected virtual void GetSurveyData() { SurveyData surveyById = new Surveys().GetSurveyById(this.SurveyId, this.LanguageCode); this._surveyRow = surveyById.Surveys[0]; this._surveyTitle = this._surveyRow.Title; this._redirectionURL = this._surveyRow.RedirectionURL; this._unAuthentifiedUserAction = (UnAuthentifiedUserAction)this._surveyRow.UnAuthentifiedUserActionID; this._enableNavigation = this._surveyRow.NavigationEnabled; this._progressMode = (ProgressDisplayMode)this._surveyRow.ProgressDisplayModeID; this._notificationMode = (NotificationMode)this._surveyRow.NotificationModeID; this._resumeMode = (ResumeMode)this._surveyRow.ResumeModeID; this._emailFrom = this._surveyRow.EmailFrom; this._emailTo = this._surveyRow.EmailTo; this._emailSubject = this._surveyRow.EmailSubject; this._isScored = this._surveyRow.Scored; this._showQuestionNumbers = !this._surveyRow.QuestionNumberingDisabled; this._multiLanguageMode = (MultiLanguageMode)this._surveyRow.MultiLanguageModeId; this._languageVariable = this._surveyRow.MultiLanguageVariable; this.TotalPageNumber = this._surveyRow.TotalPageNumber; if ((this._surveyRow.ThankYouMessage != null) && (this._surveyRow.ThankYouMessage.Length != 0)) { this._thankYouMessage = this._surveyRow.ThankYouMessage; } else { this._thankYouMessage = ResourceManager.GetString("ThankYouMessage", this.LanguageCode); } }