Imports BVSoftware.BVC.Core Imports System.Text Public Class checkout_confirm Inherits BaseStorePage Protected WithEvents lblBillAddress As System.Web.UI.WebControls.Label Protected WithEvents lblPaymentMethod As System.Web.UI.WebControls.Label Protected WithEvents lblSubTotal 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 lblGrandTotal As System.Web.UI.WebControls.Label Protected WithEvents lblEmail As System.Web.UI.WebControls.Label Protected WithEvents lblHandlingTotal As System.Web.UI.WebControls.Label Protected WithEvents chkAgree As System.Web.UI.WebControls.CheckBox Protected WithEvents AgreePanel As System.Web.UI.WebControls.Panel Protected WithEvents EditPaymentLink As System.Web.UI.WebControls.HyperLink Protected WithEvents DefaultButtons1 As MetaBuilders.WebControls.DefaultButtons Protected WithEvents Imagebutton2 As System.Web.UI.WebControls.ImageButton Protected WithEvents btnSubmit As System.Web.UI.WebControls.ImageButton Protected WithEvents NonPackageItems As System.Web.UI.WebControls.DataGrid Protected WithEvents PackageList As System.Web.UI.WebControls.DataList Protected WithEvents NonShippingLabel As System.Web.UI.WebControls.Label Protected WithEvents ShipToMultipleAddressesButton As System.Web.UI.WebControls.ImageButton Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents lblGiftWrapCharge As System.Web.UI.WebControls.Label Protected WithEvents Hyperlink1 As System.Web.UI.WebControls.HyperLink Protected WithEvents pnlInstuctions As System.Web.UI.WebControls.Panel Protected WithEvents InstructionsField As System.Web.UI.WebControls.TextBox Protected WithEvents CSSTag1 As BVSoftware.WebControls.CSSTag Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Private thisOrder As Orders.Order #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub 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 this page if set up Me.RequiresSSL = True '-SP2 End Sub #End Region Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription CSSTag1.StyleSheetURL = PersonalizationServices.GetPersonalizedStyleSheet PageTitle = "Confirm" btnSubmit.ImageUrl = ImageHelper.GetThemedButton("PlaceOrder.gif") ShipToMultipleAddressesButton.ImageUrl = ImageHelper.GetThemedButton("ShipToMultipleAddresses.gif") End If ' Only allow registered users at this point If BVC2004Store.IsUserAuthenticated = False Then Response.Redirect("Checkout_Login.aspx", True) End If thisOrder = BVC2004Store.GetCurrentShoppingCart ValidateForPurchase() 'If Not Page.IsPostBack Then If WebAppSettings.RequireTermsAgreement = True Then AgreePanel.Visible = True Else AgreePanel.Visible = False End If If WebAppSettings.CheckoutShowSpecialInstructions = True Then Me.pnlInstuctions.Visible = True Else Me.pnlInstuctions.Visible = False End If Me.ShipToMultipleAddressesButton.Visible = WebAppSettings.AllowMultipleShippingAddresses LoadOrder() End Sub Private Sub ValidateForPurchase() If thisOrder.UserID < 1 Then thisOrder.UserID = BVC2004Store.GetCurrentUser.ID thisOrder.UserName = BVC2004Store.GetCurrentUser.UserName OrderServices.SaveOrder(thisOrder) End If Dim v As Pipelines.OrderPipelineResponse = Pipelines.CheckoutPipeline.Run(thisOrder) If v.HasItems = False Then Response.Redirect(WebAppSettings.SiteStandardRoot & "cart.aspx") End If If (v.ShippingAddressRequired = True And v.ShippingAddressReady = False) Then Response.Redirect("Checkout_Address.aspx") End If If (v.BillingAddressRequired = True And v.BillingAddressReady = False) Then Response.Redirect("Checkout_Address.aspx") End If If (v.ShippingMethodRequired = True And v.ShippingMethodReady = False) Then Response.Redirect("Checkout_Shipping.aspx") End If If (v.PaymentMethodRequired = True And v.PaymentMethodReady = False) Then Response.Redirect("Checkout_Shipping.aspx") End If If v.ReadyForCheckout = True Then Me.btnSubmit.Visible = True Else Me.btnSubmit.Visible = False End If End Sub Sub LoadOrder() Try If thisOrder.ItemCount < 2 Then Me.ShipToMultipleAddressesButton.Visible = False End If If thisOrder.Packages.Length > 0 Then Me.PackageList.Visible = True Me.PackageList.DataSource = thisOrder.Packages Me.PackageList.DataBind() End If If thisOrder.HasShippingItems = False Then Me.ShipToMultipleAddressesButton.Visible = False End If ' Load non-shipping items If thisOrder.GetNonShippingItems.Count > 0 Then Me.NonPackageItems.DataSource = thisOrder.GetNonShippingItems Me.NonPackageItems.DataBind() Me.NonShippingLabel.Visible = True Else Me.NonShippingLabel.Visible = False End If ' Load Billing Address lblBillAddress.Text = ContactServices.Addresses.ToHtmlString(thisOrder.BillingAddress) ' Get Payment Method lblPaymentMethod.Text = "" If thisOrder.Payments.Length > 0 Then Dim sb As New StringBuilder For i As Integer = 0 To thisOrder.Payments.Length - 1 If thisOrder.Payments(i).PaymentType = BVSoftware.BVC.Interfaces.PaymentRecordType.Information Then Select Case thisOrder.Payments(i).PaymentMethod Case BVSoftware.BVC.Interfaces.PaymentMethod.Cash sb.Append("
Cash ") Case BVSoftware.BVC.Interfaces.PaymentMethod.Check sb.Append("
Check " & thisOrder.Payments(i).CheckNumber & " ") Case BVSoftware.BVC.Interfaces.PaymentMethod.CreditCard Select Case thisOrder.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 thisOrder.Payments(i).CreditCardNumber.Length > 14 Then sb.Append(thisOrder.Payments(i).CreditCardNumber.Substring(thisOrder.Payments(i).CreditCardNumber.Length - 4, 4) & " ") Else sb.Append("") End If Case BVSoftware.BVC.Interfaces.PaymentMethod.GiftCertificate sb.Append("
Gift Cert. " & thisOrder.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 " & thisOrder.Payments(i).PurchaseOrderNumber & " ") End Select sb.Append(String.Format("{0:C}", thisOrder.Payments(i).Amount)) sb.Append("
") End If Next lblPaymentMethod.Text = sb.ToString sb = Nothing Else lblPaymentMethod.Text = "none" End If ' Populate Totals 'lblSubTotal.Text = String.Format("{0:c}", thisOrder.SubTotal) 'SP2- Modified for clearer display and inclusion of Shipping Discounts If thisOrder.OrderDiscountsTotal > 0 Then lblSubTotal.Text = String.Format("{0:c}", thisOrder.SubTotal + thisOrder.OrderDiscountsTotal) lblSubTotal.Text += "
" & String.Format("{0:c}", -thisOrder.OrderDiscountsTotal) lblSubTotal.Text += "
" lblSubTotal.Text += String.Format("{0:c}", thisOrder.SubTotal) lblSubTotal.Text += "" Else lblSubTotal.Text = "" lblSubTotal.Text += String.Format("{0:c}", thisOrder.SubTotal) lblSubTotal.Text += "" End If lblTaxTotal.Text = "" lblTaxTotal.Text += String.Format("{0:c}", thisOrder.TaxTotal) lblTaxTotal.Text += "" lblHandlingTotal.Text = "" lblHandlingTotal.Text += String.Format("{0:c}", thisOrder.HandlingFee) lblHandlingTotal.Text += "" If thisOrder.ShippingDiscountsTotal > 0 Then lblShippingTotal.Text = String.Format("{0:c}", thisOrder.ShippingTotal + thisOrder.ShippingDiscountsTotal) lblShippingTotal.Text += "
" & String.Format("{0:c}", -thisOrder.ShippingDiscountsTotal) lblShippingTotal.Text += "
" lblShippingTotal.Text += String.Format("{0:c}", thisOrder.ShippingTotal) lblShippingTotal.Text += "" Else lblShippingTotal.Text = "" lblShippingTotal.Text += String.Format("{0:c}", thisOrder.ShippingTotal) lblShippingTotal.Text += "" End If lblGrandTotal.Text = "Grand Total: " & String.Format("{0:c}", thisOrder.GrandTotal) If thisOrder.OrderDiscountsTotal + thisOrder.ShippingDiscountsTotal > 0 Then lblGrandTotal.Text += "

You Saved: " & String.Format("{0:c}", thisOrder.OrderDiscountsTotal + thisOrder.ShippingDiscountsTotal) lblGrandTotal.Text += "
" & FormatPercent((thisOrder.OrderDiscountsTotal + thisOrder.ShippingDiscountsTotal) / (thisOrder.GrandTotal + thisOrder.OrderDiscountsTotal + thisOrder.ShippingDiscountsTotal), 1) End If lblEmail.Text = thisOrder.UserName lblGiftWrapCharge.Text = "" lblGiftWrapCharge.Text += String.Format("{0:c}", thisOrder.GiftWrapCharge) lblGiftWrapCharge.Text += "" '-SP2 If Not Page.IsPostBack Then Me.InstructionsField.Text = thisOrder.Instructions End If Catch Ex As Exception msg.ShowException(Ex) End Try End Sub Sub btnApply_OnClick(ByVal Sender As Object, ByVal E As ImageClickEventArgs) msg.Clear() If ApplyChanges() = True Then Response.Redirect("Checkout_Confirm.aspx") End If 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.OriginalBasePrice > Item.AdjustedSitePrice Then sDescription += "
List Price: " & String.Format("{0:c}", Item.OriginalBasePrice) & "" sDescription += "
Your Price: " & String.Format("{0:c}", Item.AdjustedSitePrice) Else sDescription += "
Price: " & String.Format("{0:c}", Item.AdjustedSitePrice) End If sDescription += "
" & Item.DisplayDescription e.Item.Cells(0).Text = sDescription e.Item.Cells(2).Text = String.Format("{0:c}", Item.LineTotal) End If Item = Nothing End If End Sub Private Sub EditShipping_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Response.Redirect("Checkout_Address.aspx", True) End Sub Private Sub EditBilling_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Response.Redirect("Checkout_Billing.aspx", True) End Sub Private Sub EditPayment_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Response.Redirect("Checkout_Billing.aspx", True) 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 ShipTypeLabel As Label = e.Item.FindControl("PackageShipMethod") If Not ShipTypeLabel Is Nothing Then ShipTypeLabel.Text = pak.ShippingMethodName 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 = thisOrder.GetItemsForPackage(pak.ID) PackageItems.DataBind() End If End If pak = Nothing End If End Sub Private Sub ShipToMultipleAddressesButton_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ShipToMultipleAddressesButton.Click msg.Clear() ApplyChanges() Response.Redirect("Checkout_Address_Multiple.aspx", True) End Sub Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click msg.Clear() ApplyChanges() If WebAppSettings.RequireTermsAgreement = True Then If chkAgree.Checked = True Then Page.SmartNavigation = False Response.Redirect("checkout_receipt.aspx") Else msg.ShowWarning("You must agree to the Terms And Conditions to place this order.") End If Else Page.SmartNavigation = False Dim sDestination As String = "checkout_receipt.aspx" Trace.Write("Redirecting to: " & sDestination) Response.Redirect(sDestination) End If End Sub Private Function ApplyChanges() As Boolean If WebAppSettings.CheckoutShowSpecialInstructions = True Then If Not thisOrder Is Nothing Then thisOrder.Instructions = HttpUtility.HtmlEncode(InstructionsField.Text.Trim) End If OrderServices.SaveOrder(thisOrder) End If End Function End Class