コード例 #1
0
        public static int Delete(SurveyAnswers o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SAID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SAID, o.SAID.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SurveyAnswers_Delete", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
コード例 #2
0
        public static int Insert(SurveyAnswers o)
        {

            SqlParameter[] arrParams = new SqlParameter[22];

            arrParams[0] = new SqlParameter("@SRID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SRID, o.SRID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            arrParams[3] = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[4] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[5] = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));
            arrParams[6] = new SqlParameter("@DateAnswered", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateAnswered, o.DateAnswered.GetTypeCode()));
            arrParams[7] = new SqlParameter("@QType", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QType, o.QType.GetTypeCode()));
            arrParams[8] = new SqlParameter("@FreeFormAnswer", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FreeFormAnswer, o.FreeFormAnswer.GetTypeCode()));
            arrParams[9] = new SqlParameter("@ClarificationText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ClarificationText, o.ClarificationText.GetTypeCode()));
            arrParams[10] = new SqlParameter("@ChoiceAnswerIDs", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceAnswerIDs, o.ChoiceAnswerIDs.GetTypeCode()));
            arrParams[11] = new SqlParameter("@ChoiceAnswerText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceAnswerText, o.ChoiceAnswerText.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[13] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[14] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[15] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));
            arrParams[21] = new SqlParameter("@SAID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SAID, o.SAID.GetTypeCode()));
            arrParams[21].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SurveyAnswers_Insert", arrParams);

            o.SAID = int.Parse(arrParams[21].Value.ToString());

            return o.SAID;

        }
コード例 #3
0
        public static int Update(SurveyAnswers o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[22];

            arrParams[0] = new SqlParameter("@SAID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SAID, o.SAID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@SRID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SRID, o.SRID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[3] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            arrParams[4] = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[5] = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[6] = new SqlParameter("@SQMLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SQMLID, o.SQMLID.GetTypeCode()));
            arrParams[7] = new SqlParameter("@DateAnswered", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateAnswered, o.DateAnswered.GetTypeCode()));
            arrParams[8] = new SqlParameter("@QType", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QType, o.QType.GetTypeCode()));
            arrParams[9] = new SqlParameter("@FreeFormAnswer", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FreeFormAnswer, o.FreeFormAnswer.GetTypeCode()));
            arrParams[10] = new SqlParameter("@ClarificationText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ClarificationText, o.ClarificationText.GetTypeCode()));
            arrParams[11] = new SqlParameter("@ChoiceAnswerIDs", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceAnswerIDs, o.ChoiceAnswerIDs.GetTypeCode()));
            arrParams[12] = new SqlParameter("@ChoiceAnswerText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ChoiceAnswerText, o.ChoiceAnswerText.GetTypeCode()));
            arrParams[13] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[14] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[15] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SurveyAnswers_Update", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;

        }
コード例 #4
0
        public bool Fetch(int SAID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SAID", SAID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_SurveyAnswers_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                SurveyAnswers result = new SurveyAnswers();

                DateTime _datetime;

                int _int;

                if (int.TryParse(dr["SAID"].ToString(), out _int)) this.SAID = _int;
                if (int.TryParse(dr["SRID"].ToString(), out _int)) this.SRID = _int;
                if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int;
                if (int.TryParse(dr["PID"].ToString(), out _int)) this.PID = _int;
                if (int.TryParse(dr["SID"].ToString(), out _int)) this.SID = _int;
                if (int.TryParse(dr["QID"].ToString(), out _int)) this.QID = _int;
                if (int.TryParse(dr["SQMLID"].ToString(), out _int)) this.SQMLID = _int;
                if (DateTime.TryParse(dr["DateAnswered"].ToString(), out _datetime)) this.DateAnswered = _datetime;
                if (int.TryParse(dr["QType"].ToString(), out _int)) this.QType = _int;
                this.FreeFormAnswer = dr["FreeFormAnswer"].ToString();
                this.ClarificationText = dr["ClarificationText"].ToString();
                this.ChoiceAnswerIDs = dr["ChoiceAnswerIDs"].ToString();
                this.ChoiceAnswerText = dr["ChoiceAnswerText"].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;

        }
コード例 #5
0
        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();

            }

        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();

        }
コード例 #8
0
        public bool Fetch(int SAID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@SAID", SAID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_SurveyAnswers_GetByID", arrParams);

            if (dr.Read())
            {
                // declare return value

                SurveyAnswers result = new SurveyAnswers();

                DateTime _datetime;

                int _int;

                if (int.TryParse(dr["SAID"].ToString(), out _int))
                {
                    this.SAID = _int;
                }
                if (int.TryParse(dr["SRID"].ToString(), out _int))
                {
                    this.SRID = _int;
                }
                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    this.TenID = _int;
                }
                if (int.TryParse(dr["PID"].ToString(), out _int))
                {
                    this.PID = _int;
                }
                if (int.TryParse(dr["SID"].ToString(), out _int))
                {
                    this.SID = _int;
                }
                if (int.TryParse(dr["QID"].ToString(), out _int))
                {
                    this.QID = _int;
                }
                if (int.TryParse(dr["SQMLID"].ToString(), out _int))
                {
                    this.SQMLID = _int;
                }
                if (DateTime.TryParse(dr["DateAnswered"].ToString(), out _datetime))
                {
                    this.DateAnswered = _datetime;
                }
                if (int.TryParse(dr["QType"].ToString(), out _int))
                {
                    this.QType = _int;
                }
                this.FreeFormAnswer    = dr["FreeFormAnswer"].ToString();
                this.ClarificationText = dr["ClarificationText"].ToString();
                this.ChoiceAnswerIDs   = dr["ChoiceAnswerIDs"].ToString();
                this.ChoiceAnswerText  = dr["ChoiceAnswerText"].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);
        }