/// <summary> /// This Listener for Edit button when press add button /// </summary> private void Edit_Click(object sender, EventArgs e) { try { QuestionWillDeleteOrEdit = GetObjectSelect(); ListOfQuestion.ClearSelection(); if (QuestionWillDeleteOrEdit != null) { QuestionsInformation QuestionsInformationPage = new QuestionsInformation(QuestionWillDeleteOrEdit, Global.TypeOfChoice.Edit.ToString()); QuestionsInformationPage.ShowDialog(); if (StaticObjects.SuccOfFail == 1) { ListOfAllQuestion = Operation.GetQustion(); ShowData(); StaticObjects.SuccOfFail = 0; } } else { MessageBox.Show(Survey.Properties.Resource1.NoSelectItem, Global.Constant.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { StaticObjects.Erros.Log(ex); MessageBox.Show(Survey.Properties.Resource1.MessageError); } }
private void ListOfQuestion_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { QuestionsInformation.ReturnNewQuestion = GetObjectSelect(); Qustion OldObject = QuestionsInformation.ReturnNewQuestion; Operation.ListOfAllQuestion.Remove(OldObject); ListOfQuestion.ClearSelection(); if (QuestionsInformation.ReturnNewQuestion != null) { QuestionsInformation QuestionsInformationPage = new QuestionsInformation(TypeOfChoice.Edit); if (QuestionsInformationPage.ShowDialog() == DialogResult.OK) { Operation.ListOfAllQuestion.Remove(OldObject); Operation.ListOfAllQuestion.Add(QuestionsInformation.ReturnNewQuestion); ShowData(Operation.ListOfAllQuestion); } } else { MessageBox.Show(Survey.Properties.Messages.NoSelectItem, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { GenralVariables.Errors.Log(ex.Message); MessageBox.Show(Survey.Properties.Messages.MessageError); } }
/// <summary> /// This Functions for thread to refresh data /// </summary> private void Refresh() { try { var DelegateFunction = new SafeCallDelegate(ShowData); ListOfQuestion.Invoke(DelegateFunction, Operation.ListOfAllQuestion); } catch (Exception ex) { GenralVariables.Errors.Log(ex.Message); MessageBox.Show(Survey.Properties.Messages.MessageError); } }
/// <summary> /// This Listener for Add button when press add button /// </summary> private void Add_Click(object sender, EventArgs e) { try { ListOfQuestion.ClearSelection(); QuestionsInformation QuestionsInformationPage = new QuestionsInformation(TypeOfChoice.Add); if (QuestionsInformationPage.ShowDialog() == DialogResult.OK) { Operation.ListOfAllQuestion.Add(QuestionsInformation.ReturnNewQuestion); ShowData(Operation.ListOfAllQuestion); } } catch (Exception ex) { GenralVariables.Errors.Log(ex.Message); MessageBox.Show(Survey.Properties.Messages.MessageError); } }
/// <summary> /// This Listener for Add button when press add button /// </summary> private void Add_Click(object sender, EventArgs e) { try { ListOfQuestion.ClearSelection(); QuestionsInformation QuestionsInformationPage = new QuestionsInformation(QuestionWillDeleteOrEdit, Global.TypeOfChoice.Add.ToString()); QuestionsInformationPage.ShowDialog(); if (StaticObjects.SuccOfFail == 1) { ListOfAllQuestion = Operation.GetQustion(); ShowData(); StaticObjects.SuccOfFail = 0; } }catch (Exception ex) { StaticObjects.Erros.Log(ex); MessageBox.Show(Survey.Properties.Resource1.MessageError); } }
/// <summary> /// Show data function get the question from MyList and show it in datagridview /// </summary> private void ShowData() { try { ListOfQuestion.Rows.Clear(); foreach (Qustions Temp in ListOfAllQuestion) { int Index = ListOfQuestion.Rows.Add(); ListOfQuestion.Rows[Index].Cells[0].Value = Temp.NewText; ListOfQuestion.Rows[Index].Cells[2].Value = Temp.Order; ListOfQuestion.Rows[Index].Cells[1].Value = Temp.TypeOfQuestion; } }catch (Exception ex) { StaticObjects.Erros.Log(ex); MessageBox.Show(Survey.Properties.Resource1.MessageError); } ListOfQuestion.ClearSelection(); }
/// <summary> /// Show data function get the question from MyList and show it in datagridview /// </summary> private void ShowData(List <Qustion> ListOfAllQuestion) { try { ListOfQuestion.Rows.Clear(); foreach (Qustion Temp in ListOfAllQuestion) { if (Temp != null) { int Index = ListOfQuestion.Rows.Add(); ListOfQuestion.Rows[Index].Cells[0].Value = Temp.NewText; ListOfQuestion.Rows[Index].Cells[2].Value = Temp.Order; ListOfQuestion.Rows[Index].Cells[1].Value = Temp.TypeOfQuestion; } } ListOfQuestion.ClearSelection(); } catch (Exception ex) { GenralVariables.Errors.Log(ex.Message); MessageBox.Show(Survey.Properties.Messages.MessageError); } }
protected void Button1_Click(object sender, EventArgs e) { // Accesss the current question from PlaceHolder Control userControl = PlaceHolder1.FindControl(Session["CURRENT_QUESTION_TYPE"].ToString()); Stack <int> followupQuestionList = (Stack <int>)Session["FOLLOWUP_ID_LIST"]; int currentQuestionIdInSeeion = ((Stack <int>)Session["FOLLOWUP_ID_LIST"]).Pop(); Question question = getNextQuestion(currentQuestionIdInSeeion); if (question.nextQId != null) { //followupQuestionList.Push((int)question.nextQId); insertNextQuestionId((int)question.nextQId, followupQuestionList); } ListOfQuestion.Add(currentQuestionIdInSeeion.ToString()); if (userControl is TextBoxUserControl) { TextBoxUserControl textBoxcontr = (TextBoxUserControl)userControl; //Label1.Text = textBoxcontr.getControl().Text; Session["UserAnswer"] = textBoxcontr.getControl().Text; System.Diagnostics.Debug.WriteLine("Answer = " + textBoxcontr.getControl().Text); } else if (userControl is CheckBoxUserControl) { CheckBoxUserControl checkBoxcontr = (CheckBoxUserControl)userControl; string answerVar = ""; foreach (ListItem item in checkBoxcontr.getControl().Items) { if (item.Selected) { answerVar += item.Text + ","; if (item.Attributes["nextQId"] != null) { // followupQuestionList.Push(int.Parse(item.Attributes["nextQId"])); insertNextQuestionId((int.Parse(item.Attributes["nextQId"])), followupQuestionList); } } } Session["UserAnswer"] = answerVar; } else { RadioButtonUserControl radioBtnControl = (RadioButtonUserControl)userControl; string answerVar = ""; foreach (ListItem item in radioBtnControl.getControl().Items) { if (item.Selected) { answerVar += item.Value; if (item.Attributes["nextQId"] != null) { insertNextQuestionId((int.Parse(item.Attributes["next_q_id"])), followupQuestionList); } } } Session["UserAnswer"] = answerVar; // Radio button } // 1. Identify which type of question is current question // 2. Access that question to get answer out from it // Label1.Text = "Test label"; if (followupQuestionList.Count > 0) { Object userAnwser = Session["UserAnswer"]; ListOfAnswer.Add(userAnwser.ToString()); Session["CURRENT_QUESTION_ID"] = question.nextQId; Response.Redirect("Survay.aspx"); } else { Object userAnwser = Session["UserAnswer"]; ListOfAnswer.Add(userAnwser.ToString()); Session["ListOfAnswer"] = ListOfAnswer; Response.Redirect("EndSurvey.aspx"); } }