private void Button1_Click(object sender, System.EventArgs e) { OTC.Web.Promotion.OTCPromotion p = new OTC.Web.Promotion.OTCPromotion(Convert.ToInt32(this.ddPromotions.SelectedValue)); OTCProduct pd = new OTCProduct(Convert.ToInt32(this.lstProducts.SelectedValue)); OTCShoppingCart c = new OTCShoppingCart(this.m_page.ShoppingCartId); OTCShoppingCartItem i = new OTCShoppingCartItem(); i.ProductID = pd.ProductId; i.ProductPrice = pd.Price; i.ItemCount = 1; c.AddCartItem(i); c.ApplyPromotion(this.ddPromotions.SelectedItem.Text,c.ShoppingCartID); c = null; c = new OTCShoppingCart(this.m_page.ShoppingCartId); this.txtProductPrice.Text = c.CartTotal.ToString("c"); Response.Write(this.m_page.ShoppingCartId); p.AddPromotionUsage(1,999999); /* OTCProduct pd = new OTCProduct(Convert.ToInt32(this.lstProducts.SelectedValue)); if(p.DiscountAmount > 0) { string displayPrice = Convert.ToDouble(pd.Price - p.DiscountAmount).ToString("c"); this.txtProductPrice.Text = pd.Price.ToString("c"); this.txtPromotionPrice.Text = displayPrice; } if(p.DiscountPercentage > 0) { string displayPrice = Convert.ToDouble(pd.Price - (pd.Price * p.DiscountPercentage)).ToString("c"); this.txtProductPrice.Text = pd.Price.ToString("c"); this.txtPromotionPrice.Text = displayPrice; } */ }
protected void Session_Start(Object sender, EventArgs e) { OTCShoppingCart cart = new OTCShoppingCart(Session.SessionID); OTCUser user = new OTCUser(); Session["shoppingCartId"] = cart.AddNew(); Session["user"] = new OTCUser(); Session["SID"] = 0; Session["WantsMembership"] = true; Session["viewedMemberShip"] = false; Session.Timeout = 240; }
public ITCShoppingCartManager(int cartID) { _cartID = cartID; try { _cart = new OTCShoppingCart(_cartID); } catch(Exception e) { throw new Exception(e.Message); } }
private void Page_Load(object sender, System.EventArgs e) { try { this.m_page = new ITCPage(); OTCShoppingCart cart = new OTCShoppingCart(Session.SessionID); Session["wantsMembership"] = Convert.ToBoolean(Request.QueryString["wantsMembership"]); int productId = getCorrectProductId(Convert.ToInt32(Request.QueryString["PID"])); bool addedItems = false; string f = Request.Form.ToString(); cart = new OTCShoppingCart(this.m_page.ShoppingCartId); //cart.RemoveAllItems(this.m_page.ShoppingCartId); OTCShoppingCartItem item = new OTCShoppingCartItem(); OTCProduct product = new OTCProduct(Convert.ToInt32(productId)); item.ProductID = Convert.ToInt32(productId); item.ProductPrice = product.Price; item.ItemCount = 1; cart.AddCartItem(item); string key = ""; string host = Request.ServerVariables["HTTP_HOST"]; if (host.IndexOf("localhost") > -1 || host == "cjeycjey.homedns.org:9001" || host == "68.14.68.91:40401") Response.Redirect("/interceuticals/order/precheckout.aspx?" + Request.QueryString.ToString() + "&PID2=" + productId + "&SCID=" + this.m_page.ShoppingCartId + "&site=" + Session["site"] + "&" + (key.Length > 0 ? "?PKY=" + key : "")); else if (host == "interceuticals.serveronline.net") Response.Redirect("http://interceuticals.serveronline.net/interceuticals/order/precheckOut.aspx?" + Request.QueryString.ToString() + "&PID2=" + productId + "&SCID=" + this.m_page.ShoppingCartId + "&site=" + Session["site"] + "&" + (key.Length > 0 ? "?PKY=" + key : "")); else Response.Redirect("https://www.interceuticals.com/interceuticals/order/precheckout.aspx?" + Request.QueryString.ToString() + "&PID2=" + productId + "&SCID=" + this.m_page.ShoppingCartId + "&site=" + Session["site"] + "&" + (key.Length > 0 ? "?PKY=" + key : "")); } catch(System.Web.HttpUnhandledException ex) { string mailBody = Request.QueryString.ToString(); EmailSender mail = new EmailSender(); String subject = "Site Error : " + Request.QueryString["PID"]; String notifyEmails = AppLookup.RecipientsAlerts; mail.AddEmailAddresses(notifyEmails); mail.SendEmail(subject, mailBody + (char)10 + ex.Message); Response.Write("There was an error in our process. We apologize for the inconvenience. We have notified the web master and the problem will be addressed shortly."); } }
private void Page_Load(object sender, System.EventArgs e) { this.m_page = new ITCPage(); if (m_page.IsBetterWoman) { Website = "bw"; } else Website = "bm"; string removeId = Request.QueryString.ToString().IndexOf("remove") > -1 ? Request.QueryString["remove"] : "0"; string thread = Request.QueryString.ToString().IndexOf("thread") > -1 ? Request.QueryString["thread"] : ""; string promotionKey = Request.QueryString.ToString().IndexOf("PRID") > -1 ? Request.QueryString["PRID"] : ""; this.m_shoppingCartId = Request.QueryString.ToString().IndexOf("SCID") > -1 ? Convert.ToInt32(Request.QueryString["SCID"]) : 0; m_productID = Convert.ToInt32(Request.QueryString["PID2"]); m_site = Request.QueryString["site"]; if (Convert.ToInt32(removeId) > 0) { OTCShoppingCartItem i = new OTCShoppingCartItem(Convert.ToInt32(removeId)); OTCShoppingCart c = new OTCShoppingCart(this.m_shoppingCartId); c.RemoveCartItem(i); string newQueryString = ""; foreach (string s in Request.QueryString.ToString().Split('&')) { Response.Write(s + "<br>" + CR); if (s != ("remove=" + removeId)) { newQueryString += s + "&"; } } Response.Redirect("Checkout.aspx?" + newQueryString.Trim('&')); } if (Convert.ToInt32(Session["SID"]) > 0) { this.resetForm(); } if (!Page.IsPostBack && (thread != "reset")) { this.ddState.SQL = "spGetOTCState"; this.ddState.TextField = "StateName"; this.ddState.IdField = "StateAbbreviation"; this.ddState.IntroText = "Please Select"; this.ddState.Fill(); bindStateShipControl(); this.ddCountry.IntroText = "Please Select"; this.ddCountry.SQL = "spGetOTCCountry"; this.ddCountry.TextField = "CountryName"; this.ddCountry.IdField = "OTCCountryId"; this.ddCountry.Fill(); int index1 = 0; int index2 = 0; foreach (ListItem i in this.ddCountry.Items) { switch (i.Text) { case "United States": i.Attributes.Add("style", "color:Red"); break; case "Canada": i.Attributes.Add("style", "color:Red"); break; case "Cameroon": index1 = ddCountry.Items.IndexOf(i); break; case "United Arab Emirates": index2 = ddCountry.Items.IndexOf(i); break; } } //ddCountry.Items.Insert(index1 + 1, new ListItem("Canada", "126")); //ddCountry.Items.Insert(index2 + 2, new ListItem("United States", "222")); this.ddShippingCountry.IntroText = "Please Select"; this.ddShippingCountry.SQL = "spGetOTCCountry"; this.ddShippingCountry.TextField = "CountryName"; this.ddShippingCountry.IdField = "OTCCountryId"; this.ddShippingCountry.Fill(); index1 = 0; index2 = 0; foreach (ListItem i in this.ddShippingCountry.Items) { switch (i.Text) { case "United States": i.Attributes.Add("style", "color:Red"); break; case "Canada": i.Attributes.Add("style", "color:Red"); break; case "Cameroon": index1 = ddShippingCountry.Items.IndexOf(i); break; case "United Arab Emirates": index2 = ddShippingCountry.Items.IndexOf(i); break; } } ddShippingCountry.Items.Insert(index1 + 1, new ListItem("Canada", "126")); ddShippingCountry.Items.Insert(index2 + 2, new ListItem("United States", "222")); this.fillCCLists(); this.fillShippingMethods(); } this.fillShippingMethods(); this.m_salesTax = this.ddStateShip.SelectedValue == "MA" ? .0625 : 00; if (Request.ServerVariables["HTTP_HOST"].ToString().IndexOf("localhost") > -1) if (!Page.IsPostBack) this.setDevelopmentForm(); }
/// <summary> /// /// </summary> /// <returns></returns> private double getShippingRate() { OTCShoppingCart cart = new OTCShoppingCart(this.m_shoppingCartId); //Response.Write(cart.CartTotal); double shippingRate = 0.00; double orderTotal = cart.CartTotal; if(orderTotal < 50) shippingRate = 7.99; else if(orderTotal > 50 && orderTotal < 100) shippingRate = 10.99; else if(orderTotal > 100 && orderTotal < 200) shippingRate = 12.99; else shippingRate = 14.99; return(shippingRate); }
/// <summary> /// Need to fix this /// </summary> /// <returns></returns> private double getOrderTotal() { double promotionDiscount = 0.0; string promotionName = ""; if(Request.QueryString.ToString().IndexOf("PKY") > -1){ OTCPromotion p = new OTCPromotion(Request.QueryString["PKY"]); promotionDiscount = p.PromotionDiscount; promotionName = p.PromotionName; } OTCShoppingCart cart = new OTCShoppingCart(this.m_shoppingCartId); double transactionTotal = cart.CartTotal;// + Convert.ToDouble(this.ddShippingMethods.SelectedItem.Value)); double discount = transactionTotal * promotionDiscount; double productTotal = discount> 0 ? (transactionTotal - discount) : transactionTotal; double shippingTotal = Convert.ToDouble(this.ddShippingMethods.SelectedItem.Value); double tax = productTotal * this.m_salesTax; double total = (productTotal + tax) + shippingTotal; return(total); }
protected void btnCheckout_Click(object sender, System.EventArgs e) { if(!(doValidate())) return; int sessionOrderId = Convert.ToInt32(Session["SID"]); ITC itc = new ITC(); OTCShoppingCart cart = new OTCShoppingCart(this.m_shoppingCartId); string promotionKey = Request.Form["promotion"].Length > 0 ? Request.Form["promotion"] : ""; if (promotionKey.Length > 0) { //If we have a promotion, apply here & the next instance will recognize it. We could //have a function that would reload the shopping cart? This is much easier for the sake of time. cart.ApplyPromotion(promotionKey, this.m_shoppingCartId); } //BG - Added swap product sku for international and canadian string shippingType = String.Empty; if (isInternationalAutoShip()) shippingType = "International"; else if (isCanadianAutoShip()) shippingType = "Canadian"; if (!String.IsNullOrEmpty(shippingType)) { foreach (var item in cart.CartItems) swapProduct(shippingType, item.ProductID); } //refresh cart cart = new OTCShoppingCart(this.m_shoppingCartId); OTCSalesOrder order = new OTCSalesOrder(); order.ShoppingCartId = cart.ShoppingCartID; order.OTCPromotionId = cart.OTCPromotionId; order.Address = this.txtAddress.Text; order.City = this.txtCity.Text; order.Country = this.ddCountry.SelectedItem.Text; order.EmailAddress = this.txtEmailAddress.Text; order.FirstName = this.txtFirstName.Text; order.LastName = this.txtLastName.Text; order.Phone = this.txtPhone.Text; order.OrderCost = cart.CartTotal; order.SalesTax = this.m_salesTax; order.OTCSiteId = itc.SiteId; order.ShippingAddress = this.txtShippingAddress.Text; order.ShippingCity = this.txtShippingCity.Text; order.ShippingCost = getShippingCost(this.ddShippingMethods.SelectedItem.Value); order.ShippingFirstName = this.txtShippingFirstName.Text; order.ShippingLastName = this.txtShippingLastName.Text; //order.ShippingState = this.txtShippingStateProvince.Text; order.ShippingState = this.getShippingStateOrProvince(); order.ShippingZip = this.txtShippingZipPostalCode.Text; //bug fix //order.State = this.ddState.SelectedIndex > 0 ? this.ddState.SelectedItem.Text : ""; order.State = this.getBillingStateOrProvince(); order.ShippingPhone = this.txtShippingPhone.Text; order.Zip = this.txtZipPostalCode.Text; order.ShippingCountryId = Convert.ToInt32(this.ddShippingCountry.SelectedValue); order.ShippingCountry = this.ddShippingCountry.SelectedItem.Text; order.ShippingMethod = this.ddShippingMethods.SelectedItem.Text; order.ShippingEmailAddress = this.txtShippingEmailAddress.Text; order.Comments = this.txtComments.Value.Length > 0 ? this.txtComments.Value : ""; int id = order.Add(); OTCCreditCard cc = new OTCCreditCard(); cc.OTCSalesOrderId = order.OTCSalesOrderId; cc.OTCSiteMemberId = order.OTCSiteMemberId; cc.CardNumber = this.txtCardNumber.Text; cc.CardType = this.ddCCType.SelectedValue; cc.ExpirationMonth = this.ddMonth.SelectedValue; cc.ExpirationYear = this.ddYear.SelectedValue; cc.IISSessionId = Session.SessionID; cc.Add(); if(Convert.ToBoolean(Session["WantsMemberShip"])) { OTCPromotion.AddMemberPromotion(order.OTCSiteMemberId,1); } //if(this.txtComments.Value.Length > 0) //{ // OTCContact contact = new OTCContact(); // contact.SiteId = 7; // contact.EmailAddress = this.txtEmailAddress.Text; // contact.FirstName = this.txtFirstName.Text; // contact.LastName = this.txtLastName.Text; // contact.Comment1 = this.txtComments.Value; // contact.Add(); //} try { string sql = ""; this.m_db.Open(); string howDidYouHear = Request.Form["txtHowDidYouHear"]; if(howDidYouHear.Length > 0) { sql = "spInsertOTCSiteMemberQuestionAnswerAffiliation " + "@OTCSiteMemberId = " + order.OTCSiteMemberId + "," + "@OTCSiteMemberQuestionId = 1," + "@OTCSiteMemberAnswerID = 1," + "@AnswerText = " + OTCDatabase.SqlFormat(howDidYouHear) ; this.m_db.SendSQLUpdate(sql); } foreach(string s in Request.Form.ToString().Split('&')){ if(s.IndexOf("mq_") > -1){ int questionId = Convert.ToInt32(s.Split('=')[0].Replace("mq_","")); int answerId = Convert.ToInt32(s.Split('=')[1]); sql = "spInsertOTCSiteMemberQuestionAnswerAffiliation " + "@OTCSiteMemberId = " + order.OTCSiteMemberId + "," + "@OTCSiteMemberQuestionId = " + questionId + "," + "@OTCSiteMemberAnswerID = " + answerId ; this.m_db.SendSQLUpdate(sql); } } sql = "spUpdateCartAbandonmentOrderID @sessionId = " + OTCDatabase.SqlFormat(Session.SessionID); sql += ",@cartId = " + cart.ShoppingCartID; sql += ",@OrderId = " + order.OTCSalesOrderId; this.m_db.SendSQLUpdate(sql); this.m_db.ReleaseConnection(); } catch(Exception ex) {/*do nothing*/} OTCEncryption crypt = new OTCEncryption(7); cart = new OTCShoppingCart(Session.SessionID); Session["shoppingCartId"] = cart.AddNew(); Session["SID"] = 0; if (Page.IsValid) { Session["SessionID"] = Session.SessionID; Response.Redirect("../order/creditcardpost.aspx?OID=" + id.ToString() + "&_ga=" + Request.QueryString["_ga"] + "&site=" + Request.QueryString["site"]); } }
/// <summary> /// /// </summary> public void buildStep1() { OTCShoppingCart cart = new OTCShoppingCart(this.m_shoppingCartId); OTC.Web.Promotion.OTCPromotion p = new OTC.Web.Promotion.OTCPromotion(cart.OTCPromotionId); if(cart.CartItems.Length == 0) this.btnCheckout.Enabled = false; if (cart.CartItems.Length == 0) { Response.Write("<br><br><div align=\"center\" class=\"no-items\"><font color=\"red\">You have no items in your bag!</font><br><a href=\"http://www.interceuticals.com/interceuticals/product/default.aspx" + (this.m_page.IsBetterWoman ? "?site=bw" : "") + "\"><font class=\"tableFont\">continue shopping</a></div>"); Control form = this.Page.Controls[0]; foreach (Control c in form.Controls) { if (c.GetType().ToString() == "System.Web.UI.WebControls.TextBox") { System.Web.UI.WebControls.TextBox ctrl = (System.Web.UI.WebControls.TextBox)c; ctrl.Enabled = false; } } } else { Response.Write(CR + "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" border=\"0\" class=\"tableWrapper\">" + CR + " <tr>" + CR + " <td class=\"rowWrapper\" width=\"50%\"><font class=\"tableFont\">You've Added The Item(s) Below To Your Cart</td>" //+ CR + " <td class=\"rowWrapper\"><font class=\"tableFont\">Quantity</td>" + CR + " <td class=\"rowWrapper\"><font class=\"tableFont\">Unit Price</td>" + CR + " <td class=\"rowWrapper\"><font class=\"tableFont\">Total Price</td>" + CR + " <td> </td>" + CR + " </tr>" + CR ); } //Response.Write(cart.CartItems.Length > 0); //Response.Write(Request.QueryString.ToString()); //return; if(cart.CartItems.Length > 0) { foreach(OTCShoppingCartItem item in cart.CartItems) { string memberShipString = ""; OTCProduct prod = new OTCProduct(item.ProductID); if(item.ProductPrice * item.ItemCount != item.OrderPrice * item.ItemCount) { Response.Write("<tr><td>" + p.PromotionName + " " + p.PromotionDescription + "</td></tr>"); Response.Write(" <tr>" + CR + " <td class=\"productInfo\">" + prod.ProductName + " " + memberShipString + "</td>" //+ CR + " <td class=\"productInfo\">" + item.ItemCount + "</td>" + CR + " <td class=\"productInfoStrikeThrough\">" + item.ProductPrice.ToString("c") + "</td>" + CR + " <td class=\"productInfo\">" + (item.OrderPrice * item.ItemCount).ToString("c") + "</td>" + CR + " <td>[ <a href=\"CheckOut.aspx?" + Request.QueryString.ToString() + "&remove=" + item.ShoppingCartItemID + "\">remove</a> ]</td>" + CR + " </tr>" + CR ); } else { Response.Write(" <tr>" + CR + " <td class=\"productInfo\">" + prod.ProductName + " " + memberShipString + "</td>" //+ CR + " <td class=\"productInfo\">" + item.ItemCount + "</td>" + CR + " <td class=\"productInfo\">" + item.ProductPrice.ToString("c") + "</td>" + CR + " <td class=\"productInfo\">" + (item.ProductPrice * item.ItemCount).ToString("c") + "</td>" + CR + " <td>[ <a href=\"CheckOut.aspx?" + Request.QueryString.ToString() + "&remove=" + item.ShoppingCartItemID + "\">remove</a> ]</td>" + CR + " </tr>" + CR ); } try { if(prod.CategoryId == 21) this.m_googleTrackingCode = "UA-1185020-2"; else this.m_googleTrackingCode = "UA-1185020-1"; } catch(Exception ex) {} } } Response.Write("</table>"); }
public void BuildCartTotals() { double promotionDiscount = 0.00; string promotionName = ""; if(Request.QueryString.ToString().IndexOf("PKY") > -1){ OTCPromotion p = new OTCPromotion(Request.QueryString["PKY"]); promotionDiscount = p.PromotionDiscount; promotionName = p.PromotionName; } OTCShoppingCart cart = new OTCShoppingCart(this.m_shoppingCartId); double transactionTotal = cart.CartTotal;// + Convert.ToDouble(this.ddShippingMethods.SelectedItem.Value)); double discount = transactionTotal * promotionDiscount; double productTotal = discount> 0 ? (transactionTotal - discount) : transactionTotal; double shippingTotal = getShippingCost(this.ddShippingMethods.SelectedItem.Value); double tax = productTotal * this.m_salesTax; double total = (productTotal + tax) + shippingTotal; Response.Write("<input type=\"hidden\" value=\"" + cart.CartTotal + "\" id=\"cartTotal\">" + CR + "<table border=\"0\">" + CR + " <tr>" + CR + " <td>SubTotal: </td>" + CR + " <td><b>" + cart.CartTotal.ToString("c") + "</td>" + CR + " </tr>" + CR + " <tr>" + CR + " <td>Shipping: </td>" + CR + " <td><b><span id=\"shippingTotal\">" + shippingTotal.ToString("c") + "</span></td>" + CR + " </tr>" + CR + " <tr class=\"tax\">" + CR + " <td>Tax: </td>" + CR + " <td>6.25% for MA Residents</td>" + CR + " </tr>" ); if(promotionDiscount > 0) Response.Write(" <tr>" + CR + " <td>Promotion Discount: </td>" + CR + " <td>" + promotionDiscount.ToString("p") + "</td>" + CR + " </tr>" ); this.m_orderTotal = total; Response.Write(" <tr>" + CR + " <td>Total: </td>" + CR + " <td><b><font color=\"red\"><span id=\"total\">" + total.ToString("c") + "</span></td>" + CR + " </tr>" + CR + "</table>" + CR ); }
/// <summary> /// /// </summary> private void resetForm() { int salesOrderId = Convert.ToInt32(Session["SID"]); OTCSalesOrder salesOrder = new OTCSalesOrder(salesOrderId); OTCShoppingCart cart = new OTCShoppingCart(Session.SessionID); Session["shoppingCartId"] = cart.AddNew(); cart = new OTCShoppingCart(Convert.ToInt32(Session["shoppingCartId"])); OTCShoppingCartItem item = new OTCShoppingCartItem(); string sql = "SELECT * FROM OTCSalesOrderDetail WHERE OTCSalesOrderId = " + salesOrder.OTCSalesOrderId; this.m_db.Open(); DataTable dt = this.m_db.GetDataset(sql).Tables[0]; this.m_db.ReleaseConnection(); foreach(DataRow dr in dt.Rows) { item.ProductID = Convert.ToInt32(dr["OTCProductId"]); item.ProductPrice = Convert.ToDouble(dr["ItemPrice"]); item.ItemCount = Convert.ToInt32(dr["ItemCount"]); OTCProduct p = new OTCProduct(item.ProductID); if(p.CategoryId == 21) Session["site"] = "bm"; else Session["site"] = "bw"; cart.AddCartItem(item); } OTCSiteMember m = new OTCSiteMember(salesOrder.OTCSiteMemberId); OTCCreditCard c = new OTCCreditCard(salesOrder.OTCSalesOrderId); if(Page.IsPostBack) return; this.txtAddress.Text = m.Address; //this.txtBillingStreet.Text = m.Address; this.txtCardNumber.Text = c.CardNumber; this.txtCity.Text = m.City; this.txtComments.Value = salesOrder.Comments; this.txtEmailAddress.Text = m.EmailAddress; this.txtFirstName.Text = m.FirstName; this.txtLastName.Text = m.LastName; this.txtPhone.Text = salesOrder.Phone; this.txtZipPostalCode.Text = m.Zip; this.txtShippingAddress.Text = salesOrder.ShippingAddress; this.txtShippingCity.Text = salesOrder.City; this.txtShippingEmailAddress.Text = salesOrder.ShippingEmailAddress; this.txtShippingFirstName.Text = salesOrder.ShippingFirstName; this.txtShippingLastName.Text = salesOrder.LastName; this.txtShippingPhone.Text = salesOrder.Phone; this.txtShippingEmailAddress.Text = salesOrder.EmailAddress; this.txtShippingStateProvince.Text = salesOrder.ShippingState; this.txtShippingZipPostalCode.Text = salesOrder.ShippingZip; this.ddState.SQL = "spGetOTCState"; this.ddState.TextField = "StateName"; this.ddState.IdField = "StateAbbreviation"; this.ddState.IntroText = "Please Select"; this.ddState.Fill(); foreach(ListItem i in this.ddState.Items){ if(i.Text == salesOrder.State){ i.Selected = true; break; } } bindStateShipControl(); foreach (ListItem i in this.ddStateShip.Items) { if (i.Text == salesOrder.State) { i.Selected = true; break; } } this.ddCountry.IntroText = "Please Select"; this.ddCountry.SQL = "spGetOTCCountry"; this.ddCountry.TextField = "CountryName"; this.ddCountry.IdField = "CountryAbbreviation"; this.ddCountry.Fill(); foreach(ListItem i in this.ddCountry.Items){ if(i.Text == salesOrder.Country){ i.Selected = true; break; } if (i.Value == "United States") i.Attributes.Add("style", "color:Blue"); } this.ddShippingCountry.IntroText = "Please Select"; this.ddShippingCountry.SQL = "spGetOTCCountry"; this.ddShippingCountry.TextField = "CountryName"; this.ddShippingCountry.IdField = "OTCCountryId"; this.ddShippingCountry.Fill(); foreach(ListItem i in this.ddShippingCountry.Items){ if(i.Text == salesOrder.Country){ i.Selected = true; break; } } this.fillCCLists(); this.fillShippingMethods(); foreach(ListItem i in this.ddCCType.Items){ if(i.Text== c.CardType){ i.Selected = true; break; } } foreach(ListItem i in this.ddMonth.Items){ if(i.Value == c.ExpirationMonth){ i.Selected = true; break; } } foreach(ListItem i in this.ddYear.Items){ if(i.Value == c.ExpirationYear){ i.Selected = true; break; } } double shippingRate = this.getShippingRate(); this.ddShippingMethods.Items.Clear(); ListItem it = new ListItem(); it.Text = "S/H in US - $" + shippingRate; if(salesOrder.ShippingMethod == it.Text) it.Selected = true; it.Value = "10.99"; this.ddShippingMethods.Items.Add(it); it = new ListItem(); it.Text = "Rush S/H in US - " + (shippingRate + 9.99).ToString(); it.Value = "19.99"; if(salesOrder.ShippingMethod == it.Text) it.Selected = true; this.ddShippingMethods.Items.Add(it); it= new ListItem(); it.Text = "S/H to Canada - $" + (shippingRate + 5.00).ToString(); it.Value = (shippingRate + 5.00).ToString(); if(salesOrder.ShippingMethod == it.Text) it.Selected = true; this.ddShippingMethods.Items.Add(it); it = new ListItem(); it.Text = "S/H to other countries and the Carribean-$30.99"; it.Value = "30.99"; if(salesOrder.ShippingMethod == it.Text) it.Selected = true; this.ddShippingMethods.Items.Add(it); }
private void Page_Load(object sender, System.EventArgs e) { //loadJavaScript(); Session["site"] = this.m_site = Request.QueryString.ToString().IndexOf("site") > - 1 ? Request.QueryString["site"] : "bm"; this.m_googleTrackingCode = (this.m_site == "bm" ? "UA-1185020-2" : "UA-1185020-1"); this.m_preselectedProduct = Request.QueryString.ToString().IndexOf("PID") > - 1 ? Convert.ToInt32(Request.QueryString["PID"]) : 0; this.m_thread = Request.QueryString.ToString().IndexOf("thread") > - 1 ? Request.QueryString["thread"] : ""; this.m_page = new ITCPage(); this.chkAutoship.Attributes.Add("onClick", "changeAutoShipState()"); //this.chkNotAutoship.Attributes.Add("onClick", "changeNotAutoShipState()"); Log.InfoFormat("Starting order for product id: {0}", m_preselectedProduct.ToString()); if(!Page.IsPostBack) { if(this.m_thread == "test") this.txtPromotionCode.Text = Request.QueryString["PKEY"]; OTCDatabase db = new OTCDatabase(); string categoryId = this.m_site == "bm" ? "21" : "22"; db.Open(); this.m_dt = db.GetDataset("spGetINT_VisibleProducts " + categoryId).Tables[0]; db.ReleaseConnection(); OTCShoppingCart cart = new OTCShoppingCart(Session.SessionID); bool haveSelection = false; foreach(DataRow dr in this.m_dt.Rows) { ListItem item = new ListItem(dr["DisplayText"].ToString(),dr["OTCProductId"].ToString()); if(cart.CartContainsProduct(Convert.ToInt32(item.Value)) || cart.CartContainsProduct(Convert.ToInt32(dr["OTCSubordinateProductId"]))){ if(!haveSelection) item.Selected = true; haveSelection = true; } if(!ddProducts.Items.Contains(item)) this.ddProducts.Items.Add(item); } if(Convert.ToBoolean(Session["wantsMembership"])) this.chkAutoship.Checked = true; string file = Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Product\\MembershipHTML\\" + this.ddProducts.SelectedValue + ".htm"; OTCHtmlReader reader = new OTCHtmlReader(file); this.m_membershipHTML = reader.HTML; DirectoryInfo dInfo = new DirectoryInfo(Request.ServerVariables["APPL_PHYSICAL_PATH"] + "Product\\MembershipHTML\\"); foreach(FileInfo f in dInfo.GetFiles()) { reader = new OTCHtmlReader(f.FullName); this.m_hiddenDivs += "<div id=\"div" + f.Name.Replace(".htm","") + "\" class=\"hidden\">" + reader.HTML + "</div>" + CR; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddToCart_Click(object sender, System.EventArgs e) { OTCShoppingCart cart = new OTCShoppingCart(Session.SessionID); //?what am i doing here ? int productId = this.getCorrectProductId(Convert.ToInt32(this.ddProducts.SelectedValue)); bool addedItems = false; string f = Request.Form.ToString(); cart = new OTCShoppingCart(this.m_page.ShoppingCartId); cart.RemoveAllItems(this.m_page.ShoppingCartId); OTCShoppingCartItem item = new OTCShoppingCartItem(); OTCProduct product = new OTCProduct(Convert.ToInt32(this.ddProducts.SelectedValue)); item.ProductID = Convert.ToInt32(productId); item.ProductPrice = product.Price; item.ItemCount = 1; cart.AddCartItem(item); string key = ""; string howie = "?__utma=1.1914565456.1179433560.1179515921.1179867123.5&__utmb=1&__utmc=1&__utmx=-&__utmz=1.1179433560.1.1.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)&__utmv=-&__utmk=233877919"; //if(this.txtPromotionCode.Text.Length > 0) // if(OTCPromotion.PromotionKeyExists(this.txtPromotionCode.Text)) // key = this.txtPromotionCode.Text; if ((Request.ServerVariables["HTTP_HOST"] == "localhost:1047") || (Request.ServerVariables["HTTP_HOST"] == "MVCDesktop")) Response.Redirect("../order/PreCheckOut.aspx" + howie + "&SCID=" + this.m_page.ShoppingCartId + "&site=" + Session["site"] + "&" + (key.Length > 0 ? "?PKY=" + key : "") + Request.QueryString); else if ((Request.ServerVariables["HTTP_HOST"] == "interceuticals.serveronline.net")) Response.Redirect("http://interceuticals.serveronline.net/interceuticals/order/PreCheckOut.aspx" + howie + "&SCID=" + this.m_page.ShoppingCartId + "&site=" + Session["site"] + "&" + (key.Length > 0 ? "?PKY=" + key : "")); else Response.Redirect("https://www.interceuticals.com/interceuticals/order/PreCheckOut.aspx" + howie + "&SCID=" + this.m_page.ShoppingCartId + "&site=" + Session["site"] + "&" + (key.Length > 0 ? "?PKY=" + key : "")); }
public void Close() { if (_product != null) _product = null; if (_item != null) _item = null; if (_cart != null) _cart = null; }
public void buildStep1() { //Note: Using HTML5 in MasterPage. Table attribute only supports border "" or 1. Response.Write("<div align=\"center\">" + CR + "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"2\" border=\"0\" class=\"tableWrapper\">" + CR + " <tr>" + CR + " <td colspan=\"4\" align=\"left\" class=\"formHeader\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><font face=\"arial\" size='4'><b>Your order info: </b></td><td align=\"right\"></td></tr></table></td>" + CR + " </tr>" + CR + " <tr>" + CR + " <td class=\"rowWrapper\" align=\"left\" width=\"50%\"><font class=\"productHeader\">Product</td>" //+ CR + " <td class=\"rowWrapper\"><font class=\"tableFont\">Quantity</td>" + CR + " <td class=\"rowWrapper\" align=\"left\"><font class=\"productHeader\">Unit Price</td>" + CR + " <td class=\"rowWrapper\" align=\"left\"><font class=\"productHeader\">Total Price</td>" + CR + " <td> </td>" + CR + " </tr><tr><td colspan='4'> </td><tr>" + CR ); OTCShoppingCart cart = new OTCShoppingCart(this.m_shoppingCartId); OTC.Web.Promotion.OTCPromotion p = new OTC.Web.Promotion.OTCPromotion(cart.OTCPromotionId); if (cart.CartItems.Length == 0) this.btnCheckout.Enabled = false; if (cart.CartItems.Length == 0) { string baseUrl = "http://www.interceuticals.com/interceuticals/product/default.aspx"; string host = Request.ServerVariables["HTTP_HOST"]; if (host.IndexOf("localhost") > -1) baseUrl = "/interceuticals/product/default.aspx"; Response.Write("<br><br><div align=\"center\" class=\"tableFont\"><font color=\"red\">You have no items in your bag!</font><br><a href=\"" + baseUrl + (this.m_page.IsBetterWoman ? "?site=bw" : "") + "\"><font class=\"tableFont\">continue shopping</a></div><br><br>"); Control form = this.Page.Controls[0]; foreach (Control c in form.Controls) { if (c.GetType().ToString() == "System.Web.UI.WebControls.TextBox") { System.Web.UI.WebControls.TextBox ctrl = (System.Web.UI.WebControls.TextBox)c; ctrl.Enabled = false; } } } if (cart.CartItems.Length > 0) { foreach (OTCShoppingCartItem item in cart.CartItems) { string memberShipString = ""; OTCProduct prod = new OTCProduct(item.ProductID); if (item.ProductPrice * item.ItemCount != item.OrderPrice * item.ItemCount) { Response.Write("<tr><td>" + p.PromotionName + " " + p.PromotionDescription + "</td></tr>"); Response.Write(" <tr>" + CR + " <td align=\"left\" class=\"productInfo\">" + prod.ProductName + " " + memberShipString + "</td>" //+ CR + " <td class=\"productInfo\">" + item.ItemCount + "</td>" + CR + " <td align=\"left\" class=\"productInfoStrikeThrough\">" + item.ProductPrice.ToString("c") + "</td>" + CR + " <td align=\"left\" class=\"productInfo\">" + (item.OrderPrice * item.ItemCount).ToString("c") + "</td>" + CR + " <td>[ <a href=\"PreCheckOut.aspx?" + Request.QueryString.ToString() + "&remove=" + item.ShoppingCartItemID + "\">remove</a> ]</td>" + CR + " </tr>" + CR ); } else { Response.Write(" <tr>" + CR + " <td align=\"left\" class=\"productInfo\">" + prod.ProductName + " " + memberShipString + "</td>" //+ CR + " <td class=\"productInfo\">" + item.ItemCount + "</td>" + CR + " <td align=\"left\" class=\"productInfo\">" + item.ProductPrice.ToString("c") + "</td>" + CR + " <td align=\"left\" class=\"productInfo\">" + (item.ProductPrice * item.ItemCount).ToString("c") + "</td>" + CR + " <td>[ <a href=\"PreCheckOut.aspx?" + Request.QueryString.ToString() + "&remove=" + item.ShoppingCartItemID + "\">remove</a> ]</td>" + CR + " </tr>" + CR ); } try { if (prod.CategoryId == 21) this.m_googleTrackingCode = "UA-1185020-2"; else this.m_googleTrackingCode = "UA-1185020-1"; } catch (Exception ex) { } } } Response.Write("<tr><td colspan='4'> </td><tr></table>" + CR + "</div>" + CR ); }
private void reloadShoppingCart() { if (Convert.ToInt32(m_removeId) > 0) { OTCShoppingCartItem i = new OTCShoppingCartItem(Convert.ToInt32(m_removeId)); OTCShoppingCart c = new OTCShoppingCart(this.m_shoppingCartId); c.RemoveCartItem(i); string newQueryString = ""; foreach (string s in Request.QueryString.ToString().Split('&')) { Response.Write(s + "<br>" + CR); if (s != ("remove=" + m_removeId)) { newQueryString += s + "&"; } } Response.Redirect("PreCheckout.aspx?" + newQueryString.Trim('&')); } }