protected void GiftButton_Click(object sender, EventArgs e) { try { // If a user does not have a gift registry create one int giftRegistryID = GiftRegistries.GetGiftRegistry(0, GetLoggedCustomerID(), string.Empty, false).GiftRegistryID; if (giftRegistryID == 0) { GiftRegistry giftRegistry = new GiftRegistry() { CustomerID = GetLoggedCustomerID(), DateCreated = DateTime.Now, Active = true }; giftRegistryID = GiftRegistries.AddGiftRegistry(giftRegistry); } // Add this product GiftRegistries.AddGiftRegistryProduct(new GiftRegistryProduct() { GiftRegistryID = giftRegistryID, ProductID = CartProduct.ProductID, Active = true }); Response.Redirect("MyAccount/GiftRegistry.aspx"); } catch (Exception ex) { ((Button)sender).Text = "Error " + ex.Message; } }
protected void GiftRegistryListView_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "Remove") { GiftRegistries.RemoveGiftRegistryProduct(GetLoggedCustomerID(), Convert.ToInt32(e.CommandArgument)); BindRegistry(); } }
private void BindRegistry() { GiftRegistry = GiftRegistries.GetGiftRegistry(0, 0, EmailTextBox.Text, true); if (GiftRegistry.IsPublic || GetLoggedCustomerID() > -1) { GiftRegistryListView.DataSource = GiftRegistry.Products; GiftRegistryListView.DataBind(); } else if (!GiftRegistry.IsPublic) { PrivateListLiteral.Visible = true; } }
private void AddOrderItems(Order order) { order.OrderItems = new List <OrderItem>(); foreach (CartItem item in Cart.CartItems) { OrderItem orderItem = new OrderItem() { ProductID = item.ProductID, PricePerUnit = item.PricePerUnit, Discount = 0, OrderDate = DateTime.Now, Quantity = item.Quantity, Shipping = 0, TotalPrice = item.Subtotal, ProductName = item.ProductName, CatalogNumber = item.CatalogNumber, Active = true }; // For downloadable products get a key if needed if (item.IsDownloadable) { orderItem.DownloadURL = item.DownloadURL; if (item.IsDownloadKeyRequired) { orderItem.DownloadKey = Products.GetNextProductKey(item.ProductID, item.IsDownloadKeyUnique); } } // Deactivate item in gift registry if (Cart.GiftRegistryID > 0 && item.GiftRegistryProductID > 0) { GiftRegistries.UpdateRegistryProductActive(Cart.GiftRegistryID, item.GiftRegistryProductID, false); } foreach (ProductOption option in item.ProductOptions) { orderItem.OptionList.Add(new OrderProductOption() { ProductOptionID = option.ProductOptionID }); } foreach (CustomField field in item.CustomFields) { orderItem.OrderProductCustomFieldList.Add(new OrderProductCustomField() { Active = true, CustomFieldID = field.CustomFieldID, OrderProductCustomFieldValue = field.CustomFieldValue, CustomFieldName = field.CustomFieldName }); } order.OrderItems.Add(orderItem); } }
private void BindRegistry() { giftRegistry = GiftRegistries.GetGiftRegistry(0, GetLoggedCustomerID(), string.Empty, true); GiftRegistryListView.DataSource = giftRegistry.Products; GiftRegistryListView.DataBind(); if (giftRegistry.IsPublic) { VisibilityRadioButtonList.SelectedValue = "true"; } else { VisibilityRadioButtonList.SelectedValue = "false"; } }
protected void VisibilityRadioButtonList_SelectedIndexChanged(object sender, EventArgs e) { if (giftRegistry == null) { giftRegistry = GiftRegistries.GetGiftRegistry(0, GetLoggedCustomerID(), string.Empty, true); } // Create a registry if it doesnt exist if (giftRegistry.GiftRegistryID == 0) { giftRegistry = new GiftRegistry() { CustomerID = GetLoggedCustomerID(), DateCreated = DateTime.Now, Active = true }; giftRegistry.GiftRegistryID = GiftRegistries.AddGiftRegistry(giftRegistry); } GiftRegistries.UpdateGiftRegistryPublic(giftRegistry.GiftRegistryID, Convert.ToBoolean(VisibilityRadioButtonList.SelectedValue)); }
private Order AddOrder(Customer customer) { PasswordGenerator gen = new PasswordGenerator() { ConsecutiveCharacters = true, ExcludeSymbols = true, Maximum = 25, Minimum = 25, RepeatCharacters = true }; string orderNo = gen.Generate(); Order order = new Order() { CustomerID = customer.CustomerID, OrderNumber = orderNo, DatePlaced = DateTime.Now, OrderStatusID = (int)OrderStatusEnum.Accepted, Tax = Cart.Tax, Shipping = Cart.Shipping, Total = Cart.Total, OrderDate = DateTime.Now, Active = true, Comments = CommentsTextBox.Text }; if (Cart.GiftRegistryID > 0) { order.Comments = "This is a Gift Registry Order " + order.Comments; } if (ShippingLookupDataDropDownList.Visible) { order.ShippingProviderID = Convert.ToInt32(ShippingLookupDataDropDownList.SelectedValue); } if (ShippingCheckBox.Checked && Cart.GiftRegistryID == 0) { order.Address = BillingAddressControl.Address; order.City = BillingAddressControl.City; order.CountryID = BillingAddressControl.CountryID; order.StateID = BillingAddressControl.StateID; order.ProvinceID = BillingAddressControl.ProvinceID; order.Zipcode = BillingAddressControl.Zipcode; } else if (ShippingCheckBox.Checked && Cart.GiftRegistryID > 0) { // Get the address of the Gift Registry int customerID = GiftRegistries.GetGiftRegistry(Cart.GiftRegistryID, 0, string.Empty, false).CustomerID; Customer registryCustomer = Customers.GetCustomer(customerID); order.Address = registryCustomer.Address; order.City = registryCustomer.City; order.CountryID = registryCustomer.CountryID; order.StateID = registryCustomer.StateID; order.ProvinceID = registryCustomer.ProvinceID; order.Zipcode = registryCustomer.Zipcode; } else { order.Address = ShippingAddressControl.Address; order.City = ShippingAddressControl.City; order.CountryID = ShippingAddressControl.CountryID; order.StateID = ShippingAddressControl.StateID; order.ProvinceID = ShippingAddressControl.ProvinceID; order.Zipcode = ShippingAddressControl.Zipcode; } AddOrderItems(order); order.OrderID = Orders.AddOrder(order); SendNewCustomerOrderEmail(orderNo); EmailManager.SendNewStoreOrderEmail(order, customer); return(order); }