/// <summary>
        /// This method creates an instance of a
        /// 'FindStateStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'State_Find'.
        /// </summary>
        /// <param name="state">The 'State' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static new FindStateStoredProcedure CreateFindStateStoredProcedure(State state)
        {
            // Initial Value
            FindStateStoredProcedure findStateStoredProcedure = null;

            // verify state exists
            if (state != null)
            {
                // Instanciate findStateStoredProcedure
                findStateStoredProcedure = new FindStateStoredProcedure();

                // if state.FindByName is true
                if (state.FindByName)
                {
                    // Change the procedure name
                    findStateStoredProcedure.ProcedureName = "State_FindByName";

                    // Create the @Name parameter
                    findStateStoredProcedure.Parameters = SqlParameterHelper.CreateSqlParameters("@Name", state.Name);
                }
                else
                {
                    // Now create parameters for this procedure
                    findStateStoredProcedure.Parameters = CreatePrimaryKeyParameter(state);
                }
            }

            // return value
            return(findStateStoredProcedure);
        }
        /// <summary>
        /// This method finds a  'State' object.
        /// This method uses the 'State_Find' procedure.
        /// </summary>
        /// <returns>A 'State' object.</returns>
        /// </summary>
        public State FindState(FindStateStoredProcedure findStateProc, DataConnector databaseConnector)
        {
            // Initial Value
            State state = null;

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

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

                    // if row exists
                    if (row != null)
                    {
                        // Load State
                        state = StateReader.Load(row);
                    }
                }
            }

            // return value
            return(state);
        }
예제 #3
0
        /// <summary>
        /// This method finds a 'State' object.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'State' to delete.
        /// <returns>A PolymorphicObject object with a Boolean value.
        internal PolymorphicObject FindState(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            State state = null;

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

                // verify the first parameters is a 'State'.
                if (parameters[0].ObjectValue as State != null)
                {
                    // Get StateParameter
                    State paramState = (State)parameters[0].ObjectValue;

                    // verify paramState exists
                    if (paramState != null)
                    {
                        // Now create findStateProc from StateWriter
                        // The DataWriter converts the 'State'
                        // to the SqlParameter[] array needed to find a 'State'.
                        findStateProc = StateWriter.CreateFindStateStoredProcedure(paramState);
                    }

                    // Verify findStateProc exists
                    if (findStateProc != null)
                    {
                        // Execute Find Stored Procedure
                        state = this.DataManager.StateManager.FindState(findStateProc, dataConnector);

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

            // return value
            return(returnObject);
        }
예제 #4
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FindStateStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'State_Find'.
        /// </summary>
        /// <param name="state">The 'State' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static FindStateStoredProcedure CreateFindStateStoredProcedure(State state)
        {
            // Initial Value
            FindStateStoredProcedure findStateStoredProcedure = null;

            // verify state exists
            if (state != null)
            {
                // Instanciate findStateStoredProcedure
                findStateStoredProcedure = new FindStateStoredProcedure();

                // Now create parameters for this procedure
                findStateStoredProcedure.Parameters = CreatePrimaryKeyParameter(state);
            }

            // return value
            return(findStateStoredProcedure);
        }