private void LoadForm(int id) { ResetForm(); STD_QUESTION question = ServiceInterfaceManager.STD_QUESTION_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id); if (question != null) { hideSurveyFieldId.Value = question.ID.ToString(); txtQuestionNumber.Text = question.QUESTION_NUMBER; txtSortOrder.Text = question.SORT_ORDER.GetValueOrDefault().ToString(); txtQuestionText.Text = question.QUESTION_TEXT; gridFieldChoices.DataBind(); } }
private bool SaveForm(ref string strResult) { int oldQuestionID = 0; STD_QUESTION question = null; if (string.IsNullOrEmpty(txtQuestionNumber.Text)) { strResult = "Question Number is Required<br /><br />"; } else if (string.IsNullOrEmpty(txtSortOrder.Text)) { strResult = "Sort Order is Required<br /><br />"; } else if (string.IsNullOrEmpty(txtQuestionText.Text)) { strResult = "Question Text is Required<br /><br />"; } else { int id = 0; if (!string.IsNullOrEmpty(hideSurveyFieldId.Value)) { int.TryParse(hideSurveyFieldId.Value, out id); } if (id > 0) { question = ServiceInterfaceManager.STD_QUESTION_GET(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, id); } if (question == null) { question = new STD_QUESTION(); } else { //If text changes, INACTIVATE current question and save a new one if (txtQuestionText.Text != question.QUESTION_TEXT) { oldQuestionID = question.ID; ServiceInterfaceManager.STD_QUESTION_DELETE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, question.ID); question = new STD_QUESTION(); } } question.STD_SURVEY_TYPE_ID = UserSession.CurrentSurveyId; question.CREATEDBY = question.UPDATEDBY = HttpContext.Current.User.Identity.Name; question.INACTIVE_FLAG = false; question.QUESTION_NUMBER = txtQuestionNumber.Text; int sortOrder = 0; if (int.TryParse(txtSortOrder.Text, out sortOrder)) { question.SORT_ORDER = sortOrder; } question.QUESTION_TEXT = txtQuestionText.Text; question.ID = ServiceInterfaceManager.STD_QUESTION_SAVE(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, question); if (question.ID > 0) { hideSurveyFieldId.Value = question.ID.ToString(); strResult = "Save successful<br /><br />"; if (oldQuestionID > 0) { ServiceInterfaceManager.STD_QUESTION_COPY_CHOICES(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, oldQuestionID, question.ID); } return(true); } else { strResult = "Error saving Survey Field, please try again<br /><br />"; } } //else //{ // strResult = "<ul><li>Question text is Required</li></ul>"; // } return(false); }