private void SetAnswers() { dt = answerBLO.SelectAnswerOfAFE(afeId); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { answers[i].SelectedValue = dt.Rows[i][2].ToString(); if (answers[i].SelectedValue.Equals("True")) { int answerId = int.Parse(dt.Rows[i][0].ToString()); if (specifyPanels[i].Controls.Count == 3) { specifyGeneralVO = specifyGeneralBLO.SelectSpecifyGeneralOfAnswer( answerId); string specifiedValue = specifyGeneralVO.SpecifyValue; TextBox txtSpecify = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "Specify"); txtSpecify.Text = specifiedValue; specifyPanels[i].Visible = true; } else if (specifyPanels[i].Controls.Count == 5) { specifyRelativeVO = specifyRelativeBLO.SelectSpecifyRelativeOfAnswer( answerId); string specifiedCompany = specifyRelativeVO.CompanyName; string specifiedRelative = specifyRelativeVO.RelativeName; TextBox txtSpecifyCompany = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "SpecifyCompany"); TextBox txtSpecifyRelative = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "SpecifyRelative"); txtSpecifyCompany.Text = specifiedCompany; txtSpecifyRelative.Text = specifiedRelative; specifyPanels[i].Visible = true; } } } } }
protected void btnNext_Click(object sender, EventArgs e) { if (rblQ1.SelectedValue == "" || (pnlQ1Yes.Visible == true && txtQ1Specify.Text.Length == 0) || rblQ2.SelectedValue == "" || (pnlQ2Yes.Visible == true && txtQ2Specify.Text.Length == 0) || rblQ3.SelectedValue == "" || (pnlQ3Yes.Visible == true && txtQ3Specify.Text.Length == 0) || rblQ4.SelectedValue == "" || (pnlQ4Yes.Visible == true && (txtQ4SpecifyCompany.Text.Length == 0 || txtQ4SpecifyRelative.Text.Length == 0)) || rblQ5.SelectedValue == "" || (pnlQ5Yes.Visible == true && (txtQ5SpecifyCompany.Text.Length == 0 || txtQ5SpecifyRelative.Text.Length == 0)) || rblQ6.SelectedValue == "" || (pnlQ6Yes.Visible == true && txtQ6Specify.Text.Length == 0) || rblQ7.SelectedValue == "" || (pnlQ7Yes.Visible == true && txtQ7Specify.Text.Length == 0)) { lblError.Text = "Please answer all questions."; } else { dt = answerBLO.SelectAnswerOfAFE(afeId); if (dt.Rows.Count == 0) { for (int i = 0; i < 7; i++) { int answerId = int.Parse(answerBLO.InsertAnswer(afeId, questionCodes[i], answers[i].SelectedValue).Rows[i][0].ToString()); if (answers[i].SelectedValue.Equals("True")) { if (specifyPanels[i].Controls.Count == 3) { TextBox txtSpecify = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "Specify"); specifyGeneralBLO.InsertSpecifyGeneral(answerId, txtSpecify.Text.Trim()); } if (specifyPanels[i].Controls.Count == 5) { TextBox txtSpecifyCompany = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "SpecifyCompany"); TextBox txtSpecifyRelative = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "SpecifyRelative"); specifyRelativeBLO.InsertSpecifyRelative(answerId, txtSpecifyCompany.Text.Trim(), txtSpecifyRelative.Text.Trim()); } } } } else { for (int i = 0; i < dt.Rows.Count; i++) { int answerId = int.Parse(dt.Rows[i][0].ToString()); answerBLO.UpdateAnswer(answerId, answers[i].SelectedValue); if (answers[i].SelectedValue.Equals("True")) { if (specifyPanels[i].Controls.Count == 3) { specifyGeneralVO = specifyGeneralBLO. SelectSpecifyGeneralOfAnswer(answerId); TextBox txtSpecify = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "Specify"); if (specifyGeneralVO == null) { specifyGeneralBLO.InsertSpecifyGeneral(answerId, txtSpecify.Text.Trim()); } else { int specifyGeneralId = specifyGeneralVO.SpecifyGeneralId; specifyGeneralBLO.UpdateSpecifyGeneral(specifyGeneralId, txtSpecify.Text.Trim()); } } else if (specifyPanels[i].Controls.Count == 5) { specifyRelativeVO = specifyRelativeBLO. SelectSpecifyRelativeOfAnswer(answerId); TextBox txtSpecifyCompany = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "SpecifyCompany"); TextBox txtSpecifyRelative = (TextBox)specifyPanels[i].FindControl ("txtQ" + (i + 1) + "SpecifyRelative"); if (specifyRelativeVO == null) { specifyRelativeBLO.InsertSpecifyRelative(answerId, txtSpecifyCompany.Text.Trim(), txtSpecifyRelative.Text.Trim()); } else { int specifyRelativeId = specifyRelativeVO.SpecifyRelativeId; specifyRelativeBLO.UpdateSpecifyRelative(specifyRelativeId, txtSpecifyCompany.Text.Trim(), txtSpecifyRelative.Text.Trim()); } } } } } Response.Redirect("ApplicantProfessionalReferencesForm.aspx"); } }