Exemplo n.º 1
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            CatalogDto catalog = null;

            if (Parameters["CatalogId"] != null)
            {
                catalog = CatalogContext.Current.GetCatalogDto(Int32.Parse(Parameters["CatalogId"].ToString()));
            }
            else
            {
                catalog = new CatalogDto();
            }

            IDictionary context = new ListDictionary();

            context.Add("Catalog", catalog);

            ViewControl.SaveChanges(context);

            int catalogId = catalog.Catalog[0].CatalogId;

            if (catalog.HasChanges())
            {
                CatalogContext.Current.SaveCatalog(catalog);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            WarehouseDto warehouse = (WarehouseDto)Session[_WarehouseDtoEditSessionKey];

            if (WarehouseId > 0 && warehouse == null)
            {
                warehouse = WarehouseManager.GetWarehouseByWarehouseId(WarehouseId);
            }
            else if (WarehouseId == 0)
            {
                warehouse = new WarehouseDto();
            }

            IDictionary context = new ListDictionary();

            context.Add(_WarehouseDtoString, warehouse);

            ViewControl.SaveChanges(context);

            if (warehouse.HasChanges())
            {
                WarehouseManager.SaveWarehouse(warehouse);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_WarehouseDtoEditSessionKey);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            PolicyDto policy = (PolicyDto)Session[_PolicyDtoEditSessionKey];

            if (PolicyId > 0 && policy == null)
            {
                policy = PolicyManager.GetPolicyDto(PolicyId);
            }
            else if (PolicyId == 0)
            {
                policy = new PolicyDto();
            }

            IDictionary context = new ListDictionary();

            context.Add(_PolicyDtoString, policy);

            ViewControl.SaveChanges(context);

            if (policy.HasChanges())
            {
                PolicyManager.SavePolicy(policy);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_PolicyDtoEditSessionKey);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, EventArgs e)
        {
            TemplateDto dto = null;

            if (TemplateId > 0)
            {
                dto = DictionaryManager.GetTemplateDto(TemplateId);
            }
            else
            {
                dto = new TemplateDto();
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            dic.Add(_TemplateDtoString, dto);

            ViewControl.SaveChanges(dic);

            // Save modifications
            if (dto.HasChanges())
            {
                DictionaryManager.SaveTemplateDto(dto);
            }

            // Call commit changes
            ViewControl.CommitChanges(dic);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            CampaignDto campaign = (CampaignDto)Session[_CampaignDtoEditSessionKey];             //null;

            if (CampaignId > 0 && campaign == null)
            {
                campaign = CampaignManager.GetCampaignDto(CampaignId);                 //Int32.Parse(Parameters[_CampaignIdString].ToString()));
            }
            else if (CampaignId == 0)
            {
                campaign = new CampaignDto();
            }

            IDictionary context = new ListDictionary();

            context.Add(_CampaignDtoString, campaign);

            ViewControl.SaveChanges(context);

            if (campaign.HasChanges())
            {
                CampaignManager.SaveCampaign(campaign);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_CampaignDtoEditSessionKey);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            ExpressionDto expression = (ExpressionDto)Session[_ExpressionDtoEditSessionKey];             //null;

            if (ExpressionId > 0 && expression == null)
            {
                expression = ExpressionManager.GetExpressionDto(ExpressionId);                 //Int32.Parse(Parameters["ExpressionId"].ToString()));
            }
            else if (ExpressionId == 0)
            {
                expression = new ExpressionDto();
            }

            IDictionary context = new ListDictionary();

            context.Add(_ExpressionDtoString, expression);

            ViewControl.SaveChanges(context);

            if (expression.HasChanges())
            {
                ExpressionManager.SaveExpression(expression);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_ExpressionDtoEditSessionKey);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            JurisdictionDto jurisdiction = (JurisdictionDto)Session[_JurisdictionDtoEditSessionKey];

            if (JurisdictionGroupId > 0 && jurisdiction == null)
            {
                jurisdiction = JurisdictionManager.GetJurisdictionGroup(JurisdictionGroupId);
            }
            else if (JurisdictionGroupId == 0)
            {
                jurisdiction = new JurisdictionDto();
            }

            IDictionary context = new ListDictionary();

            context.Add(_JurisdictionDtoString, jurisdiction);

            ViewControl.SaveChanges(context);

            if (jurisdiction.HasChanges())
            {
                JurisdictionManager.SaveJurisdiction(jurisdiction);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_JurisdictionDtoEditSessionKey);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Handles the ServerClick event of the btnSaveAndClose control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnSaveAndClose_ServerClick(object sender, EventArgs e)
        {
            ViewControl.SaveChanges(null);

            CommandParameters cp = new CommandParameters("cmdCoreLayoutAddControl");

            CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString());
        }
Exemplo n.º 9
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                CountryDto country = (CountryDto)Session[_CountryDtoEditSessionKey];

                if (CountryId > 0 && country == null)
                {
                    country = CountryManager.GetCountry(CountryId, true);
                }
                else if (CountryId == 0)
                {
                    country = new CountryDto();
                }

                country.EnforceConstraints = false;

                IDictionary context = new ListDictionary();
                context.Add(_CountryDtoString, country);

                ViewControl.SaveChanges(context);

                if (country.HasChanges())
                {
                    // if new country has just been created, update countryid for stateProvince rows
                    if (country.Country.Rows.Count > 0 && country.Country[0].RowState == DataRowState.Added)
                    {
                        int cId = country.Country[0].CountryId;
                        foreach (CountryDto.StateProvinceRow row in country.StateProvince.Rows)
                        {
                            row.CountryId = cId;
                        }
                    }

                    country.EnforceConstraints = true;

                    // commit changes to the db
                    CountryManager.SaveCountry(country);
                }
            }
            catch (Exception ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
            finally
            {
                // we don't need to store Dto in session any more
                Session.Remove(_CountryDtoEditSessionKey);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handles the ServerClick event of the btnDefault control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnDefault_ServerClick(object sender, EventArgs e)
        {
            IDictionary dic = new ListDictionary();

            dic.Add(_SaveOptionKey, _SaveDefaultKey);
            ViewControl.SaveChanges(dic);

            CommandParameters cp = new CommandParameters("cmdCoreLayoutAddControl");

            CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            ViewControl.SaveChanges(null);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            ViewControl.SaveChanges(dic);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            PromotionDto promo = (PromotionDto)Session[_PromotionDtoEditSessionKey];

            if (promo == null && PromotionId > 0)
            {
                promo = PromotionManager.GetPromotionDto(PromotionId); //Int32.Parse(Parameters["PromotionId"].ToString()));
            }
            if (PromotionId == 0)
            {
                promo = new PromotionDto();
            }

            /*
             * // if we add a new promotion, remove all other segments from Dto that is passed to control that saves changes
             * if (PromotionId == 0 && promo != null && promo.Promotion.Count > 0)
             * {
             *      PromotionDto.PromotionRow[] rows2del = (PromotionDto.PromotionRow[])promo.Promotion.Select(String.Format("{0} <> {1}", _PromotionIdString, PromotionId));
             *      if (rows2del != null)
             *              foreach (PromotionDto.PromotionRow row in rows2del)
             *                      promo.Promotion.RemovePromotionRow(row);
             * }*/

            IDictionary context = new ListDictionary();

            context.Add(_PromotionDtoString, promo);

            ViewControl.SaveChanges(context);

            if (promo.HasChanges())
            {
                PromotionManager.SavePromotion(promo);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_PromotionDtoEditSessionKey);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                ViewControl.SaveChanges(null);
            }
            catch (MembershipCreateUserException ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                ViewControl.SaveChanges(null);
            }
            catch (Exception ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            CatalogNodeDto dto = null;

            if (CatalogNodeId > 0)
            {
                dto = CatalogContext.Current.GetCatalogNodeDto(CatalogNodeId);
            }
            else
            {
                dto = new CatalogNodeDto();
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            dic.Add(_CatalogNodeDtoString, dto);

            using (TransactionScope scope = new TransactionScope())
            {
                // Call tabs save
                ViewControl.SaveChanges(dic);

                // Save modifications
                if (dto.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogNode(dto);
                }

                ViewControl.CommitChanges(dic);

                scope.Complete();
            }

            // we don't need to store Dto in session any more
            Session.Remove(_CatalogNodeDtoString);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                PermissionDto permission = (PermissionDto)Session[_PermissionDtoEditSessionKey];

                if (!String.IsNullOrEmpty(RoleId))
                {
                    permission = PermissionManager.GetPermissionDto(RoleId);
                }
                else
                {
                    permission = new PermissionDto();
                }

                IDictionary context = new ListDictionary();
                context.Add(_PermissionDtoString, permission);

                ViewControl.SaveChanges(context);

                if (permission.HasChanges())
                {
                    PermissionManager.SavePermission(permission);
                }
            }
            catch (MembershipCreateUserException ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
            finally
            {
                // we don't need to store Dto in session any more
                Session.Remove(_PermissionDtoEditSessionKey);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            PaymentMethodDto pm = null;

            if (PaymentMethodId != Guid.Empty)
            {
                pm = (PaymentMethodDto)Session[_PaymentMethodDtoEditSessionKey];
            }

            if (pm == null && PaymentMethodId != Guid.Empty)
            {
                pm = PaymentManager.GetPaymentMethod(PaymentMethodId, true);
            }

            CreateEmptyDto(ref pm, true);

            IDictionary dic = new ListDictionary();

            dic.Add(_PaymentMethodDtoString, pm);

            ViewControl.SaveChanges(dic);

            // save changes
            if (pm.HasChanges())
            {
                PaymentManager.SavePayment(pm);
            }

            ViewControl.CommitChanges(dic);

            // we don't need to store Dto in session any more
            Session.Remove(GetPaymentMethodSessionKey());
        }
Exemplo n.º 19
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                SettingsDto settings = (SettingsDto)Session[_SettingsDtoEditSessionKey];

                if (settings == null)
                {
                    settings = new SettingsDto();
                }

                IDictionary context = new ListDictionary();
                context.Add(_SettingsDtoString, settings);

                ViewControl.SaveChanges(context);

                if (settings.HasChanges())
                {
                    // commit changes to the db
                    CommonSettingsManager.SaveSettings(settings);
                }
            }
            catch (Exception ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
            finally
            {
                // we don't need to store Dto in session any more
                Session.Remove(_SettingsDtoEditSessionKey);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            TaxDto tax = null;

            if (TaxId > 0)
            {
                tax = (TaxDto)Session[_TaxDtoEditSessionKey];
            }

            if (tax == null && TaxId > 0)
            {
                tax = TaxManager.GetTax(TaxId);
            }

            CreateEmptyDto(ref tax, true);

            IDictionary dic = new ListDictionary();

            dic.Add(_TaxDtoString, tax);

            ViewControl.SaveChanges(dic);

            // save changes
            if (tax.HasChanges())
            {
                TaxManager.SaveTax(tax);
            }

            ViewControl.CommitChanges(dic);

            // we don't need to store Dto in session any more
            Session.Remove(_TaxDtoEditSessionKey);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            ShippingMethodDto sm = null;

            if (ShippingOptionId != Guid.Empty)
            {
                sm = (ShippingMethodDto)Session[GetShippingMethodSessionKey()];
            }

            if (sm == null && ShippingOptionId != Guid.Empty)
            {
                sm = ShippingManager.GetShippingOption(ShippingOptionId, true);
            }

            CreateEmptyDto(ref sm, true);

            IDictionary dic = new ListDictionary();

            dic.Add(_ShippingMethodDtoString, sm);

            ViewControl.SaveChanges(dic);

            // save changes
            if (sm.HasChanges())
            {
                ShippingManager.SaveShipping(sm);
            }

            ViewControl.CommitChanges(dic);

            // we don't need to store Dto in session any more
            Session.Remove(GetShippingMethodSessionKey());
        }
Exemplo n.º 22
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                // Always load, since we need application data
                SiteDto dto = (SiteDto)Session[_SiteEditSessionKey];

                if (dto == null && SiteId != Guid.Empty)
                {
                    if (NeedCopy)
                    {
                        dto = new SiteDto();
                    }
                    else
                    {
                        dto = CMSContext.Current.GetSiteDto(SiteId, true);
                    }
                }
                else if (dto == null && SiteId == Guid.Empty)
                {
                    dto = new SiteDto();
                }

                // Put a dictionary key that can be used by other tabs
                IDictionary dic = new ListDictionary();
                dic.Add(_SiteDtoDestinationString, dto);

                dto.EnforceConstraints = false;

                ViewControl.SaveChanges(dic);

                // get saveddto from the dictionary
                dto = (SiteDto)dic[_SiteDtoDestinationString];

                // Save modifications
                if (dto.HasChanges())
                {
                    if (dto.Site.Count > 0)
                    {
                        // update siteId for the GlobalVariable rows that have just been addded
                        SiteDto.main_GlobalVariablesRow[] variableRows = (SiteDto.main_GlobalVariablesRow[])dto.main_GlobalVariables.Select("", "", DataViewRowState.Added);
                        if (variableRows != null && variableRows.Length > 0)
                        {
                            foreach (SiteDto.main_GlobalVariablesRow row in variableRows)
                            {
                                row.SiteId = dto.Site[0].SiteId;
                            }
                        }
                    }

                    dto.EnforceConstraints = true;

                    CMSContext.Current.SaveSite(dto);

                    if (NeedCopy && SiteId != Guid.Empty)
                    {
                        CopyHelper helper = new CopyHelper();

                        //Menu copy
                        helper.CopySiteMenu(SiteId, dto.Site[0].SiteId);

                        //Folders and pages copy
                        helper.CopySiteContent(SiteId, dto.Site[0].SiteId);
                    }
                }

                // Call commit changes
                ViewControl.CommitChanges(dic);
            }
            catch (SiteImportExportException ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
            finally
            {
                // we don't need to store Dto in session any more
                Session.Remove(_SiteEditSessionKey);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, EventArgs e)
        {
            OrderGroup order      = (OrderGroup)Session[_OrderGroupDtoSessionKey];
            bool       cartLoaded = false;
            Cart       cart       = null;

            if (order == null && OrderGroupId > 0)
            {
                if (this.ViewId.StartsWith(_PaymentPlanViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetPaymentPlan(CustomerId, OrderGroupId);
                }
                else if (this.ViewId.StartsWith(_PurchaseOrderViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetPurchaseOrder(CustomerId, OrderGroupId);
                }
                else if (this.ViewId.StartsWith(_ShoppingCartViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetCart(CustomerId, OrderGroupId);
                }
            }

            // if order is still null, create an empty cart
            if (order == null)
            {
                cart       = CreateFreshCart();
                cartLoaded = true;
                Session[_OrderGroupDtoSessionKey] = cart;
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            if (cartLoaded)
            {
                dic.Add(_OrderContextObjectString, cart);
            }
            else
            {
                dic.Add(_OrderContextObjectString, order);
            }

            // Call tabs save
            OrderGroupEdit.SaveChanges(dic);
            ViewControl.SaveChanges(dic);

            Cart cartFromSession = order as Cart;

            if (cartFromSession != null)             // if we're in create mode, save cart as order (payment plan, cart)
            {
                if (this.ViewId.StartsWith(_PaymentPlanViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.SaveAsPaymentPlan();
                }
                else if (this.ViewId.StartsWith(_PurchaseOrderViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.SaveAsPurchaseOrder();
                }
                else if (this.ViewId.StartsWith(_ShoppingCartViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.AcceptChanges();
                }
            }
            else
            {
                // Persist changes to the database
                order.AcceptChanges();
            }

            Session.Remove(_OrderGroupDtoSessionKey);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Mediachase.Commerce.Manager.Core.SaveControl.SaveEventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            CatalogEntryDto       dto         = null;
            CatalogRelationDto    relation    = null;
            CatalogAssociationDto association = null;

            using (TransactionScope scope = new TransactionScope())
            {
                if (CatalogEntryId > 0)
                {
                    dto         = (CatalogEntryDto)Session[_CatalogEntryDtoString];
                    relation    = (CatalogRelationDto)Session[_CatalogRelationDtoString];
                    association = (CatalogAssociationDto)Session[_CatalogAssociationDtoString];
                }

                if (association == null && CatalogEntryId > 0)
                {
                    association = LoadAssociation();
                }

                if (relation == null && CatalogEntryId > 0)
                {
                    relation = LoadRelation();
                }

                if (dto == null && CatalogEntryId > 0)
                {
                    dto = LoadEntry();
                }

                CreateEmptyDtos(ref dto, ref relation, ref association, true);

                // Put a dictionary key that can be used by other tabs
                IDictionary dic = new ListDictionary();
                dic.Add(_CatalogEntryDtoString, dto);
                dic.Add(_CatalogRelationDtoString, relation);
                dic.Add(_CatalogAssociationDtoString, association);

                // Call tabs save
                ViewControl.SaveChanges(dic);

                // Save modifications
                if (dto.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogEntry(dto);
                }

                // get current CatalogEntryId
                int currentCatalogEntryId = this.CatalogEntryId;
                if (dto.CatalogEntry != null && dto.CatalogEntry.Rows.Count > 0)
                {
                    currentCatalogEntryId = dto.CatalogEntry[0].CatalogEntryId;
                }

                // Modify relationship
                CatalogRelationDto.NodeEntryRelationRow relRow = null;

                // Find existing row
                if (relation.NodeEntryRelation.Count > 0)
                {
                    foreach (CatalogRelationDto.NodeEntryRelationRow row in relation.NodeEntryRelation.Rows)
                    {
                        if (row.CatalogEntryId == currentCatalogEntryId && row.CatalogId == ParentCatalogId && row.CatalogNodeId == ParentCatalogNodeId)
                        {
                            relRow = row;
                            break;
                        }
                    }
                }

                // If no existing record found, create a new one
                if (ParentCatalogId > 0 && ParentCatalogNodeId > 0)
                {
                    if (relRow == null)
                    {
                        relRow = relation.NodeEntryRelation.NewNodeEntryRelationRow();
                    }

                    if (ParentCatalogId > 0)
                    {
                        relRow.CatalogId = ParentCatalogId;
                    }

                    if (this.ParentCatalogNodeId > 0)
                    {
                        relRow.CatalogNodeId = this.ParentCatalogNodeId;
                    }

                    relRow.CatalogEntryId = currentCatalogEntryId;

                    // Attach if it is a new row
                    if (relRow.RowState == DataRowState.Detached)
                    {
                        relRow.SortOrder = 0;
                        relation.NodeEntryRelation.Rows.Add(relRow);
                    }
                }

                // Update newly added entry relationships with a parent catalog entry id
                if (relation.CatalogEntryRelation.Rows.Count > 0)
                {
                    foreach (CatalogRelationDto.CatalogEntryRelationRow row in relation.CatalogEntryRelation.Rows)
                    {
                        if (row.RowState == DataRowState.Added && row.ParentEntryId <= 0)
                        {
                            row.ParentEntryId = currentCatalogEntryId;
                        }
                    }
                }

                if (relation.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogRelationDto(relation);
                }

                // Update newly added entry relationships with a parent catalog entry id
                if (association.CatalogAssociation.Rows.Count > 0)
                {
                    foreach (CatalogAssociationDto.CatalogAssociationRow row in association.CatalogAssociation.Rows)
                    {
                        if (row.RowState == DataRowState.Added && row.CatalogEntryId <= 0)
                        {
                            row.CatalogEntryId = currentCatalogEntryId;
                        }
                    }
                }

                // Save association modifications
                if (association.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogAssociation(association);
                }

                // Call commit changes
                ViewControl.CommitChanges(dic);

                // Save modifications
                if (dto.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogEntry(dto);
                }

                // Save relation modifications
                if (relation.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogRelationDto(relation);
                }

                // Save association modifications
                if (association.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogAssociation(association);
                }

                // Complete transaction
                scope.Complete();

                // we don't need to store Dto in session any more
                Session.Remove(_CatalogEntryDtoString);
                Session.Remove(_CatalogRelationDtoString);
                Session.Remove(_CatalogAssociationDtoString);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            try
            {
                CurrencyDto currency = (CurrencyDto)Session[_CurrencyDtoEditSessionKey];

                if (CurrencyId > 0 && currency == null)
                {
                    currency = CurrencyManager.GetCurrencyDto();
                }
                else if (CurrencyId == 0)
                {
                    currency = LoadFresh();
                }

                IDictionary context = new ListDictionary();
                context.Add(_CurrencyDtoContextString, currency);
                context.Add(_CurrencyIdContextString, CurrencyId);

                ViewControl.SaveChanges(context);

                if (currency.HasChanges())
                {
                    CurrencyDto.CurrencyRow currentCurrencyRow = null;

                    // search for the row that has just been added
                    CurrencyDto.CurrencyRow[] tempCurrencyRows = (CurrencyDto.CurrencyRow[])currency.Currency.Select("", "", DataViewRowState.Added);
                    if (tempCurrencyRows != null && tempCurrencyRows.Length > 0)
                    {
                        currentCurrencyRow = tempCurrencyRows[0];
                    }

                    if (currentCurrencyRow != null)
                    {
                        int cId = currentCurrencyRow.CurrencyId;

                        // if new currency has just been created, update currencyid for CurrencyRate rows
                        CurrencyDto.CurrencyRateRow[] rateRows = (CurrencyDto.CurrencyRateRow[])currency.CurrencyRate.Select("", "", DataViewRowState.Added | DataViewRowState.ModifiedCurrent);
                        if (rateRows != null && rateRows.Length > 0)
                        {
                            foreach (CurrencyDto.CurrencyRateRow row in rateRows)
                            {
                                row.FromCurrencyId = cId;
                            }
                        }
                    }

                    currency.EnforceConstraints = true;

                    // commit changes to the db
                    CurrencyManager.SaveCurrency(currency);
                }
            }
            catch (Exception ex)
            {
                e.RunScript = false;
                DisplayErrorMessage(ex.Message);
            }
            finally
            {
                // we don't need to store Dto in session any more
                Session.Remove(_CurrencyDtoEditSessionKey);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e)
        {
            // Validate form
            if (!this.Page.IsValid)
            {
                e.RunScript = false;
                return;
            }

            SegmentDto    segment    = (SegmentDto)Session[_SegmentDtoEditSessionKey];
            ExpressionDto expression = (ExpressionDto)Session[_ExpressionDtoEditSessionKey];

            if (segment == null && SegmentId > 0)
            {
                segment = SegmentManager.GetSegmentDto(SegmentId);
            }
            else if (segment == null && SegmentId == 0)
            {
                segment = new SegmentDto();
            }


            if (expression == null && SegmentId > 0)
            {
                expression = ExpressionManager.GetExpressionBySegmentDto(SegmentId);
            }
            else if (expression == null && SegmentId == 0)
            {
                expression = new ExpressionDto();
            }

            /*
             * // if we add a new segment, remove all other segments from Dto that is passed to control that saves changes
             * if (SegmentId == 0 && segment != null && segment.Segment.Count > 0)
             * {
             *      SegmentDto.SegmentRow[] rows2del = (SegmentDto.SegmentRow[])segment.Segment.Select(String.Format("{0} <> {1}", _SegmentIdString, SegmentId));
             *      if (rows2del != null)
             *              foreach (SegmentDto.SegmentRow row in rows2del)
             *                      segment.Segment.RemoveSegmentRow(row);
             * }*/

            IDictionary context = new ListDictionary();

            context.Add(_SegmentDtoString, segment);
            context.Add(_ExpressionDtoString, expression);

            ViewControl.SaveChanges(context);

            // save expressionDto
            if (expression.HasChanges())
            {
                ExpressionManager.SaveExpression(expression);
            }

            // update segment conditions
            foreach (ExpressionDto.ExpressionRow tmpRow in expression.Expression.Rows)
            {
                // skip deleted rows
                if (tmpRow.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                // add SegmentConditionRow
                SegmentDto.SegmentConditionRow[] segmentConditionRows = (SegmentDto.SegmentConditionRow[])segment.SegmentCondition.Select(String.Format("ExpressionId={0}", tmpRow.ExpressionId));
                if (segmentConditionRows == null || segmentConditionRows.Length == 0)
                {
                    // add new expression
                    SegmentDto.SegmentConditionRow newSCRow = segment.SegmentCondition.NewSegmentConditionRow();
                    newSCRow.ExpressionId = tmpRow.ExpressionId;
                    newSCRow.SegmentId    = segment.Segment[0].SegmentId;

                    if (newSCRow.RowState == DataRowState.Detached)
                    {
                        segment.SegmentCondition.Rows.Add(newSCRow);
                    }
                }
            }

            // save segmentDto
            if (segment.HasChanges())
            {
                SegmentManager.SaveSegment(segment);
            }

            // we don't need to store Dto in session any more
            Session.Remove(_SegmentDtoEditSessionKey);
            Session.Remove(_ExpressionDtoEditSessionKey);
        }