Beispiel #1
0
        private void SaveData()
        {
            ShippingMethod.Name           = NameField.Text.Trim();
            ShippingMethod.ZoneId         = long.Parse(lstZones.SelectedItem.Value);
            ShippingMethod.AdjustmentType =
                (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue);
            ShippingMethod.Adjustment = decimal.Parse(AdjustmentTextBox.Text, NumberStyles.Currency);

            if (ShippingMethod.AdjustmentType == ShippingMethodAdjustmentType.Amount)
            {
                ShippingMethod.Adjustment = Money.RoundCurrency(ShippingMethod.Adjustment);
            }


            // Global Settings
            HccApp.CurrentStore.Settings.ShippingUpsAccountNumber           = AccountNumberField.Text.Trim();
            HccApp.CurrentStore.Settings.ShippingUpsFreightForceResidential = ResidentialAddressCheckBox.Checked;

            HccApp.CurrentStore.Settings.ShippingUpsDefaultService          = int.Parse(DefaultServiceField.SelectedValue);
            HccApp.CurrentStore.Settings.ShippingUpsFreightDefaultPackaging = int.Parse(DefaultPackagingField.SelectedValue);
            HccApp.CurrentStore.Settings.ShippingUpsFreightSkipDimensions   = SkipDimensionsCheckBox.Checked;
            HccApp.CurrentStore.Settings.ShippingUPSFreightDiagnostics      = chkDiagnostics.Checked;


            HccApp.CurrentStore.Settings.ShippingUpsFreightBillingOption     = Convert.ToInt32(PayerShipmentBillingOptionDropDownList.SelectedValue);
            HccApp.CurrentStore.Settings.ShippingUpsFreightHandleOneUnitType = PayerShipmentBillingOptionDropDownList.SelectedValue;
            HccApp.CurrentStore.Settings.ShippingUpsFreightFreightClass      = DefaultFreightClassField.SelectedValue;

            // Method Settings
            var Settings = new UPSFreightServiceSettings();

            Settings.Merge(ShippingMethod.Settings);

            var filter = new List <IServiceCode>();

            Settings.GetAllRates = false;
            foreach (ListItem item in ShippingTypesRadioButtonList.Items)
            {
                if (item.Selected)
                {
                    var code = new ServiceCode {
                        Code = item.Value, DisplayName = item.Text
                    };
                    filter.Add(code);
                }
            }

            Settings.ServiceCodeFilter = filter;
            Settings["highlight"]      = lstHighlights.SelectedValue;
            ShippingMethod.Settings.Merge(Settings);

            HccApp.AccountServices.Stores.Update(HccApp.CurrentStore);
        }
Beispiel #2
0
        private void LoadData()
        {
            // Name
            NameField.Text = ShippingMethod.Name;

            if (string.IsNullOrEmpty(NameField.Text))
            {
                NameField.Text = Localization.GetString("UPSFreightShipping");
            }

            // Adjustment
            AdjustmentDropDownList.SelectedValue = ((int)ShippingMethod.AdjustmentType).ToString();

            if (ShippingMethod.AdjustmentType == ShippingMethodAdjustmentType.Amount)
            {
                AdjustmentTextBox.Text = string.Format("{0:c}", ShippingMethod.Adjustment);
            }
            else
            {
                AdjustmentTextBox.Text = string.Format("{0:f}", ShippingMethod.Adjustment);
            }

            // Zones
            if (lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()) != null)
            {
                lstZones.ClearSelection();
                lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()).Selected = true;
            }

            // Global Settings
            AccountNumberField.Text            = HccApp.CurrentStore.Settings.ShippingUpsAccountNumber;
            ResidentialAddressCheckBox.Checked = HccApp.CurrentStore.Settings.ShippingUpsFreightForceResidential;
            PayerShipmentBillingOptionDropDownList.SelectedValue = HccApp.CurrentStore.Settings.ShippingUpsFreightBillingOption.ToString();
            HandlineOneUnitTypeDropDownList.SelectedValue        = HccApp.CurrentStore.Settings.ShippingUpsFreightHandleOneUnitType;



            DefaultPackagingField.SelectedValue    = HccApp.CurrentStore.Settings.ShippingUpsFreightDefaultPackaging.ToString();
            DefaultServiceField.SelectedValue      = HccApp.CurrentStore.Settings.ShippingUpsDefaultService.ToString();
            DefaultFreightClassField.SelectedValue = HccApp.CurrentStore.Settings.ShippingUpsFreightFreightClass.ToString();

            if (HccApp.CurrentStore.Settings.ShippingUpsLicense.Trim().Length > 0)
            {
                lnkRegister.Text = Localization.GetString("AlreadyRegistered");
            }
            else
            {
                lnkRegister.Text = Localization.GetString("RegisterWithUPS");
            }

            SkipDimensionsCheckBox.Checked = HccApp.CurrentStore.Settings.ShippingUpsFreightSkipDimensions;
            chkDiagnostics.Checked         = HccApp.CurrentStore.Settings.ShippingUPSFreightDiagnostics;

            // Method Settings
            var Settings = new UPSFreightServiceSettings();

            Settings.Merge(ShippingMethod.Settings);

            if (Settings.ServiceCodeFilter == null)
            {
                Settings.ServiceCodeFilter = new List <IServiceCode>();
            }



            foreach (ServiceCode code in Settings.ServiceCodeFilter)
            {
                foreach (ListItem item in ShippingTypesRadioButtonList.Items)
                {
                    if (string.Compare(item.Value, code.Code, true) == 0)
                    {
                        item.Selected = true;
                        break;
                    }
                }
            }


            // Select Hightlights
            var highlight = Settings.GetSettingOrEmpty("highlight");

            if (lstHighlights.Items.FindByText(highlight) != null)
            {
                lstHighlights.ClearSelection();
                lstHighlights.Items.FindByText(highlight).Selected = true;
            }
        }