/// <summary>
        /// This method finds a  'LastName' object.
        /// This method uses the 'LastName_Find' procedure.
        /// </summary>
        /// <returns>A 'LastName' object.</returns>
        /// </summary>
        public LastName FindLastName(FindLastNameStoredProcedure findLastNameProc, DataConnector databaseConnector)
        {
            // Initial Value
            LastName lastName = null;

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

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

                    // if row exists
                    if (row != null)
                    {
                        // Load LastName
                        lastName = LastNameReader.Load(row);
                    }
                }
            }

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

            // locals
            LastName lastName = null;

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

                // verify the first parameters is a 'LastName'.
                if (parameters[0].ObjectValue as LastName != null)
                {
                    // Get LastNameParameter
                    LastName paramLastName = (LastName)parameters[0].ObjectValue;

                    // verify paramLastName exists
                    if (paramLastName != null)
                    {
                        // Now create findLastNameProc from LastNameWriter
                        // The DataWriter converts the 'LastName'
                        // to the SqlParameter[] array needed to find a 'LastName'.
                        findLastNameProc = LastNameWriter.CreateFindLastNameStoredProcedure(paramLastName);
                    }

                    // Verify findLastNameProc exists
                    if (findLastNameProc != null)
                    {
                        // Execute Find Stored Procedure
                        lastName = this.DataManager.LastNameManager.FindLastName(findLastNameProc, dataConnector);

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

            // verify lastName exists
            if (lastName != null)
            {
                // Instanciate findLastNameStoredProcedure
                findLastNameStoredProcedure = new FindLastNameStoredProcedure();

                // Now create parameters for this procedure
                findLastNameStoredProcedure.Parameters = CreatePrimaryKeyParameter(lastName);
            }

            // return value
            return(findLastNameStoredProcedure);
        }