/// <summary>
        /// The Page_Load event handler on this User Control populates the comboboxes
        /// for portals and module types for the ContentManager.
        /// It uses the Appleseed.ContentManagerDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //populate module types dropdownlist.
                ContentManagerDB contentDB = new ContentManagerDB();

                //populate moduleTypes list
                ModuleTypes.DataSource = contentDB.GetModuleTypes();
                ModuleTypes.DataValueField = "ItemID";
                ModuleTypes.DataTextField = "FriendlyName";
                ModuleTypes.DataBind();

                //populate source portal list
                SourcePortal.DataValueField = "PortalID";
                SourcePortal.DataTextField = "PortalAlias";
                SourcePortal.DataSource = contentDB.GetPortals();
                SourcePortal.DataBind();

                //destination portal list.
                DestinationPortal.DataValueField = "PortalID";
                DestinationPortal.DataTextField = "PortalAlias";
                DestinationPortal.DataSource = contentDB.GetPortals();
                DestinationPortal.DataBind();

                //Function to set visibility for Portal dropdowns and select current portal
                //as default
                MultiPortalSupport();

                //functions to load the modules in the currently selected portal.
                LoadSourceModules();
                LoadDestinationModules();
            }
        }
        /// <summary>
        /// Loads the source modules.
        /// </summary>
        private void LoadSourceModules()
        {
            if (ModuleTypes.SelectedIndex > -1)
            {
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();

                SourceInstance.DataValueField = "ModuleID";
                SourceInstance.DataTextField = "TabModule";

                SourceInstance.DataSource =
                    contentDB.GetModuleInstances(ModuleTypeID, Int32.Parse(SourcePortal.SelectedItem.Value));
                SourceInstance.DataBind();

                //if items exist in the sourceinstance, select the first item
                if (SourceInstance.Items.Count > 0)
                {
                    SourceInstance.SelectedIndex = 0;
                    LoadSourceModuleData();
                }
                else
                {
                    //if there are no instances, there can be no data!!
                    SourceListBox.Items.Clear();
                }
            }
        }
        /// <summary>
        /// Handles the Click event of the MoveRight control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void MoveRight_Click(object sender, EventArgs e)
        {
            if (SourceListBox.SelectedIndex > -1 && SourceInstance.SelectedIndex > -1 &&
                DestinationInstance.SelectedIndex > -1)
            {
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);

                //these two lines opposite in MoveLeft_Click
                int DestModID = Int32.Parse(DestinationInstance.SelectedItem.Value);
                int ItemToMove = Int32.Parse(SourceListBox.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                contentDB.MoveItemRight(ModuleTypeID, ItemToMove, DestModID);
                LoadSourceModuleData();
                LoadDestinationModuleData();
            }
        }
        /// <summary>
        /// Loads the destination modules.
        /// </summary>
        private void LoadDestinationModules()
        {
            if (ModuleTypes.SelectedIndex > -1 && SourceInstance.Items.Count > 0)
            {
                //Get the Module Type(ex announcements) and the Source ModuleID
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);
                int SourceModID = Int32.Parse(SourceInstance.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();

                DestinationInstance.DataValueField = "ModuleID";
                DestinationInstance.DataTextField = "TabModule";
                DestinationInstance.DataSource = contentDB.GetModuleInstancesExc(ModuleTypeID,
                                                                                 SourceModID,
                                                                                 Int32.Parse(
                                                                                     DestinationPortal.SelectedItem.
                                                                                         Value));
                DestinationInstance.DataBind();

                //if any items exist in destination instance dropdown, select first and
                //load data for that instance.
                if (DestinationInstance.Items.Count > 0)
                {
                    DestinationInstance.SelectedIndex = 0;
                    LoadDestinationModuleData();
                }
                else
                {
                    DestListBox.Items.Clear();
                }
            }
        }
        /// <summary>
        /// Loads the source module data.
        /// </summary>
        private void LoadSourceModuleData()
        {
            //check to be sure that a source instance has been selected before proceeding.
            //this can cause errors if not checked for!
            if (SourceInstance.SelectedIndex > -1)
            {
                int SourceModID = Int32.Parse(SourceInstance.SelectedItem.Value);
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                SourceListBox.DataValueField = "ItemID";
                SourceListBox.DataTextField = "ItemDesc";
                SourceListBox.DataSource = contentDB.GetSourceModuleData(ModuleTypeID, SourceModID);
                SourceListBox.DataBind();
            }
        }
        /// <summary>
        /// Loads the destination module data.
        /// </summary>
        private void LoadDestinationModuleData()
        {
            if (DestinationInstance.SelectedIndex > -1)
            {
                int DestModID = Int32.Parse(DestinationInstance.SelectedItem.Value);
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                DestListBox.DataValueField = "ItemID";
                DestListBox.DataTextField = "ItemDesc";
                DestListBox.DataSource = contentDB.GetDestModuleData(ModuleTypeID, DestModID);
                DestListBox.DataBind();
            }
        }
        /// <summary>
        /// Handles the Click event of the DeleteRight control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void DeleteRight_Click(object sender, EventArgs e)
        {
            if (DestListBox.SelectedIndex > -1)
            {
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);
                int ItemToDelete = Int32.Parse(DestListBox.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                contentDB.DeleteItemRight(ModuleTypeID, ItemToDelete);
                LoadDestinationModuleData();
            }
        }
        /// <summary>
        /// Handles the Click event of the DeleteLeft control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void DeleteLeft_Click(object sender, EventArgs e)
        {
            if (SourceListBox.SelectedIndex > -1)
            {
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);
                int ItemToDelete = Int32.Parse(SourceListBox.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                contentDB.DeleteItemLeft(ModuleTypeID, ItemToDelete);
                LoadSourceModuleData();
            }
        }
        /// <summary>
        /// Handles the Click event of the CopyRight control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void CopyRight_Click(object sender, EventArgs e)
        {
            if (SourceListBox.SelectedIndex > -1 && SourceInstance.SelectedIndex > -1 &&
                DestinationInstance.SelectedIndex > -1)
            {
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);
                int DestModID = Int32.Parse(DestinationInstance.SelectedItem.Value);
                int ItemToMove = Int32.Parse(SourceListBox.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                contentDB.CopyItem(ModuleTypeID, ItemToMove, DestModID);
                LoadDestinationModuleData();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handles the Click event of the CopyAll control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void CopyAll_Click(object sender, EventArgs e)
        {
            if (SourceListBox.Items.Count > 0 && SourceInstance.SelectedIndex > -1 &&
                DestinationInstance.SelectedIndex > -1)
            {
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);
                int DestModID = Int32.Parse(DestinationInstance.SelectedItem.Value);
                int SourceModID = Int32.Parse(SourceInstance.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                contentDB.CopyAll(ModuleTypeID, SourceModID, DestModID);
                LoadDestinationModuleData();
            }
        }