示例#1
0
        }// Close method getMenus.

        #endregion

        #region MenuItem Update methods

        // ==================================================================================
        /// <summary>
        /// This class updates Menus data object in the database using it unique object identifier.
        /// </summary>
        /// <param name="MenuItem">EvMenuItem: menus data object</param>
        /// <returns>Evado.Model.EvEventCodes: an update item code</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the title is not defined.
        ///
        /// 2. Define the SQL query parameters and load the query values.
        ///
        /// 3. Execute the update command.
        ///
        /// 4. Return update item code
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public Evado.Model.EvEventCodes updateItem(Evado.Digital.Model.EvMenuItem MenuItem)
        {
            this.LogMethod("updateItem method. ");
            //
            // Initialize a debug log
            //

            //
            // Validate whether the menu title exists
            //
            if (MenuItem.Title == String.Empty)
            {
                return(Evado.Model.EvEventCodes.Data_InvalidId_Error);
            }

            //
            // Define the SQL query parameters and load the query values.
            //
            SqlParameter [] _cmdParms = GetParameters( );
            SetParameters(_cmdParms, MenuItem);

            //
            // Execute the update command.
            //
            if (EvSqlMethods.StoreProcUpdate(_storedProcedureUpdateItem, _cmdParms) == 0)
            {
                return(Evado.Model.EvEventCodes.Database_Record_Update_Error);
            }

            return(Evado.Model.EvEventCodes.Ok);
        }//END updateItem method
示例#2
0
        }//END addItem class

        // ==================================================================================
        /// <summary>
        /// This class deletes items from MenuItem table.
        /// </summary>
        /// <param name="MenuItem">EvMenuItem: a menu item object</param>
        /// <returns>Evado.Model.EvEventCodes: a delete item code</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the Guid is empty.
        ///
        /// 2. Define the SQL query parameters and load the query values.
        ///
        /// 3. Execute the update command.
        ///
        /// 4. Return update item code
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public Evado.Model.EvEventCodes deleteItem(Evado.Digital.Model.EvMenuItem MenuItem)
        {
            this.LogMethod("addItem method");
            this.LogDebug("Guid: " + MenuItem.Guid);
            //
            // Initialize a debug log
            //

            //
            // Validate whether the menu guid exists
            //
            if (MenuItem.Guid == Guid.Empty)
            {
                return(Evado.Model.EvEventCodes.Data_InvalidId_Error);
            }

            //
            // Define the query parameters.
            //
            SqlParameter [] _cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_GUID, SqlDbType.UniqueIdentifier)
            };
            _cmdParms [0].Value = MenuItem.Guid;

            //
            // Execute the update command.
            //
            if (EvSqlMethods.StoreProcUpdate(_storedProcedureDeleteItem, _cmdParms) == 0)
            {
                return(Evado.Model.EvEventCodes.Database_Record_Update_Error);
            }

            return(Evado.Model.EvEventCodes.Ok);
        }//END deleteItem class
示例#3
0
        }//END GroupExists method

        #endregion

        #region Retreival methods

        // =====================================================================================
        /// <summary>
        /// This class gets Menus data object by its unique object identifier.
        /// </summary>
        /// <param name="MenuGuid">Guid: (Mandatory)a global unique object identifier.</param>
        /// <returns>EvMenuItem: a menu data object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty MenuItem object, if the Guid is empty.
        ///
        /// 2. Define the SQL query parameters and a query string.
        ///
        /// 3. Execute the query string and store the results on datatable.
        ///
        /// 4. Return an empty MenuItem object if the table has no value.
        ///
        /// 5. Else, Extract the table row to the MenuItem object.
        ///
        /// 6. Return the MenuItem object.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EvMenuItem getItem(Guid MenuGuid)
        {
            this.LogMethod("getItem");
            this.LogDebug("MenuGuid: " + MenuGuid);
            //
            // Initialize a debug log and a menu item object
            //
            Evado.Digital.Model.EvMenuItem menuItem = new  Evado.Digital.Model.EvMenuItem( );

            //
            // Check that there is a valid unique identifier.
            //
            if (MenuGuid == Guid.Empty)
            {
                return(menuItem);
            }

            //
            // Define the query parameters.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_GUID, SqlDbType.UniqueIdentifier);

            cmdParms.Value = MenuGuid;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQuery_View + " WHERE (Mnu_Guid = @Guid ); ";

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // If not rows the return
                //
                if (table.Rows.Count == 0)
                {
                    return(menuItem);
                }

                //
                // Extract the table row
                //
                DataRow row = table.Rows [0];

                //
                // Process the results.
                //
                menuItem = this.getRowData(row);
            }//END Using statement

            //
            // Pass back the data object.
            //
            return(menuItem);
        }//END getItem class
示例#4
0
        }//END getItem class

        // =====================================================================================
        /// <summary>
        /// This class gets Menus data object by its object identifier.
        /// </summary>
        /// <param name="Title">string: a name menu item</param>
        /// <returns>EvMenuItem: a menu item</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty MenuItem object, if the Name is empty
        ///
        /// 2. Define the SQL query parameters and a query string.
        ///
        /// 3. Execute the query string and store the results on datatable.
        ///
        /// 4. Return an empty MenuItem object if the table has no value.
        ///
        /// 5. Else, Extract the table row to the MenuItem object.
        ///
        /// 6. Return the MenuItem object.
        ///
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EvMenuItem getItem(string Title)
        {
            this.LogMethod("getItem");
            this.LogDebug("Title: " + Title);
            //
            // Initialize a debug log and a menu item object
            //
            Evado.Digital.Model.EvMenuItem menuItem = new  Evado.Digital.Model.EvMenuItem( );

            //
            // Check that there is a valid name.
            //
            if (Title == String.Empty)
            {
                return(menuItem);
            }

            //
            // Define the query parameters.
            //
            SqlParameter cmdParms = new SqlParameter(PARM_TITLE, SqlDbType.NVarChar, 20);

            cmdParms.Value = Title;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQuery_View + " WHERE (Mnu_Title = @Title ); ";

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // If not rows the return
                //
                if (table.Rows.Count == 0)
                {
                    return(menuItem);
                }

                //
                // Extract the table row
                //
                DataRow row = table.Rows [0];

                //
                // Process the results.
                //
                menuItem = this.getRowData(row);
            }//END Using statement

            return(menuItem);
        }// Close method getMenus.
示例#5
0
        }//END GetParameters method

        // ==================================================================================
        /// <summary>
        /// This class sets the query parameter values.
        /// </summary>
        /// <param name="cmdParms">SqlParameter: an arraylist of Database parameters</param>
        /// <param name="MenuItem">EvMenuItem: a menus data object</param>
        /// <remarks>
        /// This method consists of the following step:
        ///
        /// 1. Update MenuItem object'a values to the array of sql parameters.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private void SetParameters(
            SqlParameter [] cmdParms,
            Evado.Digital.Model.EvMenuItem MenuItem)
        {
            //
            // Update elements of MenuItem object to the cmdParms arraylist
            //
            cmdParms [0].Value = MenuItem.Guid;
            cmdParms [1].Value = MenuItem.PageId;
            cmdParms [2].Value = MenuItem.Title;
            cmdParms [3].Value = MenuItem.Order;
            cmdParms [4].Value = MenuItem.Group;
            cmdParms [5].Value = MenuItem.GroupHeader;
            cmdParms [6].Value = MenuItem.Platform;
            cmdParms [7].Value = MenuItem.UserTypes;
            cmdParms [8].Value = MenuItem.RoleList;
            cmdParms [9].Value = MenuItem.Parameters;
        }//END SetLetterParameters.
示例#6
0
        }//END SetLetterParameters.

        #endregion

        #region ReaderData methods

        // =====================================================================================
        /// <summary>
        /// This class reads the content of the data reader object into Menus business object.
        /// </summary>
        /// <param name="Row">DataRow: a sql data row</param>
        /// <returns>EvMenuItem: a row data of the menu item</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Add page identifier to a menu item object if it exists
        ///
        /// 2. Append the row strings of EvSqlMethods object to the menu item object.
        ///
        /// 3. Rename the role visitSchedule members and add them to the menu item object.
        ///
        /// 4. Return the menu item object
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public Evado.Digital.Model.EvMenuItem getRowData(DataRow Row)
        {
            //
            // Initialise the menu item object and a page identifier string.
            //
            Evado.Digital.Model.EvMenuItem menu = new  Evado.Digital.Model.EvMenuItem( );

            menu.Guid        = EvSqlMethods.getGuid(Row, "MNU_GUID");
            menu.PageId      = EvSqlMethods.getString(Row, "MNU_PAGE_ID");
            menu.Title       = EvSqlMethods.getString(Row, "MNU_TITLE");
            menu.Order       = EvSqlMethods.getInteger(Row, "MNU_ORDER");
            menu.Group       = EvSqlMethods.getString(Row, "MNU_GROUP");
            menu.GroupHeader = EvSqlMethods.getBool(Row, "MNU_GROUP_HEADER");
            menu.Platform    = EvSqlMethods.getString(Row, "MNU_PLATFORM");
            menu.UserTypes   = EvSqlMethods.getString(Row, "MNU_USER_TYPES");
            menu.RoleList    = EvSqlMethods.getString(Row, "MNU_ROLES");
            menu.Parameters  = EvSqlMethods.getString(Row, "MNU_PARAMETERS");

            return(menu);
        }//END getRowData method.
示例#7
0
        }//END getRowData method.

        #endregion

        #region Query methods

        // ==================================================================================
        /// <summary>
        /// This class gets a List containing a EvMenutItem data objects.
        /// </summary>
        /// <param name="PlatformId">String: (Optional) The Site identifier.</param>
        /// <param name="Group">String: (Optional) The Group identifier.</param>
        /// <returns>List of  Evado.Digital.Model.EvMenuItem : a view of menu item list</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Define the SQL query parameters and a query string.
        ///
        /// 2. Execute the query and store the results on datatable.
        ///
        /// 3. Loop through the table and extract data row to the MenuItem object.
        ///
        /// 4. Add MenuItem object's values to the MenuItem list.
        ///
        /// 5. Return the MenuItem list.
        ///
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public List <Evado.Digital.Model.EvMenuItem> getView(
            String PlatformId,
            String Group)
        {
            //
            // Initialize a debug log
            //
            this.LogMethod("getView method");
            this.LogDebug("PlatformId: " + PlatformId);
            this.LogDebug("Group: " + Group);

            //
            // Initialize a return list of menu item, site 1 and site 2.
            //
            List <Evado.Digital.Model.EvMenuItem> view = new List <Evado.Digital.Model.EvMenuItem> ( );

            //
            // Define the SQL query parameters.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_PLATFORM, SqlDbType.VarChar, 10),
                new SqlParameter(PARM_GROUP, SqlDbType.NVarChar, 50),
            };
            cmdParms [0].Value = PlatformId;
            cmdParms [1].Value = Group;

            //
            // Define the query string.
            //
            _sqlQueryString = _sqlQuery_View + " WHERE (MNU_PLATFORM = @PLATFORM)";

            if (Group != String.Empty)
            {
                _sqlQueryString += " AND (Mnu_Group = @Group) ";
            }

            _sqlQueryString += " ORDER BY   Mnu_Order";

            this.LogDebug(_sqlQueryString);

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_sqlQueryString, cmdParms))
            {
                //
                // Iterate through the results extracting the role information.
                //
                for (int Count = 0; Count < table.Rows.Count; Count++)
                {
                    //
                    // Extract the table row
                    //
                    DataRow row = table.Rows [Count];

                    Evado.Digital.Model.EvMenuItem menu = this.getRowData(row);

                    //
                    // Append the value to the visit
                    //
                    view.Add(menu);
                } //END interation loop.
            }     //END using method

            //
            // Update debug log with a view count number
            //
            this.LogDebug("view count: " + view.Count);
            //
            // Pass back the result arrray.
            //
            return(view);
        } // Close getView method.