/// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (customerObj == null)
        {
            return;
        }

        if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers");
        }

        if (customerId != 0)
        {
            string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine")
                                  .NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity")
                                  .NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode")
                                  .NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result;

            // Check country presence
            if (errorMessage == "" && (ucCountrySelector.CountryID <= 0))
            {
                errorMessage = GetString("countryselector.selectedcountryerr");
            }

            if (errorMessage == "")
            {
                // Get object
                AddressInfo addressObj = AddressInfoProvider.GetAddressInfo(addressId);
                if (addressObj == null)
                {
                    addressObj = new AddressInfo();
                }

                addressObj.AddressIsBilling    = chkAddressIsBilling.Checked;
                addressObj.AddressIsShipping   = chkAddressIsShipping.Checked;
                addressObj.AddressZip          = txtAddressZip.Text.Trim();
                addressObj.AddressPhone        = txtAddressDeliveryPhone.Text.Trim();
                addressObj.AddressPersonalName = txtPersonalName.Text.Trim();
                addressObj.AddressLine1        = txtAddressLine1.Text.Trim();
                addressObj.AddressEnabled      = chkAddressEnabled.Checked;
                addressObj.AddressLine2        = txtAddressLine2.Text.Trim();
                addressObj.AddressCity         = txtAddressCity.Text.Trim();
                addressObj.AddressCountryID    = ucCountrySelector.CountryID;
                addressObj.AddressStateID      = ucCountrySelector.StateID;
                addressObj.AddressIsCompany    = chkAddressIsCompany.Checked;
                addressObj.AddressName         = AddressInfoProvider.GetAddressName(addressObj);
                addressObj.AddressCustomerID   = customerId;

                AddressInfoProvider.SetAddressInfo(addressObj);

                URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerId + "&addressId=" + Convert.ToString(addressObj.AddressID) + "&saved=1");
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = errorMessage;
            }
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        int addressId = ValidationHelper.GetInteger(actionArgument, 0);

        if (actionName == "edit")
        {
            URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerObj.CustomerID + "&addressId=" + addressId);
        }
        else if (actionName == "delete")
        {
            if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers");
            }

            var address = AddressInfoProvider.GetAddressInfo(addressId);

            // Check for the address dependencies
            if ((address != null) && address.Generalized.CheckDependencies())
            {
                ShowError(ECommerceHelper.GetDependencyMessage(address));
                return;
            }

            // Delete AddressInfo object from database
            AddressInfoProvider.DeleteAddressInfo(address);
        }
    }
    /// <summary>
    /// Binds address object from controls
    /// </summary>
    /// <param name="customerID"></param>
    /// <returns> AddressInfo object</returns>
    private AddressInfo BindAddressObject(int customerID)
    {
        try
        {
            int itemID = Request.QueryString["id"] != null?ValidationHelper.GetInteger(Request.QueryString["id"], default(int)) : default(int);

            if (itemID != default(int))
            {
                var customerData = IsUserCustomer(CurrentUser.UserID);
                if (!DataHelper.DataSourceIsEmpty(customerData))
                {
                    var addressData = AddressInfoProvider.GetAddressInfo(itemID);
                    if (!DataHelper.DataSourceIsEmpty(addressData))
                    {
                        addressData.AddressLine1        = ValidationHelper.GetString(txtAddressLine1.Text.Trim(), string.Empty);
                        addressData.AddressLine2        = ValidationHelper.GetString(txtAddressLine2.Text.Trim(), string.Empty);
                        addressData.AddressCity         = ValidationHelper.GetString(txtCity.Text.Trim(), string.Empty);
                        addressData.AddressZip          = ValidationHelper.GetString(txtZipcode.Text.Trim(), string.Empty);
                        addressData.AddressName         = string.Format("{0}{1}{2}", !string.IsNullOrEmpty(addressData.AddressLine1) ? addressData.AddressLine1 + "," : addressData.AddressLine1, !string.IsNullOrEmpty(addressData.AddressLine2) ? addressData.AddressLine2 + "," : addressData.AddressLine2, addressData.AddressCity);
                        addressData.AddressPhone        = ValidationHelper.GetString(txtTelephone.Text.Trim(), string.Empty);
                        addressData.AddressPersonalName = ValidationHelper.GetString(txtName.Text.Trim(), string.Empty);
                        addressData.AddressCountryID    = ValidationHelper.GetInteger(uniSelectorCountry.Value, 0);
                        addressData.AddressStateID      = ValidationHelper.GetInteger(uniSelectorState.Value, 0);
                        addressData.SetValue("AddressType", ddlAddressType.ValueDisplayName);
                        addressData.SetValue("Email", txtEmail.Text.Trim());
                        addressData.SetValue("CompanyName", txtComapnyName.Text.Trim());
                        addressData.SetValue("AddressTypeID", ddlAddressType.Value);
                        addressData.SetValue("Status", ddlStatus.SelectedValue);
                        return(addressData);
                    }
                }
            }
            else
            {
                AddressInfo objAddress = new AddressInfo();
                objAddress.AddressLine1      = ValidationHelper.GetString(txtAddressLine1.Text.Trim(), string.Empty);
                objAddress.AddressLine2      = ValidationHelper.GetString(txtAddressLine2.Text.Trim(), string.Empty);
                objAddress.AddressCity       = ValidationHelper.GetString(txtCity.Text.Trim(), string.Empty);
                objAddress.AddressZip        = ValidationHelper.GetString(txtZipcode.Text.Trim(), string.Empty);
                objAddress.AddressCustomerID = customerID;
                objAddress.AddressName       = string.Format("{0}{1}{2}", !string.IsNullOrEmpty(objAddress.AddressLine1) ? objAddress.AddressLine1 + "," : objAddress.AddressLine1,
                                                             !string.IsNullOrEmpty(objAddress.AddressLine2) ? objAddress.AddressLine2 + "," : objAddress.AddressLine2, objAddress.AddressCity);
                objAddress.AddressPhone        = ValidationHelper.GetString(txtTelephone.Text.Trim(), string.Empty);
                objAddress.AddressPersonalName = ValidationHelper.GetString(txtName.Text.Trim(), string.Empty);
                objAddress.AddressCountryID    = ValidationHelper.GetInteger(uniSelectorCountry.Value, 0);
                objAddress.AddressStateID      = ValidationHelper.GetInteger(uniSelectorState.Value, 0);
                objAddress.SetValue("AddressType", ddlAddressType.ValueDisplayName);
                objAddress.SetValue("Email", txtEmail.Text.Trim());
                objAddress.SetValue("CompanyName", txtComapnyName.Text.Trim());
                objAddress.SetValue("AddressTypeID", ddlAddressType.Value);
                objAddress.SetValue("Status", ddlStatus.SelectedValue);
                return(objAddress);
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("CreateAddress.ascx.cs", "BindAddressObject()", ex);
        }
        return(null);
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Orders.General"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Orders.General");
        }

        this.CurrentMaster.Title.TitleText = GetString("Order_Edit_Address.Title");

        rqvCity.ErrorMessage         = GetString("Customer_Edit_Address_Edit.rqvCity");
        rqvLine.ErrorMessage         = GetString("Customer_Edit_Address_Edit.rqvLine");
        rqvZipCode.ErrorMessage      = GetString("Customer_Edit_Address_Edit.rqvZipCode");
        rqvPersonalName.ErrorMessage = GetString("Customer_Edit_Address_Edit.rqvPersonalName");

        // control initializations
        lblAddressZip.Text = GetString("Customer_Edit_Address_Edit.AddressZipLabel");
        //lblAddressState.Text = GetString("Customer_Edit_Address_Edit.AddressStateIDLabel");
        lblAddressDeliveryPhone.Text = GetString("Customer_Edit_Address_Edit.AddressDeliveryPhoneLabel");
        lblAddressCountry.Text       = GetString("Customer_Edit_Address_Edit.AddressCountryIDLabel");
        //lblAddressName.Text = GetString("Customer_Edit_Address_Edit.AddressNameLabel");
        //lblAddressLine3.Text = GetString("Customer_Edit_Address_Edit.AddressLine3Label");
        lblAddressLine1.Text = GetString("Customer_Edit_Address_Edit.AddressLine1Label");
        //lblAddressLine2.Text = GetString("Customer_Edit_Address_Edit.AddressLine2Label");
        lblAddressCity.Text  = GetString("Customer_Edit_Address_Edit.AddressCityLabel");
        lblPersonalName.Text = GetString("Customer_Edit_Address_Edit.lblPersonalName");

        btnOk.Text     = GetString("General.OK");
        btnCancel.Text = GetString("General.Cancel");

        // Get ids from querystring
        customerId = QueryHelper.GetInteger("customerId", 0);
        addressId  = QueryHelper.GetInteger("addressId", 0);
        typeId     = QueryHelper.GetInteger("typeId", -1);

        if (addressId > 0)
        {
            AddressInfo addressObj = AddressInfoProvider.GetAddressInfo(addressId);
            EditedObject = addressObj;

            if (addressObj != null)
            {
                // fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(addressObj);
                }
            }
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_Address/object.png");
        }

        else
        {
            if (!RequestHelper.IsPostBack())
            {
                // Init data due to customer settings
                InitData();
            }
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_Address/new.png");
        }
    }
        public JsonResult CustomerAddress(int addressID)
        {
            // Gets the address with its ID
            AddressInfo address = AddressInfoProvider.GetAddressInfo(addressID);

            // Checks whether the address was retrieved
            if (address == null)
            {
                return(null);
            }

            // Creates a response with all address information
            var responseModel = new
            {
                Line1        = address.AddressLine1,
                Line2        = address.AddressLine2,
                City         = address.AddressCity,
                PostalCode   = address.AddressZip,
                CountryID    = address.AddressCountryID,
                StateID      = address.AddressStateID,
                PersonalName = address.AddressPersonalName
            };

            // Returns serialized information of the address
            return(Json(responseModel));
        }
Esempio n. 6
0
 /// <summary>
 /// Create Shopping cart with item by customer
 /// </summary>
 /// <param name="customerAddressID"></param>
 /// <param name="txtQty"></param>
 private void CreateShoppingCartByCustomer(SKUInfo product, int customerAddressID, int productQty, double skuPrice)
 {
     try
     {
         var customerAddress = AddressInfoProvider.GetAddressInfo(customerAddressID);
         if (!DataHelper.DataSourceIsEmpty(product))
         {
             ShoppingCartInfo cart = new ShoppingCartInfo();
             cart.ShoppingCartSiteID     = CurrentSite.SiteID;
             cart.ShoppingCartCustomerID = customerAddressID;
             cart.ShoppingCartCurrencyID = CurrencyInfoProvider.GetMainCurrency(CurrentSite.SiteID).CurrencyID;
             cart.SetValue("ShoppingCartCampaignID", ProductCampaignID);
             cart.SetValue("ShoppingCartProgramID", ProductProgramID);
             cart.SetValue("ShoppingCartDistributorID", customerAddressID);
             cart.SetValue("ShoppingCartInventoryType", ProductType);
             cart.User = CurrentUser;
             cart.ShoppingCartShippingAddress  = customerAddress;
             cart.ShoppingCartShippingOptionID = ProductShippingID;
             ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
             ShoppingCartItemParameters parameters = new ShoppingCartItemParameters(product.SKUID, productQty);
             parameters.CustomParameters.Add("CartItemCustomerID", customerAddressID);
             ShoppingCartItemInfo cartItem = cart.SetShoppingCartItem(parameters);
             cartItem.SetValue("CartItemPrice", skuPrice);
             cartItem.SetValue("CartItemDistributorID", customerAddressID);
             cartItem.SetValue("CartItemCampaignID", ProductCampaignID);
             cartItem.SetValue("CartItemProgramID", ProductProgramID);
             ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(cartItem);
             cart.InvalidateCalculations();
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CustomerCartOperations.ascx.cs", "CreateShoppingCartByCustomer()", ex);
     }
 }
Esempio n. 7
0
    protected void drpAddresses_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Get selected address
        int         selectedAddressId = ValidationHelper.GetInteger(drpAddresses.SelectedValue, 0);
        AddressInfo address           = AddressInfoProvider.GetAddressInfo(selectedAddressId);

        SetupSelectedAddress(address, true);
    }
Esempio n. 8
0
    /// <summary>
    /// On btnOK click, save edited or new created address.
    /// </summary>
    protected void btnOK_OnClick(object sender, EventArgs e)
    {
        if (mCustomerId != 0)
        {
            // Check field emptiness
            string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine").NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity").NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode").NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result;

            // Check country presence
            if ((errorMessage == "") && (ucCountrySelector.CountryID <= 0))
            {
                errorMessage = GetString("countryselector.selectedcountryerr");
            }

            if (errorMessage == "")
            {
                AddressInfo ai = null;
                // Create new addressinfo or get the existing one
                if (AddressId == 0)
                {
                    ai = new AddressInfo();
                    ai.AddressEnabled    = true;
                    ai.AddressIsBilling  = true;
                    ai.AddressIsShipping = true;
                    ai.AddressIsCompany  = true;
                    ai.AddressCustomerID = mCustomerId;
                }
                else
                {
                    ai = AddressInfoProvider.GetAddressInfo(AddressId);
                }

                if (ai != null)
                {
                    ai.AddressPersonalName = txtPersonalName.Text;
                    ai.AddressLine1        = txtAddressLine1.Text;
                    ai.AddressLine2        = txtAddressLine2.Text;
                    ai.AddressCity         = txtAddressCity.Text;
                    ai.AddressZip          = txtAddressZip.Text;
                    ai.AddressCountryID    = ucCountrySelector.CountryID;
                    ai.AddressStateID      = ucCountrySelector.StateID;
                    ai.AddressPhone        = txtAddressDeliveryPhone.Text;
                    ai.AddressName         = AddressInfoProvider.GetAddressName(ai);
                    // Save addressinfo
                    AddressInfoProvider.SetAddressInfo(ai);
                    AddressId = ai.AddressID;

                    lblInfo.Visible = true;
                    lblAddress.Text = "> " + HTMLHelper.HTMLEncode(ai.AddressName);
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = errorMessage;
            }
        }
    }
        public void DeleteAddress(int addressID)
        {
            var address = AddressInfoProvider.GetAddressInfo(addressID);

            if (address != null)
            {
                AddressInfoProvider.DeleteAddressInfo(addressID);
            }
        }
        public ActionResult DeliveryDetails(DeliveryDetailsViewModel model)
        {
            // Gets the user's current shopping cart
            ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart();

            // Gets all enabled shipping options for the shipping option selector
            SelectList shippingOptions = new SelectList(ShippingOptionInfoProvider.GetShippingOptions(SiteContext.CurrentSiteID, true).ToList(),
                                                        "ShippingOptionID",
                                                        "ShippingOptionDisplayName");

            // If the ModelState is not valid, assembles the country list and the shipping option list and displays the step again
            if (!ModelState.IsValid)
            {
                model.BillingAddress.Countries       = new SelectList(CountryInfoProvider.GetCountries(), "CountryID", "CountryDisplayName");
                model.ShippingOption.ShippingOptions = new ShippingOptionViewModel(ShippingOptionInfoProvider.GetShippingOptionInfo(shoppingService.GetShippingOption()), shippingOptions).ShippingOptions;
                return(View(model));
            }

            // Gets the shopping cart's customer and applies the customer details from the checkout process step
            var customer = shoppingService.GetCurrentCustomer();

            if (customer == null)
            {
                UserInfo userInfo = cart.User;
                if (userInfo != null)
                {
                    customer = CustomerHelper.MapToCustomer(cart.User);
                }
                else
                {
                    customer = new CustomerInfo();
                }
            }
            model.Customer.ApplyToCustomer(customer);

            // Sets the updated customer object to the current shopping cart
            shoppingService.SetCustomer(customer);

            // Gets the shopping cart's billing address and applies the billing address from the checkout process step
            var address = AddressInfoProvider.GetAddressInfo(model.BillingAddress.AddressID) ?? new AddressInfo();

            model.BillingAddress.ApplyTo(address);

            // Sets the address personal name
            address.AddressPersonalName = $"{customer.CustomerFirstName} {customer.CustomerLastName}";

            // Saves the billing address
            shoppingService.SetBillingAddress(address);

            // Sets the selected shipping option and evaluates the cart
            shoppingService.SetShippingOption(model.ShippingOption.ShippingOptionID);

            // Redirects to the next step of the checkout process
            return(RedirectToAction("PreviewAndPay"));
        }
        public void SetShoppingCartAddress(int addressId)
        {
            var cart = ECommerceContext.CurrentShoppingCart;

            if (cart.ShoppingCartShippingAddress == null || cart.ShoppingCartShippingAddress.AddressID != addressId)
            {
                var address = AddressInfoProvider.GetAddressInfo(addressId);
                cart.ShoppingCartShippingAddress = address;
                ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Updates business unit for distributor
        /// </summary>
        /// <param name="distributorID">Distributor ID</param>
        public static void UpdateDistributorsBusinessUnit(int distributorID)
        {
            AddressInfo distributor        = AddressInfoProvider.GetAddressInfo(distributorID);
            long        businessUnitNumber = ValidationHelper.GetLong(Cart.GetValue("BusinessUnitIDForDistributor"), default(long));

            if (distributor != null && businessUnitNumber != default(long))
            {
                distributor.SetValue("BusinessUnit", businessUnitNumber);
                AddressInfoProvider.SetAddressInfo(distributor);
            }
        }
        /// <summary>
        /// Returns a customer's address with the specified identifier.
        /// </summary>
        /// <param name="addressId">Identifier of the customer's address.</param>
        /// <returns>Customer's address with the specified identifier. Returns <c>null</c> if not found.</returns>
        public CustomerAddress GetById(int addressId)
        {
            var addressInfo = AddressInfoProvider.GetAddressInfo(addressId);

            if (addressInfo == null)
            {
                return(null);
            }

            return(new CustomerAddress(addressInfo));
        }
Esempio n. 14
0
    protected void ddlShippingOption_SelectedIndexChanged(object sender, EventArgs e)
    {
        int PriceID   = ValidationHelper.GetInteger(ddlShippingOption.SelectedValue, -1);
        int CountryID = (AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID)).AddressCountryID;

        // SessionHelper.SetValue("PriceID", PriceID);
        // SessionHelper.SetValue("CountryID", CountryID);

        ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartPriceID", PriceID);
        ShippingExtendedInfoProvider.SetCustomFieldValue(ShoppingCart, "ShoppingCartCountryID", CountryID);

        //btnUpdate_Click1(null, null);
        //DisplayTotalPrice();
    }
    protected void UpdateCartAddress(object sender, EventArgs e)
    {
        var list      = sender as RadioButtonList;
        int addressId = 0;

        if (list == null || list.SelectedItem == null || !int.TryParse(list.SelectedItem.Value, out addressId))
        {
            return;
        }

        var address = AddressInfoProvider.GetAddressInfo(addressId);

        CurrentCartAddress = address;
    }
    /// <summary>
    /// Loads selected company address info.
    /// </summary>
    protected void LoadCompanyAddressInfo()
    {
        // Load company address info only if company part is visible
        if (plcCompanyDetail.Visible)
        {
            // Try to select company address from ViewState first
            if (!ShoppingCartControl.IsCurrentStepPostBack && ShoppingCartControl.GetTempValue(COMPANY_ADDRESS_ID) != null)
            {
                LoadCompanyFromViewState();
            }
            else
            {
                if (drpCompanyAddress.SelectedValue != "0")
                {
                    var addressId = Convert.ToInt32(drpCompanyAddress.SelectedValue);

                    var ai = AddressInfoProvider.GetAddressInfo(addressId);
                    if (ai != null)
                    {
                        txtCompanyName.Text        = ai.AddressPersonalName;
                        txtCompanyLine1.Text       = ai.AddressLine1;
                        txtCompanyLine2.Text       = ai.AddressLine2;
                        txtCompanyCity.Text        = ai.AddressCity;
                        txtCompanyZip.Text         = ai.AddressZip;
                        txtCompanyPhone.Text       = ai.AddressPhone;
                        CountrySelector3.CountryID = ai.AddressCountryID;
                        CountrySelector3.StateID   = ai.AddressStateID;
                        CountrySelector3.ReloadData(true);
                    }
                }
                else
                {
                    // clean shipping part of the form
                    CleanForm(false, false, true);

                    // Prefill customer company name or full name
                    if ((ShoppingCart.Customer != null) &&
                        (ShoppingCart.Customer.CustomerCompany != ""))
                    {
                        txtCompanyName.Text = ShoppingCart.Customer.CustomerCompany;
                    }
                    else
                    {
                        txtCompanyName.Text = ShoppingCart.Customer.CustomerFirstName + " " + ShoppingCart.Customer.CustomerLastName;
                    }
                }
            }
        }
    }
Esempio n. 17
0
    protected void btnHiddenEdit_Click(object sender, EventArgs e)
    {
        // Get AddressId from the row
        AddressId = ValidationHelper.GetInteger(hdnID.Value, 0);

        plhList.Visible = false;
        plhEdit.Visible = true;

        AddressInfo ai = AddressInfoProvider.GetAddressInfo(AddressId);

        if (ai != null)
        {
            LoadData(ai);
        }
    }
    protected void drpAddresses_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Get selected address
        int         selectedAddressId = ValidationHelper.GetInteger(drpAddresses.SelectedValue, 0);
        AddressInfo address           = AddressInfoProvider.GetAddressInfo(selectedAddressId);

        // Set address as current and propagate into UIForm
        if (address != null)
        {
            CurrentCartAddress = address;
        }

        SetupSelectedAddress();

        addressForm.ReloadData();
    }
        public string GetDistributorBusinessUnit(int distributorID)
        {
            string businessUnit = string.Empty;

            if (distributorID > 0)
            {
                AddressInfo address = AddressInfoProvider.GetAddressInfo(distributorID);
                if (address != null)
                {
                    long            businessUnitNumber = ValidationHelper.GetLong(address.GetValue("BusinessUnit"), default(long));
                    CustomTableItem businessUnitItem   = CustomTableItemProvider.GetItems(BusinessUnitsCustomTableName, "BusinessUnitNumber=" + businessUnitNumber).FirstOrDefault();
                    businessUnit = businessUnitItem != null?businessUnitItem.GetStringValue("BusinessUnitName", string.Empty) : string.Empty;
                }
            }
            return(businessUnit);
        }
    /// <summary>
    /// Loads selected billing  address info.
    /// </summary>
    protected void LoadBillingAddressInfo()
    {
        // Try to select company address from ViewState first
        if (!ShoppingCartControl.IsCurrentStepPostBack && ShoppingCartControl.GetTempValue(BILLING_ADDRESS_ID) != null)
        {
            LoadBillingFromViewState();
        }
        else
        {
            if (drpBillingAddr.SelectedValue != "0")
            {
                var addressId = Convert.ToInt32(drpBillingAddr.SelectedValue);

                var ai = AddressInfoProvider.GetAddressInfo(addressId);
                if (ai != null)
                {
                    txtBillingName.Text        = ai.AddressPersonalName;
                    txtBillingAddr1.Text       = ai.AddressLine1;
                    txtBillingAddr2.Text       = ai.AddressLine2;
                    txtBillingCity.Text        = ai.AddressCity;
                    txtBillingZip.Text         = ai.AddressZip;
                    txtBillingPhone.Text       = ai.AddressPhone;
                    CountrySelector1.CountryID = ai.AddressCountryID;
                    CountrySelector1.StateID   = ai.AddressStateID;
                    CountrySelector1.ReloadData(true);
                }
            }
            else
            {
                // Clean billing part of the form
                CleanForm(true, false, false);

                // Prefill customer company name or full name
                if ((ShoppingCart.Customer != null) &&
                    (ShoppingCart.Customer.CustomerCompany != ""))
                {
                    txtBillingName.Text = ShoppingCart.Customer.CustomerCompany;
                }
                else
                {
                    txtBillingName.Text = ShoppingCart.Customer.CustomerFirstName + " " + ShoppingCart.Customer.CustomerLastName;
                }
            }
        }
    }
    private void LoadValues(int orderId)
    {
        this._paymentValues = new NameValueCollection();
        this._paymentValues.Add("PSPID", SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".OgonePSPID"));
        this._paymentValues.Add("TXTCOLOR", "#444444");
        this._paymentValues.Add("TBLTXTCOLOR", "#444444");
        this._paymentValues.Add("TBLBGCOLOR", "#F7F7F7");
        this._paymentValues.Add("BGCOLOR", "#F7F7F7");
        this._paymentValues.Add("PM", "CreditCard");

        // this._paymentValues.Add("cancelurl", "hthttp://v2.portedorient.com/fr-BE/Webshop/ShoppingCart");
        var brand = QueryHelper.GetString("brand", String.Empty);

        if (!String.IsNullOrWhiteSpace(brand))
        {
            this._paymentValues.Add("BRAND", brand);
        }


        OrderInfo    oi  = OrderInfoProvider.GetOrderInfo(orderId);
        CustomerInfo ci  = CustomerInfoProvider.GetCustomerInfo(oi.OrderCustomerID);
        CurrencyInfo cui = CurrencyInfoProvider.GetCurrencyInfo(oi.OrderCurrencyID);

        if (oi != null && ci != null && cui != null)
        {
            this._paymentValues.Add("orderID", String.Format("{0}", oi.OrderID));
            this._paymentValues.Add("amount", String.Format("{0}", Math.Floor(oi.OrderTotalPrice * 100)));
            this._paymentValues.Add("currency", cui.CurrencyCode);
            this._paymentValues.Add("language", String.Format("{0}", LocalizationContext.PreferredCultureCode));
            this._paymentValues.Add("CN", String.Format("{0} {1}", ci.CustomerFirstName, ci.CustomerLastName));
            this._paymentValues.Add("EMAIL", ci.CustomerEmail);

            AddressInfo ai = AddressInfoProvider.GetAddressInfo(oi.OrderBillingAddressID);
            if (ai != null)
            {
                this._paymentValues.Add("owneraddress", ai.AddressLine1);
                this._paymentValues.Add("ownerZIP", ai.AddressZip);
                this._paymentValues.Add("ownertown", ai.AddressCity);
                this._paymentValues.Add("ownertelno", ai.AddressPhone);
            }
        }

        AddShaSignature();
    }
Esempio n. 22
0
 /// <summary>
 /// Updating the unit count of shopping cart Item
 /// </summary>
 private void Updatingtheunitcountofcartitem(SKUInfo product, int shoppinCartID, int unitCount, int customerAddressID, double skuPrice)
 {
     try
     {
         var customerAddress = AddressInfoProvider.GetAddressInfo(customerAddressID);
         if (!DataHelper.DataSourceIsEmpty(product))
         {
             ShoppingCartItemInfo item = null;
             ShoppingCartInfo     cart = ShoppingCartInfoProvider.GetShoppingCartInfo(shoppinCartID);
             cart.User = CurrentUser;
             cart.ShoppingCartShippingAddress = customerAddress;
             if (cart.ShoppingCartCurrencyID <= 0)
             {
                 cart.ShoppingCartCurrencyID = CurrencyInfoProvider.GetMainCurrency(CurrentSite.SiteID).CurrencyID;
                 cart.Update();
             }
             var campaingnID = ValidationHelper.GetInteger(cart.GetValue("ShoppingCartCampaignID"), default(int));
             var programID   = ValidationHelper.GetInteger(cart.GetValue("ShoppingCartProgramID"), default(int));
             item = cart.CartItems.Where(g => g.SKUID == product.SKUID).FirstOrDefault();
             if (!DataHelper.DataSourceIsEmpty(item))
             {
                 item.CartItemPrice = skuPrice;
                 ShoppingCartItemInfoProvider.UpdateShoppingCartItemUnits(item, unitCount);
                 cart.InvalidateCalculations();
             }
             else
             {
                 ShoppingCartItemParameters parameters = new ShoppingCartItemParameters(product.SKUID, unitCount);
                 parameters.CustomParameters.Add("CartItemCustomerID", customerAddressID);
                 ShoppingCartItemInfo cartItem = cart.SetShoppingCartItem(parameters);
                 cartItem.SetValue("CartItemPrice", skuPrice);
                 cartItem.SetValue("CartItemDistributorID", customerAddressID);
                 cartItem.SetValue("CartItemCampaignID", cartItem.SetValue("CartItemCampaignID", campaingnID));
                 cartItem.SetValue("CartItemProgramID", programID);
                 ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(cartItem);
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CustomerCartOperations.ascx.cs", "Updatingtheunitcountofcartitem()", ex);
     }
 }
    protected void RptPickShippingAddressItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        var drv = (System.Data.DataRowView)e.Item.DataItem;

        if (drv != null)
        {
            int addressID = ValidationHelper.GetInteger(drv["AddressID"], 0);
            if (addressID > 0)
            {
                AddressInfo ai         = AddressInfoProvider.GetAddressInfo(addressID);
                var         ltlAddress = e.Item.FindControl("ltlAddress") as Literal;
                if (ltlAddress != null)
                {
                    string addressline, addresstown;
                    addressline     = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0} {1}", ai.AddressLine1, ai.AddressLine2);
                    addresstown     = string.Format("{0} {1}", ai.AddressZip, ai.AddressCity);
                    ltlAddress.Text = string.Format("{0}, {1} - {2}, {3}", ai.AddressPersonalName, addressline, addresstown, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName);
                }
            }
        }
    }
        public bool DeleteAddress(int addressID)
        {
            bool returnValue = false;
            var  address     = AddressInfoProvider.GetAddressInfo(addressID);

            if (address != null)
            {
                AddressInfoProvider.DeleteAddressInfo(addressID);
                //Delete data from Shipping Table..
                ShippingAddressItem shippingAddress = new ShippingAddressItem();
                string        customTableClassName  = shippingAddress.ClassName;
                DataClassInfo customTable           = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
                if (customTable != null)
                {
                    CustomTableItemProvider.DeleteItems(customTableClassName, "COM_AddressID =" + addressID);
                    returnValue = true;
                }
            }

            return(returnValue);
        }
Esempio n. 25
0
    private void SetupControl()
    {
        if (StopProcessing)
        {
            return;
        }

        EditForm.RedirectUrlAfterSave        = AfterSaveRedirectURL;
        EditForm.SubmitButton.ResourceString = SubmitButtonResourceString;
        EditForm.CssClass            = CssClass;
        EditForm.MarkRequiredFields  = MarkRequiredFields;
        EditForm.UseColonBehindLabel = UseColonBehindLabel;
        EditForm.OnBeforeSave       += EditForm_OnBeforeSave;


        string[] splitFormName = AlternativeFormName.Split('.');
        // UIForm cant process full path of alternative form if object type is already specified.
        EditForm.AlternativeFormName = splitFormName.LastOrDefault();

        if (CurrentCustomerID <= 0)
        {
            ShowError(CheckPermissionErrorMessage);
        }
        else if (!CreateNewAddress)
        {
            // Customers edits existing address
            var address = AddressInfoProvider.GetAddressInfo(EditedObjectID);

            // Allow edit object if user has sufficient permissions to modify address object
            if ((address == null) || (address.AddressCustomerID != CurrentCustomerID))
            {
                ShowError(CheckPermissionErrorMessage);
            }
            else
            {
                EditForm.EditedObject = address;
            }
        }
    }
Esempio n. 26
0
    private int GetShippingID()
    {
        int result = 0;

        /*GeneralConnection cn= ConnectionHelper.GetConnection();
         * string priceID = ValidationHelper.GetString(SessionHelper.GetValue("PriceID") ,"0");
         * string stringQuery = string.Format("SELECT ShippingoptionID FROM customtable_shippingextensioncountry WHERE itemid IN (SELECT shippingextensioncountryID FROM customtable_shippingextensionpricing WHERE itemID={0})", priceID);
         * DataSet ds = cn.ExecuteQuery(stringQuery, null, CMS.SettingsProvider.QueryTypeEnum.SQLQuery, false);
         * if (!DataHelper.DataSourceIsEmpty(ds))
         * {
         *  result = Convert.ToInt32((ds.Tables[0].Rows[0]["ShippingoptionID"]));
         * }*/
        int PriceID      = ShippingExtendedInfoProvider.GetCustomFieldValue(ShoppingCart, "ShoppingCartPriceID");
        int ShippingUnit = ShippingExtendedInfoProvider.GetCartShippingUnit(ShoppingCart);
        //string priceID = ValidationHelper.GetString(SessionHelper.GetValue("PriceID"), "0");
        string priceID = PriceID.ToString();
        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@ShippingUnits", ShippingUnit);
        parameters.Add("@CountryID", (AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartShippingAddressID)).AddressCountryID);
        parameters.Add("@VATRate", 1 + ShippingExtendedInfoProvider.GetCartShippingVatRate(ShoppingCart) / 100);
        string where = string.Format("ItemID={0}", priceID);
        GeneralConnection cn = ConnectionHelper.GetConnection();
        DataSet           ds = cn.ExecuteQuery("customtable.shippingextension.ShippingCostListByCountry", parameters, where);


        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow drow in ds.Tables[0].Rows)
            {
                result = ValidationHelper.GetInteger(drow["ShippingoptionID"], 0);
                if (priceID == drow["ItemID"].ToString())
                {
                    return(result);
                }
            }
        }
        return(result);
    }
Esempio n. 27
0
    protected void btnHiddenDelete_Click(object sender, EventArgs e)
    {
        // Get AddressId from the row
        AddressId = ValidationHelper.GetInteger(hdnID.Value, 0);

        var address = AddressInfoProvider.GetAddressInfo(AddressId);

        if ((address != null) && (address.AddressCustomerID == CustomerId))
        {
            // Check for the address dependencies
            if (address.Generalized.CheckDependencies())
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Ecommerce.DeleteDisabled");
                return;
            }

            // Delete AddressInfo object from database
            AddressInfoProvider.DeleteAddressInfo(address);

            gridAddresses.ReBind();
        }
    }
Esempio n. 28
0
    /// <summary>
    /// Calculates shipping charge for the given shopping cart.
    /// Shipping taxes are not included. Result is in site main currency.
    /// </summary>
    /// <param name="cartObj">Shopping cart data</param>
    protected override double CalculateShippingInternal(ShoppingCartInfo cart)
    {
        // Calculates shipping based on customer's billing address country
        if (cart != null)
        {
            // Get site name
            string siteName = cart.SiteName;

            if ((cart.UserInfoObj != null) && (cart.UserInfoObj.IsInRole("VIP", siteName)))
            {
                // Free shipping for VIP customers
                return(0);
            }
            else
            {
                // Get shipping address details
                AddressInfo address = AddressInfoProvider.GetAddressInfo(cart.ShoppingCartShippingAddressID);
                if (address != null)
                {
                    // Get shipping address country
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(address.AddressCountryID);
                    if ((country != null) && (country.CountryName.ToLower() != "usa"))
                    {
                        // Get extra shipping for non-usa customers from 'ShippingExtraCharge' custom setting
                        double extraCharge = SettingsKeyProvider.GetDoubleValue("ShippingExtraCharge");

                        // Add an extra charge to standard shipping price for non-usa customers
                        return(base.CalculateShippingInternal(cart) + extraCharge);
                    }
                }
            }
        }

        // Calculate shipping option without tax in default way
        return(base.CalculateShippingInternal(cart));
    }
    /// <summary>
    /// Process valid values of this step.
    /// </summary>
    public override bool ProcessStep()
    {
        // AddressInfo ai = null;
        bool newAddress = false;

        if (mCustomerId > 0)
        {
            // Clean the viewstate
            RemoveBillingTempValues();
            RemoveShippingTempValues();
            RemoveCompanyTempValues();

            // Process billing address

            /*if (ai == null)
             * {
             *  ai = new AddressInfo();
             *  newAddress = true;
             * }
             *
             * if (newAddress)
             * {
             *  ai.AddressIsBilling = true;
             *  ai.AddressEnabled = true;
             * }
             * ai.AddressCustomerID = mCustomerId;
             * ai.AddressName = AddressInfoProvider.GetAddressName(ai);
             *
             * // Save address and set it's ID to ShoppingCartInfoObj
             * AddressInfoProvider.SetAddressInfo(ai);*/

            // Update current contact's address
            ModuleCommands.OnlineMarketingMapAddress(AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartBillingAddressID), ContactID);

            // If shopping cart does not need shipping
            if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart))
            {
                ShoppingCart.ShoppingCartShippingAddressID = 0;
            }
            // If shipping address is different from billing address

            /*
             * else if (chkShippingAddr.Checked)
             * {
             *
             *  newAddress = false;
             *  // Process shipping address
             *  //-------------------------
             *  if (ai == null)
             *  {
             *      ai = new AddressInfo();
             *      newAddress = true;
             *  }
             *
             *  if (newAddress)
             *  {
             *      ai.AddressIsShipping = true;
             *      ai.AddressEnabled = true;
             *      ai.AddressIsBilling = false;
             *      ai.AddressIsCompany = false;
             *      ai.AddressEnabled = true;
             *  }
             *  ai.AddressCustomerID = mCustomerId;
             *  ai.AddressName = AddressInfoProvider.GetAddressName(ai);
             *
             *  // Save address and set it's ID to ShoppingCartInfoObj
             *  AddressInfoProvider.SetAddressInfo(ai);
             *  ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID;
             * }
             * // Shipping address is the same as billing address
             * else
             * {
             *  ShoppingCart.ShoppingCartShippingAddressID = ShoppingCart.ShoppingCartBillingAddressID;
             * }*/

            try
            {
                // Update changes in database only when on the live site
                if (!ShoppingCartControl.IsInternalOrder)
                {
                    ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
                }
                return(true);
            }
            catch (Exception ex)
            {
                // Show error message
                lblError.Visible = true;
                lblError.Text    = ex.Message;
                return(false);
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = GetString("Ecommerce.NoCustomerSelected");
            return(false);
        }
    }
    /// <summary>
    /// Reloads the form data.
    /// </summary>
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // *** SERVRANX START***
        ShowPaymentList();
        if (!rdbVisa.Checked && !rdbMaestro.Checked && !rdbMastercard.Checked)
        {
            rdbVisa.Checked = true;
            rdoBtn_CheckedChanged(null, null);
        }
        ddlPaymentOption.SelectedValue = SessionHelper.GetValue("PaymentID").ToString();
        ddlPaymentOption_SelectedIndexChanged(null, null);

        string where = string.Format("AddressCustomerID={0} AND AddressIsBilling=1", ECommerceContext.CurrentCustomer.CustomerID.ToString());
        string  orderby = "AddressID";
        DataSet ds      = AddressInfoProvider.GetAddresses(where, orderby);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            AddressInfo ai = new AddressInfo(ds.Tables[0].Rows[0]);
            lblBillingAddressFullName.Text            = ai.AddressPersonalName;
            lblBillingAddressStreet.Text              = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0}, {1}", ai.AddressLine1, ai.AddressLine2);
            lblBillingAddressZipCode.Text             = ai.AddressZip;
            lblBillingAddressCityCountry.Text         = string.Format("{0}, {1}", ai.AddressCity, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName);
            ShoppingCart.ShoppingCartBillingAddressID = ai.AddressID;
        }

        where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString());
        ds    = AddressInfoProvider.GetAddresses(where, orderby);
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            AddressInfo ai = new AddressInfo(ds.Tables[0].Rows[0]);
            lblShippingAddressFullName.Text            = ai.AddressPersonalName;
            lblShippingAddressStreet.Text              = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0}, {1}", ai.AddressLine1, ai.AddressLine2);
            lblShippingAddressZipCode.Text             = ai.AddressZip;
            lblShippingAddressCityCountry.Text         = string.Format("{0}, {1}", ai.AddressCity, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName);
            ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID;
        }
        else
        {
            // NO SHIPPING ADDRESS DEFINED- PICK FIRST BILLING ADDRESS
            AddressInfo ai_shipping = AddressInfoProvider.GetAddressInfo(ShoppingCart.ShoppingCartBillingAddressID);
            ai_shipping.AddressIsShipping = true;
            AddressInfoProvider.SetAddressInfo(ai_shipping);
            where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString());
            ds    = AddressInfoProvider.GetAddresses(where, orderby);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                AddressInfo ai = new AddressInfo(ds.Tables[0].Rows[0]);
                lblShippingAddressFullName.Text            = ai.AddressPersonalName;
                lblShippingAddressStreet.Text              = string.IsNullOrEmpty(ai.AddressLine2) ? ai.AddressLine1 : string.Format("{0}, {1}", ai.AddressLine1, ai.AddressLine2);
                lblShippingAddressZipCode.Text             = ai.AddressZip;
                lblShippingAddressCityCountry.Text         = string.Format("{0}, {1}", ai.AddressCity, CountryInfoProvider.GetCountryInfo(ai.AddressCountryID).CountryDisplayName);
                ShoppingCart.ShoppingCartShippingAddressID = ai.AddressID;
            }
        }
        ReloadData();
        // *** SERVRANX END***
        mCurrentSite = SiteContext.CurrentSite;


        //lblBillingTitle.Text = GetString("ShoppingCart.BillingAddress");
        //lblShippingTitle.Text = GetString("ShoppingCart.ShippingAddress");
        //lblCompanyAddressTitle.Text = GetString("ShoppingCart.CompanyAddress");

        // Initialize labels.
        // LabelInitialize();
        //this.TitleText = GetString("Order_new.ShoppingCartOrderAddresses.Title");

        // Get customer ID from ShoppingCartInfoObj
        mCustomerId = ShoppingCart.ShoppingCartCustomerID;


        // Get customer info.
        CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(mCustomerId);

        if (ci != null)
        {
            // Display customer addresses if customer is not anonymous
            if (ci.CustomerID > 0)
            {
                if (!ShoppingCartControl.IsCurrentStepPostBack)
                {
                    // Initialize customer billing and shipping addresses
                    InitializeAddresses();
                }
            }
        }

        // If shopping cart does not need shipping
        if (!ShippingOptionInfoProvider.IsShippingNeeded(ShoppingCart))
        {
            // Hide title
            lblBillingTitle.Visible = false;

            // Change current checkout process step caption
            ShoppingCartControl.CheckoutProcessSteps[ShoppingCartControl.CurrentStepIndex].Caption = GetString("order_new.shoppingcartorderaddresses.titlenoshipping");
        }
    }