Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int iRecordDeleted = 0;
                foreach (Telerik.Web.UI.GridDataItem data in grid.SelectedItems)
                {
                    int shippingMethodId = Convert.ToInt32(data.GetDataKeyValue("ShippingMethodId"));

                    ShippingMethod method = new ShippingMethod(shippingMethodId);
                    if (method != null && method.ShippingMethodId > 0 && method.SiteId == siteSettings.SiteId && !method.IsDeleted)
                    {
                        ContentDeleted.Create(siteSettings.SiteId, method.ShippingMethodId.ToString(), "ShippingMethod", typeof(ShippingMethodDeleted).AssemblyQualifiedName, method.ShippingMethodId.ToString(), Page.User.Identity.Name);

                        method.IsDeleted = true;
                        method.Save();

                        iRecordDeleted += 1;
                    }
                }

                if (iRecordDeleted > 0)
                {
                    LogActivity.Write("Delete " + iRecordDeleted.ToString() + " shipping method(s)", "Shipping method");
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");

                    grid.Rebind();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
        protected void BtnCreate_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid ) {
            ShippingMethod shippingMethod = new ShippingMethod( StoreId, TxtName.Text );
            shippingMethod.Save();

            Redirect( WebUtils.GetPageUrl( Constants.Pages.EditShippingMethod ) + "?id=" + shippingMethod.Id + "&storeId=" + shippingMethod.StoreId );
              }
        }
        protected void BtnCreate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ShippingMethod shippingMethod = new ShippingMethod(StoreId, TxtName.Text);
                shippingMethod.Save();

                Redirect(WebUtils.GetPageUrl(Constants.Pages.EditShippingMethod) + "?id=" + shippingMethod.Id + "&storeId=" + shippingMethod.StoreId);
            }
        }
        protected void SaveButton_Clicked(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                //Get the name and media nodeId
                shippingMethod.Name            = TxtName.Text;
                shippingMethod.Alias           = TxtDictionaryItemName.Text;
                shippingMethod.Sku             = TxtSku.Text;
                shippingMethod.VatGroupId      = DrpVatGroups.SelectedValue.TryParse <long>();
                shippingMethod.ImageIdentifier = CPImage.Value;

                shippingMethod.AllowedInFollowingCountries      = new List <long>();
                shippingMethod.AllowedInFollowingCountryRegions = new List <long>();

                //Add default prices
                LoopPrices(LvDefaultCurrencies);

                //Run through countries
                foreach (ListViewDataItem item in LvCountries.Items)
                {
                    long countryId = long.Parse(item.FindControl <HiddenField>("HdfId").Value);

                    //Check to see if the country has been selected
                    if (item.FindControl <CheckBox>("ChkIsSupported").Checked)
                    {
                        shippingMethod.AllowedInFollowingCountries.Add(countryId);
                    }

                    LoopPrices(item.FindControl <ListView>("LvCurrencies"), countryId);

                    //Run through country regions
                    ListView lvCountryRegions = item.FindControl <ListView>("LvCountryRegions");
                    foreach (ListViewDataItem item2 in lvCountryRegions.Items)
                    {
                        long countryRegionId = long.Parse(item2.FindControl <HiddenField>("HdfId").Value);

                        //Check to see if the country has been selected
                        if (item2.FindControl <CheckBox>("ChkIsSupported").Checked)
                        {
                            shippingMethod.AllowedInFollowingCountryRegions.Add(countryRegionId);
                        }

                        LoopPrices(item2.FindControl <ListView>("LvCurrencies"), countryId, countryRegionId);
                    }
                }

                //Save the shippingmethod
                shippingMethod.Save();

                LoadCurrenciesAndCountries();

                //Show confirming speech bubble in umbraco
                ClientTools.ShowSpeechBubble(SpeechBubbleIcon.Save, CommonTerms.ShippingMethodSaved, string.Empty);
            }
        }
Example #5
0
        public bool RestoreContent(string shippingMethodId)
        {
            try
            {
                ShippingMethod method = new ShippingMethod(Convert.ToInt32(shippingMethodId));
                if (method != null && method.ShippingMethodId > 0)
                {
                    method.IsDeleted = false;
                    method.Save();
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
Example #6
0
        void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                bool isUpdated = false;
                foreach (GridDataItem data in grid.Items)
                {
                    TextBox  txtDisplayOrder  = (TextBox)data.FindControl("txtDisplayOrder");
                    CheckBox chkIsActive      = (CheckBox)data.FindControl("chkIsActive");
                    int      shippingMethodId = Convert.ToInt32(data.GetDataKeyValue("ShippingMethodId"));
                    int      displayOrder     = Convert.ToInt32(data.GetDataKeyValue("DisplayOrder"));
                    bool     isActive         = Convert.ToBoolean(data.GetDataKeyValue("IsActive"));

                    int displayOrderNew = displayOrder;
                    int.TryParse(txtDisplayOrder.Text, out displayOrderNew);

                    if (displayOrder != displayOrderNew || isActive != chkIsActive.Checked)
                    {
                        ShippingMethod method = new ShippingMethod(shippingMethodId);
                        if (method != null && method.ShippingMethodId != -1)
                        {
                            method.IsActive     = chkIsActive.Checked;
                            method.DisplayOrder = displayOrderNew;
                            method.Save();

                            LogActivity.Write("Update shipping method", method.Name);

                            isUpdated = true;
                        }
                    }
                }

                if (isUpdated)
                {
                    grid.Rebind();

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Example #7
0
        private int SaveData()
        {
            if (!Page.IsValid)
            {
                return(-1);
            }

            try
            {
                if (method == null || method.ShippingMethodId == -1)
                {
                    method        = new ShippingMethod();
                    method.SiteId = siteSettings.SiteId;
                }

                if (!IsLanguageTab())
                {
                    method.Name        = txtName.Text.Trim();
                    method.Description = edDescription.Text.Trim();
                }

                method.ShippingProvider = Convert.ToInt32(ddlShippingProvider.SelectedValue);
                method.IsActive         = chkIsActive.Checked;

                switch ((ShippingMethodProvider)method.ShippingProvider)
                {
                case ShippingMethodProvider.Free:
                    method.ShippingFee = 0;
                    break;

                default:
                    decimal shippingFee = 0;
                    decimal.TryParse(txtShippingFee.Text, out shippingFee);
                    method.ShippingFee = shippingFee;
                    break;
                }

                switch ((ShippingMethodProvider)method.ShippingProvider)
                {
                case ShippingMethodProvider.Free:
                case ShippingMethodProvider.ByOrderTotal:
                case ShippingMethodProvider.ByGeoZoneAndOrderTotal:
                    method.FreeShippingOverXEnabled = false;
                    method.FreeShippingOverXValue   = 0;
                    break;

                case ShippingMethodProvider.Fixed:
                case ShippingMethodProvider.FixedPerItem:
                case ShippingMethodProvider.ByWeight:
                    method.FreeShippingOverXEnabled = chkFreeShippingOverXEnabled.Checked;

                    decimal freeShippingOverXValue = 0;
                    decimal.TryParse(txtFreeShippingOverXValue.Text, out freeShippingOverXValue);
                    method.FreeShippingOverXValue = freeShippingOverXValue;

                    break;

                default:
                    method.FreeShippingOverXEnabled = chkFreeShippingOverXEnabled.Checked;
                    method.FreeShippingOverXValue   = 0;
                    break;
                }

                if (method.Save())
                {
                    SaveContentLanguage(method.Guid);
                    SaveTableRateIfNeeded(method);
                }

                if (shippingMethodId > 0)
                {
                    LogActivity.Write("Update shipping method", method.Name);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
                else
                {
                    LogActivity.Write("Create new shipping method", method.Name);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "InsertSuccessMessage");
                }

                return(method.ShippingMethodId);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            return(-1);
        }