protected void RegisterButton_Click(object sender, System.EventArgs e) { // make sure conditions appear for store Store store = AbleContext.Current.Store; string conditions = store.Settings.CheckoutTermsAndConditions; if (string.IsNullOrEmpty(conditions)) { conditions = ConditionText.Text; } else { if (!conditions.Contains(ConditionText.Text)) { conditions += "\r\n\r\n<p>" + ConditionText.Text + "</p>"; } } store.Settings.CheckoutTermsAndConditions = conditions; store.Save(); AustraliaPost provider = new AustraliaPost(); provider.AccountActive = true; ShipGateway gateway = new ShipGateway(); gateway.Name = provider.Name; gateway.ClassId = Misc.GetClassId(provider.GetType()); gateway.UpdateConfigData(provider.GetConfigData()); gateway.Enabled = true; gateway.Save(); Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id.ToString()); }
protected void Page_Init(object sender, EventArgs e) { int shipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); _OrderShipment = OrderShipmentDataSource.Load(shipmentId); if (_OrderShipment == null) { Response.Redirect(CancelLink.NavigateUrl); } // BIND THE ADDRESS initAddress(); // BIND ADDITIONAL DETAILS ShipFrom.DataSource = AbleContext.Current.Store.Warehouses; ShipFrom.DataBind(); if (!Page.IsPostBack) { ListItem selectedItem = ShipFrom.Items.FindByValue(_OrderShipment.WarehouseId.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } } ShipMessage.Text = _OrderShipment.ShipMessage; Caption.Text = string.Format(Caption.Text, _OrderShipment.Order.OrderNumber); EditShipmentCaption.Text = string.Format(EditShipmentCaption.Text, _OrderShipment.ShipmentNumber); CancelLink.NavigateUrl += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString(); TrackingNumbersLabel.Visible = (_OrderShipment.TrackingNumbers != null && _OrderShipment.TrackingNumbers.Count > 0); ShipGateway.DataSource = ShipGatewayDataSource.LoadAll(); ShipGateway.DataBind(); trAddTrackingNumber.Visible = (_OrderShipment.TrackingNumbers.Count == 0); }
protected void Page_Load(object sender, EventArgs e) { // LOCATE THE SHIP GATEWAY INFORMATION string classId = Misc.GetClassId(typeof(UPS)); IList <ShipGateway> gateways = ShipGatewayDataSource.LoadForClassId(classId); if (gateways.Count == 0) { Response.Redirect("License.aspx"); } _ShipGateway = gateways[0]; if (!Page.IsPostBack) { UPS provider = (UPS)_ShipGateway.GetProviderInstance(); // INITIALIZE THE FORM FIELDS ON FIRST VISIT UserId.Text = provider.UserId; AccessKey.Text = provider.AccessKey; Password.Text = provider.Password; EnableAddressValidation.Checked = provider.EnableAddressValidation; AddressServiceTestUrl.Text = provider.AddressServiceTestUrl; AddressServiceLiveUrl.Text = provider.AddressServiceLiveUrl; } }
protected void Page_Load(object sender, EventArgs e) { // LOCATE THE SHIP GATEWAY INFORMATION string classId = Misc.GetClassId(typeof(AustraliaPost)); IList <ShipGateway> gateways = ShipGatewayDataSource.LoadForClassId(classId); if (gateways.Count == 0) { Response.Redirect("Register.aspx"); } _ShipGateway = gateways[0]; // INITIALIZE THE PROVIDER SHIP METHOD CONTROL ShipMethods.ShipGatewayId = _ShipGateway.Id; // INITIALIZE THE FORM FIELDS ON FIRST VISIT if (!Page.IsPostBack) { AustraliaPost provider = (AustraliaPost)_ShipGateway.GetProviderInstance(); UseDebugMode.Checked = provider.UseDebugMode; EnablePackaging.Checked = provider.EnablePackageBreakup; MaxWeight.Text = provider.MaxPackageWeight.ToString(); MinWeight.Text = provider.MinPackageWeight.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { _ShipGateway = ShipGatewayDataSource.Load(this.ShipGatewayId); if (!Page.IsPostBack) { BindShipMethods(); } }
protected string GetLogoUrl(object dataItem) { ShipGateway gateway = (ShipGateway)dataItem; IShippingProvider provider = gateway.GetProviderInstance(); if (provider != null) { return(provider.GetLogoUrl(Page.ClientScript)); } return(string.Empty); }
protected List <string> GetShipMethodList(object dataItem) { ShipGateway gateway = (ShipGateway)dataItem; List <string> ShipMethods = new List <string>(); foreach (ShipMethod method in gateway.ShipMethods) { ShipMethods.Add(method.Name); } return(ShipMethods); }
protected string GetConfigUrl(object dataItem) { ShipGateway gateway = (ShipGateway)dataItem; IShippingProvider provider = gateway.GetProviderInstance(); if (provider != null) { return(provider.GetConfigUrl(Page.ClientScript) + "?ShipGatewayId=" + gateway.Id.ToString()); } return(string.Empty); }
protected void Page_Load(object sender, EventArgs e) { // LOCATE THE SHIP GATEWAY INFORMATION string classId = Misc.GetClassId(typeof(UPS)); IList <ShipGateway> gateways = ShipGatewayDataSource.LoadForClassId(classId); if (gateways.Count == 0) { Response.Redirect("License.aspx"); } _ShipGateway = gateways[0]; UPS provider = (UPS)_ShipGateway.GetProviderInstance(); // INITIALIZE THE PROVIDER SHIP METHOD CONTROL ShipMethods.ShipGatewayId = _ShipGateway.Id; // INITIALIZE THE FORM FIELDS ON FIRST VISIT UserId.Text = provider.UserId; AccessKey.Text = provider.AccessKey; if (!Page.IsPostBack) { if ((provider.CustomerType == UPS.UpsCustomerType.DailyPickup)) { CustomerType_DailyPickup.Checked = true; } else if ((provider.CustomerType == UPS.UpsCustomerType.Occasional)) { CustomerType_Occasional.Checked = true; } else if ((provider.CustomerType == UPS.UpsCustomerType.Retail)) { CustomerType_Retail.Checked = true; } else { CustomerType_Negotiated.Checked = true; } UseInsurance.Checked = provider.UseInsurance; UseDebugMode.Checked = provider.UseDebugMode; UseTestMode.Checked = provider.UseTestMode; LiveServerURL.Text = provider.LiveModeUrl; TestServerURL.Text = provider.TestModeUrl; TrackingURL.Text = provider.TrackingUrl; ShipperNumber.Text = provider.ShipperNumber; EnableLabels.Checked = provider.EnableShipping; MaxWeight.Text = provider.MaxPackageWeight.ToString(); MinWeight.Text = provider.MinPackageWeight.ToString(); EnablePackaging.Checked = provider.EnablePackageBreakup; //EnableAddressValidation.Checked = provider.EnableAddressValidation; //AddressServiceTestUrl.Text = provider.AddressServiceTestUrl; //AddressServiceLiveUrl.Text = provider.AddressServiceLiveUrl; } }
protected void RegisterButton_Click(object sender, System.EventArgs e) { CanadaPost provider = new CanadaPost(); provider.MerchantCPCID = MerchantId.Text; provider.AccountActive = true; ShipGateway gateway = new ShipGateway(); gateway.Name = provider.Name; gateway.ClassId = Misc.GetClassId(typeof(CanadaPost)); gateway.UpdateConfigData(provider.GetConfigData()); gateway.Enabled = true; gateway.Save(); Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id); }
protected void RegisterButton_Click(object sender, System.EventArgs e) { if (Page.IsValid) { DHLInternational provider = new DHLInternational(); provider.UserID = DHLUserID.Text; provider.Password = DHLPassword.Text; ShipGateway gateway = new ShipGateway(); gateway.Name = provider.Name; gateway.ClassId = Misc.GetClassId(typeof(DHLInternational)); gateway.UpdateConfigData(provider.GetConfigData()); gateway.Enabled = true; gateway.Save(); Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id); } }
private void BindServiceCodes() { ServiceCode.Items.Clear(); int shipGatewayId = AlwaysConvert.ToInt(Provider.SelectedValue); ShipGateway provider = GetProvider(shipGatewayId); if (provider != null) { IList <ShipMethod> Shipmethods = ShipMethodDataSource.LoadForShipGateway(shipGatewayId); ListItem[] servicesArray = provider.GetProviderInstance().GetServiceListItems(); foreach (ListItem item in servicesArray) { ServiceCode.Items.Add(item); } } }
protected void NextButton_Click(object sender, EventArgs e) { if (Page.IsValid) { USPS provider = new USPS(); provider.UserId = UserId.Text; provider.UserIdActive = true; ShipGateway gateway = new ShipGateway(); gateway.Name = provider.Name; gateway.ClassId = Misc.GetClassId(typeof(USPS)); gateway.UpdateConfigData(provider.GetConfigData()); gateway.Enabled = true; gateway.Save(); Response.Redirect("Configure.aspx?ShipGatewayId=" + gateway.Id); } }
protected void Page_Load(object sender, System.EventArgs e) { // LOCATE THE SHIP GATEWAY INFORMATION string classId = Misc.GetClassId(typeof(DHLInternational)); IList <ShipGateway> gateways = ShipGatewayDataSource.LoadForClassId(classId); if (gateways.Count == 0) { Response.Redirect("Register.aspx"); } _ShipGateway = gateways[0]; // INITIALIZE THE PROVIDER SHIP METHOD CONTROL ShipMethods.ShipGatewayId = _ShipGateway.Id; // INITIALIZE THE FORM FIELDS ON FIRST VISIT if (!Page.IsPostBack) { DHLInternational provider = (DHLInternational)_ShipGateway.GetProviderInstance(); UseDebugMode.Checked = provider.UseDebugMode; UseTestMode.Checked = provider.UseTestMode; EnablePackaging.Checked = provider.EnablePackageBreakup; UserID.Text = provider.UserID; Password.Text = provider.Password; ShippingKey.Text = provider.ShippingKey; AccountNumber.Text = provider.AccountNumber; DaysToShip.Text = provider.DaysToShip.ToString(); LiveServerURL.Text = provider.LiveModeUrl; TestServerURL.Text = provider.TestModeUrl; TrackingURL.Text = provider.TrackingUrl; MaxWeight.Text = provider.MaxPackageWeight.ToString(); MinWeight.Text = provider.MinPackageWeight.ToString(); DutiableFlag.Checked = provider.DutiableFlag; CustomsValueMultiplier.Text = provider.CustomsValueMultiplier.ToString(); CommerceLicensed.Checked = provider.CommerceLicensed; BindFilingType(provider.FilingType); FTRExemptionCode.Text = provider.FTRExemptionCode; ITNNumber.Text = provider.ITNNumber; EINCode.Text = provider.EINCode; } }
protected void Page_Load(object sender, EventArgs e) { // LOCATE THE SHIP GATEWAY INFORMATION string classId = Misc.GetClassId(typeof(USPS)); IList <ShipGateway> gateways = ShipGatewayDataSource.LoadForClassId(classId); if (gateways.Count == 0) { Response.Redirect("Register.aspx"); } _ShipGateway = gateways[0]; USPS provider = (USPS)_ShipGateway.GetProviderInstance(); // INITIALIZE THE PROVIDER SHIP METHOD CONTROL ShipMethods.ShipGatewayId = _ShipGateway.Id; // INITIALIZE THE FORM FIELDS ON FIRST VISIT if (!Page.IsPostBack) { UseDebugMode.Checked = provider.UseDebugMode; UseTestMode.Checked = provider.UseTestMode; UserId.Text = provider.UserId; LiveServerURL.Text = provider.LiveModeUrl; TestServerURL.Text = provider.TestModeUrl; TrackingURL.Text = provider.TrackingUrl; MaxWeight.Text = provider.MaxPackageWeight.ToString(); MinWeight.Text = provider.MinPackageWeight.ToString(); EnablePackaging.Checked = provider.EnablePackageBreakup; EnableAddressValidation.Checked = provider.EnableAddressValidation; AddressServiceUrl.Text = provider.AddressServiceUrl; UseOnlineRates.Checked = provider.UseOnlineRate; var item = IntlMailType.Items.FindByValue(provider.IntlMailType); if (item != null) { item.Selected = true; } } }
protected void NextButton_Click(object sender, EventArgs e) { if (Page.IsValid) { // CUSTOM ERROR VALIDATION if (Country.SelectedValue.Equals("US")) { // MAKE SURE POSTALCODE AND PROVINCECODE WERE PROVIDED if (string.IsNullOrEmpty(Province.Text)) { AddCustomErrorMessage("You must enter a valid 2 letter state abbreviation.", Province); } else { // MAKE SURE THE VALUE IS VALID Province.Text = Province.Text.ToUpperInvariant(); string[] states = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP".Split("|".ToCharArray()); if (Array.IndexOf(states, Province.Text) < 0) { AddCustomErrorMessage("You must enter a valid 2 letter state abbreviation.", Province); } } if (string.IsNullOrEmpty(PostalCode.Text)) { AddCustomErrorMessage("Your 5 digit ZIP code is required.", PostalCode); } else { // MAKE SURE ZIP IS VALID FORMAT if (!Regex.IsMatch(PostalCode.Text, "^\\d{5}$")) { AddCustomErrorMessage("You must enter a valid 5 digit ZIP code.", PostalCode); } } } else if (Country.SelectedValue.Equals("CA")) { // MAKE SURE POSTALCODE AND PROVINCECODE WERE PROVIDED if (string.IsNullOrEmpty(Province.Text)) { AddCustomErrorMessage("You must enter a valid 2 letter province abbreviation.", Province); } else { // MAKE SURE THE VALUE IS VALID Province.Text = Province.Text.ToUpperInvariant(); string[] states = "AB|BC|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT".Split("|".ToCharArray()); if ((Array.IndexOf(states, Province.Text) < 0)) { AddCustomErrorMessage("You must enter a valid 2 letter province abbreviation.", Province); } } if (string.IsNullOrEmpty(PostalCode.Text)) { AddCustomErrorMessage("Your 6 character postal code is required.", PostalCode); } else { // MAKE SURE ZIP IS VALID FORMAT PostalCode.Text = PostalCode.Text.ToUpperInvariant().Replace(" ", ""); if (!Regex.IsMatch(PostalCode.Text, "^([A-Za-z]\\d[A-Za-z]( |-)*\\d[A-Za-z]\\d)$")) { AddCustomErrorMessage("You must enter a valid postal code.", PostalCode); } } } // CHECK FOR VALID PHONE NUMBER Phone.Text = Regex.Replace(Phone.Text, "[^0-9]", ""); Regex phoneRegex = new Regex(@"^\d{10,16}$"); if (!phoneRegex.IsMatch(Phone.Text)) { PhoneValidator2.IsValid = false; } if (Page.IsValid) { // CONTINUE WITH REGISTRATION UPS.UpsRegistrationInformation registration = new UPS.UpsRegistrationInformation(); registration.ContactName = ContactName.Text; registration.ContactTitle = ContactTitle.Text; registration.Company = CompanyName.Text; registration.CompanyUrl = CompanyUrl.Text; registration.Address1 = Address1.Text; if (!String.IsNullOrEmpty(Address2.Text)) { registration.Address2 = Address2.Text; } registration.City = City.Text; registration.CountryCode = Country.SelectedValue; if ((registration.CountryCode.Equals("US") || registration.CountryCode.Equals("CA"))) { registration.StateProvinceCode = Province.Text; registration.PostalCode = PostalCode.Text; } else { registration.StateProvinceCode = string.Empty; registration.PostalCode = string.Empty; } Phone.Text = Phone.Text; registration.ContactPhone = Phone.Text; registration.ContactEmail = Email.Text; registration.ShipperNumber = UpsAccount.Text; registration.RequestContact = RequestContact.SelectedValue.Equals("YES"); try { // SEND THE REGISTRATION UPS provider = new UPS(); ShipGateway gateway = new ShipGateway(); gateway.Name = provider.Name; gateway.ClassId = Misc.GetClassId(typeof(UPS)); provider.Register(gateway, registration); if (provider.IsActive) { gateway.UpdateConfigData(provider.GetConfigData()); gateway.Enabled = true; gateway.Save(); Response.Redirect("Register.aspx?ShipGatewayId=" + gateway.Id); } } catch (Exception ex) { AddCustomErrorMessage("Error during registration: " + ex.Message, RequestContact); } } } }
protected void Page_Init(object sender, EventArgs e) { int shipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); _OrderShipment = OrderShipmentDataSource.Load(shipmentId); if (_OrderShipment == null) { Response.Redirect("../Default.aspx"); } _Order = _OrderShipment.Order; Caption.Text = string.Format(Caption.Text, _Order.OrderNumber); ShipmentNumber.Text = string.Format(ShipmentNumber.Text, _Order.Shipments.IndexOf(_OrderShipment.Id) + 1, _Order.Shipments.Count); ShippingMethod.Text = _OrderShipment.ShipMethodName; trShipMessage.Visible = !string.IsNullOrEmpty(_OrderShipment.ShipMessage); ShipMessage.Text = _OrderShipment.ShipMessage; ShipFrom.Text = _OrderShipment.FormatFromAddress(); ShipTo.Text = _OrderShipment.FormatToAddress(); ShipmentItems.DataSource = GetShipmentItems(); ShipmentItems.DataBind(); // check if ship gateway supports shipping feature CommerceBuilder.Shipping.ShipGateway shipGateway = _OrderShipment.ShipMethod != null ?_OrderShipment.ShipMethod.ShipGateway : null; IShippingProvider shipProvider = null; if (shipGateway != null) { shipProvider = shipGateway.GetProviderInstance(); _IsProviderSupportShipping = shipProvider != null && shipProvider.IsShippingSupported; } ShipGateway.DataSource = ShipGatewayDataSource.LoadAll(); ShipGateway.DataBind(); if (ShipGateway.Items.Count > 1) { //TRY TO PRESET THE CORRECT GATEWAY if (_OrderShipment.ShipMethod != null) { ListItem item = ShipGateway.Items.FindByValue(_OrderShipment.ShipMethod.ShipGatewayId.ToString()); if (item != null) { item.Selected = true; } } } else { ShipGateway.Visible = false; } if (_IsProviderSupportShipping) { autoTrackingInputPanel.Visible = true; // update the provider name ProviderInstructionText.Text = string.Format(ProviderInstructionText.Text, shipProvider.Name); ProviderInstructionText.Visible = true; } else { autoTrackingInputPanel.Visible = false; } CancelButton.NavigateUrl += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString(); }
protected void ChangeShipMethodOKButton_Click(object source, EventArgs e) { int shipmentId = AlwaysConvert.ToInt(Request.Form[ChangeShipMethodShipmentId.UniqueID]); int index = _Order.Shipments.IndexOf(shipmentId); if (index > -1) { // WE FOUND THE TARGET SHIPMENT. REMOVE OLD SHIPPING LINE ITEMS OrderShipment shipment = _Order.Shipments[index]; for (int i = shipment.OrderItems.Count - 1; i >= 0; i--) { OrderItemType itemType = shipment.OrderItems[i].OrderItemType; if (itemType == OrderItemType.Shipping || itemType == OrderItemType.Handling) { shipment.OrderItems.DeleteAt(i); } } // SEE IF WE HAVE A NEW SELECTED SHIPMETHOD int shipMethodId = AlwaysConvert.ToInt(Request.Form[NewShipMethod.UniqueID]); ShipMethod shipMethod = ShipMethodDataSource.Load(shipMethodId); if (shipMethod != null) { ShipRateQuote rate = shipMethod.GetShipRateQuote(shipment); if (rate != null) { // ADD NEW SHIPPING LINE ITEMS TO THE ORDER OrderItem shipRateLineItem = new OrderItem(); shipRateLineItem.OrderId = _Order.Id; shipRateLineItem.OrderItemType = OrderItemType.Shipping; shipRateLineItem.OrderShipmentId = shipmentId; shipRateLineItem.Name = shipMethod.Name; shipRateLineItem.Price = rate.Rate; shipRateLineItem.Quantity = 1; shipRateLineItem.TaxCodeId = shipMethod.TaxCodeId; shipRateLineItem.Save(); shipment.OrderItems.Add(shipRateLineItem); if (rate.Surcharge > 0) { shipRateLineItem = new OrderItem(); shipRateLineItem.OrderId = _Order.Id; shipRateLineItem.OrderItemType = OrderItemType.Handling; shipRateLineItem.OrderShipmentId = shipmentId; shipRateLineItem.Name = shipMethod.Name; shipRateLineItem.Price = rate.Surcharge; shipRateLineItem.Quantity = 1; shipRateLineItem.TaxCodeId = shipMethod.TaxCodeId; shipRateLineItem.Save(); shipment.OrderItems.Add(shipRateLineItem); } //Add the Tracking Number ShipGateway shipGateway = shipMethod.ShipGateway; foreach (TrackingNumber tn in shipment.TrackingNumbers) { tn.ShipGateway = shipGateway; } } } // UPDATE THE SHIPMENT WITH NEW METHOD ASSOCIATION shipment.ShipMethodId = shipMethodId; shipment.ShipMethodName = (shipMethod != null ? shipMethod.Name : string.Empty); shipment.Save(); // RELOAD ORDER AND REBIND THE PAGE FOR UPDATED INFO _Order = OrderDataSource.Load(_Order.Id); BindShipmentsGrid(); } }