public void SaveFreeForm() { int SRPK = int.Parse(SRID); var obj1 = SurveyResults.FetchObject(SRPK); var obj2 = new SurveyAnswers(); obj2.SRID = obj1.SRID; obj2.TenID = obj1.TenID; obj2.PID = obj1.PID; obj2.SID = obj1.SID; obj2.QID = int.Parse(QID); obj2.DateAnswered = DateTime.Now; obj2.QType = 3; obj2.FreeFormAnswer = txtAnswer.Text; obj2.Insert(); }
public void SaveMatrix() { int SRPK = int.Parse(SRID); var ds = SQChoices.GetAll(int.Parse(QID)); foreach (RepeaterItem rLine in rptrMRows.Items) { var obj1 = SurveyResults.FetchObject(SRPK); var obj2 = new SurveyAnswers(); obj2.SRID = obj1.SRID; obj2.TenID = obj1.TenID; obj2.PID = obj1.PID; obj2.SID = obj1.SID; obj2.QID = int.Parse(QID); obj2.DateAnswered = DateTime.Now; obj2.QType = 4; var SQMLID = rLine.FindControl("SQMLID") as Label; obj2.SQMLID = int.Parse(SQMLID.Text); if (DisplayControl == "1") { var rptrCheckCols = rLine.FindControl("rptrCheckCols") as Repeater; foreach (RepeaterItem rChkI in rptrCheckCols.Items) { var SQCID = rChkI.FindControl("SQCID") as Label; var chkAns = rChkI.FindControl("rbChoice") as CheckBox; var ChoiceOrder = rChkI.FindControl("ChoiceOrder") as Label; var AnsText = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString(); if (chkAns.Checked) { obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""), (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text); obj2.ChoiceAnswerText = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""), (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText); } } } if (DisplayControl == "2") { var rptrRadioCols = rLine.FindControl("rptrRadioCols") as Repeater; foreach (RepeaterItem rRdoI in rptrRadioCols.Items) { var SQCID = rRdoI.FindControl("SQCID") as Label; var rbAns = rRdoI.FindControl("rbChoice") as RadioButton; var ChoiceOrder = rRdoI.FindControl("ChoiceOrder") as Label; var AnsText = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString(); if (rbAns.Checked) { obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""), (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text); obj2.ChoiceAnswerText = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""), (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText); } } } obj2.Insert(); } }
public void SaveMultiChoice() { int SRPK = int.Parse(SRID); var obj1 = SurveyResults.FetchObject(SRPK); var obj2 = new SurveyAnswers(); obj2.SRID = obj1.SRID; obj2.TenID = obj1.TenID; obj2.PID = obj1.PID; obj2.SID = obj1.SID; obj2.QID = int.Parse(QID); obj2.DateAnswered = DateTime.Now; obj2.QType = 2; if (DisplayControl == "1") { foreach (RepeaterItem rChkI in rptrChk.Items) { var SQCID = rChkI.FindControl("SQCID") as Label; var chkAns = rChkI.FindControl("chkAns") as CheckBox; var chkClar = rChkI.FindControl("txtChkClarification") as TextBox; if (chkAns.Checked) { obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""), (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text); obj2.ClarificationText = string.Format("{0}{1}{2}", (obj2.ClarificationText.Length > 0 ? obj2.ClarificationText : ""), (obj2.ClarificationText.Length > 0 ? "~|~" : ""), chkClar.Text); obj2.ChoiceAnswerText = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""), (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), chkAns.Text); } } } if (DisplayControl == "2") { foreach (RepeaterItem rRdoI in rptrRadio.Items) { var SQCID = rRdoI.FindControl("SQCID") as Label; var rbAns = rRdoI.FindControl("rbAns") as RadioButton; var rbClar = rRdoI.FindControl("txtRBClarification") as TextBox; if (rbAns.Checked) { obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""), (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text); obj2.ClarificationText = string.Format("{0}{1}{2}", (obj2.ClarificationText.Length > 0 ? obj2.ClarificationText : ""), (obj2.ClarificationText.Length > 0 ? "~|~" : ""), rbClar.Text); obj2.ChoiceAnswerText = string.Format("{0}{1}{2}", (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""), (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), rbAns.Text); } } } if (DisplayControl == "3") { obj2.ChoiceAnswerIDs = ddMultipleChoice.SelectedValue; var ch = SQChoices.FetchObject(int.Parse(ddMultipleChoice.SelectedValue)); var ans = "N/A"; if (ch != null) { ans = ch.ChoiceText; } obj2.ChoiceAnswerText = ans; obj2.ClarificationText = txtDDClarification.Text; } obj2.Insert(); }