示例#1
0
        /// <summary>
        /// This method inserts a 'Image' object.
        /// This method uses the 'Image_Insert' procedure.
        /// </summary>
        /// <returns>The identity value of the new record.</returns>
        /// </summary>
        public int InsertImage(InsertImageStoredProcedure insertImageProc, DataConnector databaseConnector)
        {
            // Initial Value
            int newIdentity = -1;

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

            // return value
            return(newIdentity);
        }
        /// <summary>
        /// This method inserts a 'Image' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Image' to insert.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject InsertImage(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Image image = null;

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

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

                    // verify image exists
                    if (image != null)
                    {
                        // Now create insertImageProc from ImageWriter
                        // The DataWriter converts the 'Image'
                        // to the SqlParameter[] array needed to insert a 'Image'.
                        insertImageProc = ImageWriter.CreateInsertImageStoredProcedure(image);
                    }

                    // Verify insertImageProc exists
                    if (insertImageProc != null)
                    {
                        // Execute Insert Stored Procedure
                        returnObject.IntegerValue = this.DataManager.ImageManager.InsertImage(insertImageProc, 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
        /// 'InsertImageStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Image_Insert'.
        /// </summary>
        /// <param name="image"The 'Image' object to insert</param>
        /// <returns>An instance of a 'InsertImageStoredProcedure' object.</returns>
        public static InsertImageStoredProcedure CreateInsertImageStoredProcedure(Image image)
        {
            // Initial Value
            InsertImageStoredProcedure insertImageStoredProcedure = null;

            // verify image exists
            if (image != null)
            {
                // Instanciate insertImageStoredProcedure
                insertImageStoredProcedure = new InsertImageStoredProcedure();

                // Now create parameters for this procedure
                insertImageStoredProcedure.Parameters = CreateInsertParameters(image);
            }

            // return value
            return(insertImageStoredProcedure);
        }