private void SaveData() { ShippingMethod.Name = this.NameField.Text.Trim(); ShippingMethod.ZoneId = long.Parse(this.lstZones.SelectedItem.Value); ShippingMethod.AdjustmentType = (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue); ShippingMethod.Adjustment = decimal.Parse(AdjustmentTextBox.Text, System.Globalization.NumberStyles.Currency); // Global Settings MyPage.MTApp.CurrentStore.Settings.ShippingUSPostalDiagnostics = this.Diagnostics.Checked; // Method Settings USPostalServiceSettings Settings = new USPostalServiceSettings(); Settings.Merge(ShippingMethod.Settings); // Service Code List<MerchantTribe.Shipping.IServiceCode> filter = new List<MerchantTribe.Shipping.IServiceCode>(); foreach (ListItem item in ShippingTypesCheckBoxList.Items) { if (item.Selected) { MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode() { Code = item.Value, DisplayName = item.Text }; filter.Add(code); } } Settings.ServiceCodeFilter = filter; ShippingMethod.Settings.Merge(Settings); MyPage.MTApp.UpdateCurrentStore(); }
private void LoadData() { this.NameField.Text = ShippingMethod.Name; if (this.NameField.Text == string.Empty) { this.NameField.Text = "US Postal Service International"; } // 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 (this.lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()) != null) { this.lstZones.ClearSelection(); this.lstZones.Items.FindByValue(ShippingMethod.ZoneId.ToString()).Selected = true; } // Global this.Diagnostics.Checked = MyPage.MTApp.CurrentStore.Settings.ShippingUSPostalDiagnostics; USPostalServiceSettings settings = new USPostalServiceSettings(); settings.Merge(ShippingMethod.Settings); foreach (MerchantTribe.Shipping.ServiceCode code in settings.ServiceCodeFilter) { foreach (ListItem item in ShippingTypesCheckBoxList.Items) { if (string.Compare(item.Value, code.Code, true) == 0) { item.Selected = true; break; } } } }
private void SaveData() { ShippingMethod.Name = this.NameField.Text.Trim(); ShippingMethod.ZoneId = long.Parse(this.lstZones.SelectedItem.Value); ShippingMethod.AdjustmentType = (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue); ShippingMethod.Adjustment = decimal.Parse(AdjustmentTextBox.Text, System.Globalization.NumberStyles.Currency); // Global Settings MyPage.MTApp.CurrentStore.Settings.ShippingUSPostalDiagnostics = this.Diagnostics.Checked; MyPage.MTApp.AccountServices.Stores.Update(MyPage.MTApp.CurrentStore); // Method Settings USPostalServiceSettings Settings = new USPostalServiceSettings(); Settings.Merge(ShippingMethod.Settings); // Service Code List<MerchantTribe.Shipping.IServiceCode> filter = new List<MerchantTribe.Shipping.IServiceCode>(); foreach (ListItem item in ShippingTypesCheckBoxList.Items) { if (item.Selected) { MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode() { Code = item.Value, DisplayName = item.Text }; filter.Add(code); } } Settings.ServiceCodeFilter = filter; Settings["highlight"] = this.lstHighlights.SelectedValue; // Package string packageCode = this.lstPackageType.SelectedItem.Value; int packageCodeInt = -1; if (int.TryParse(packageCode, out packageCodeInt)) { Settings.PackageType = (MerchantTribe.Shipping.USPostal.v4.DomesticPackageType)packageCodeInt; } ShippingMethod.Settings.Merge(Settings); }