Ejemplo n.º 1
0
        /// <summary>
        /// This method finds a  'ZipCode' object.
        /// This method uses the 'ZipCode_Find' procedure.
        /// </summary>
        /// <returns>A 'ZipCode' object.</returns>
        /// </summary>
        public ZipCode FindZipCode(FindZipCodeStoredProcedure findZipCodeProc, DataConnector databaseConnector)
        {
            // Initial Value
            ZipCode zipCode = null;

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

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

                    // if row exists
                    if (row != null)
                    {
                        // Load ZipCode
                        zipCode = ZipCodeReader.Load(row);
                    }
                }
            }

            // return value
            return(zipCode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method finds a 'ZipCode' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'ZipCode' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindZipCode(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            ZipCode zipCode = null;

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

                // verify the first parameters is a 'ZipCode'.
                if (parameters[0].ObjectValue as ZipCode != null)
                {
                    // Get ZipCodeParameter
                    ZipCode paramZipCode = (ZipCode)parameters[0].ObjectValue;

                    // verify paramZipCode exists
                    if (paramZipCode != null)
                    {
                        // Now create findZipCodeProc from ZipCodeWriter
                        // The DataWriter converts the 'ZipCode'
                        // to the SqlParameter[] array needed to find a 'ZipCode'.
                        findZipCodeProc = ZipCodeWriter.CreateFindZipCodeStoredProcedure(paramZipCode);
                    }

                    // Verify findZipCodeProc exists
                    if (findZipCodeProc != null)
                    {
                        // Execute Find Stored Procedure
                        zipCode = this.DataManager.ZipCodeManager.FindZipCode(findZipCodeProc, dataConnector);

                        // if dataObject exists
                        if (zipCode != null)
                        {
                            // set returnObject.ObjectValue
                            returnObject.ObjectValue = zipCode;
                        }
                    }
                }
                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
        /// 'FindZipCodeStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'ZipCode_Find'.
        /// </summary>
        /// <param name="zipCode">The 'ZipCode' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static FindZipCodeStoredProcedure CreateFindZipCodeStoredProcedure(ZipCode zipCode)
        {
            // Initial Value
            FindZipCodeStoredProcedure findZipCodeStoredProcedure = null;

            // verify zipCode exists
            if (zipCode != null)
            {
                // Instanciate findZipCodeStoredProcedure
                findZipCodeStoredProcedure = new FindZipCodeStoredProcedure();

                // Now create parameters for this procedure
                findZipCodeStoredProcedure.Parameters = CreatePrimaryKeyParameter(zipCode);
            }

            // return value
            return(findZipCodeStoredProcedure);
        }