Beispiel #1
0
        public static int Delete(SurveyQuestion o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];

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

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

                var s = Survey.FetchObject(o.SID);
                if (s.CanBeScored != Survey.IsScorable(s.SID))
                {
                    s.CanBeScored = !s.CanBeScored;
                    s.Update();
                }
            }

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

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

            SqlParameter[] arrParams = new SqlParameter[18];

            arrParams[0]  = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[1]  = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[2]  = new SqlParameter("@QNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QNumber, o.QNumber.GetTypeCode()));
            arrParams[3]  = new SqlParameter("@QType", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QType, o.QType.GetTypeCode()));
            arrParams[4]  = new SqlParameter("@QName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QName, o.QName.GetTypeCode()));
            arrParams[5]  = new SqlParameter("@QText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QText, o.QText.GetTypeCode()));
            arrParams[6]  = new SqlParameter("@DisplayControl", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DisplayControl, o.DisplayControl.GetTypeCode()));
            arrParams[7]  = new SqlParameter("@DisplayDirection", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DisplayDirection, o.DisplayDirection.GetTypeCode()));
            arrParams[8]  = new SqlParameter("@IsRequired", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsRequired, o.IsRequired.GetTypeCode()));
            arrParams[9]  = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[10] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[11] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[12] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[13] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[14] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[15] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

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

                var s = Survey.FetchObject(o.SID);
                if (s.CanBeScored != Survey.IsScorable(s.SID))
                {
                    s.CanBeScored = !s.CanBeScored;
                    s.Update();
                }
            }

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

            return(iReturn);
        }
Beispiel #3
0
        public static int Insert(SurveyQuestion o)
        {
            SqlParameter[] arrParams = new SqlParameter[18];

            arrParams[0]            = new SqlParameter("@SID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SID, o.SID.GetTypeCode()));
            arrParams[1]            = new SqlParameter("@QNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QNumber, o.QNumber.GetTypeCode()));
            arrParams[2]            = new SqlParameter("@QType", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QType, o.QType.GetTypeCode()));
            arrParams[3]            = new SqlParameter("@QName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QName, o.QName.GetTypeCode()));
            arrParams[4]            = new SqlParameter("@QText", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QText, o.QText.GetTypeCode()));
            arrParams[5]            = new SqlParameter("@DisplayControl", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DisplayControl, o.DisplayControl.GetTypeCode()));
            arrParams[6]            = new SqlParameter("@DisplayDirection", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DisplayDirection, o.DisplayDirection.GetTypeCode()));
            arrParams[7]            = new SqlParameter("@IsRequired", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IsRequired, o.IsRequired.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()));
            arrParams[17]           = new SqlParameter("@QID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.QID, o.QID.GetTypeCode()));
            arrParams[17].Direction = ParameterDirection.Output;

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

            o.QID = int.Parse(arrParams[17].Value.ToString());

            var s = Survey.FetchObject(o.SID);

            if (s.CanBeScored != Survey.IsScorable(s.SID))
            {
                s.CanBeScored = !s.CanBeScored;
                s.Update();
            }

            return(o.QID);
        }