public static int Insert(SQChoices o) { SqlParameter[] arrParams = new SqlParameter[17]; arrParams[0] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode())); arrParams[1] = new SqlParameter("@ChoiceOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceOrder, o.ChoiceOrder.GetTypeCode())); arrParams[2] = new SqlParameter("@ChoiceText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceText, o.ChoiceText.GetTypeCode())); arrParams[3] = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode())); arrParams[4] = new SqlParameter("@JumpToQuestion", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.JumpToQuestion, o.JumpToQuestion.GetTypeCode())); arrParams[5] = new SqlParameter("@AskClarification", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AskClarification, o.AskClarification.GetTypeCode())); arrParams[6] = new SqlParameter("@ClarificationRequired", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ClarificationRequired, o.ClarificationRequired.GetTypeCode())); arrParams[7] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[8] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[9] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[10] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[11] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[12] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[13] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[14] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[15] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[16] = new SqlParameter("@SQCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQCID, o.SQCID.GetTypeCode())); arrParams[16].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQChoices_Insert", arrParams); o.SQCID = int.Parse(arrParams[16].Value.ToString()); return(o.SQCID); }
public static int MaxScore(int SID) { var maxScore = 0; var dsQ = SurveyQuestion.GetAll(SID); foreach (DataRow qRow in dsQ.Tables[0].Rows) { var qType = Convert.ToInt32(qRow["QType"]); if (qType == 3) { return(0); // cannot score a test that has multiple choice } var isRequired = Convert.ToBoolean(qRow["IsRequired"]); if ((qType == 2 && !isRequired) || (qType == 4 && !isRequired)) { return(0); // cannot score a test that does not have all questions/answers required } var isCheckbox = Convert.ToInt32(qRow["DisplayControl"]) == 1; var QID = Convert.ToInt32(qRow["QID"]); var qScore = 0; if (qType == 2 || qType == 4) { var dsA = SQChoices.GetAll(QID); var maxAScore = 0; foreach (DataRow aRow in dsA.Tables[0].Rows) { var score = Convert.ToInt32(aRow["Score"]); if (isCheckbox) { qScore += score; } else { if (score > maxAScore) { maxAScore = score; } } } if (!isCheckbox) { qScore += maxAScore; } } if (qType == 4) { //Matrix, how many lines? var dsML = SQMatrixLines.GetAll(QID); var numLines = dsML.Tables[0].Rows.Count; qScore = qScore * numLines; } maxScore += qScore; } return(maxScore); }
public static int Delete(SQChoices o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@SQCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQCID, o.SQCID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQChoices_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int PerformScoring(int SRID) { var score = 0; var a = SurveyAnswers.GetAll(SRID); foreach (DataRow ansRow in a.Tables[0].Rows) { var aIDs = Convert.ToString(ansRow["ChoiceAnswerIDs"]); if (aIDs != "") { var c = SQChoices.GetList(aIDs); foreach (DataRow cRow in c.Tables[0].Rows) { score += Convert.ToInt32(cRow["Score"]); } } } return(score); }
public static int Update(SQChoices o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[17]; arrParams[0] = new SqlParameter("@SQCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQCID, o.SQCID.GetTypeCode())); arrParams[1] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode())); arrParams[2] = new SqlParameter("@ChoiceOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceOrder, o.ChoiceOrder.GetTypeCode())); arrParams[3] = new SqlParameter("@ChoiceText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceText, o.ChoiceText.GetTypeCode())); arrParams[4] = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode())); arrParams[5] = new SqlParameter("@JumpToQuestion", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.JumpToQuestion, o.JumpToQuestion.GetTypeCode())); arrParams[6] = new SqlParameter("@AskClarification", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AskClarification, o.AskClarification.GetTypeCode())); arrParams[7] = new SqlParameter("@ClarificationRequired", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ClarificationRequired, o.ClarificationRequired.GetTypeCode())); arrParams[8] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[9] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[10] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[11] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[12] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[13] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[14] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[15] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[16] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQChoices_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Setup/SurveyQuestionList.aspx"; if (e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if (e.CommandName.ToLower() == "refresh") { try { odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) masterPage.PageMessage = SRPResources.RefreshOK; } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { if (Save((DetailsView) sender)) { if (e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.SaveOK; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "moveup21") { var key = Convert.ToInt32(e.CommandArgument); SQChoices.MoveUp(key); //MasterPage.PageMessage = "Survey/Test Question Moved Up!"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData41.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType2Answers"); p4 = (Panel)p4.FindControl("Panel1"); var gv = (GridView)p4.FindControl("gv21"); gv.DataBind(); } if (e.CommandName.ToLower() == "movedn21") { var key = Convert.ToInt32(e.CommandArgument); SQChoices.MoveDn(key); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData41.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType2Answers"); p4 = (Panel)p4.FindControl("Panel1"); var gv = (GridView)p4.FindControl("gv21"); gv.DataBind(); } if (e.CommandName.ToLower() == "deleterecord21") { var key = Convert.ToInt32(e.CommandArgument); var obj = SQChoices.FetchObject(key); obj.Delete(); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData41.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType2Answers"); p4 = (Panel)p4.FindControl("Panel1"); var gv = (GridView)p4.FindControl("gv21"); gv.DataBind(); } if (e.CommandName.ToLower() == "addrecord21") { var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); var p4 = (Panel)tab2.FindControl("pnlType2Answers"); var obj = new SQChoices(); obj.QID = int.Parse(lblPK.Text); obj.ChoiceText = ((TextBox)p4.FindControl("ChoiceText2")).Text; obj.Score = ((TextBox)p4.FindControl("Score2")).Text.SafeToInt(); obj.JumpToQuestion = ((DropDownList)p4.FindControl("JumpToQuestion2")).Text.SafeToInt(); obj.AskClarification = ((CheckBox)p4.FindControl("AskClarification2")).Checked; obj.ClarificationRequired = ((CheckBox)p4.FindControl("ClarificationRequired2")).Checked; obj.Insert(); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; odsData41.DataBind(); p4 = (Panel)p4.FindControl("Panel1"); var gv = (GridView)p4.FindControl("gv21"); gv.DataBind(); } if (e.CommandName.ToLower() == "moveup41") { var key = Convert.ToInt32(e.CommandArgument); SQChoices.MoveUp(key); //MasterPage.PageMessage = "Survey/Test Question Moved Up!"; var tab2 = ((DetailsView) sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData41.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView) p4.FindControl("gv41"); gv.DataBind(); } if (e.CommandName.ToLower() == "movedn41") { var key = Convert.ToInt32(e.CommandArgument); SQChoices.MoveDn(key); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData41.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv41"); gv.DataBind(); } if (e.CommandName.ToLower() == "deleterecord41") { var key = Convert.ToInt32(e.CommandArgument); var obj = SQChoices.FetchObject(key); obj.Delete(); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData41.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv41"); gv.DataBind(); } if (e.CommandName.ToLower() == "addrecord41") { var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); var obj = new SQChoices(); obj.QID = int.Parse(lblPK.Text); obj.ChoiceText = ((TextBox)p4.FindControl("ChoiceText4")).Text; obj.Score = ((TextBox)p4.FindControl("Score4")).Text.SafeToInt(); obj.JumpToQuestion = ((DropDownList)p4.FindControl("JumpToQuestion4")).Text.SafeToInt(); obj.Insert(); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; odsData41.DataBind(); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv41"); gv.DataBind(); } if (e.CommandName.ToLower() == "moveupl") { var key = Convert.ToInt32(e.CommandArgument); SQMatrixLines.MoveUp(key); //MasterPage.PageMessage = "Survey/Test Question Moved Up!"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData42.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv42"); gv.DataBind(); } if (e.CommandName.ToLower() == "movednl") { var key = Convert.ToInt32(e.CommandArgument); SQMatrixLines.MoveDn(key); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData42.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv42"); gv.DataBind(); } if (e.CommandName.ToLower() == "deleterecordl") { var key = Convert.ToInt32(e.CommandArgument); var obj = SQMatrixLines.FetchObject(key); obj.Delete(); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); odsData42.DataBind(); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv42"); gv.DataBind(); } if (e.CommandName.ToLower() == "addrecordl") { var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2"); var p4 = (Panel)tab2.FindControl("pnlType4Answers"); var obj = new SQMatrixLines(); obj.QID = int.Parse(lblPK.Text); obj.LineText = ((TextBox)p4.FindControl("LineText4")).Text; obj.Insert(); //MasterPage.PageMessage = "Survey/Test Question Moved Down"; odsData42.DataBind(); p4 = (Panel)p4.FindControl("Panel2"); var gv = (GridView)p4.FindControl("gv42"); gv.DataBind(); } }
protected void SaveType4Answers(int QID) { if (Session["tmpQ4"] == null) return; var ds = (DataSet)Session["tmpQ4"]; foreach (DataRow r in ds.Tables[0].Rows) { var obj = new SQChoices(); obj.QID = QID; obj.ChoiceText = r["ChoiceText"].ToString(); obj.Score = (int)r["Score"]; obj.JumpToQuestion = (int)r["JumpToQuestion"]; obj.Insert(); } }
public bool Fetch(int SQCID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@SQCID", SQCID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_SQChoices_GetByID", arrParams); if (dr.Read()) { // declare return value SQChoices result = new SQChoices(); int _int; if (int.TryParse(dr["SQCID"].ToString(), out _int)) { this.SQCID = _int; } if (int.TryParse(dr["QID"].ToString(), out _int)) { this.QID = _int; } if (int.TryParse(dr["ChoiceOrder"].ToString(), out _int)) { this.ChoiceOrder = _int; } this.ChoiceText = dr["ChoiceText"].ToString(); if (int.TryParse(dr["Score"].ToString(), out _int)) { this.Score = _int; } if (int.TryParse(dr["JumpToQuestion"].ToString(), out _int)) { this.JumpToQuestion = _int; } this.AskClarification = bool.Parse(dr["AskClarification"].ToString()); this.ClarificationRequired = bool.Parse(dr["ClarificationRequired"].ToString()); if (int.TryParse(dr["FldInt1"].ToString(), out _int)) { this.FldInt1 = _int; } if (int.TryParse(dr["FldInt2"].ToString(), out _int)) { this.FldInt2 = _int; } if (int.TryParse(dr["FldInt3"].ToString(), out _int)) { this.FldInt3 = _int; } this.FldBit1 = bool.Parse(dr["FldBit1"].ToString()); this.FldBit2 = bool.Parse(dr["FldBit2"].ToString()); this.FldBit3 = bool.Parse(dr["FldBit3"].ToString()); this.FldText1 = dr["FldText1"].ToString(); this.FldText2 = dr["FldText2"].ToString(); this.FldText3 = dr["FldText3"].ToString(); dr.Close(); return(true); } dr.Close(); return(false); }
public static int Delete(SQChoices o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@SQCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQCID, o.SQCID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQChoices_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Update(SQChoices o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[17]; arrParams[0] = new SqlParameter("@SQCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQCID, o.SQCID.GetTypeCode())); arrParams[1] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode())); arrParams[2] = new SqlParameter("@ChoiceOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceOrder, o.ChoiceOrder.GetTypeCode())); arrParams[3] = new SqlParameter("@ChoiceText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceText, o.ChoiceText.GetTypeCode())); arrParams[4] = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode())); arrParams[5] = new SqlParameter("@JumpToQuestion", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.JumpToQuestion, o.JumpToQuestion.GetTypeCode())); arrParams[6] = new SqlParameter("@AskClarification", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AskClarification, o.AskClarification.GetTypeCode())); arrParams[7] = new SqlParameter("@ClarificationRequired", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ClarificationRequired, o.ClarificationRequired.GetTypeCode())); arrParams[8] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[9] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[10] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[11] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[12] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[13] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[14] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[15] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[16] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQChoices_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Insert(SQChoices o) { SqlParameter[] arrParams = new SqlParameter[17]; arrParams[0] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode())); arrParams[1] = new SqlParameter("@ChoiceOrder", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceOrder, o.ChoiceOrder.GetTypeCode())); arrParams[2] = new SqlParameter("@ChoiceText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceText, o.ChoiceText.GetTypeCode())); arrParams[3] = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode())); arrParams[4] = new SqlParameter("@JumpToQuestion", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.JumpToQuestion, o.JumpToQuestion.GetTypeCode())); arrParams[5] = new SqlParameter("@AskClarification", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AskClarification, o.AskClarification.GetTypeCode())); arrParams[6] = new SqlParameter("@ClarificationRequired", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ClarificationRequired, o.ClarificationRequired.GetTypeCode())); arrParams[7] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[8] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[9] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[10] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[11] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[12] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[13] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[14] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[15] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[16] = new SqlParameter("@SQCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQCID, o.SQCID.GetTypeCode())); arrParams[16].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SQChoices_Insert", arrParams); o.SQCID = int.Parse(arrParams[16].Value.ToString()); return o.SQCID; }
public bool Fetch(int SQCID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@SQCID", SQCID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_SQChoices_GetByID", arrParams); if (dr.Read()) { // declare return value SQChoices result = new SQChoices(); int _int; if (int.TryParse(dr["SQCID"].ToString(), out _int)) this.SQCID = _int; if (int.TryParse(dr["QID"].ToString(), out _int)) this.QID = _int; if (int.TryParse(dr["ChoiceOrder"].ToString(), out _int)) this.ChoiceOrder = _int; this.ChoiceText = dr["ChoiceText"].ToString(); if (int.TryParse(dr["Score"].ToString(), out _int)) this.Score = _int; if (int.TryParse(dr["JumpToQuestion"].ToString(), out _int)) this.JumpToQuestion = _int; this.AskClarification = bool.Parse(dr["AskClarification"].ToString()); this.ClarificationRequired = bool.Parse(dr["ClarificationRequired"].ToString()); if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int; if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int; if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int; this.FldBit1 = bool.Parse(dr["FldBit1"].ToString()); this.FldBit2 = bool.Parse(dr["FldBit2"].ToString()); this.FldBit3 = bool.Parse(dr["FldBit3"].ToString()); this.FldText1 = dr["FldText1"].ToString(); this.FldText2 = dr["FldText2"].ToString(); this.FldText3 = dr["FldText3"].ToString(); dr.Close(); return true; } dr.Close(); return false; }