Esempio n. 1
0
        /// <summary>
        /// This method finds a  'Enumeration' object.
        /// This method uses the 'Enumeration_Find' procedure.
        /// </summary>
        /// <returns>A 'Enumeration' object.</returns>
        /// </summary>
        public Enumeration FindEnumeration(FindEnumerationStoredProcedure findEnumerationProc, DataConnector databaseConnector)
        {
            // Initial Value
            Enumeration enumeration = null;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // First Get Dataset
                DataSet enumerationDataSet = this.DataHelper.LoadDataSet(findEnumerationProc, databaseConnector);

                // Verify DataSet Exists
                if (enumerationDataSet != null)
                {
                    // Get DataTable From DataSet
                    DataRow row = this.DataHelper.ReturnFirstRow(enumerationDataSet);

                    // if row exists
                    if (row != null)
                    {
                        // Load Enumeration
                        enumeration = EnumerationReader.Load(row);
                    }
                }
            }

            // return value
            return(enumeration);
        }
        /// <summary>
        /// This method finds a 'Enumeration' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Enumeration' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindEnumeration(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            Enumeration enumeration = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Create Find StoredProcedure
                FindEnumerationStoredProcedure findEnumerationProc = null;

                // verify the first parameters is a 'Enumeration'.
                if (parameters[0].ObjectValue as Enumeration != null)
                {
                    // Get EnumerationParameter
                    Enumeration paramEnumeration = (Enumeration)parameters[0].ObjectValue;

                    // verify paramEnumeration exists
                    if (paramEnumeration != null)
                    {
                        // Now create findEnumerationProc from EnumerationWriter
                        // The DataWriter converts the 'Enumeration'
                        // to the SqlParameter[] array needed to find a 'Enumeration'.
                        findEnumerationProc = EnumerationWriter.CreateFindEnumerationStoredProcedure(paramEnumeration);
                    }

                    // Verify findEnumerationProc exists
                    if (findEnumerationProc != null)
                    {
                        // Execute Find Stored Procedure
                        enumeration = this.DataManager.EnumerationManager.FindEnumeration(findEnumerationProc, dataConnector);

                        // if dataObject exists
                        if (enumeration != null)
                        {
                            // set returnObject.ObjectValue
                            returnObject.ObjectValue = enumeration;
                        }
                    }
                }
                else
                {
                    // Raise Error Data Connection Not Available
                    throw new Exception("The database connection is not available.");
                }
            }

            // return value
            return(returnObject);
        }
        /// <summary>
        /// This method creates an instance of a
        /// 'FindEnumerationStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Enumeration_Find'.
        /// </summary>
        /// <param name="enumeration">The 'Enumeration' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static FindEnumerationStoredProcedure CreateFindEnumerationStoredProcedure(Enumeration enumeration)
        {
            // Initial Value
            FindEnumerationStoredProcedure findEnumerationStoredProcedure = null;

            // verify enumeration exists
            if (enumeration != null)
            {
                // Instanciate findEnumerationStoredProcedure
                findEnumerationStoredProcedure = new FindEnumerationStoredProcedure();

                // Now create parameters for this procedure
                findEnumerationStoredProcedure.Parameters = CreatePrimaryKeyParameter(enumeration);
            }

            // return value
            return(findEnumerationStoredProcedure);
        }