protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["CreditCardInfo"] != null && Session["CheckOutDataSource"] != null) { if (!IsAgentRole) { AgentLiteral.Text = "Selected Agent: " + Session["SelectedAgent"].ToString(); } ShoppingCartService.ShoppingCartInfo cartInfo = (ShoppingCartService.ShoppingCartInfo)Session["CheckOutDataSource"]; OrderService.OrderInfo orderInfo = (OrderService.OrderInfo)Session["CreditCardInfo"]; TransactionNoLiteral.Text = orderInfo.TransactionCode.ToString(); AssignDataSource(cartInfo, orderInfo.CreditCard); } else { Response.Redirect("~/Members/ProductCatalog.aspx"); } } }
private void AssignDataSource(OrderService.OrderInfo orderInfo, OrderService.CreditCardInfo cardInfo) { OrderNoLiteral.Text = orderInfo.OrderId.ToString(); OrderDateLiteral.Text = orderInfo.Date.ToShortDateString(); PaymentDetailsLiteral.Text = cardInfo.Type.Name + " ," + "XXXX-XXXX-XXXX-" + cardInfo.Number.Substring(cardInfo.Number.Length - 4); BillingAddressLiteral.Text = cardInfo.Address.Address1 + ", "; if (cardInfo.Address.Address2 != string.Empty && cardInfo.Address.Address2 != null) { BillingAddressLiteral.Text += cardInfo.Address.Address2 + ", "; } BillingAddressLiteral.Text += cardInfo.Address.City + ", " + cardInfo.Address.State.Name + "-" + cardInfo.Address.Zip; if (orderInfo.RefundAmount != null && orderInfo.RefundAmount != 0) { RefundAmountLiteral.Text = orderInfo.RefundAmount.ToString(); RefundPanel.Visible = true; } else { RefundPanel.Visible = false; } if (orderInfo.Items.Length > 0) { ShoppingCartInfo cartInfo1 = new ShoppingCartInfo(); ShoppingCartItemInfo cartItemInfo = new ShoppingCartItemInfo(); List <ShoppingCartItemInfo> cartItems = new List <ShoppingCartItemInfo>(); foreach (OrderService.OrderItemInfo orderItem in orderInfo.Items) { cartItemInfo = new ShoppingCartItemInfo(); cartItemInfo.Description = orderItem.Title; cartItemInfo.Price = orderItem.Rate; cartItemInfo.Quantity = orderItem.Quantity; cartItemInfo.ProductId = orderItem.ItemId; cartItemInfo.TotalPrice = cartItemInfo.Quantity * cartItemInfo.Price; cartInfo1.SubTotal += cartItemInfo.TotalPrice; cartInfo1.SubTotal = Math.Round(cartInfo1.SubTotal, 2); cartItems.Add(cartItemInfo); } cartInfo1.CartItems = cartItems.ToArray(); if (cardInfo.Address.State.Name.ToLower() == "colorado") { CommonService commonService = ServiceAccess.GetInstance().GetCommon(); if (commonService.GetProperty("Tax") != null) { cartInfo1.Tax = Convert.ToDecimal(commonService.GetProperty("Tax").Value); } } else { cartInfo1.Tax = 0; } ShoppingCartService cartService = ServiceAccess.GetInstance().GetShoppingCart(); ShoppingCartInfo cartInfo = cartService.CalculateGrandTotal(cartInfo1); CartGridView.DataSource = cartInfo.CartItems; CartGridView.DataBind(); SubTotalLiteral.Text = cartInfo.SubTotal.ToString(); ShippingLiteral.Text = cartInfo.ShippingAndHandling.ToString(); TaxLiteral.Text = cartInfo.Tax.ToString(); GrandTotalLiteral.Text = cartInfo.GrandTotal.ToString(); DiscountLiteral.Text = cartInfo.Discount.ToString(); } else { ProductsPanel.Visible = false; } }
protected void FinishButton_Click(object sender, EventArgs e) { ErrorLiteral.Text = ""; RegistrationService.RegistrationInfo registration = (RegistrationService.RegistrationInfo)Session["registrationInfo"]; int userId = 0; string folderPath = Request.PhysicalPath.Replace("AgentRegistrationConf.aspx", "Members\\UserData\\"); String username = registration.UserName; registration.UserName = username + ";" + folderPath; OrderService.OrderInfo orderInfo = new OrderService.OrderInfo(); int membershipFee; try { // Get the service loader ServiceAccess serviceLoader = ServiceAccess.GetInstance(); CommonService.CommonService commonService = serviceLoader.GetCommon(); // Get the Membership fee CommonService.PropertyInfo property = commonService.GetProperty("Membership Fee"); membershipFee = Convert.ToInt32(property.Value); // Insert the registration details RegistrationService.RegistrationService registrationService = serviceLoader.GetRegistration(); userId = registrationService.Insert(registration); registration.UserName = username; // Insert the membership details if (registration.Role == Irmac.MailingCycle.BLLServiceLoader.Registration.UserRole.Agent) { try { OrderService.CreditCardInfo creditCard = new OrderService.CreditCardInfo(); OrderService.StateInfo billingState = new OrderService.StateInfo(); billingState.StateId = registration.Address.State.StateId; billingState.Name = registration.Address.State.Name; OrderService.CountryInfo billingCountry = new OrderService.CountryInfo(); billingCountry.CountryId = registration.Address.Country.CountryId; billingCountry.Name = registration.Address.Country.Name; OrderService.AddressInfo billingAddress = new OrderService.AddressInfo(); billingAddress.Address1 = registration.Address.Address1; billingAddress.Address2 = registration.Address.Address2; billingAddress.City = registration.Address.City; billingAddress.State = billingState; billingAddress.Zip = registration.Address.Zip; billingAddress.Country = billingCountry; OrderService.LookupInfo creditCardType = new OrderService.LookupInfo(); creditCardType.LookupId = registration.CreditCard.Type.LookupId; creditCardType.Name = registration.CreditCard.Type.Name; creditCard.Type = creditCardType; creditCard.Number = registration.CreditCard.Number; creditCard.CvvNumber = registration.CreditCard.CvvNumber; creditCard.HolderName = registration.CreditCard.HolderName; creditCard.ExpirationMonth = registration.CreditCard.ExpirationMonth; creditCard.ExpirationYear = registration.CreditCard.ExpirationYear; creditCard.Address = billingAddress; orderInfo.Number = 100; orderInfo.Type = Irmac.MailingCycle.BLLServiceLoader.Order.OrderType.MembershipFee; orderInfo.Date = DateTime.Now; orderInfo.Amount = membershipFee; orderInfo.CreditCard = creditCard; orderInfo.TransactionCode = -1; orderInfo.TransactionMessage = "Dummy Transaction"; orderInfo.Items = null; OrderService.OrderService orderService = serviceLoader.GetOrder(); orderService.Insert(userId, orderInfo, userId); } catch (Exception ex) { log.Error("Transaction is not sucessful", ex); ErrorLiteral.Text = "credit card transaction failed"; } } } catch (Exception ex) { log.Error("User Registration is not sucessful", ex); ErrorLiteral.Text = "User registration failed" + " | " + ex.Message + " | " + ex.StackTrace.ToString(); } if (ErrorLiteral.Text == "") { RegistrationService.LoginInfo loginInfo = new RegistrationService.LoginInfo(); loginInfo.UserId = userId; loginInfo.UserName = registration.UserName; loginInfo.FirstName = registration.FirstName; loginInfo.LastName = registration.LastName; loginInfo.Role = registration.Role; loginInfo.Status = registration.Status; SendRegistrationEmail(registration); Session["registrationInfo"] = null; Session["loginInfo"] = loginInfo; Response.Redirect("AgentRegistrationThanks.aspx"); } }