Imports BVSoftware.BVC.Core Imports System.IO Imports System.Text Public Class orders_ship_UPS Inherits BaseAdminPage #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents FromCompanyField As System.Web.UI.WebControls.TextBox Protected WithEvents FromNameField As System.Web.UI.WebControls.TextBox Protected WithEvents FromPhoneField As System.Web.UI.WebControls.TextBox Protected WithEvents FromAddress1Field As System.Web.UI.WebControls.TextBox Protected WithEvents FromAddress2Field As System.Web.UI.WebControls.TextBox Protected WithEvents FromCityField As System.Web.UI.WebControls.TextBox Protected WithEvents FromPostalCodeField As System.Web.UI.WebControls.TextBox Protected WithEvents FromCountryField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents ToCompanyField As System.Web.UI.WebControls.TextBox Protected WithEvents ToNameField As System.Web.UI.WebControls.TextBox Protected WithEvents ToPhoneField As System.Web.UI.WebControls.TextBox Protected WithEvents ToAddress1Field As System.Web.UI.WebControls.TextBox Protected WithEvents ToAddress2Field As System.Web.UI.WebControls.TextBox Protected WithEvents ToCityField As System.Web.UI.WebControls.TextBox Protected WithEvents ToPostalCodeField As System.Web.UI.WebControls.TextBox Protected WithEvents ToCountryField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents chkResidential As System.Web.UI.WebControls.CheckBox Protected WithEvents chkNotification As System.Web.UI.WebControls.CheckBox Protected WithEvents NotificationEmailField As System.Web.UI.WebControls.TextBox Protected WithEvents PackageTypeField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents btnCanel As System.Web.UI.WebControls.ImageButton Protected WithEvents btnShip As System.Web.UI.WebControls.ImageButton Protected WithEvents WeightField As System.Web.UI.WebControls.TextBox Protected WithEvents DeclaredValueField As System.Web.UI.WebControls.TextBox Protected WithEvents Reference1Field As System.Web.UI.WebControls.TextBox Protected WithEvents DeliveryConfirmationField As System.Web.UI.WebControls.DropDownList Protected WithEvents LengthField As System.Web.UI.WebControls.TextBox Protected WithEvents WidthField As System.Web.UI.WebControls.TextBox Protected WithEvents HeightField As System.Web.UI.WebControls.TextBox Protected WithEvents WeightUnitsField As System.Web.UI.WebControls.DropDownList Protected WithEvents DimensionalUnitsField As System.Web.UI.WebControls.DropDownList Protected WithEvents BillToCountryField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents chkAddressVerification As System.Web.UI.WebControls.CheckBox Protected WithEvents BillToField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents BillToAccountNumberField As System.Web.UI.WebControls.TextBox Protected WithEvents ToStateField As System.Web.UI.WebControls.TextBox Protected WithEvents FromStateField As System.Web.UI.WebControls.TextBox Protected WithEvents ServiceField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents pnlRates As System.Web.UI.WebControls.Panel Protected WithEvents Imagebutton1 As System.Web.UI.WebControls.ImageButton Protected WithEvents Imagebutton2 As System.Web.UI.WebControls.ImageButton Protected WithEvents pnlGetRates As System.Web.UI.WebControls.Panel Protected WithEvents lblRate As System.Web.UI.WebControls.Label Protected WithEvents lblShipCharges As System.Web.UI.WebControls.Label Protected WithEvents lblServiceOptions As System.Web.UI.WebControls.Label Protected WithEvents lnkLabel As System.Web.UI.WebControls.HyperLink Protected WithEvents pnlPrint As System.Web.UI.WebControls.Panel Protected WithEvents CCNumberField As System.Web.UI.WebControls.TextBox Protected WithEvents CCExpMonthField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents CCExpYearField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents CCTypeField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents trWarning As System.Web.UI.HtmlControls.HtmlTableRow Protected WithEvents chkAdditionalHandling As System.Web.UI.WebControls.CheckBox Protected WithEvents CODAmountField As System.Web.UI.WebControls.TextBox Protected WithEvents DeclaredValueCurrencyField As System.Web.UI.WebControls.DropDownList Protected WithEvents CODCurrencyField As System.Web.UI.WebControls.DropDownList Protected WithEvents chkSaturdayDelivery As System.Web.UI.WebControls.CheckBox Protected WithEvents chkVerbalConfirmation As System.Web.UI.WebControls.CheckBox Protected WithEvents VerbalNameField As System.Web.UI.WebControls.TextBox Protected WithEvents VerbalPhoneField As System.Web.UI.WebControls.TextBox Protected WithEvents DescriptionField As System.Web.UI.WebControls.TextBox Protected WithEvents NotificationFromField As System.Web.UI.WebControls.TextBox Protected WithEvents NotificationMessage As System.Web.UI.WebControls.TextBox Protected WithEvents NotificationTypeField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents NotificationSubjectField As BVSoftware.WebControls.SelectDropDownList Protected WithEvents Reference2Field As System.Web.UI.WebControls.TextBox Protected WithEvents btnContinue As System.Web.UI.WebControls.ImageButton Protected WithEvents Imagebutton8 As System.Web.UI.WebControls.ImageButton Protected WithEvents Imagebutton4 As System.Web.UI.WebControls.ImageButton Protected WithEvents BillToPostalCodeField As System.Web.UI.WebControls.TextBox 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() 'SP2- Assures that SSL is used for CC pages even if Admin SSL is disabled Me.RequiresSSLForCC = True '-SP2 End Sub #End Region Private Property PackageID() As Integer Get If Not ViewState("PackageID") Is Nothing Then Return ViewState("PackageID") Else Return 0 End If End Get Set(ByVal Value As Integer) ViewState("PackageID") = Value End Set End Property Private Property OrderID() As Integer Get If Not ViewState("OrderID") Is Nothing Then Return ViewState("OrderID") Else Return 0 End If End Get Set(ByVal Value As Integer) ViewState("OrderID") = Value End Set End Property Private Property InternalOrderID() As Integer Get If Not ViewState("InternalOrderID") Is Nothing Then Return ViewState("InternalOrderID") Else Return 0 End If End Get Set(ByVal Value As Integer) ViewState("InternalOrderID") = Value End Set End Property Private Property ReturnURL() As String Get If Not ViewState("ReturnURL") Is Nothing Then Return ViewState("ReturnURL") Else Return "" End If End Get Set(ByVal Value As String) ViewState("ReturnURL") = Value End Set End Property Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BVC2004Store.CheckThisPage(Security.RolePermission.LoginToAdmin) BVC2004Store.CheckThisPage(Security.RolePermission.AccessOrderArea) If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription LoadCountries() SetDefaults() PopulateFromAddress() If Request.Params("PackageID") <> Nothing Then Me.PackageID = Request.Params("PackageID") End If If Request.Params("OrderID") <> Nothing Then Me.OrderID = Request.Params("OrderID") End If If Request.Params("ReturnURL") <> Nothing Then Me.ReturnURL = Request.Params("ReturnURL") End If If Request.Params("oID") <> Nothing Then Me.InternalOrderID = Request.Params("oID") End If If Me.PackageID > 0 Then LoadPackageSettings() End If End If End Sub Private Sub LoadCountries() Dim dt As DataTable = ContentServices.Countries.GetAllCountries(False) If Not dt Is Nothing Then If dt.Rows.Count > 0 Then Me.FromCountryField.Items.Clear() Me.ToCountryField.Items.Clear() Me.FromCountryField.DataSource = dt Me.FromCountryField.DataTextField = "DisplayName" Me.FromCountryField.DataValueField = "UPSCode" Me.FromCountryField.DataBind() Me.FromCountryField.SelectByValue("US") Me.ToCountryField.DataSource = dt Me.ToCountryField.DataTextField = "DisplayName" Me.ToCountryField.DataValueField = "UPSCode" Me.ToCountryField.DataBind() Me.ToCountryField.SelectByValue("US") End If End If End Sub Private Sub SetDefaults() Me.ServiceField.SelectByValue(WebAppSettings.ShippingUpsDefaultService) Me.PackageTypeField.SelectByValue(WebAppSettings.ShippingUpsDefaultPackaging) Me.BillToAccountNumberField.Text = WebAppSettings.ShippingUpsDefaultAccountNumber Me.BillToField.SelectByValue(WebAppSettings.ShippingUpsDefaultPaymentMethod) Me.CCExpYearField.Items.Clear() For i As Integer = DateTime.Now.Year To DateTime.Now.Year + 10 Me.CCExpYearField.Items.Add(New ListItem(i, i)) Next Shipping.UPS.OnlineTools.PopulateListWithCurrencies(Me.CODCurrencyField.Items) Shipping.UPS.OnlineTools.PopulateListWithCurrencies(Me.DeclaredValueCurrencyField.Items) If Request.IsSecureConnection = False Then Me.trWarning.Visible = True Else Me.trWarning.Visible = False End If End Sub Private Sub PopulateFromAddress() Dim siteAddress As Contacts.Address = WebAppSettings.ContactAddress If Not siteAddress Is Nothing Then Me.FromCompanyField.Text = siteAddress.CompanyName Me.FromNameField.Text = siteAddress.FirstName & " " & siteAddress.LastName Me.FromPhoneField.Text = siteAddress.PhoneNumber Me.FromAddress1Field.Text = siteAddress.StreetLine1 Me.FromAddress2Field.Text = siteAddress.StreetLine2 Me.FromCityField.Text = siteAddress.City Dim r As New Content.Region(siteAddress.StateCode) If Not r Is Nothing Then Me.FromStateField.Text = r.Abbreviation End If Me.FromPostalCodeField.Text = siteAddress.PostalCode End If End Sub Private Sub LoadPackageSettings() Dim p As Shipping.Package = ShippingServices.Packages.GetPackageByID(Me.PackageID) If Not p Is Nothing Then ' To Address Me.ToAddress1Field.Text = p.DestinationAddress.StreetLine1 Me.ToAddress2Field.Text = p.DestinationAddress.StreetLine2 Me.ToCityField.Text = p.DestinationAddress.City Me.ToCompanyField.Text = p.DestinationAddress.CompanyName Me.ToCountryField.SelectByValue(p.DestinationAddress.CountryCode) Me.ToNameField.Text = p.DestinationAddress.FirstName If p.DestinationAddress.MiddleInitial.Length > 0 Then Me.ToNameField.Text += " " & p.DestinationAddress.MiddleInitial End If Me.ToNameField.Text += " " & p.DestinationAddress.LastName Me.ToPhoneField.Text = p.DestinationAddress.PhoneNumber Me.ToPostalCodeField.Text = p.DestinationAddress.PostalCode If p.DestinationAddress.StateCode.Length > 0 Then Dim r As New Content.Region(p.DestinationAddress.StateCode) If Not r Is Nothing Then Me.ToStateField.Text = r.Abbreviation Else Me.ToStateField.Text = p.DestinationAddress.StateName End If Else Me.ToStateField.Text = p.DestinationAddress.StateName End If Me.ServiceField.SelectByValue(Shipping.UPS.OnlineTools.TranslateBVShipMethodToUPSCode(p.ShippingType)) If p.Weight > 0 Then Me.WeightField.Text = p.Weight End If '2004.6 'If p.Height > 0 Then ' Me.HeightField.Text = p.Height 'End If 'If p.Width > 0 Then ' Me.WidthField.Text = p.Width 'End If 'If p.Length > 0 Then ' Me.LengthField.Text = p.Length 'End If If p.DeclaredValue > 0 Then Me.DeclaredValueField.Text = p.DeclaredValue End If Me.Reference1Field.Text = "Order " & Me.OrderID & "-P" & Me.PackageID Me.Reference2Field.Text = p.DestinationAddress.PhoneNumber Dim o As Orders.Order = OrderServices.GetExistingOrder(Me.InternalOrderID) If Not o Is Nothing Then Me.NotificationEmailField.Text = o.UserName End If End If End Sub Private Sub btnCanel_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCanel.Click OnContinue() End Sub Private Sub btnShip_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnShip.Click Me.pnlPrint.Visible = False Me.pnlRates.Visible = False msg.Clear() Dim req As New BVSoftware.UPS.OnlineTools.ShipRequest req.AddressVerification = Me.chkAddressVerification.Checked req.BillTo = Me.BillToField.SelectedValue If req.BillTo = BVSoftware.UPS.OnlineTools.PaymentType.ShipperCreditCard Then req.BillToCreditCardExpirationMonth = Me.CCExpMonthField.SelectedValue req.BillToCreditCardExpirationYear = Me.CCExpYearField.SelectedValue Dim ccval As New BVSoftware.Utilities.CreditCardValidator req.BillToCreditCardNumber = ccval.CleanCardNumber(Me.CCNumberField.Text) req.BillToCreditCardType = Me.CCTypeField.SelectedValue Else req.BillToAccountNumber = Me.BillToAccountNumberField.Text If Me.BillToPostalCodeField.Text.Trim.Length > 0 Then req.BillToPostalCode = Me.BillToPostalCodeField.Text.Trim End If End If req.BillToCountryCode = Me.BillToCountryField.SelectedValue req.BrowserHttpUserAgentString = Request.UserAgent req.COD = False If Me.DescriptionField.Text.Trim <> String.Empty Then req.ShipmentDescription = Me.DescriptionField.Text.Trim End If req.InvoiceLineTotal = False req.LabelFormat = BVSoftware.UPS.OnlineTools.ShipLabelFormat.Gif 'req.LabelStockSizeHeight = 4 'req.LabelStockSizeWidth = 6 req.NonValuedDocumentsOnly = False req.Notification = Me.chkNotification.Checked req.NotificationEmailAddress = Me.NotificationEmailField.Text req.NotificationFromName = Me.NotificationFromField.Text req.NotificationMemo = Me.NotificationMessage.Text req.NotificationSubjectType = Me.NotificationSubjectField.SelectedValue req.NotificationType = Me.NotificationTypeField.SelectedValue req.SaturdayDelivery = False req.Service = CType(Me.ServiceField.SelectedValue, BVSoftware.UPS.OnlineTools.ServiceType) req.Settings.UserID = WebAppSettings.ShippingUpsUsername req.Settings.Password = WebAppSettings.ShippingUpsPassword req.Settings.License = WebAppSettings.ShippingUpsLicense req.Settings.ServerUrl = WebAppSettings.ShippingUpsServer If Me.FromCompanyField.Text.Trim.Length < 1 Then req.ShipFrom.CompanyOrContactName = Me.FromNameField.Text Else req.ShipFrom.CompanyOrContactName = Me.FromCompanyField.Text End If req.ShipFrom.AttentionName = Me.FromNameField.Text req.ShipFrom.AccountNumber = WebAppSettings.ShippingUpsAccountNumber req.ShipFrom.PhoneNumber = Me.FromPhoneField.Text req.ShipFrom.AddressLine1 = Me.FromAddress1Field.Text.Trim req.ShipFrom.AddressLine2 = Me.FromAddress2Field.Text.Trim req.ShipFrom.City = Me.FromCityField.Text req.ShipFrom.StateProvinceCode = Me.FromStateField.Text req.ShipFrom.PostalCode = Me.FromPostalCodeField.Text.Trim req.ShipFrom.CountryCode = Me.FromCountryField.SelectedValue req.Shipper = req.ShipFrom If Me.ToCompanyField.Text.Trim.Length < 1 Then req.ShipTo.CompanyOrContactName = Me.ToNameField.Text Else req.ShipTo.CompanyOrContactName = Me.ToCompanyField.Text End If req.ShipTo.AttentionName = Me.ToNameField.Text req.ShipTo.PhoneNumber = Me.ToPhoneField.Text req.ShipTo.AddressLine1 = Me.ToAddress1Field.Text.Trim req.ShipTo.AddressLine2 = Me.ToAddress2Field.Text.Trim req.ShipTo.City = Me.ToCityField.Text req.ShipTo.StateProvinceCode = Me.ToStateField.Text req.ShipTo.PostalCode = Me.ToPostalCodeField.Text.Trim req.ShipTo.CountryCode = Me.ToCountryField.SelectedValue req.ShipTo.ResidentialAddress = Me.chkResidential.Checked Dim useDeclaredValueInsteadOfInsurance As Boolean = False req.InvoiceLineTotal = False '2004.6 If Me.DeclaredValueField.Text.Trim <> String.Empty Then If req.ShipFrom.CountryCode = "US" Then If Me.PackageTypeField.SelectedValue <> 1 Then If req.ShipTo.CountryCode = "CA" Or req.ShipTo.CountryCode = "PR" Then useDeclaredValueInsteadOfInsurance = True req.InvoiceLineTotal = True req.InvoiceLineTotalAmount = Me.DeclaredValueField.Text.Trim req.InvoiceLineTotalCurrency = BVSoftware.UPS.OnlineTools.XmlTools.ConvertStringToCurrencyCode(Me.DeclaredValueCurrencyField.SelectedValue) End If End If End If End If Dim p As New BVSoftware.UPS.OnlineTools.Package p.AdditionalHandlingIsRequired = Me.chkAdditionalHandling.Checked If Me.CODAmountField.Text.Trim <> String.Empty Then p.COD = True p.CODAmount = Me.CODAmountField.Text.Trim p.CODCurrencyCode = BVSoftware.UPS.OnlineTools.XmlTools.ConvertStringToCurrencyCode(Me.CODCurrencyField.SelectedValue) Else p.COD = False End If If Me.DeliveryConfirmationField.SelectedValue = 0 Then p.DeliveryConfirmation = False Else p.DeliveryConfirmation = True p.DeliveryConfirmationType = Me.DeliveryConfirmationField.SelectedValue End If p.DimensionalUnits = Me.DimensionalUnitsField.SelectedValue If Me.HeightField.Text.Trim <> String.Empty Then p.Height = Me.HeightField.Text End If '2004.6 If useDeclaredValueInsteadOfInsurance = False Then If Me.DeclaredValueField.Text.Trim <> String.Empty Then p.InsuredValue = Me.DeclaredValueField.Text.Trim p.InsuredValueCurrency = BVSoftware.UPS.OnlineTools.XmlTools.ConvertStringToCurrencyCode(Me.DeclaredValueCurrencyField.SelectedValue) End If End If If Me.LengthField.Text.Trim <> String.Empty Then p.Length = Me.LengthField.Text End If p.Packaging = Me.PackageTypeField.SelectedValue If Me.Reference1Field.Text.Trim <> String.Empty Then p.ReferenceNumber = Me.Reference1Field.Text p.ReferenceNumberType = BVSoftware.UPS.OnlineTools.ReferenceNumberCode.TransactionReferenceNumber End If If Me.Reference2Field.Text.Trim <> String.Empty Then p.ReferenceNumber2 = Me.Reference2Field.Text p.ReferenceNumber2Type = BVSoftware.UPS.OnlineTools.ReferenceNumberCode.TransactionReferenceNumber End If p.VerbalConfirmation = False If Me.WeightField.Text.Trim <> String.Empty Then p.Weight = Me.WeightField.Text End If p.WeightUnits = Me.WeightUnitsField.SelectedValue If Me.WidthField.Text.Trim <> String.Empty Then p.Width = Me.WidthField.Text End If p.VerbalConfirmation = Me.chkVerbalConfirmation.Checked If p.VerbalConfirmation = True Then p.VerbalConfirmationName = Me.VerbalNameField.Text.Trim p.VerbalConfirmationPhoneNumber = Me.VerbalPhoneField.Text.Trim End If req.AddPackage(p) ViewState("ShipDigest") = Nothing ViewState("TrackingNumber") = Nothing Dim res As BVSoftware.UPS.OnlineTools.ShipResponse res = BVSoftware.UPS.OnlineTools.XmlTools.SendConfirmRequest(req) If Not res Is Nothing Then If WebAppSettings.ShippingUpsWriteXml = True Then Me.SaveXmlStringToFile("Confirm_" & res.TrackingNumber & "_Request.xml", req.XmlConfirmRequest) Me.SaveXmlStringToFile("Confirm_" & res.TrackingNumber & "_Response.xml", req.XmlConfirmResponse) End If If res.Success = True Then ViewState("ShipDigest") = res.ShipmentDigest ViewState("TrackingNumber") = res.TrackingNumber msg.ShowInformation("Please review the courtesy rate and select an action.") Me.lblServiceOptions.Text = String.Format("{0:C}", res.ServiceOptionsCharge) Me.lblShipCharges.Text = String.Format("{0:C}", res.TransportationCharge) Me.lblRate.Text = String.Format("{0:C}", res.TotalCharge) Me.pnlGetRates.Visible = False Me.pnlRates.Visible = True Else Me.msg.ShowWarning("Error " & res.ErrorCode & ": " & res.ErrorMessage) End If Else msg.ShowError("Response object was empty") End If End Sub Private Sub Imagebutton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Imagebutton1.Click msg.Clear() Me.pnlPrint.Visible = False Me.pnlRates.Visible = False Me.pnlGetRates.Visible = True End Sub Private Sub Imagebutton2_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Imagebutton2.Click msg.Clear() Dim digest As String = String.Empty If Not (ViewState("ShipDigest") Is Nothing) Then digest = ViewState("ShipDigest") End If ' Send accept here If digest <> String.Empty Then Dim req As New BVSoftware.UPS.OnlineTools.ShipAcceptRequest req.Settings.UserID = WebAppSettings.ShippingUpsUsername req.Settings.Password = WebAppSettings.ShippingUpsPassword req.Settings.License = WebAppSettings.ShippingUpsLicense req.Settings.ServerUrl = WebAppSettings.ShippingUpsServer req.ShipDigest = digest Dim res As BVSoftware.UPS.OnlineTools.ShipAcceptResponse res = BVSoftware.UPS.OnlineTools.XmlTools.SendShipAcceptRequest(req) If WebAppSettings.ShippingUpsWriteXml = True Then Me.SaveXmlStringToFile("Accept_" & ViewState("TrackingNumber") & "_Request.xml", req.XmlAcceptRequest) Me.SaveXmlStringToFile("Accept_" & ViewState("TrackingNumber") & "_Response.xml", req.XmlAcceptResponse) End If If Not res Is Nothing Then If res.Success = True Then If Not (res.Packages Is Nothing) Then If res.Packages.Count > 0 Then Dim pak As BVSoftware.UPS.OnlineTools.ShippedPackageInformation pak = res.Packages(0) If Not pak Is Nothing Then If pak.LabelFormat = BVSoftware.UPS.OnlineTools.ShipLabelFormat.Epl2 Then SaveBase64ToFile(pak.TrackingNumber & ".elp2", pak.Base64Image) Else SaveBase64ToFile("label" & pak.TrackingNumber & ".gif", pak.Base64Image) End If SaveBase64ToFile(pak.TrackingNumber & ".htm", pak.Base64Html) AddPopUpWindow(Path.Combine(WebAppSettings.SiteStandardRoot, "images/UPS/" & pak.TrackingNumber & ".htm")) Me.pnlPrint.Visible = True Me.lnkLabel.NavigateUrl = Path.Combine(WebAppSettings.SiteStandardRoot, "images/UPS/" & pak.TrackingNumber & ".htm") msg.ShowOK("Package Shipped with UPS Tracking Number: " & res.TrackingNumber) If Me.PackageID > 0 Then Dim p As Shipping.Package = ShippingServices.Packages.GetPackageByID(Me.PackageID) If Not p Is Nothing Then p.TrackingNumber = res.TrackingNumber p.ShippingType = Shipping.UPS.OnlineTools.TranslateUPSCodeToBVShipType(Me.ServiceField.SelectedValue) ShippingServices.Packages.Update(p) End If End If Else msg.ShowError("Unable to load label for shipment!") End If Else msg.ShowError("Empty Package List Found!") End If Else msg.ShowError("No package list was found!") End If Else Me.msg.ShowWarning("Error " & res.ErrorCode & ": " & res.ErrorMessage) End If Else msg.ShowError("Unable to parse response with label!") End If Else msg.ShowError("Ship Response Object was empty.") End If Me.pnlGetRates.Visible = True Me.pnlRates.Visible = False End Sub Private Function SaveBase64ToFile(ByVal filename As String, ByVal base64data As String) As Boolean Dim result As Boolean = False Dim UPSLabelDirectory As String = Path.Combine(Request.PhysicalApplicationPath, "images\UPS") Try If Directory.Exists(UPSLabelDirectory) = False Then Directory.CreateDirectory(UPSLabelDirectory) End If Dim fs As New FileStream(Path.Combine(UPSLabelDirectory, filename), FileMode.Create) Dim data As Byte() = BVSoftware.Encryption.Base64.ConvertFromBase64(base64data) fs.Write(data, 0, data.Length - 1) fs.Flush() fs.Close() Catch ex As Exception EventLog.LogEvent(ex) End Try Return result End Function Private Sub AddPopUpWindow(ByVal url As String) Dim sb As New StringBuilder sb.Append("") sb.Append("") RegisterStartupScript("onLoad", sb.ToString()) sb = Nothing End Sub Private Function SaveXmlStringToFile(ByVal filename As String, ByVal data As String) As Boolean Dim result As Boolean = False Dim UPSLabelDirectory As String = Path.Combine(Request.PhysicalApplicationPath, "images\UPS\Xml") Try If Directory.Exists(UPSLabelDirectory) = False Then Directory.CreateDirectory(UPSLabelDirectory) End If Dim writer As New StreamWriter(Path.Combine(UPSLabelDirectory, filename), False) writer.Write(data) writer.Flush() writer.Close() Catch ex As Exception EventLog.LogEvent(ex) End Try Return result End Function Private Sub btnContinue_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnContinue.Click OnContinue() End Sub Private Sub OnContinue() If Me.ReturnURL.Length > 0 Then Response.Redirect(Me.ReturnURL) Else Response.Redirect("Orders_Default.aspx") End If End Sub End Class