/// <summary>
        /// Read a category from the current reader record.
        /// </summary>
        internal static SwitchboardPanel ReadEntityRecord(SQLiteDataReader reader)
        {
            SwitchboardPanel record = new SwitchboardPanel();

            record.ID          = reader.GetInt32(0);
            record.Name        = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
            record.Description = reader.IsDBNull(2) ? string.Empty : reader.GetString(2);
            record.Width       = reader.IsDBNull(3) ? 1 : reader.GetInt32(3);
            record.Height      = reader.IsDBNull(4) ? 1 : reader.GetInt32(4);

            return(record);
        }
        /// <summary>
        /// Adds a new panel into the current project.
        /// </summary>
        /// <param name="panel">An instance of <see cref="SwitchboardPanel"/> containing the data for the new panel.</param>
        public void Add(SwitchboardPanel panel)
        {
            string sql = string.Empty;

            Logger.LogDebug(this, "[CLASS].Add([{0}])", panel);

            try
            {
                Connect();

                // Añade el registro
                sql = @"INSERT INTO 
                        " + SwitchboardPanelManager.SQL_TABLE + @" (" + SwitchboardPanelManager.SQL_FIELDS_INSERT + @") 
                    VALUES 
                        (@name, @description, @width, @height)";

                SetParameter("name", panel.Name);
                SetParameter("description", panel.Description);
                SetParameter("width", panel.Width);
                SetParameter("height", panel.Height);

                ExecuteNonQuery(sql);

                // Obtiene el nuevo ID
                sql = @"SELECT 
                        Max(id) As id 
                    FROM 
                        " + SwitchboardPanelManager.SQL_TABLE;

                panel.ID = (int)ExecuteScalar(sql);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
        /// <summary>
        /// Gets a panel by its name.
        /// </summary>
        /// <param name="name">The panel's name.</param>
        /// <returns>The requested instance of <see cref="SwitchboardPanel"/>.</returns>
        public SwitchboardPanel GetByName(string name)
        {
            string           sql  = string.Empty;
            SwitchboardPanel item = null;

            Logger.LogDebug(this, "[CLASS].GetByName({0})", name);

            try
            {
                Connect();

                sql = @"SELECT 
                        " + SwitchboardPanelManager.SQL_FIELDS_SELECT + @" 
                    FROM 
                        " + SwitchboardPanelManager.SQL_TABLE + @" 
                    WHERE 
                        LCase(name) = @name";

                SetParameter("name", name);

                using (SQLiteDataReader reader = ExecuteReader(sql))
                {
                    if (reader.Read())
                    {
                        item = SwitchboardPanelManager.ReadEntityRecord(reader);
                    }
                }

                return(item);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
        /// <summary>
        /// Update the specified switchboard panel data.
        /// </summary>
        /// <param name="panel">An instance with the updated data.</param>
        public void Update(SwitchboardPanel panel)
        {
            string sql = string.Empty;

            Logger.LogDebug(this, "[CLASS].Update([{0}])", panel);

            try
            {
                Connect();

                sql = @"UPDATE 
                        " + SwitchboardPanelManager.SQL_TABLE + @" 
                    SET 
                        name        = @name, 
                        description = @description, 
                        width       = @width,
                        height      = @height 
                    WHERE 
                        id = @id";

                SetParameter("name", panel.Name);
                SetParameter("description", panel.Description);
                SetParameter("width", panel.Width);
                SetParameter("height", panel.Height);
                SetParameter("id", panel.ID);

                ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }