Imports BVSoftware.BVC.Core Imports System.Text Public Class OrderViewer Inherits System.Web.UI.UserControl #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Protected WithEvents lblError As System.Web.UI.WebControls.Label Protected WithEvents lblOrderNumber As System.Web.UI.WebControls.Label Protected WithEvents lblStatus As System.Web.UI.WebControls.Label Protected WithEvents lblTime As System.Web.UI.WebControls.Label Protected WithEvents downloadLink As System.Web.UI.WebControls.HyperLink Protected WithEvents DownloadButton As System.Web.UI.WebControls.ImageButton Protected WithEvents DownloadPanel As System.Web.UI.WebControls.Panel Protected WithEvents lblBillAddress As System.Web.UI.WebControls.Label Protected WithEvents lblPaymentMethod As System.Web.UI.WebControls.Label Protected WithEvents lblCoupon As System.Web.UI.WebControls.Label Protected WithEvents lblInstructions As System.Web.UI.WebControls.Label Protected WithEvents PackageList As System.Web.UI.WebControls.DataList Protected WithEvents NonShippingLabel As System.Web.UI.WebControls.Label Protected WithEvents NonPackageItems As System.Web.UI.WebControls.DataGrid Protected WithEvents lblSubTotal As System.Web.UI.WebControls.Label Protected WithEvents lblGiftWrapCharge As System.Web.UI.WebControls.Label Protected WithEvents lblTaxTotal As System.Web.UI.WebControls.Label Protected WithEvents lblShippingTotal As System.Web.UI.WebControls.Label Protected WithEvents lblHandlingTotal As System.Web.UI.WebControls.Label Protected WithEvents lblGrandTotal As System.Web.UI.WebControls.Label Protected WithEvents PrintButton As System.Web.UI.HtmlControls.HtmlImage Protected WithEvents downloadLinkUnpaid As System.Web.UI.WebControls.HyperLink Protected WithEvents pnlDownloadUnPaid As System.Web.UI.WebControls.Panel Protected WithEvents lblShippingMethod As System.Web.UI.WebControls.Label '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() End Sub #End Region Private _o As Orders.Order Public Property CurrentOrder() As Orders.Order Get Return _o End Get Set(ByVal Value As Orders.Order) _o = Value End Set End Property Public Property ErrorMessage() As String Get Return lblError.Text End Get Set(ByVal Value As String) lblError.Text = Value End Set End Property Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then DownloadButton.ImageUrl = ImageHelper.GetThemedButton("Download.gif") PrintButton.Src = ImageHelper.GetThemedButton("Print.gif") LoadCurrentOrder() End If End Sub Public Sub LoadOrderByID(ByVal orderID As Integer) _o = OrderServices.GetExistingOrder(orderID) LoadOrder(_o) End Sub Public Sub LoadOrder(ByRef ord As Orders.Order) _o = ord LoadCurrentOrder() End Sub Public Sub LoadCurrentOrder() Try If Not _o Is Nothing Then lblOrderNumber.Text = "Order Number " & _o.CompletedOrderID lblTime.Text = " - " & _o.TimeOfOrder.ToString 'lblStatus.Text = _o.StatusName '2004.6 lblStatus.Text = OrderServices.TranslateOrderCodesToFriendlyName(_o.StatusCode, _o.PaymentStatus, _o.ShippingStatus) ' Downloads If _o.DownloadKey.Length() > 0 Then ViewState("DownloadKey") = _o.DownloadKey downloadLink.NavigateUrl = WebAppSettings.SiteStandardRoot & "downloadFiles.aspx?key=" & _o.DownloadKey downloadLink.Text = WebAppSettings.SiteStandardRoot & "downloadFiles.aspx?key=" & _o.DownloadKey downloadLinkUnpaid.NavigateUrl = downloadLink.NavigateUrl downloadLinkUnpaid.Text = downloadLink.Text End If DownloadPanel.Visible = False Me.pnlDownloadUnPaid.Visible = False If CatalogServices.Files.GetFilesForDownloadKey(_o.DownloadKey).Rows.Count() > 0 Then If _o.PaymentStatus = Orders.OrderPaymentStatus.Charged Then DownloadPanel.Visible = True Else Me.pnlDownloadUnPaid.Visible = True End If End If ' Shipping Items If _o.Packages.Length > 0 Then PackageList.Visible = True PackageList.DataSource = _o.Packages PackageList.DataBind() End If ' Load non-shipping items If _o.GetNonShippingItems.Count > 0 Then NonPackageItems.DataSource = _o.GetNonShippingItems NonPackageItems.DataBind() NonShippingLabel.Visible = True Else NonShippingLabel.Visible = False End If ' Load Billing Address lblBillAddress.Text = ContactServices.Addresses.ToHtmlString(_o.BillingAddress) ' Get Payment Method lblPaymentMethod.Text = "" If _o.Payments.Length > 0 Then Dim sb As New StringBuilder For i As Integer = 0 To _o.Payments.Length - 1 If _o.Payments(i).PaymentType = BVSoftware.BVC.Interfaces.PaymentRecordType.Information Then Select Case _o.Payments(i).PaymentMethod Case BVSoftware.BVC.Interfaces.PaymentMethod.Cash sb.Append("
Cash ") Case BVSoftware.BVC.Interfaces.PaymentMethod.Check sb.Append("
Check " & _o.Payments(i).CheckNumber & " ") Case BVSoftware.BVC.Interfaces.PaymentMethod.CreditCard Select Case _o.Payments(i).CreditCardType Case BVSoftware.BVC.Interfaces.CreditCardType.Amex sb.Append("
Amex ") Case BVSoftware.BVC.Interfaces.CreditCardType.DinersClub sb.Append("
Diner's Club ") Case BVSoftware.BVC.Interfaces.CreditCardType.Discover sb.Append("
Discover ") Case BVSoftware.BVC.Interfaces.CreditCardType.JCB sb.Append("
JCB ") Case BVSoftware.BVC.Interfaces.CreditCardType.MasterCard sb.Append("
Mastercard ") Case BVSoftware.BVC.Interfaces.CreditCardType.Visa sb.Append("
Visa ") End Select If _o.Payments(i).CreditCardNumber.Length > 14 Then sb.Append(_o.Payments(i).CreditCardNumber.Substring(_o.Payments(i).CreditCardNumber.Length - 4, 4) & " ") Else sb.Append("") End If Case BVSoftware.BVC.Interfaces.PaymentMethod.GiftCertificate sb.Append("
Gift Cert. " & _o.Payments(i).GiftCertificateNumber & " ") Case BVSoftware.BVC.Interfaces.PaymentMethod.Other sb.Append("
Other ") Case BVSoftware.BVC.Interfaces.PaymentMethod.PayPal sb.Append("
PayPal ") Case BVSoftware.BVC.Interfaces.PaymentMethod.Telephone sb.Append("
Telephone ") Case BVSoftware.BVC.Interfaces.PaymentMethod.Fax sb.Append("
Fax ") Case BVSoftware.BVC.Interfaces.PaymentMethod.Email sb.Append("
Email ") Case BVSoftware.BVC.Interfaces.PaymentMethod.PurchaseOrder sb.Append("
Purchase Order " & _o.Payments(i).PurchaseOrderNumber & " ") End Select sb.Append(String.Format("{0:C}", _o.Payments(i).Amount)) sb.Append("
") End If Next lblPaymentMethod.Text = sb.ToString sb = Nothing Else lblPaymentMethod.Text = "none" End If ' Populate Coupon lblCoupon.Text = "" If _o.Coupons.Length = 0 Then lblCoupon.Text = "none" Else For k As Integer = 0 To _o.Coupons.Length - 1 lblCoupon.Text += _o.Coupons(k) & "
" Next End If ' Populate Totals 'lblSubTotal.Text = String.Format("{0:c}", _o.SubTotal) If _o.OrderDiscountsTotal > 0 Then lblSubTotal.Text = String.Format("{0:c}", _o.SubTotal + _o.OrderDiscountsTotal) lblSubTotal.Text += "
-" lblSubTotal.Text += String.Format("{0:c}", _o.OrderDiscountsTotal) lblSubTotal.Text += "" Else lblSubTotal.Text = String.Format("{0:c}", _o.SubTotal) End If lblTaxTotal.Text = String.Format("{0:c}", _o.TaxTotal) lblHandlingTotal.Text = String.Format("{0:c}", _o.HandlingFee) If _o.ShippingDiscountsTotal > 0 Then lblShippingTotal.Text = String.Format("{0:c}", _o.ShippingTotal + _o.ShippingDiscountsTotal) lblShippingTotal.Text += "
-" lblShippingTotal.Text += String.Format("{0:c}", _o.ShippingDiscountsTotal) lblShippingTotal.Text += "" Else lblShippingTotal.Text = String.Format("{0:c}", _o.ShippingTotal) End If '2004.6 If Not _o.Packages Is Nothing Then If _o.Packages.Length > 0 Then With _o.Packages(0) Me.lblShippingMethod.Text = .ShippingMethodName End With End If End If lblGrandTotal.Text = String.Format("{0:c}", _o.GrandTotal) lblGiftWrapCharge.Text = String.Format("{0:c}", _o.GiftWrapCharge) lblInstructions.Text = HttpUtility.HtmlEncode(_o.Instructions) Else lblError.Text = "There was an error while loading this order." End If Catch Ex As Exception lblError.Text += "
" & Ex.Message & Ex.Source End Try End Sub Private Sub DownloadButton_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles DownloadButton.Click Response.Redirect("downloadFiles.aspx?key=" & Server.UrlEncode(ViewState("DownloadKey")), True) End Sub Public Sub NonPackageItems_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles NonPackageItems.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim editID As String = CType(sender, DataGrid).DataKeys(e.Item.ItemIndex) 'Dim editID As String = NonPackageItems.DataKeys(e.Item.ItemIndex) Dim Item As Orders.OrderItem = OrderServices.OrderItems.GetByID(editID) If Not Item Is Nothing Then Dim sDescription As String = Item.DisplayName If Item.DisplayDescription.Trim.Length > 0 Then sDescription += "
" & Item.DisplayDescription End If e.Item.Cells(0).Text = sDescription If Item.OriginalBasePrice > Item.AdjustedSitePrice Then Dim sPrice As String = "" & String.Format("{0:c}", Item.OriginalBasePrice) & "
" sPrice += String.Format("{0:c}", Item.AdjustedSitePrice) e.Item.Cells(1).Text = sPrice Else e.Item.Cells(1).Text = String.Format("{0:c}", Item.AdjustedSitePrice) End If e.Item.Cells(3).Text = String.Format("{0:c}", Item.LineTotal) If Item.NonShipping = False Then e.Item.Cells(4).Text = Item.QtyShipped If Item.QtyShipped > 0 Then Dim p As Shipping.Package = ShippingServices.Packages.GetPackageByID(Item.PackageID) If Not p Is Nothing Then If p.TrackingNumber.Trim.Length > 0 Then e.Item.Cells(4).Text += "
" & ShippingServices.GenerateTrackingLink(p.TrackingNumber, p.ShippingType) End If End If p = Nothing End If End If End If Item = Nothing End If End Sub Private Sub PackageList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles PackageList.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim editID As String = PackageList.DataKeys(e.Item.ItemIndex) Dim pak As Shipping.Package = ShippingServices.Packages.GetPackageByID(editID) If Not pak Is Nothing Then Dim ShipToLabel As Label = e.Item.FindControl("PackageShipAddress") If Not ShipToLabel Is Nothing Then ShipToLabel.Text = ContactServices.Addresses.ToHtmlString(pak.DestinationAddress) End If Dim PackageItems As DataGrid = e.Item.FindControl("PackageItems") If Not PackageItems Is Nothing Then AddHandler PackageItems.ItemDataBound, AddressOf Me.NonPackageItems_ItemDataBound PackageItems.DataSource = _o.GetItemsForPackage(pak.ID) PackageItems.DataBind() End If End If pak = Nothing End If End Sub End Class