Example #1
0
        protected void treeProductGroup_SelectedNodeChanged(object sender, EventArgs e)
        {
            // Determine new ProductId
            string productGroupId = treeProductGroup.SelectedNode.Value;

            if (productGroupId.StartsWith("_"))
            {
                ProductGroupId = Convert.ToInt32(productGroupId.Substring(1));
            }

            // Enabling / Disabling Edit Controls
            pnlProductGroupTree.Visible    = false;
            pnlProductGroupDetails.Visible = true;

            cmdCancel.Visible = true;

            if (ProductGroupId > -1 || EditState == "new")
            {
                pnlProductGroupEditDetails.Visible = true;
                cmdUpdate.Visible = true;
                BindFeatureListsData();
            }
            else
            {
                pnlProductGroupEditDetails.Visible = false;
                cmdUpdate.Visible = false;
            }
            cmdAdd.Visible = (EditState != "new");

            // if product exists

            if (ProductGroupId > 0)
            {
                ProductGroup = Controller.GetProductGroup(PortalId, CurrentLanguage, ProductGroupId);
            }

            if (ProductGroup != null)
            {
                // Fill in the Language information
                List <ILanguageEditorInfo> dbLangs = new List <ILanguageEditorInfo>();
                foreach (ProductGroupLangInfo productGroupLang in Controller.GetProductGroupLangs(ProductGroup.ProductGroupId))
                {
                    dbLangs.Add(productGroupLang);
                }
                lngProductGroups.Langs = dbLangs;

                // Set Image Info
                int    imageFileId = -1;
                string imageUrl    = "";
                if (!String.IsNullOrEmpty(ProductGroup.Image))
                {
                    IFileInfo imageFile = FileManager.Instance.GetFile(PortalId, ProductGroup.Image);
                    if (imageFile != null)
                    {
                        imageFileId = imageFile.FileId;
                    }
                }
                if (imageFileId > -1)
                {
                    imageUrl = "FileID=" + imageFileId.ToString();
                }
                else
                {
                    imageUrl = _imageDir + "This_fileName-Should_not_3xist";
                }

                // Set Icon Info
                int    iconFileId = -1;
                string iconUrl    = "";
                if (!String.IsNullOrEmpty(ProductGroup.Icon))
                {
                    IFileInfo iconFile = FileManager.Instance.GetFile(PortalId, ProductGroup.Icon);
                    if (iconFile != null)
                    {
                        iconFileId = iconFile.FileId;
                    }
                }

                if (iconFileId > -1)
                {
                    iconUrl = "FileID=" + iconFileId.ToString();
                }
                else
                {
                    iconUrl = _iconDir + "This_fileName-Should_not_3xist";
                }

                ImageSelector.Url   = imageUrl;
                IconSelector.Url    = iconUrl;
                imgImage.ImageUrl   = BBStoreHelper.FileNameToImgSrc(imageUrl, PortalSettings);
                imgIcon.ImageUrl    = BBStoreHelper.FileNameToImgSrc(iconUrl, PortalSettings);
                urlTarget.Url       = ProductGroup.ProductListTabId.ToString();
                chkDisabled.Checked = ProductGroup.Disabled;
                txtViewOrder.Text   = ProductGroup.ViewOrder.ToString();
            }
            else
            {
                ImageSelector.Url   = "";
                IconSelector.Url    = "";
                imgImage.ImageUrl   = "";
                imgIcon.ImageUrl    = "";
                urlTarget.Url       = "";
                chkDisabled.Checked = false;
                txtViewOrder.Text   = "0";
            }

            // If collapsed we have to expand first to see if there are childs
            if (treeProductGroup.SelectedNode.Expanded == false)
            {
                treeProductGroup.SelectedNode.Expand();
                treeProductGroup.SelectedNode.Collapse();
            }
            int childCount = treeProductGroup.SelectedNode.ChildNodes.Count;

            // We are only allowed to delete if no childs
            cmdDelete.Visible    = (childCount == 0);
            lblPGDetails.Text    = treeProductGroup.SelectedNode.Text + (ProductGroup == null ? "" : " (ID:" + ProductGroup.ProductGroupId.ToString() + ")");
            lblPGDetails.Visible = true;
        }