Exemplo n.º 1
0
        public void RefreshPage()
        {
            Address BillingAddress  = new Address();
            Address ShippingAddress = new Address();

            BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
            ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping);

            if (Checkout)
            {
                if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 ||
                    !ThisCustomer.HasAtLeastOneAddress() || (AppLogic.AppConfigBool("DisallowShippingToPOBoxes") && (!(new POBoxAddressValidator()).IsValid(ShippingAddress))))
                {
                    lblErrorMessage.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                    pnlErrorMsg.Visible  = true;
                }
            }

            ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));

            lblErrorMessage.Text     += Server.HtmlEncode(e.Message);
            pnlAccountUpdated.Visible = AccountUpdated;
            if (AccountUpdated)
            {
                if (!NewEmailAddressAllowed)
                {
                    lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                    ctrlAccount.Email      = ThisCustomer.EMail;
                }
                else
                {
                    lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting);
                }

                //In case email address confirmation is on.
                TextBox txtReEnterEmail = (TextBox)ctrlAccount.FindControl("txtReEnterEmail");
                if (txtReEnterEmail != null)
                {
                    txtReEnterEmail.Text = String.Empty;
                }
            }

            pnlNotCheckOutButtons.Visible      = !Checkout;
            pnlShowWishButton.Visible          = AppLogic.AppConfigBool("ShowWishButtons");
            pnlShowGiftRegistryButtons.Visible = AppLogic.AppConfigBool("ShowGiftRegistryButtons");
            pnlSubscriptionExpiresOn.Visible   = (ThisCustomer.SubscriptionExpiresOn > System.DateTime.Now);
            lblSubscriptionExpiresOn.Text      = String.Format(AppLogic.GetString("account.aspx.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn));
            OriginalEMail.Text = ThisCustomer.EMail;
            //lblCustomerLevel.Visible = pnlCustomerLevel.Visible = (ThisCustomer.CustomerLevelID != 0);
            lblCustomerLevel.Visible      = pnlCustomerLevel.Visible = false;
            lblCustomerLevel.Text         = String.Format(AppLogic.GetString("account.aspx.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CustomerLevelName);
            lblMicroPayEnabled.Visible    = pnlMicroPayEnabled.Visible = (AppLogic.MicropayIsEnabled() && ThisCustomer.IsRegistered && AppLogic.GetMicroPayProductID() != 0);
            lblMicroPayEnabled.Text       = String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance));
            btnContinueToCheckOut.Visible = Checkout;

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (ThisCustomer.PrimaryBillingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryBillingAddress))
            {
                //  pnlBilling.Visible = false;
            }
            if (ThisCustomer.PrimaryShippingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryShippingAddress))
            {
                //pnlShipping.Visible = false;
            }
            lnkChangeBilling.NavigateUrl  = "javascript:self.location='JWMyAddresses.aspx?Checkout=" + Checkout.ToString() + "&AddressType=1&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            lnkChangeShipping.NavigateUrl = "javascript:self.location='JWMyAddresses.aspx?Checkout=" + Checkout.ToString() + "&AddressType=2&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";

            //lnkAddBillingAddress.NavigateUrl = "JWMyAddresses.aspx?add=true&addressType=1&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            //lnkAddBillingAddress.Text = "<div>" + AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting) + "</div>";
            //lnkAddShippingAddress.NavigateUrl = "JWMyAddresses.aspx?add=true&addressType=2&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            //lnkAddShippingAddress.Text = "<div>" + AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting) + "</div>";

            if (BillingAddress.AddressID != 0)
            {
                litBillingAddress.Text = BillingAddress.DisplayHTML(true);
            }
            if (BillingAddress.PaymentMethodLastUsed.Length != 0)
            {
                //need for future use
                //litBillingAddress.Text += "<div>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting);
                //  litBillingAddress.Text += "<div>" + BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed) + "</div>";
            }

            if (!(new POBoxAddressValidator()).IsValid(ShippingAddress))
            {
                litShippingAddress.Text = "<div class='error-wrap'>" + "createaccount_process.aspx.3".StringResource() + "</div>"; //PO box not allowed
            }
            else
            {
                if (ShippingAddress.AddressID != 0)
                {
                    litShippingAddress.Text = "Cannot ship to P.O boxes" + ShippingAddress.DisplayHTML(true);
                }
            }


            pnlOrderHistory.Visible = !Checkout;

            GiftCards gc = new GiftCards(ThisCustomer.CustomerID, GiftCardCollectionFilterType.UsingCustomerID);

            if (gc.Count > 0)
            {
                rptrGiftCards.DataSource = gc;
                rptrGiftCards.DataBind();
                pnlGiftCards.Visible = true;
            }

            if (ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0)
            {
                ltRecurringOrders.Text = "<div class=\"group-header account-header recurring-header\">" + AppLogic.GetString("account.aspx.35", SkinID, ThisCustomer.LocaleSetting) + "</div>";

                // build JS code to show/hide address update block:
                StringBuilder tmpS = new StringBuilder(4096);
                tmpS.Append("<script type=\"text/javascript\">\n");
                tmpS.Append("function toggleLayer(DivID)\n");
                tmpS.Append("{\n");
                tmpS.Append("	var elem;\n");
                tmpS.Append("	var vis;\n");
                tmpS.Append("	if(document.getElementById)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// standards\n");
                tmpS.Append("		elem = document.getElementById(DivID);\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.all)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// old msie versions\n");
                tmpS.Append("		elem = document.all[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.layers)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// nn4\n");
                tmpS.Append("		elem = document.layers[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis = elem.style;\n");
                tmpS.Append("	if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n");
                tmpS.Append("}\n");
                tmpS.Append("</script>\n");
                tmpS.Append("\n");
                tmpS.Append("<style type=\"text/css\">\n");
                tmpS.Append("	.addressBlockDiv { margin: 0px 20px 0px 20px;  display: none;}\n");
                tmpS.Append("</style>\n");
                ltRecurringOrders.Text += tmpS.ToString();

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", con))
                    {
                        while (rsr.Read())
                        {
                            ltRecurringOrders.Text += AppLogic.GetRecurringCart(base.EntityHelpers, base.GetParser, ThisCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false);
                        }
                    }
                }
            }

            string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) };

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " +
                                                               "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes  from dbo.orders   with (NOLOCK)  where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates),
                                                               ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con))
                {
                    orderhistorylist.DataSource = rs;
                    orderhistorylist.DataBind();
                }
            }

            accountaspx55.Visible = (orderhistorylist.Items.Count == 0);

            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true);

            ctrlAccount.Password        = String.Empty;
            ctrlAccount.PasswordConfirm = String.Empty;
        }
Exemplo n.º 2
0
        public void ProcessCart(bool DoingFullCheckout, bool ForceOnePageCheckout, bool InternationalCheckout)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            ThisCustomer.RequireCustomerRecord();
            CartTypeEnum cte = CartTypeEnum.ShoppingCart;

            if (CommonLogic.QueryStringCanBeDangerousContent("CartType").Length != 0)
            {
                cte = (CartTypeEnum)CommonLogic.QueryStringUSInt("CartType");
            }

            cart = new ShoppingCart(1, ThisCustomer, cte, 0, false);

            if (cart.InventoryTrimmed || this.InventoryTrimmed)
            {
                HandleInventoryTrimmed();
                return; //Bail and warn the customer that their cart changed before putting them into checkout
            }

            if (cart.IsEmpty())
            {
                cart.ClearCoupon();
                // can't have this at this point:
                switch (cte)
                {
                case CartTypeEnum.ShoppingCart:
                    Response.Redirect("shoppingcart.aspx");
                    break;

                case CartTypeEnum.WishCart:
                    Response.Redirect("wishlist.aspx");
                    break;

                case CartTypeEnum.GiftRegistryCart:
                    Response.Redirect("giftregistry.aspx");
                    break;

                default:
                    Response.Redirect("shoppingcart.aspx");
                    break;
                }
            }

            // update cart quantities:
            UpdateCartQuantity();

            // save coupon code, no need to reload cart object
            // will update customer record also:
            if (cte == CartTypeEnum.ShoppingCart)
            {
                cart.SetCoupon(CouponCode.Text, true);

                // kind of backwards, but if DisallowOrderNotes is false, then
                // allow order notes
                if (!AppLogic.AppConfigBool("DisallowOrderNotes"))
                {
                    if (OrderNotes.Text.Trim().Length > 0)
                    {
                        SqlParameter sp = new SqlParameter("@OrderNotes", SqlDbType.NText);
                        sp.Value = OrderNotes.Text.Trim();
                        SqlParameter[] spa = { sp };
                        ThisCustomer.UpdateCustomer(spa);
                    }
                }

                // rebind the cart summary control to handle coupon
                ctrlCartSummary.DataSource = cart;

                // check for upsell products
                if (CommonLogic.FormCanBeDangerousContent("Upsell").Length != 0)
                {
                    foreach (String s in CommonLogic.FormCanBeDangerousContent("Upsell").Split(','))
                    {
                        int ProductID = Localization.ParseUSInt(s);
                        if (ProductID != 0)
                        {
                            int VariantID = AppLogic.GetProductsDefaultVariantID(ProductID);
                            if (VariantID != 0)
                            {
                                int            NewRecID = cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, ProductID, VariantID, 1, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, CartTypeEnum.ShoppingCart, true, false, 0, System.Decimal.Zero);
                                Decimal        PR       = AppLogic.GetUpsellProductPrice(0, ProductID, ThisCustomer.CustomerLevelID);
                                SqlParameter[] spa      = { DB.CreateSQLParameter("@Price", SqlDbType.Decimal, 10, PR, ParameterDirection.Input), DB.CreateSQLParameter("@CartRecID", SqlDbType.Int, 4, NewRecID, ParameterDirection.Input) };
                                DB.ExecuteSQL("update shoppingcart set IsUpsell=1, ProductPrice=@Price where ShoppingCartRecID=@CartRecID", spa);
                            }
                        }
                    }
                }

                if (cart.CheckInventory(ThisCustomer.CustomerID))
                {
                    ErrorMsgLabel.Text += Server.HtmlEncode(AppLogic.GetString("shoppingcart_process.aspx.1", SkinID, ThisCustomer.LocaleSetting));
                    // inventory got adjusted, send them back to the cart page to confirm the new values!
                }
            }

            if (cte == CartTypeEnum.WishCart)
            {
                Response.Redirect("wishlist.aspx");
            }
            if (cte == CartTypeEnum.GiftRegistryCart)
            {
                Response.Redirect("giftregistry.aspx");
            }

            cart.ClearShippingOptions();
            if (DoingFullCheckout)
            {
                bool validated =
                    cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")) &&
                    cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")) &&
                    !cart.ExceedsMaximumOrderQuantity(AppLogic.AppConfigUSInt("MaxCartItemsBeforeCheckout")) &&
                    (!cart.HasCoupon() || cart.CouponIsValid);

                if (validated)
                {
                    AppLogic.eventHandler("BeginCheckout").CallEvent("&BeginCheckout=true");

                    if (InternationalCheckout)
                    {
                        Response.Redirect("internationalcheckout.aspx");
                    }

                    if ((ThisCustomer.IsRegistered || ThisCustomer.EMail.Length != 0) && (ThisCustomer.Password.Length == 0 || ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress()))
                    {
                        Response.Redirect("createaccount.aspx?checkout=true");
                    }

                    if (!ThisCustomer.IsRegistered || ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress())
                    {
                        Response.Redirect("createaccount.aspx?checkout=true");
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SkipShippingOnCheckout") || cart.IsAllSystemComponents() || cart.IsAllDownloadComponents())
                        {
                            if (cart.ContainsGiftCard())
                            {
                                Response.Redirect("checkoutgiftcard.aspx");
                            }
                            else
                            {
                                Response.Redirect("checkoutpayment.aspx");
                            }
                        }

                        if ((cart.HasMultipleShippingAddresses() || cart.HasGiftRegistryComponents()) && cart.TotalQuantity() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection)
                        {
                            Response.Redirect("checkoutshippingmult.aspx");
                        }
                        else
                        {
                            Response.Redirect("checkoutshipping.aspx");
                        }
                    }
                }
                InitializePageContent();
            }

            //Make sure promotions is updated when the cart changes
            BindPromotions();
        }
Exemplo n.º 3
0
        public void ProcessCart(bool DoingFullCheckout)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            ThisCustomer.RequireCustomerRecord();
            CartTypeEnum cte = CartTypeEnum.ShoppingCart;

            if (CommonLogic.QueryStringCanBeDangerousContent("CartType").Length != 0)
            {
                cte = (CartTypeEnum)CommonLogic.QueryStringUSInt("CartType");
            }
            cart = new InterpriseShoppingCart(null, 1, ThisCustomer, cte, string.Empty, false, true);

            if (!Page.IsPostBack)
            {
                string couponCode = string.Empty;
                if (cart.HasCoupon(ref couponCode))
                {
                    CouponCode.Text = couponCode;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(CouponCode.Text))
                {
                    cart.ClearCoupon();
                }
            }

            // check if credit on hold
            if (ThisCustomer.IsCreditOnHold)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (cart.IsEmpty())
            {
                // can't have this at this point:
                switch (cte)
                {
                case CartTypeEnum.ShoppingCart:
                    Response.Redirect("shoppingcart.aspx");
                    break;

                case CartTypeEnum.WishCart:
                    Response.Redirect("wishlist.aspx");
                    break;

                case CartTypeEnum.GiftRegistryCart:
                    Response.Redirect("giftregistry.aspx");
                    break;

                default:
                    Response.Redirect("shoppingcart.aspx");
                    break;
                }
            }

            //Make it a method
            UpdateCartItems();

            // save coupon code, no need to reload cart object
            // will update customer record also:
            if (cte == CartTypeEnum.ShoppingCart)
            {
                if (!string.IsNullOrEmpty(CouponCode.Text))
                {
                    string errorMessage = string.Empty;
                    if (cart.IsCouponValid(ThisCustomer, CouponCode.Text, ref errorMessage))
                    {
                        cart.ApplyCoupon(CouponCode.Text);
                    }
                    else
                    {
                        // NULL out the coupon for this cusotmer...
                        InterpriseHelper.ClearCustomerCoupon(ThisCustomer.CustomerCode, ThisCustomer.IsRegistered);

                        ErrorMsgLabel.Text = errorMessage;
                        CouponCode.Text    = string.Empty;
                        return;
                    }
                }

                // check for upsell products
                if (CommonLogic.FormCanBeDangerousContent("Upsell").Length != 0)
                {
                    foreach (string s in CommonLogic.FormCanBeDangerousContent("Upsell").Split(','))
                    {
                        int ProductID = Localization.ParseUSInt(s);
                        if (ProductID == 0)
                        {
                            continue;
                        }

                        string itemCode = InterpriseHelper.GetInventoryItemCode(ProductID);
                        string shippingAddressID;

                        shippingAddressID = CommonLogic.IIF(ThisCustomer.IsNotRegistered, string.Empty, ThisCustomer.PrimaryShippingAddressID);

                        var umInfo = InterpriseHelper.GetItemDefaultUnitMeasure(itemCode);
                        cart.AddItem(ThisCustomer, shippingAddressID, itemCode, ProductID, 1, umInfo.Code, CartTypeEnum.ShoppingCart);
                    }
                }

                bool hasCheckedOptions = false;

                if (pnlOrderOptions.Visible)
                {
                    // Process the Order Options
                    foreach (RepeaterItem ri in OrderOptionsList.Items)
                    {
                        hasCheckedOptions = true;
                        DataCheckBox cbk = (DataCheckBox)ri.FindControl("OrderOptions");
                        if (cbk.Checked)
                        {
                            string      itemCode  = (string)cbk.Data;
                            HiddenField hfCounter = ri.FindControl("hfItemCounter") as HiddenField;
                            TextBox     txtNotes  = ri.FindControl("txtOrderOptionNotes") as TextBox;

                            string strNotes = HttpUtility.HtmlEncode(txtNotes.Text);
                            string notes    = CommonLogic.IIF((strNotes != null), CommonLogic.CleanLevelOne(strNotes), string.Empty);

                            //check the length of order option notes
                            //should not exceed 1000 characters including spaces
                            int maxLen = 1000;
                            if (notes.Length > maxLen)
                            {
                                notes = notes.Substring(0, maxLen);
                            }

                            string unitMeasureCode = string.Empty;

                            // check if the item has only 1 unit measure
                            // hence it's rendered as a label
                            // else it would be rendered as a drop down list
                            Label lblUnitMeasureCode = ri.FindControl("lblUnitMeasureCode") as Label;
                            if (null != lblUnitMeasureCode && lblUnitMeasureCode.Visible)
                            {
                                unitMeasureCode = lblUnitMeasureCode.Text;
                            }
                            else
                            {
                                // it's rendered as combobox because the item has multiple unit measures configured
                                DropDownList cboUnitMeasureCode = ri.FindControl("cboUnitMeasureCode") as DropDownList;
                                if (null != cboUnitMeasureCode && cboUnitMeasureCode.Visible)
                                {
                                    unitMeasureCode = cboUnitMeasureCode.SelectedValue;
                                }
                            }

                            if (CommonLogic.IsStringNullOrEmpty(unitMeasureCode))
                            {
                                throw new ArgumentException("Unit Measure not specified!!!");
                            }

                            //check if this Order Option has Restricted Quantity and Minimum Order Qty set.
                            decimal itemQuantity = 1;

                            using (var con = DB.NewSqlConnection())
                            {
                                con.Open();
                                using (var reader = DB.GetRSFormat(con, "SELECT iw.RestrictedQuantity, iw.MinOrderQuantity FROM InventoryItem i with (NOLOCK) INNER JOIN InventoryItemWebOption iw with (NOLOCK) ON i.ItemCode = iw.ItemCode AND iw.WebsiteCode = {0} WHERE i.ItemCode = {1}", DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode), DB.SQuote(itemCode)))
                                {
                                    if (reader.Read())
                                    {
                                        string  restrictedQuantitiesValue = DB.RSField(reader, "RestrictedQuantity");
                                        decimal minimumOrderQuantity      = Convert.ToDecimal(DB.RSFieldDecimal(reader, "MinOrderQuantity"));
                                        if (!CommonLogic.IsStringNullOrEmpty(restrictedQuantitiesValue))
                                        {
                                            string[] quantityValues = restrictedQuantitiesValue.Split(',');
                                            if (quantityValues.Length > 0)
                                            {
                                                int  ctr  = 0;
                                                bool loop = true;
                                                while (loop)
                                                {
                                                    int    quantity      = 0;
                                                    string quantityValue = quantityValues[ctr];
                                                    if (int.TryParse(quantityValue, out quantity))
                                                    {
                                                        if (quantity >= minimumOrderQuantity)
                                                        {
                                                            itemQuantity = quantity;
                                                            loop         = false;
                                                        }
                                                    }
                                                    ctr++;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (minimumOrderQuantity > 0)
                                            {
                                                itemQuantity = minimumOrderQuantity;
                                            }
                                        }
                                    }
                                }
                            }
                            // Add the selected Order Option....
                            Guid cartItemId = Guid.Empty;
                            cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, itemCode, int.Parse(hfCounter.Value), itemQuantity, unitMeasureCode, CartTypeEnum.ShoppingCart);
                        }
                    }
                }

                if (hasCheckedOptions)
                {
                    //refresh the option items
                    RenderOrderOptions();
                }

                if (OrderNotes.Visible)
                {
                    string sOrderNotes = CommonLogic.CleanLevelOne(OrderNotes.Text);
                    //check the length of order notes
                    //should not exceed 255 characters including spaces
                    if (sOrderNotes.Length > DomainConstants.ORDER_NOTE_MAX_LENGTH)
                    {
                        sOrderNotes = sOrderNotes.Substring(0, DomainConstants.ORDER_NOTE_MAX_LENGTH);
                    }

                    DB.ExecuteSQL(
                        String.Format("UPDATE Customer SET Notes = {0} WHERE CustomerCode = {1}",
                                      sOrderNotes.ToDbQuote(),
                                      ThisCustomer.CustomerCode.ToDbQuote())
                        );
                }
            }
            bool validated = true;

            if (cart.InventoryTrimmed)
            {
                // inventory got adjusted, send them back to the cart page to confirm the new values!
                ErrorMsgLabel.Text += Server.UrlDecode(AppLogic.GetString("shoppingcart.cs.43", SkinID, ThisCustomer.LocaleSetting));
                validated           = false;
            }
            cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);

            if (AppLogic.AppConfigBool("ShowShipDateInCart") && AppLogic.AppConfigBool("ShowStockHints"))
            {
                cart.BuildSalesOrderDetails();
            }

            if (cte == CartTypeEnum.WishCart)
            {
                Response.Redirect("wishlist.aspx");
            }
            if (cte == CartTypeEnum.GiftRegistryCart)
            {
                Response.Redirect("giftregistry.aspx");
            }

            if (DoingFullCheckout)
            {
                if (!cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
                {
                    validated = false;
                }

                if (!cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
                {
                    validated = false;
                }

                string couponCode         = string.Empty;
                string couponErrorMessage = string.Empty;
                if (cart.HasCoupon(ref couponCode) && !cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
                {
                    validated = false;
                }

                //One page checkout is not implemented in mobile.

                //if (AppLogic.AppConfigBool("Checkout.UseOnePageCheckout") && !cart.HasMultipleShippingAddresses())
                //{
                //    Response.Redirect("checkout1.aspx");
                //}

                if (validated)
                {
                    if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryBillingAddressID == string.Empty)) // || !ThisCustomer.HasAtLeastOneAddress()
                    {
                        Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=true&addressType=Billing");
                    }

                    if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryShippingAddressID == string.Empty)) //  || !ThisCustomer.HasAtLeastOneAddress()
                    {
                        Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=False&addressType=Shipping");
                    }

                    if (ThisCustomer.IsNotRegistered || ThisCustomer.PrimaryBillingAddressID == string.Empty || ThisCustomer.PrimaryShippingAddressID == string.Empty || !ThisCustomer.HasAtLeastOneAddress())
                    {
                        Response.Redirect("checkoutanon.aspx?checkout=true");
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SkipShippingOnCheckout") ||
                            !cart.HasShippableComponents())
                        {
                            cart.MakeShippingNotRequired();
                            Response.Redirect("checkoutpayment.aspx");
                        }

                        if ((cart.HasMultipleShippingAddresses() && cart.NumItems() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection))
                        {
                            Response.Redirect("checkoutshippingmult.aspx");
                        }
                        else
                        {
                            Response.Redirect("checkoutshipping.aspx");
                        }
                    }
                }
                InitializePageContent();
            }
        }
Exemplo n.º 4
0
        public void RefreshPage()
        {
            Address BillingAddress  = new Address();
            Address ShippingAddress = new Address();

            BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
            ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping);

            if (Checkout)
            {
                pnlCheckoutImage.Visible = true;
                CheckoutImage.ImageUrl   = AppLogic.SkinImage("step_2.gif");
                if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress() || (AppLogic.AppConfigBool("DisallowShippingToPOBoxes") && CheckPOBox(ShippingAddress.Address1)))
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);;
                }
            }

            String XRI = AppLogic.SkinImage("redarrow.gif");

            redarrow1.ImageUrl       = XRI;
            redarrow2.ImageUrl       = XRI;
            redarrow3.ImageUrl       = XRI;
            pnlCheckoutImage.Visible = Checkout;
            ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));

            ErrorMsgLabel.Text       += Server.HtmlEncode(e.Message);
            pnlAccountUpdated.Visible = AccountUpdated;
            if (AccountUpdated)
            {
                if (!NewEmailAddressAllowed)
                {
                    lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting);
                }
            }

            pnlNotCheckOutButtons.Visible      = !Checkout;
            pnlShowWishButton.Visible          = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("ShowWishButtons");
            pnlShowGiftRegistryButtons.Visible = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("ShowGiftRegistryButtons");
            pnlSubscriptionExpiresOn.Visible   = (ThisCustomer.SubscriptionExpiresOn > System.DateTime.Now);
            lblSubscriptionExpiresOn.Text      = String.Format(AppLogic.GetString("account.aspx.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn));
            OriginalEMail.Text      = ThisCustomer.EMail;
            imgAccountinfo.ImageUrl = AppLogic.SkinImage("accountinfo.gif");
            note1.Visible           = (ThisCustomer.CustomerLevelID != 0);
            note1.Text = String.Format(AppLogic.GetString("account.aspx.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CustomerLevelName);
            MicroPayEnabled.Visible       = (AppLogic.MicropayIsEnabled() && ThisCustomer.IsRegistered && AppLogic.GetMicroPayProductID() != 0);
            MicroPayEnabled.Text          = String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance));
            btnContinueToCheckOut.Visible = Checkout;

            lnkChangeBilling.ImageUrl  = AppLogic.SkinImage("change.gif");
            lnkChangeShipping.ImageUrl = AppLogic.SkinImage("change.gif");
            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (ThisCustomer.PrimaryBillingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryBillingAddress))
            {
                pnlBilling.Visible = false;
            }
            if (ThisCustomer.PrimaryShippingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryShippingAddress))
            {
                pnlShipping.Visible = false;
            }
            lnkChangeBilling.NavigateUrl  = "javascript:self.location='address.aspx?Checkout=" + Checkout.ToString() + "&AddressType=billing&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            lnkChangeShipping.NavigateUrl = "javascript:self.location='address.aspx?Checkout=" + Checkout.ToString() + "&AddressType=shipping&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            imgAddressbook.ImageUrl       = AppLogic.SkinImage("addressbook.gif");

            lnkAddBillingAddress.NavigateUrl  = "address.aspx?add=true&addressType=Billing&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            lnkAddBillingAddress.Text         = AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting);
            lnkAddShippingAddress.NavigateUrl = "address.aspx?add=true&addressType=Shipping&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            lnkAddShippingAddress.Text        = AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting);

            litBillingAddress.Text = BillingAddress.DisplayHTML(Checkout);
            if (BillingAddress.PaymentMethodLastUsed.Length != 0)
            {
                litBillingAddress.Text += "<b>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting) + "</b><br/>";
                litBillingAddress.Text += BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed);
            }

            if (CheckPOBox(ShippingAddress.Address1))
            {
                litShippingAddress.Text = "<span style=\"color:red; font-weight:bold;\">" + "createaccount_process.aspx.3".StringResource() + "</span>"; //PO box not allowed
            }
            else
            {
                litShippingAddress.Text = ShippingAddress.DisplayHTML(Checkout);
            }

            pnlOrderHistory.Visible  = !Checkout;
            imgOrderhistory.ImageUrl = AppLogic.SkinImage("orderhistory.gif");


            if (!AppLogic.m_ProductIsML())
            {
                // gift cards not supported in PRO
            }
            else
            {
                GiftCards gc = new GiftCards(ThisCustomer.CustomerID, GiftCardCollectionFilterType.UsingCustomerID);
                if (gc.Count > 0)
                {
                    rptrGiftCards.DataSource = gc;
                    rptrGiftCards.DataBind();
                    tblGiftCards.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor"));
                    tblGiftCardsBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle"));
                    giftcards_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/giftcards.gif");
                    pnlGiftCards.Visible   = true;
                }
            }
            if (ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0)
            {
                RecurringOrders.Text = "<p align=\"left\"><b>" + AppLogic.GetString("account.aspx.35", SkinID, ThisCustomer.LocaleSetting) + "</b></p>";

                // build JS code to show/hide address update block:
                StringBuilder tmpS = new StringBuilder(4096);
                tmpS.Append("<script type=\"text/javascript\">\n");
                tmpS.Append("function toggleLayer(DivID)\n");
                tmpS.Append("{\n");
                tmpS.Append("	var elem;\n");
                tmpS.Append("	var vis;\n");
                tmpS.Append("	if(document.getElementById)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// standards\n");
                tmpS.Append("		elem = document.getElementById(DivID);\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.all)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// old msie versions\n");
                tmpS.Append("		elem = document.all[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	else if(document.layers)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		// nn4\n");
                tmpS.Append("		elem = document.layers[DivID];\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis = elem.style;\n");
                tmpS.Append("	if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n");
                tmpS.Append("	{\n");
                tmpS.Append("		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n");
                tmpS.Append("	}\n");
                tmpS.Append("	vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n");
                tmpS.Append("}\n");
                tmpS.Append("</script>\n");
                tmpS.Append("\n");
                tmpS.Append("<style type=\"text/css\">\n");
                tmpS.Append("	.addressBlockDiv { margin: 0px 20px 0px 20px;  display: none;}\n");
                tmpS.Append("</style>\n");
                RecurringOrders.Text += tmpS.ToString();

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart   with (NOLOCK)  where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", con))
                    {
                        while (rsr.Read())
                        {
                            RecurringOrders.Text += AppLogic.GetRecurringCart(base.EntityHelpers, base.GetParser, ThisCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false);
                        }
                    }
                }

                RecurringOrders.Text += "<br/><br/>";
            }

            string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) };

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " +
                                                               "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes  from dbo.orders   with (NOLOCK)  where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates),
                                                               ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con))
                {
                    orderhistorylist.DataSource = rs;
                    orderhistorylist.DataBind();
                }
            }

            accountaspx55.Visible = (orderhistorylist.Items.Count == 0);

            ctrlAccount.Password        = String.Empty;
            ctrlAccount.PasswordConfirm = String.Empty;

            ClientScriptManager cs = Page.ClientScript;

            cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true);
        }
Exemplo n.º 5
0
        //converted to private since it should now be called outside
        private void RefreshPage()
        {
            Address BillingAddress  = ThisCustomer.PrimaryBillingAddress;
            Address ShippingAddress = ThisCustomer.PrimaryShippingAddress;

            Checkout = CommonLogic.QueryStringBool("checkout");

            if (Checkout)
            {
                //pnlCheckoutImage.Visible = true;
                //CheckoutImage.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "step_2.gif");
                if (ThisCustomer.PrimaryBillingAddressID == String.Empty || ThisCustomer.PrimaryShippingAddressID == String.Empty || !ThisCustomer.HasAtLeastOneAddress())
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("account.aspx.33", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "&nbsp;&nbsp;";
                }
            }

            //string XRI = AppLogic.LocateImageURL(SkinImagePath + "redarrow.gif");
            //redarrow1.ImageUrl = XRI;
            //redarrow2.ImageUrl = XRI;
            //pnlCheckoutImage.Visible = Checkout;
            //remove unknownerrormsg.Text use ErrorMsgLabel for messages
            ErrorMsgLabel.Text  = Server.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("unknownerror")) + "<br />";
            ErrorMsgLabel.Text += Server.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("errormsg"));

            //Optimize the code - remove lblAcctUpdateMsg and use the ErrorMsgLabel
            ErrorMsgLabel.Text = AppLogic.GetString(AccountUpdated ? "account.aspx.1" : "account.aspx.2", SkinID, ThisCustomer.LocaleSetting);

            //pnlNotCheckOutButtons.Visible = !Checkout;
            pnlShowWishButton.Visible = AppLogic.AppConfigBool("ShowWishListButton");
            //imgAccountinfo.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "accountinfo.gif");
            btnContinueToCheckOut.Visible = Checkout;

            lnkChangeBilling.ImageUrl    = AppLogic.LocateImageURL(string.Format("skins/Skin_{0}/images/change.gif", ThisCustomer.SkinID.ToString()));
            lnkChangeBilling.NavigateUrl = "javascript:self.location='selectaddress.aspx?Checkout=" + Checkout.ToString() + "&AddressType=billing&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
            //imgAddressbook.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "addressbook.gif");
            litBillingAddress.Text = BillingAddress.DisplayHTML(Checkout);
            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = false;
            }
            else
            {
                lnkChangeShipping.ImageUrl        = AppLogic.LocateImageURL(string.Format("skins/Skin_{0}/images/change.gif", this.ThisCustomer.SkinID));
                lnkChangeShipping.NavigateUrl     = "javascript:self.location='selectaddress.aspx?Checkout=" + Checkout.ToString() + "&AddressType=shipping&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
                lnkAddShippingAddress.NavigateUrl = "selectaddress.aspx?add=true&addressType=Shipping&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
                litShippingAddress.Text           = ThisCustomer.PrimaryShippingAddress.DisplayHTML(Checkout);
            }

            if (ThisCustomer.PrimaryBillingAddress.PaymentMethod.Length != 0)
            {
                return;
            }

            litBillingAddress.Text += "<b>" + AppLogic.GetString("account.aspx.9", SkinID, ThisCustomer.LocaleSetting) + "</b><br/>";
            litBillingAddress.Text += ThisCustomer.PrimaryBillingAddress.DisplayPaymentMethod(ThisCustomer);
            //btnOrderHistory.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "orderhistory.gif");
            //change the link to a button- and it's always visible
            //AccountOrderHistoryLink.Visible = true;
        }
        public void RefreshPage()
        {
            Address BillingAddress  = new Address();
            Address ShippingAddress = new Address();

            BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
            ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping);

            if (Checkout)
            {
                pnlCheckoutImage.Visible  = true;
                pnlAccountInfoMP.Visible  = false;
                pnlOrderHistoryMP.Visible = false;
                if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress())
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);;
                }
            }

            pnlCheckoutImage.Visible = Checkout;
            ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg"));

            ErrorMsgLabel.Text       += Server.HtmlEncode(e.Message);
            pnlAccountUpdated.Visible = AccountUpdated;
            if (AccountUpdated)
            {
                if (!NewEmailAddressAllowed)
                {
                    lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting);
                }
            }

            OriginalEMail.Text            = ThisCustomer.EMail;
            btnContinueToCheckOut.Visible = phContinueCheckout.Visible = Checkout;

            if (ThisCustomer.PrimaryBillingAddressID == 0)
            {
                pnlBilling.Visible = false;
            }
            if (ThisCustomer.PrimaryShippingAddressID == 0)
            {
                pnlShipping.Visible = false;
            }

            lnkAddBillingAddress.NavigateUrl  = "address.aspx?add=true&addressType=Billing&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            lnkAddBillingAddress.Text         = AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting);
            lnkAddShippingAddress.NavigateUrl = "address.aspx?add=true&addressType=Shipping&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
            lnkAddShippingAddress.Text        = AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting);

            litBillingAddress.Text = BillingAddress.DisplayHTML(Checkout);
            if (BillingAddress.PaymentMethodLastUsed.Length != 0)
            {
                litBillingAddress.Text += "<b>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting) + "</b><br/>";
                litBillingAddress.Text += BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed);
            }

            litShippingAddress.Text = ShippingAddress.DisplayHTML(Checkout);
            pnlOrderHistory.Visible = !Checkout;

            if (!String.IsNullOrEmpty(ShippingAddress.Address1))
            {
                litShipTeaser.Text = "(" + TextUtil.ClipText(ShippingAddress.Address1, 15) + ")";
            }

            if (!String.IsNullOrEmpty(BillingAddress.Address1))
            {
                litBillTeaser.Text = "(" + TextUtil.ClipText(BillingAddress.Address1, 15) + ")";
            }

            string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) };

            using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
            {
                con.Open();
                using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " +
                                                               "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes  from dbo.orders   with (NOLOCK)  where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates),
                                                               ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con))
                {
                    orderhistorylist.DataSource = rs;
                    orderhistorylist.DataBind();
                }
            }

            accountaspx55.Visible = (orderhistorylist.Items.Count == 0);

            #region Vortx Mobile Modification
            pnlOrderHistory.Visible = !accountaspx55.Visible;
            #endregion

            ctrlAccount.Password        = String.Empty;
            ctrlAccount.PasswordConfirm = String.Empty;

            ClientScriptManager cs = Page.ClientScript;
            cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true);
        }
Exemplo n.º 7
0
        public void RefreshPage()
        {
            Address BillingAddress  = ThisCustomer.PrimaryBillingAddress;
            Address ShippingAddress = ThisCustomer.PrimaryShippingAddress;

            Checkout = CommonLogic.QueryStringBool("checkout");

            if (Checkout)
            {
                pnlCheckoutImage.Visible = true;
                CheckoutImage.ImageUrl   = AppLogic.LocateImageURL(SkinImagePath + "step_2.gif");
                if (ThisCustomer.PrimaryBillingAddressID == string.Empty || ThisCustomer.PrimaryShippingAddressID == string.Empty || !ThisCustomer.HasAtLeastOneAddress())
                {
                    ErrorMsgLabel.Text = AppLogic.GetString("account.aspx.33", ThisCustomer.SkinID, ThisCustomer.LocaleSetting, true) + "&nbsp;&nbsp;";
                }
            }

            string XRI = AppLogic.LocateImageURL(SkinImagePath + "redarrow.gif");

            redarrow1.ImageUrl        = XRI;
            redarrow2.ImageUrl        = XRI;
            pnlCheckoutImage.Visible  = Checkout;
            unknownerrormsg.Text      = Server.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("unknownerror"));
            ErrorMsgLabel.Text       += Server.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("errormsg"));
            pnlAccountUpdated.Visible = AccountUpdated;
            if (AccountUpdated)
            {
                lblAcctUpdateMsg.Text = AppLogic.GetString("account.aspx.1", SkinID, ThisCustomer.LocaleSetting, true);
            }
            else
            {
                lblAcctUpdateMsg.Text = AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting, true);
            }

            pnlNotCheckOutButtons.Visible = !Checkout;
            pnlShowWishButton.Visible     = AppLogic.AppConfigBool("ShowWishListButton");
            btnContinueToCheckOut.Visible = Checkout;

            lnkChangeBilling.ImageUrl    = AppLogic.LocateImageURL(SkinImagePath + "change.gif");
            lnkChangeBilling.NavigateUrl = "javascript:self.location='selectaddress.aspx?Checkout=" + Checkout.ToString() + "&AddressType=billing&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";

            litBillingAddress.Text = BillingAddress.DisplayHTML(Checkout);

            if (!AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"))
            {
                pnlShipping.Visible = false;
            }
            else
            {
                lnkChangeShipping.ImageUrl        = AppLogic.LocateImageURL(SkinImagePath + "change.gif");
                lnkChangeShipping.NavigateUrl     = "javascript:self.location='selectaddress.aspx?Checkout=" + Checkout.ToString() + "&AddressType=shipping&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'";
                lnkAddShippingAddress.NavigateUrl = "selectaddress.aspx?add=true&addressType=Shipping&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString());
                litShippingAddress.Text           = ShippingAddress.DisplayHTML(Checkout);
            }

            if (BillingAddress.PaymentMethod.Length == 0)
            {
                litBillingAddress.Text += "<b>" + AppLogic.GetString("account.aspx.9", SkinID, ThisCustomer.LocaleSetting, true) + "</b><br/>";
                litBillingAddress.Text += BillingAddress.DisplayPaymentMethod(ThisCustomer);
            }

            // btnOrderHistory.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "orderhistory.gif");
            accountOrderHistoryLink.Visible = true;
        }