Beispiel #1
0
        public static int Insert(SurveyResults o)
        {
            SqlParameter[] arrParams = new SqlParameter[22];

            arrParams[0]            = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[1]            = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            arrParams[2]            = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[3]            = new SqlParameter("@StartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode()));
            arrParams[4]            = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[5]            = new SqlParameter("@IsComplete", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsComplete, o.IsComplete.GetTypeCode()));
            arrParams[6]            = new SqlParameter("@IsScorable", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsScorable, o.IsScorable.GetTypeCode()));
            arrParams[7]            = new SqlParameter("@LastAnswered", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastAnswered, o.LastAnswered.GetTypeCode()));
            arrParams[8]            = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode()));
            arrParams[9]            = new SqlParameter("@ScorePct", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ScorePct, o.ScorePct.GetTypeCode()));
            arrParams[10]           = new SqlParameter("@Source", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Source, o.Source.GetTypeCode()));
            arrParams[11]           = new SqlParameter("@SourceID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SourceID, o.SourceID.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("@SRID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SRID, o.SRID.GetTypeCode()));
            arrParams[21].Direction = ParameterDirection.Output;

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

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

            return(o.SRID);
        }
        public bool SaveTestPage() {
            var sr = new SurveyResults();
            var p = (Patron)Session["Patron"];
            int srid;
            if(SRID.Text != "0") {
                sr = SurveyResults.FetchObject(int.Parse(SRID.Text));
                srid = sr.SRID;
            } else {
                sr.TenID = p.TenID;
                sr.PID = p.PID;
                sr.SID = int.Parse(SID.Text);
                sr.StartDate = DateTime.Now;
                sr.IsComplete = false;
                sr.LastAnswered = 0;
                sr.Source = Session["SSrc"] == null ? "" : Session["SSrc"].ToString();
                sr.SourceID = Session["SSrcID"] == null ? 0 : int.Parse(Session["SSrcID"].ToString());

                sr.Insert();
                Session["SRID"] = sr.SRID;
                srid = sr.SRID;
                SRID.Text = sr.SRID.ToString();
            }

            // Save answers, in a loop;
            foreach(RepeaterItem i in SurveyQLst.Items) {
                var qp = i.FindControl("qp") as QuestionPreview;
                if(qp != null) {
                    qp.Save(srid);
                    sr.LastAnswered = int.Parse(qp.QNumber);
                    sr.Update();
                }
            }

            // Check in a loop if any of the answers generated a jump condition, and if so, set the start of the next page.))
            foreach(RepeaterItem i in SurveyQLst.Items) {
                var qp = i.FindControl("qp") as QuestionPreview;
                if(qp != null) {
                    var jq = qp.JumpLogicActivated();
                    if(jq > 0) {
                        QNumber.Text = (jq - 1).ToString();
                        sr.LastAnswered = int.Parse(QNumber.Text);   //If they quit, then they come back and start at the jump
                        sr.Update();
                        JumpActivated = true;
                        break;
                    }
                }
            }

            return true;
        }
Beispiel #3
0
        public static int Delete(SurveyResults o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_SurveyResults_Delete", arrParams);
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }
Beispiel #4
0
        public static int Update(SurveyResults o)
        {
            int iReturn = -1; //assume the worst

            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("@StartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@IsComplete", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsComplete, o.IsComplete.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@IsScorable", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsScorable, o.IsScorable.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@LastAnswered", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastAnswered, o.LastAnswered.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode()));
            arrParams[10] = new SqlParameter("@ScorePct", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ScorePct, o.ScorePct.GetTypeCode()));
            arrParams[11] = new SqlParameter("@Source", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Source, o.Source.GetTypeCode()));
            arrParams[12] = new SqlParameter("@SourceID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SourceID, o.SourceID.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_SurveyResults_Update", arrParams);
            }

            catch (SqlException exx)
            {
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return(iReturn);
        }
        public static int Delete(SurveyResults o)
        {

            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

            try
            {

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

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;

        }
        public static int Update(SurveyResults o)
        {

            int iReturn = -1; //assume the worst

            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("@StartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode()));
            arrParams[5] = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[6] = new SqlParameter("@IsComplete", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsComplete, o.IsComplete.GetTypeCode()));
            arrParams[7] = new SqlParameter("@IsScorable", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsScorable, o.IsScorable.GetTypeCode()));
            arrParams[8] = new SqlParameter("@LastAnswered", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastAnswered, o.LastAnswered.GetTypeCode()));
            arrParams[9] = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode()));
            arrParams[10] = new SqlParameter("@ScorePct", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ScorePct, o.ScorePct.GetTypeCode()));
            arrParams[11] = new SqlParameter("@Source", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Source, o.Source.GetTypeCode()));
            arrParams[12] = new SqlParameter("@SourceID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SourceID, o.SourceID.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_SurveyResults_Update", arrParams);

            }

            catch (SqlException exx)
            {

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

            }

            return iReturn;

        }
        public static int Insert(SurveyResults o)
        {

            SqlParameter[] arrParams = new SqlParameter[22];

            arrParams[0] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode()));
            arrParams[2] = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[3] = new SqlParameter("@StartDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.StartDate, o.StartDate.GetTypeCode()));
            arrParams[4] = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[5] = new SqlParameter("@IsComplete", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsComplete, o.IsComplete.GetTypeCode()));
            arrParams[6] = new SqlParameter("@IsScorable", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsScorable, o.IsScorable.GetTypeCode()));
            arrParams[7] = new SqlParameter("@LastAnswered", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastAnswered, o.LastAnswered.GetTypeCode()));
            arrParams[8] = new SqlParameter("@Score", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Score, o.Score.GetTypeCode()));
            arrParams[9] = new SqlParameter("@ScorePct", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ScorePct, o.ScorePct.GetTypeCode()));
            arrParams[10] = new SqlParameter("@Source", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Source, o.Source.GetTypeCode()));
            arrParams[11] = new SqlParameter("@SourceID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SourceID, o.SourceID.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("@SRID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SRID, o.SRID.GetTypeCode()));
            arrParams[21].Direction = ParameterDirection.Output;

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

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

            return o.SRID;

        }
        public bool Fetch(int SRID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

            if (dr.Read())
            {

                // declare return value

                SurveyResults result = new SurveyResults();

                DateTime _datetime;

                int _int;

                decimal _decimal;

                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 (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime)) this.StartDate = _datetime;
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) this.EndDate = _datetime;
                this.IsComplete = bool.Parse(dr["IsComplete"].ToString());
                this.IsScorable = bool.Parse(dr["IsScorable"].ToString());
                if (int.TryParse(dr["LastAnswered"].ToString(), out _int)) this.LastAnswered = _int;
                if (int.TryParse(dr["Score"].ToString(), out _int)) this.Score = _int;
                if (decimal.TryParse(dr["ScorePct"].ToString(), out _decimal)) this.ScorePct = _decimal;
                this.Source = dr["Source"].ToString();
                if (int.TryParse(dr["SourceID"].ToString(), out _int)) this.SourceID = _int;
                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 SurveyResults FetchObject(int PID, int SID, string SrcType, int SrcID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[4];

            arrParams[0] = new SqlParameter("@PID", PID);
            arrParams[1] = new SqlParameter("@SID", SID);
            arrParams[2] = new SqlParameter("@SrcType", SrcType);
            arrParams[3] = new SqlParameter("@SrcID", SrcID);

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

            if (dr.Read())
            {

                // declare return value

                SurveyResults result = new SurveyResults();

                DateTime _datetime;

                int _int;

                decimal _decimal;

                if (int.TryParse(dr["SRID"].ToString(), out _int)) result.SRID = _int;
                if (int.TryParse(dr["TenID"].ToString(), out _int)) result.TenID = _int;
                if (int.TryParse(dr["PID"].ToString(), out _int)) result.PID = _int;
                if (int.TryParse(dr["SID"].ToString(), out _int)) result.SID = _int;
                if (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime)) result.StartDate = _datetime;
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) result.EndDate = _datetime;
                result.IsComplete = bool.Parse(dr["IsComplete"].ToString());
                result.IsScorable = bool.Parse(dr["IsScorable"].ToString());
                if (int.TryParse(dr["LastAnswered"].ToString(), out _int)) result.LastAnswered = _int;
                if (int.TryParse(dr["Score"].ToString(), out _int)) result.Score = _int;
                if (decimal.TryParse(dr["ScorePct"].ToString(), out _decimal)) result.ScorePct = _decimal;
                result.Source = dr["Source"].ToString();
                if (int.TryParse(dr["SourceID"].ToString(), out _int)) result.SourceID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) result.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) result.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) result.FldInt3 = _int;
                result.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return result;

            }

            dr.Close();

            return null;

        }
Beispiel #10
0
        public bool Fetch(int SRID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

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

                SurveyResults result = new SurveyResults();

                DateTime _datetime;

                int _int;

                decimal _decimal;

                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 (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime))
                {
                    this.StartDate = _datetime;
                }
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime))
                {
                    this.EndDate = _datetime;
                }
                this.IsComplete = bool.Parse(dr["IsComplete"].ToString());
                this.IsScorable = bool.Parse(dr["IsScorable"].ToString());
                if (int.TryParse(dr["LastAnswered"].ToString(), out _int))
                {
                    this.LastAnswered = _int;
                }
                if (int.TryParse(dr["Score"].ToString(), out _int))
                {
                    this.Score = _int;
                }
                if (decimal.TryParse(dr["ScorePct"].ToString(), out _decimal))
                {
                    this.ScorePct = _decimal;
                }
                this.Source = dr["Source"].ToString();
                if (int.TryParse(dr["SourceID"].ToString(), out _int))
                {
                    this.SourceID = _int;
                }
                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);
        }
Beispiel #11
0
        public static SurveyResults FetchObject(int PID, int SID, string SrcType, int SrcID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[4];

            arrParams[0] = new SqlParameter("@PID", PID);
            arrParams[1] = new SqlParameter("@SID", SID);
            arrParams[2] = new SqlParameter("@SrcType", SrcType);
            arrParams[3] = new SqlParameter("@SrcID", SrcID);

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

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

                SurveyResults result = new SurveyResults();

                DateTime _datetime;

                int _int;

                decimal _decimal;

                if (int.TryParse(dr["SRID"].ToString(), out _int))
                {
                    result.SRID = _int;
                }
                if (int.TryParse(dr["TenID"].ToString(), out _int))
                {
                    result.TenID = _int;
                }
                if (int.TryParse(dr["PID"].ToString(), out _int))
                {
                    result.PID = _int;
                }
                if (int.TryParse(dr["SID"].ToString(), out _int))
                {
                    result.SID = _int;
                }
                if (DateTime.TryParse(dr["StartDate"].ToString(), out _datetime))
                {
                    result.StartDate = _datetime;
                }
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime))
                {
                    result.EndDate = _datetime;
                }
                result.IsComplete = bool.Parse(dr["IsComplete"].ToString());
                result.IsScorable = bool.Parse(dr["IsScorable"].ToString());
                if (int.TryParse(dr["LastAnswered"].ToString(), out _int))
                {
                    result.LastAnswered = _int;
                }
                if (int.TryParse(dr["Score"].ToString(), out _int))
                {
                    result.Score = _int;
                }
                if (decimal.TryParse(dr["ScorePct"].ToString(), out _decimal))
                {
                    result.ScorePct = _decimal;
                }
                result.Source = dr["Source"].ToString();
                if (int.TryParse(dr["SourceID"].ToString(), out _int))
                {
                    result.SourceID = _int;
                }
                if (int.TryParse(dr["FldInt1"].ToString(), out _int))
                {
                    result.FldInt1 = _int;
                }
                if (int.TryParse(dr["FldInt2"].ToString(), out _int))
                {
                    result.FldInt2 = _int;
                }
                if (int.TryParse(dr["FldInt3"].ToString(), out _int))
                {
                    result.FldInt3 = _int;
                }
                result.FldBit1  = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2  = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3  = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();

                dr.Close();

                return(result);
            }

            dr.Close();

            return(null);
        }