//to get the camper answers from the database void getCamperAnswers() { string strFJCID; DataSet dsAnswers; DataView dv; RadioButton rb; string strFilter; strFJCID = hdnFJCIDStep2_2.Value; if (!strFJCID.Equals(string.Empty)) { dsAnswers = CamperAppl.getCamperAnswers(strFJCID, "3", "8", "N"); if (dsAnswers.Tables[0].Rows.Count > 0) //if there are records for the current FJCID { dv = dsAnswers.Tables[0].DefaultView; //to display answers for the QuestionId 3,6,7 and 8 for step 2_2_Midsex for (int i = 3; i <= 8; i++) { strFilter = "QuestionId = '" + i.ToString() + "'"; switch (i) { case 3: //assigning the answer for question 3 foreach (DataRow dr in dv.Table.Select(strFilter)) { if (!dr["OptionID"].Equals(DBNull.Value)) { rb = (RadioButton)Panel2.FindControl("RadioBtnQ3" + dr["OptionID"].ToString()); rb.Checked = true; } } break; case 6: // assigning the answer for question 6 foreach (DataRow dr in dv.Table.Select(strFilter)) { if (!dr["Answer"].Equals(DBNull.Value)) { ddlGrade.SelectedValue = dr["Answer"].ToString(); } } break; case 7: // assigning the answer for question 7 foreach (DataRow dr in dv.Table.Select(strFilter)) { if (!dr["OptionID"].Equals(DBNull.Value)) { RadioButtionQ5.SelectedValue = dr["OptionID"].ToString(); } } break; case 8: // assigning the answer for question 8 int intSchool; DataSet dsSchool = new DataSet(); foreach (DataRow dr in dv.Table.Select(strFilter)) { if (!dr["OptionID"].Equals(DBNull.Value)) { if (!dr["Answer"].Equals(DBNull.Value)) { Int32.TryParse(dr["Answer"].ToString(), out intSchool); if (intSchool > 0) { dsSchool = CamperAppl.GetSchool(intSchool); txtCamperSchool.Text = dsSchool.Tables[0].Rows[0]["Answer"].ToString(); } else { txtCamperSchool.Text = dr["Answer"].ToString(); } } } else { if (!dr["Answer"].Equals(DBNull.Value)) { txtCamperSchool.Text = dr["Answer"].ToString(); } } } break; } } } //to set the school text box to enable / disable based on the school type selected setTextBoxStatus(); } //end if for null check of fjcid }
private int StatusBasedOnSchool(string FJCID, bool EligibleNoCamp, int statusValue) { //What kind of the school the camper go to //Jewish Day School ineligible int StatusValue = statusValue; int JewishSchool = 0, TimeInCamp = 0; DataSet dsJewishSchool, dsTimeInCamp; CamperApplication oCA = new CamperApplication(); dsJewishSchool = oCA.getCamperAnswers(FJCID, "7", "7", "N"); dsTimeInCamp = oCA.getCamperAnswers(FJCID, "3", "3", "N"); DataRow drJewishSchool, drTimeInCamp; if (dsTimeInCamp.Tables[0].Rows.Count > 0) { drTimeInCamp = dsTimeInCamp.Tables[0].Rows[0]; TimeInCamp = Convert.ToInt32(drTimeInCamp["OptionID"]); } if (dsJewishSchool.Tables[0].Rows.Count > 0) { drJewishSchool = dsJewishSchool.Tables[0].Rows[0]; JewishSchool = Convert.ToInt32(drJewishSchool["OptionID"]); if (JewishSchool == 4) { if (TimeInCamp >= 2) { StatusValue = (int)StatusInfo.SystemEligible; } else { StatusValue = (int)StatusInfo.SystemInEligible; } return(StatusValue); } else if (JewishSchool == 3) { if (EligibleNoCamp) { StatusValue = (int)StatusInfo.PendingSchoolAndCamp; } else { StatusValue = (int)StatusInfo.EligiblePendingSchool; } } else { DataSet dsApproveSchool; dsApproveSchool = oCA.getCamperAnswers(FJCID, "8", "8", "N"); DataRow drApproveSchool; //DataRow drApproveSchool2; int SchoolOptionID = 0; int SchoolID = 0; if (dsApproveSchool.Tables[0].Rows.Count > 0) { int i; for (i = 0; i < dsApproveSchool.Tables[0].Rows.Count; i++) { drApproveSchool = dsApproveSchool.Tables[0].Rows[i]; if (drApproveSchool["OptionID"] != System.DBNull.Value) { SchoolOptionID = Convert.ToInt32(drApproveSchool["OptionID"]); if (SchoolOptionID == 1) { SchoolID = Convert.ToInt32(drApproveSchool["Answer"]); if (SchoolID == -1) { if (EligibleNoCamp) { StatusValue = (int)StatusInfo.PendingSchoolAndCamp; } else { StatusValue = (int)StatusInfo.EligiblePendingSchool; } return(StatusValue); } else { DataSet dsSchool; dsSchool = oCA.GetSchool(SchoolID); DataRow drSchool; Boolean Approved = false; if (dsSchool.Tables[0].Rows.Count > 0) { drSchool = dsSchool.Tables[0].Rows[0]; Approved = Convert.ToBoolean(drSchool["Approved"]); if (Approved) { StatusValue = (int)StatusInfo.SystemEligible; } else { StatusValue = (int)StatusInfo.SystemInEligible; return(StatusValue); } } else { if (EligibleNoCamp) { StatusValue = (int)StatusInfo.PendingSchoolAndCamp; } else { StatusValue = (int)StatusInfo.EligiblePendingSchool; } return(StatusValue); } } break; } } } } } } return(StatusValue); }
//to get the camper answers from the database void getCamperAnswers() { string strFilter, strFJCID, strModifiedBy; DataSet dsAnswers; DataView dv; RadioButtonList rb; DataRow dr; DataRow[] drows; HiddenField hdnval; DropDownList ddl; TextBox tb; DataSet dsSchool = new DataSet(); strFJCID = hdnFJCID.Value; strModifiedBy = Master.UserId; if (!strFJCID.Equals(string.Empty)) { dsAnswers = CamperAppl.getCamperAnswers(strFJCID, "3", "33", "N"); if (dsAnswers.Tables[0].Rows.Count > 0) //if there are records for the current FJCID { dv = dsAnswers.Tables[0].DefaultView; //to display answers for the Questions 3 -11 for (int i = 3; i <= 9; i++) { //to get the QuestionId for the Questions hdnval = (HiddenField)PnlHidden.FindControl("hdnQ" + i.ToString() + "Id"); strFilter = "QuestionId = '" + hdnval.Value + "'"; tb = null; ddl = null; rb = null; switch (i) { case 3: //assigning the answer for question 3 rb = (RadioButtonList)Panel2.FindControl("RadioBtnQ" + i.ToString()); goto default; case 4: // assigning the answer for question 4 rb = (RadioButtonList)Panel2.FindControl("RadioBtnQ" + i.ToString()); goto default; case 5: // assigning the answer for question 5 rb = (RadioButtonList)Panel2.FindControl("RadioBtnQ" + i.ToString()); goto default; case 6: // assigning the answer for question 6 ddl = ddlGrade; goto default; case 7: // assigning the answer for question 9 rb = (RadioButtonList)Panel2.FindControl("RadioBtnQ9"); goto default; case 8: // assigning the answer for question 10 //ddl = ddlQ10; //tb = txtJewishSchool; goto default; case 9: // assigning the answer for question 11 tb = txtCamperSchool; goto default; default: //to implement the common logic drows = dv.Table.Select(strFilter); int intSchool; if (drows.Length > 0) //if there are rows for the filter { dr = (DataRow)drows.GetValue(0); if (!dr["OptionID"].Equals(DBNull.Value)) { if (!dr["Answer"].Equals(DBNull.Value)) { Int32.TryParse(dr["Answer"].ToString(), out intSchool); if (intSchool > 0) { dsSchool = CamperAppl.GetSchool(intSchool); dr = (DataRow)dsSchool.Tables[0].Rows[0]; } else if (intSchool == -1) { if (drows.Length > 1) { dr = (DataRow)drows.GetValue(1); } } } } //for dropdownlist if (ddl != null) { if (ddl == ddlGrade) //for the grade question the value is stored in "Answer" { if (!dr["Answer"].Equals(DBNull.Value)) { ddl.SelectedValue = dr["Answer"].ToString(); } } else if (!dr["OptionID"].Equals(DBNull.Value)) { ddl.SelectedValue = dr["OptionID"].ToString(); } } //for text box if (tb != null) { if (!dr["Answer"].Equals(DBNull.Value)) { tb.Text = dr["Answer"].ToString(); } } //for radio buttonlist if (rb != null) { if (!dr["OptionID"].Equals(DBNull.Value)) { rb.SelectedValue = dr["OptionID"].ToString(); } } } break; } } } //to set the status of the panel based on the radio button selected setPanelStatus(); } //end if for null check of fjcid }