Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                StoreController storeController = new StoreController();
                bool            newStore        = false;

                if (StoreSettings == null)
                {
                    StoreSettings = new StoreInfo();
                    newStore      = true;
                }

                StoreSettings.PortalID   = PortalId;
                StoreSettings.Name       = txtStoreName.Text;
                StoreSettings.SEOFeature = chkSEOFeature.Checked;
                if (StoreSettings.SEOFeature)
                {
                    StoreSettings.Description = txtDescription.Text;
                    StoreSettings.Keywords    = txtKeywords.Text;
                }
                StoreSettings.DefaultEmailAddress = txtEmail.Text;
                StoreSettings.CurrencySymbol      = txtCurrencySymbol.Text;
                StoreSettings.PortalTemplates     = chkUsePortalTemplates.Checked;
                StoreSettings.StyleSheet          = lstStyleSheet.SelectedValue;
                StoreSettings.StorePageID         = int.Parse(lstStorePageID.SelectedValue);
                StoreSettings.ShoppingCartPageID  = int.Parse(lstShoppingCartPageID.SelectedValue);
                StoreSettings.AuthorizeCancel     = chkAuthorizeCancel.Checked;
                StoreSettings.InventoryManagement = chkInventoryManagement.Checked;
                if (StoreSettings.InventoryManagement)
                {
                    StoreSettings.OutOfStock         = lstOutOfStock.SelectedIndex;
                    StoreSettings.ProductsBehavior   = lstProductsBehavior.SelectedIndex;
                    StoreSettings.AvoidNegativeStock = chkAvoidNegativeStock.Checked;
                }
                StoreSettings.OrderRoleID   = int.Parse(lstOrderRole.SelectedValue);
                StoreSettings.CatalogRoleID = int.Parse(lstCatalogRole.SelectedValue);
                StoreSettings.SecureCookie  = chkSecureCookie.Checked;
                StoreSettings.CheckoutMode  = (CheckoutType)int.Parse(lstCheckoutMode.SelectedValue);
                if (StoreSettings.CheckoutMode != CheckoutType.Registred)
                {
                    StoreSettings.ImpersonatedUserID = int.Parse(hidImpersonatedUserID.Value);
                }
                else
                {
                    StoreSettings.ImpersonatedUserID   = Null.NullInteger;
                    StoreSettings.AllowVirtualProducts = chkAllowVirtualProducts.Checked;
                }
                StoreSettings.NoDelivery          = chkNoDelivery.Checked;
                StoreSettings.AllowCoupons        = chkAllowCoupons.Checked;
                StoreSettings.AllowFreeShipping   = chkAllowFreeShipping.Checked;
                StoreSettings.MinOrderAmount      = chkAllowFreeShipping.Checked ? Decimal.Parse(txtMinOrderAmount.Text) : 0;
                StoreSettings.RestrictToCountries = chkRestrictToCountries.Checked;
                StoreSettings.AuthorizedCountries = GetSelectedCountries();
                StoreSettings.OnOrderPaidRoleID   = Int32.Parse(lstOnPaidOrderRole.SelectedValue);
                StoreSettings.GatewayName         = lstGateway.SelectedItem.Text;
                if ((_gatewayControl != null) && (_gatewayControl.DataSource != null))
                {
                    StoreSettings.GatewaySettings = _gatewayControl.DataSource.ToString();
                }
                StoreSettings.AddressName = lstAddressProviders.SelectedValue;
                StoreSettings.TaxName     = lstTaxProviders.SelectedValue;
                if (StoreSettings.NoDelivery)
                {
                    StoreSettings.ShippingName = "Default";
                }
                else
                {
                    StoreSettings.ShippingName = lstShippingProviders.SelectedValue;
                }

                if (newStore)
                {
                    StoreSettings.CreatedByUser = UserInfo.Username;
                    storeController.AddStoreInfo(StoreSettings);
                    plhAddressProvider.Visible = true;
                    plhTaxProvider.Visible     = true;
                    if (!chkNoDelivery.Checked)
                    {
                        trShippingProviderSelection.Visible = true;
                        plhShippingProvider.Visible         = true;
                    }
                    else
                    {
                        trShippingProviderSelection.Visible = false;
                        plhShippingProvider.Visible         = false;
                    }
                }
                else
                {
                    storeController.UpdateStoreInfo(StoreSettings);
                }

                if (StoreSettings.PortalTemplates)
                {
                    CopyTemplates();
                }
                InvokeEditComplete();
            }
        }