Example #1
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            lngProductGroups.UpdateLangs();
            switch (EditState)
            {
            case "new":
                ProductGroupInfo pgNew = new ProductGroupInfo();
                pgNew.ParentId         = ProductGroupId;
                pgNew.PortalId         = PortalId;
                pgNew.Image            = BBStoreHelper.GetRelativeFilePath(ImageSelector.Url);
                pgNew.Icon             = BBStoreHelper.GetRelativeFilePath(IconSelector.Url);
                pgNew.ProductListTabId = Convert.ToInt32(urlTarget.Url);
                pgNew.Disabled         = chkDisabled.Checked;
                pgNew.ViewOrder        = Convert.ToInt32(txtViewOrder.Text);
                int productGroupId = Controller.NewProductGroup(pgNew);
                foreach (ProductGroupLangInfo pgl in lngProductGroups.Langs)
                {
                    pgl.ProductGroupId = productGroupId;
                    Controller.NewProductGroupLang(pgl);
                }
                ProductGroupId = productGroupId;
                EditState      = "update";
                break;

            case "update":
                ProductGroupInfo pgUpdate = Controller.GetProductGroup(PortalId, ProductGroupId);
                pgUpdate.Image            = BBStoreHelper.GetRelativeFilePath(ImageSelector.Url);
                pgUpdate.Icon             = BBStoreHelper.GetRelativeFilePath(IconSelector.Url);
                pgUpdate.ProductListTabId = Convert.ToInt32(urlTarget.Url);
                pgUpdate.Disabled         = chkDisabled.Checked;
                pgUpdate.ViewOrder        = Convert.ToInt32(txtViewOrder.Text);
                Controller.UpdateProductGroup(pgUpdate);
                Controller.DeleteProductGroupLangs(ProductGroupId);
                foreach (ProductGroupLangInfo pgl in lngProductGroups.Langs)
                {
                    pgl.ProductGroupId = ProductGroupId;
                    Controller.NewProductGroupLang(pgl);
                }
                break;

            default:
                break;
            }
            if (Request.QueryString["adminmode"] != null)
            {
                Response.Redirect(Globals.NavigateURL(TabId, "", "adminmode=productgroup"), true);
            }
            else
            {
                Response.Redirect(EditUrl(), true);
            }
        }