Пример #1
0
        /// <summary>
        /// This method inserts a 'Noun' object.
        /// This method uses the 'Noun_Insert' procedure.
        /// </summary>
        /// <returns>The identity value of the new record.</returns>
        /// </summary>
        public int InsertNoun(InsertNounStoredProcedure insertNounProc, DataConnector databaseConnector)
        {
            // Initial Value
            int newIdentity = -1;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // Execute Non Query
                newIdentity = this.DataHelper.InsertRecord(insertNounProc, databaseConnector);
            }

            // return value
            return(newIdentity);
        }
Пример #2
0
        /// <summary>
        /// This method inserts a 'Noun' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Noun' to insert.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject InsertNoun(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Noun noun = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Insert StoredProcedure
                InsertNounStoredProcedure insertNounProc = null;

                // verify the first parameters is a(n) 'Noun'.
                if (parameters[0].ObjectValue as Noun != null)
                {
                    // Create Noun Parameter
                    noun = (Noun)parameters[0].ObjectValue;

                    // verify noun exists
                    if (noun != null)
                    {
                        // Now create insertNounProc from NounWriter
                        // The DataWriter converts the 'Noun'
                        // to the SqlParameter[] array needed to insert a 'Noun'.
                        insertNounProc = NounWriter.CreateInsertNounStoredProcedure(noun);
                    }

                    // Verify insertNounProc exists
                    if (insertNounProc != null)
                    {
                        // Execute Insert Stored Procedure
                        returnObject.IntegerValue = this.DataManager.NounManager.InsertNoun(insertNounProc, dataConnector);
                    }
                }
                else
                {
                    // Raise Error Data Connection Not Available
                    throw new Exception("The database connection is not available.");
                }
            }

            // return value
            return(returnObject);
        }
Пример #3
0
        /// <summary>
        /// This method creates an instance of an
        /// 'InsertNounStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Noun_Insert'.
        /// </summary>
        /// <param name="noun"The 'Noun' object to insert</param>
        /// <returns>An instance of a 'InsertNounStoredProcedure' object.</returns>
        public static InsertNounStoredProcedure CreateInsertNounStoredProcedure(Noun noun)
        {
            // Initial Value
            InsertNounStoredProcedure insertNounStoredProcedure = null;

            // verify noun exists
            if (noun != null)
            {
                // Instanciate insertNounStoredProcedure
                insertNounStoredProcedure = new InsertNounStoredProcedure();

                // Now create parameters for this procedure
                insertNounStoredProcedure.Parameters = CreateInsertParameters(noun);
            }

            // return value
            return(insertNounStoredProcedure);
        }