Esempio n. 1
0
        /// <summary>
        /// This method creates an instance of a
        /// 'FindMethodStoredProcedure' object and
        /// creates the sql parameter[] array needed
        /// to execute the procedure 'Method_Find'.
        /// </summary>
        /// <param name="method">The 'Method' to use to
        /// get the primary key parameter.</param>
        /// <returns>An instance of an FetchUserStoredProcedure</returns>
        public static new FindMethodStoredProcedure CreateFindMethodStoredProcedure(Method method)
        {
            // Initial Value
            FindMethodStoredProcedure findMethodStoredProcedure = null;

            // verify method exists
            if (method != null)
            {
                // Instanciate findMethodStoredProcedure
                findMethodStoredProcedure = new FindMethodStoredProcedure();

                // if method.FindByName is true
                if (method.FindByName)
                {
                    // Change the procedure name
                    findMethodStoredProcedure.ProcedureName = "Method_FindByName";

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

            // return value
            return(findMethodStoredProcedure);
        }
Esempio n. 2
0
        /// <summary>
        /// This method finds a  'Method' object.
        /// This method uses the 'Method_Find' procedure.
        /// </summary>
        /// <returns>A 'Method' object.</returns>
        /// </summary>
        public Method FindMethod(FindMethodStoredProcedure findMethodProc, DataConnector databaseConnector)
        {
            // Initial Value
            Method method = null;

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

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

                    // if row exists
                    if (row != null)
                    {
                        // Load Method
                        method = MethodReader.Load(row);
                    }
                }
            }

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

            // locals
            Method method = null;

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

                // verify the first parameters is a 'Method'.
                if (parameters[0].ObjectValue as Method != null)
                {
                    // Get MethodParameter
                    Method paramMethod = (Method)parameters[0].ObjectValue;

                    // verify paramMethod exists
                    if (paramMethod != null)
                    {
                        // Now create findMethodProc from MethodWriter
                        // The DataWriter converts the 'Method'
                        // to the SqlParameter[] array needed to find a 'Method'.
                        findMethodProc = MethodWriter.CreateFindMethodStoredProcedure(paramMethod);
                    }

                    // Verify findMethodProc exists
                    if (findMethodProc != null)
                    {
                        // Execute Find Stored Procedure
                        method = this.DataManager.MethodManager.FindMethod(findMethodProc, dataConnector);

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

            // verify method exists
            if (method != null)
            {
                // Instanciate findMethodStoredProcedure
                findMethodStoredProcedure = new FindMethodStoredProcedure();

                // Now create parameters for this procedure
                findMethodStoredProcedure.Parameters = CreatePrimaryKeyParameter(method);
            }

            // return value
            return(findMethodStoredProcedure);
        }