public void SaveShippingAddress(DeliveryAddress address)
        {
            var customer = ECommerceContext.CurrentCustomer;
            var info     = new AddressInfo
            {
                AddressID           = address.Id,
                AddressLine1        = address.Address1,
                AddressLine2        = address.Address2,
                AddressCity         = address.City,
                AddressStateID      = address.State.Id,
                AddressCountryID    = address.Country.Id,
                AddressZip          = address.Zip,
                AddressCustomerID   = customer.CustomerID,
                AddressPersonalName = $"{customer.CustomerFirstName} {customer.CustomerLastName}",
                AddressPhone        = address.Phone
            };

            info.AddressName = $"{info.AddressPersonalName}, {info.AddressLine1}, {info.AddressCity}";
            info.SetValue("AddressType", AddressType.Shipping.Code);
            info.SetValue("CompanyName", address.CustomerName);
            info.SetValue("Email", address.Email);

            AddressInfoProvider.SetAddressInfo(info);
            address.Id = info.AddressID;
        }
    /// <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);
    }
        protected void CreateCustomerAddress(int customerID, UserDto userDto)
        {
            var country = FindCountry(userDto.Country);

            if (country == null)
            {
                EventLogProvider.LogInformation("Import users", "INFO", $"Skipping creation of address of user { userDto.Email }. Reason - invalid country.");
                return;
            }

            var state = FindState(userDto.State);

            var addressNameFields = new[] { $"{userDto.FirstName} {userDto.LastName}", userDto.AddressLine, userDto.AddressLine2, userDto.City }
            .Where(af => !string.IsNullOrWhiteSpace(af));
            var newAddress = new AddressInfo
            {
                AddressName         = string.Join(", ", addressNameFields),
                AddressLine1        = userDto.AddressLine ?? "",
                AddressLine2        = userDto.AddressLine2,
                AddressCity         = userDto.City ?? "",
                AddressZip          = userDto.PostalCode ?? "",
                AddressPersonalName = userDto.ContactName ?? $"{userDto.FirstName} {userDto.LastName}",
                AddressPhone        = userDto.PhoneNumber ?? "",
                AddressCustomerID   = customerID,
                AddressCountryID    = country.CountryID,
                AddressStateID      = state?.StateID ?? 0
            };

            newAddress.SetValue("AddressType", AddressType.Shipping.Code);

            AddressInfoProvider.SetAddressInfo(newAddress);
        }
Exemple #4
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>
    /// OK click handler (Proceed registration).
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        System.Globalization.CultureInfo currentUI = System.Globalization.CultureInfo.CurrentUICulture;

        if ((PageManager.ViewMode == ViewModeEnum.Design) || (HideOnCurrentPage) || (!IsVisible))
        {
            // Do not process
        }
        else
        {
            String siteName = SiteContext.CurrentSiteName;

            #region "Banned IPs"

            // Ban IP addresses which are blocked for registration
            if (!BannedIPInfoProvider.IsAllowed(siteName, BanControlEnum.Registration))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("banip.ipisbannedregistration");
                return;
            }

            #endregion

            #region "Pr�nom"

            if (string.IsNullOrEmpty(txtFirstName.Text) || (txtFirstName.Text.ToLower() == "firstname") || (txtFirstName.Text.ToLower() == "pr�nom") || (txtFirstName.Text.ToLower() == "prenom"))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("errornom");
                return;
            }

            #endregion

            #region "Nom"

            if (string.IsNullOrEmpty(txtLastName.Text) || (txtLastName.Text.ToLower() == "nom") || (txtLastName.Text.ToLower() == "lastname"))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("errorprenom");
                return;
            }

            #endregion

            #region "T�l�phone"

            if (string.IsNullOrEmpty(txtTelephone.Text) || (txtTelephone.Text.ToLower() == "telephone"))
            {
                lblError.Visible = true;
                lblError.Text    = GetString("errortelephone");
                return;
            }

            #endregion


            #region Soci�t�
            if (rboui.Checked)
            {
                if ((txtnomsociete.Text == "") || (txtnomsociete.Text == "Nom soci�t�") || (txtnomsociete.Text == "Company Name"))
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("errornomsociete ");
                    return;
                }

                //if ((txtTva.Text == "") || (txtTva.Text == "TVA") || (txtTva.Text == "VAT"))
                //{
                //    lblError.Visible = true;
                //    lblError.Text = GetString("errortva ");
                //    return;
                //}

                //if (!EUVatChecker.Check(txtTva.Text))
                //{
                //    lblError.Visible = true;
                //    lblError.Text = GetString("errortva2 ");
                //    return;
                //}
            }
            #endregion

            #region "Captcha"

            // Check if captcha is required
            if (DisplayCaptcha)
            {
                // Verifiy captcha text
                if (!scCaptcha.IsValid())
                {
                    // Display error message if catcha text is not valid
                    lblError.Visible = true;
                    lblError.Text    = GetString("Webparts_Membership_RegistrationForm.captchaError");
                    return;
                }
                else
                {
                    // Generate new captcha
                    scCaptcha.GenerateNew();
                }
            }

            #endregion


            // Set password
            //UserInfoProvider.SetPassword(ui, passStrength.Text);

            // UserInfoProvider.SetPassword(ui, txtPassword.Text.Trim());
            if (!CurrentUser.IsAuthenticated())
            {
                // Set password
                //    UserInfoProvider.SetPassword(ui, txtPassword.Text.Trim());
            }
            else
            {
                #region "Modif User"
                //Update User
                UserInfo updateUser = CurrentUser;
                updateUser.PreferredCultureCode = "";
                updateUser.FirstName            = txtFirstName.Text.Trim();
                updateUser.FullName             = UserInfoProvider.GetFullName(txtFirstName.Text.Trim(), String.Empty, txtLastName.Text.Trim());
                updateUser.LastName             = txtLastName.Text.Trim();
                updateUser.MiddleName           = "";

                if (payement_option.SelectedValue != "0")
                {
                    updateUser.SetValue("Civilite", payement_option.SelectedValue);
                }

                //updateUser.SetValue("Telephone", txtTelephone.Text);
                updateUser.SetValue("Telephone", txtTelephone.Text);

                /*if ((txtPassword.Text != "Mot de passe") && (txtPassword.Text != "Password"))
                 * {
                 *  UserInfoProvider.SetPassword(updateUser, txtPassword.Text);
                 *  //updateUser.SetValue("UserPassword",txtPassword.Text);
                 * }*/
                UserInfoProvider.SetUserInfo(updateUser);

                //Update Customer
                CustomerInfo updateCustomer = ECommerceContext.CurrentCustomer;
                updateCustomer.CustomerUserID    = updateUser.UserID;
                updateCustomer.CustomerLastName  = txtLastName.Text.Trim();
                updateCustomer.CustomerFirstName = txtFirstName.Text.Trim();
                updateCustomer.CustomerEmail     = txtEmail.Text.Trim();
                //add update phone
                updateCustomer.CustomerPhone          = txtTelephone.Text.Trim();
                updateCustomer.CustomerEnabled        = true;
                updateCustomer.CustomerLastModified   = DateTime.Now;
                updateCustomer.CustomerSiteID         = CMSContext.CurrentSiteID;
                updateCustomer.CustomerOrganizationID = "";
                if (rboui.Checked)
                {
                    updateCustomer.CustomerCompany           = txtnomsociete.Text.Trim();
                    updateCustomer.CustomerTaxRegistrationID = txtTva.Text;
                }
                else
                {
                    updateCustomer.CustomerCompany           = string.Empty;
                    updateCustomer.CustomerTaxRegistrationID = string.Empty;
                }

                if ((rboui.Checked) && (txtTva.Text.Trim() != "TVA") && (txtTva.Text.Trim() != "VAT"))
                {
                    updateCustomer.CustomerTaxRegistrationID = txtTva.Text;
                    updateCustomer.CustomerCompany           = txtnomsociete.Text.ToString();
                }
                else
                {
                    updateCustomer.CustomerTaxRegistrationID = "";
                    updateCustomer.CustomerCompany           = "";
                }

                CustomerInfoProvider.SetCustomerInfo(updateCustomer);
                #endregion

                #region "Insert new adress / Update selected adress"
                //if (chkNewAddress.Checked)
                //{
                #region "n�"

                if ((txtnumero.Text == "") || (txtnumero.Text == "Numero") || (txtnumero.Text == "Number"))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("errornumerorue");
                    return;
                }

                #endregion

                #region "adresse 1"

                if ((txtadresse1.Text == "") || (txtadresse1.Text == "Adresse 1") || (txtadresse1.Text == "Address 1"))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("erroradresse1");
                    return;
                }

                #endregion

                #region "adresse 2"

                if ((txtadresse2.Text == "") || (txtadresse2.Text == "Adresse 2") || (txtadresse2.Text == "Address 2"))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("erroradresse2");
                    return;
                }

                #endregion

                #region "CP"

                if ((txtcp.Text == "") || (txtcp.Text == "CP") || (txtcp.Text == "ZIP"))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("errorcp");
                    return;
                }

                #endregion

                #region "Ville"

                if ((txtville.Text == "") || (txtville.Text == "Ville") || (txtville.Text == "City"))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("errorville");
                    return;
                }

                #endregion

                #region "Pays"

                if ((ddlShippingCountry.Text == "Choose your country") || (ddlShippingCountry.Text == "Choisissez votre pays"))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("errorchoixpays ");
                    return;
                }

                #endregion

                #region "Adresse"

                if ((chkShippingAddr.Checked == false) && (chkBillingAddr.Checked == false))
                {
                    lblErrorAdress.Visible = true;
                    lblErrorAdress.Text    = GetString("erroradressechek");
                    return;
                }

                #endregion

                if (txtIdAdresse.Text == "")
                {
                    #region "New adress"

                    // Create new address object
                    AddressInfo newAddress = new AddressInfo();

                    int          CountryID = ValidationHelper.GetInteger(ddlShippingCountry.SelectedValue, 0);
                    CustomerInfo uc        = ECommerceContext.CurrentCustomer;
                    mCustomerId = uc.CustomerID;
                    string mCustomerName = uc.CustomerFirstName + " " + uc.CustomerLastName;
                    // Set the properties
                    newAddress.AddressName  = mCustomerName + " , " + txtnumero.Text + " " + txtadresse1.Text + " - " + txtcp.Text + " " + txtville.Text;
                    newAddress.AddressLine1 = txtadresse1.Text;
                    newAddress.AddressLine2 = txtadresse2.Text;
                    newAddress.AddressCity  = txtville.Text;
                    newAddress.AddressZip   = txtcp.Text;
                    if (chkBillingAddr.Checked)
                    {
                        newAddress.AddressIsBilling = true;
                    }
                    else
                    {
                        newAddress.AddressIsBilling = false;
                    }
                    if (chkShippingAddr.Checked)
                    {
                        newAddress.AddressIsShipping = true;
                    }
                    else
                    {
                        newAddress.AddressIsShipping = false;
                    }
                    newAddress.AddressEnabled      = true;
                    newAddress.AddressPersonalName = mCustomerName;
                    newAddress.AddressCustomerID   = mCustomerId;
                    newAddress.AddressCountryID    = CountryID;
                    newAddress.SetValue("AddressNumber", txtnumero.Text);

                    // Create the address
                    AddressInfoProvider.SetAddressInfo(newAddress);
                    txtnumero.Text   = string.Empty;
                    txtadresse1.Text = string.Empty;
                    txtadresse2.Text = string.Empty;
                    txtcp.Text       = string.Empty;
                    txtville.Text    = string.Empty;
                    // PnlInsertAdress.Visible = false;
                    if (newAddress != null && newAddress.AddressIsShipping == true)
                    {
                        Session["newAddress"] = newAddress.AddressID;
                        //EventLogProvider eve = new EventLogProvider();
                        //eve.LogEvent("I", DateTime.Now, "id new address= " + Session["newAddress"], "code");
                    }

                    #endregion
                }

                else
                {
                    #region "Update selected adress"

                    /*
                     *  // Udpate selected adress object
                     *  int CountryID = ValidationHelper.GetInteger(ddlShippingCountry.SelectedValue, 0);
                     *  int AddressId = Convert.ToInt32(txtIdAdresse.Text);
                     *  AddressInfo UpdateAdress = AddressInfoProvider.GetAddressInfo(AddressId);
                     *  CustomerInfo uc = ECommerceContext.CurrentCustomer;
                     *  mCustomerId = uc.CustomerID;
                     *  string mCustomerName = uc.CustomerFirstName + " " + uc.CustomerLastName;
                     *  // Set the properties
                     *  UpdateAdress.AddressName = mCustomerName + " , " + txtnumero.Text + " " + txtadresse1.Text + " - " + txtcp.Text + " " + txtville.Text;
                     *  UpdateAdress.SetValue("AddressNumber", txtnumero.Text);
                     *  UpdateAdress.AddressLine1 = txtadresse1.Text;
                     *  UpdateAdress.AddressLine2 = txtadresse2.Text;
                     *  UpdateAdress.AddressCity = txtville.Text;
                     *  UpdateAdress.AddressZip = txtcp.Text;
                     *  UpdateAdress.AddressIsBilling = chkBillingAddr.Checked;
                     *  UpdateAdress.AddressIsShipping = chkShippingAddr.Checked;
                     *  UpdateAdress.AddressEnabled = true;
                     *  UpdateAdress.AddressPersonalName = mCustomerName;
                     *  UpdateAdress.AddressCustomerID = mCustomerId;
                     *  UpdateAdress.AddressCountryID = CountryID;
                     *
                     *  // Save addressinfo
                     *  AddressInfoProvider.SetAddressInfo(UpdateAdress);
                     *  AddressId = UpdateAdress.AddressID;
                     */
                    #endregion
                }

                ReloadDataAdress();

                //}
                #endregion
            }

            lblError.Visible = false;
            // PnlInsertAdress.Visible = false;
        }
    }
    protected void rptAdressItemCommand(object source, RepeaterCommandEventArgs e)
    {
        // Get AddressId from the row
        int AddressId = ValidationHelper.GetInteger(e.CommandArgument, 0);

        // Delete selected address
        if (e.CommandName.Equals("Remove"))
        {
            int idShoppingCart = 0;
            //   EventLogProvider ev = new EventLogProvider();
            // test du nombre d'adresse
            int idCustomer = ECommerceContext.CurrentCustomer.CustomerID;
            string where, orderby;
            where   = "AddressEnabled = 1 AND AddressCustomerID  = " + idCustomer;
            orderby = "AddressID";
            InfoDataSet <AddressInfo> listadresse = AddressInfoProvider.GetAddresses(where, orderby);
            if (listadresse.Tables[0].Rows.Count <= 1)
            {
                return;
            }

            else
            {
                // Delete AddressInfo object from database if address not used for order
                if ((OrderBillingAddress(AddressId) == 0) && (OrderShippingAddress(AddressId) == 0))
                {
                    SqlConnection con4  = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
                    var           query = "Select ShoppingCartID from COM_ShoppingCart where ShoppingCartShippingAddressID = " + AddressId;
                    SqlCommand    cmd2  = new SqlCommand(query, con4);
                    //  ev.LogEvent("I", DateTime.Now, "ds billig&shipping=0", "code");
                    con4.Open();
                    try
                    {
                        idShoppingCart = (int)cmd2.ExecuteScalar();
                        //  ev.LogEvent("I", DateTime.Now, "dans try  " + idShoppingCart, "code");
                    }
                    catch (Exception ex)
                    {
                    }
                    con4.Close();
                    if (idShoppingCart != 0)
                    {
                        var        query2 = "Delete  from COM_ShoppingCartSKU WHERE ShoppingCartID = " + idShoppingCart;
                        SqlCommand cmd1   = new SqlCommand(query2, con4);
                        cmd1.ExecuteScalar();

                        var        stringQuery = "Delete  from COM_ShoppingCart WHERE ShoppingCartShippingAddressID = " + AddressId;
                        SqlCommand cmd3        = new SqlCommand(stringQuery, con4);
                        cmd3.ExecuteScalar();

                        con4.Dispose();
                    }
                    if (Session["newAddress"] != null)
                    {
                        int temp2 = Int32.Parse(Session["newAddress"].ToString());

                        if (temp2 != 0)
                        {
                            if (temp2 == AddressId)
                            {
                                Session["newAddress"] = null;
                            }
                        }
                    }
                    AddressInfoProvider.DeleteAddressInfo(AddressId);

                    //ev.LogEvent("I", DateTime.Now, "button delete enabled true", "code");
                    //
                    int id1 = ECommerceContext.CurrentCustomer.CustomerID;
                }
                // Disable AddressInfo object from database if address used for order
                else
                {
                    SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);
                    // con3.Open();
                    //   ev.LogEvent("I", DateTime.Now, "iD = " + AddressId, "code");
                    var        query = "Select ShoppingCartID from COM_ShoppingCart where ShoppingCartShippingAddressID = " + AddressId;
                    SqlCommand cmd2  = new SqlCommand(query, con3);
                    //  ev.LogEvent("I", DateTime.Now, "test", "code");
                    con3.Open();
                    try
                    {
                        idShoppingCart = (int)cmd2.ExecuteScalar();
                        con3.Dispose();
                    }
                    catch (Exception ex)
                    {
                    }
                    con3.Close();

                    SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString);

                    //  ev.LogEvent("I", DateTime.Now, "idShoppingCart = " + idShoppingCart, "code");

                    if (idShoppingCart != 0)
                    {
                        connect.Open();
                        var        query2 = "Delete  from COM_ShoppingCartSKU WHERE ShoppingCartID = " + idShoppingCart;
                        SqlCommand cmd1   = new SqlCommand(query2, connect);
                        cmd1.ExecuteScalar();


                        var        stringQuery = "Delete  from COM_ShoppingCart WHERE ShoppingCartShippingAddressID = " + AddressId;
                        SqlCommand cmd3        = new SqlCommand(stringQuery, connect);
                        cmd3.ExecuteScalar();
                        connect.Close();
                        Response.Redirect("~/Special-Page/Mon-compte.aspx");
                    }
                    //    ev.LogEvent("I", DateTime.Now, "btn delet enabled false", "code");
                    AddressInfo  UpdateAdress = AddressInfoProvider.GetAddressInfo(AddressId);
                    CustomerInfo uc           = ECommerceContext.CurrentCustomer;
                    UpdateAdress.AddressEnabled    = false;
                    UpdateAdress.AddressCustomerID = mCustomerId;
                    AddressInfoProvider.SetAddressInfo(UpdateAdress);
                    AddressId = UpdateAdress.AddressID;
                }
            }
            ReloadDataAdress();
            // PnlInsertAdress.Visible = false;
        }

        // Update selected adress
        if (e.CommandName.Equals("Update"))
        {
            // lblErrorAdress
            var lblErrorAdress = e.Item.FindControl("lblErrorAdress") as Label;

            // chkShippingAddr
            var chkShippingAddr = e.Item.FindControl("chkShippingAddr") as CheckBox;

            // chkBillingAddr
            var chkBillingAddr = e.Item.FindControl("chkBillingAddr") as CheckBox;

            if (!chkBillingAddr.Checked && !chkShippingAddr.Checked)
            {
                lblErrorAdress.Text    = "V�rifier le type d'adresse";
                lblErrorAdress.Visible = true;
                return;
            }

            int         AddressID = Convert.ToInt32(e.CommandArgument);
            AddressInfo ai        = AddressInfoProvider.GetAddressInfo(AddressID);
            string      s         = ai.AddressZip;

            // txtnumero
            var txtnumero = e.Item.FindControl("txtnumero") as TextBox;
            if (txtnumero != null)
            {
                ai.SetValue("AddressNumber", txtnumero.Text);
            }

            // txtadresse1
            var txtadresse1 = e.Item.FindControl("txtadresse1") as TextBox;
            if (txtadresse1 != null)
            {
                ai.AddressLine1 = txtadresse1.Text;
            }

            // txtadresse2
            var txtadresse2 = e.Item.FindControl("txtadresse2") as TextBox;
            if (txtadresse2 != null)
            {
                ai.AddressLine2 = txtadresse2.Text;
            }

            // txtcp
            TextBox txtcp = e.Item.FindControl("txtcp") as TextBox;
            if (txtcp != null)
            {
                ai.AddressZip = txtcp.Text;
                // Response.Write("<script>alert('This is Alert " + txtcp.Text + " " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + "');</script>");
            }

            // txtville
            var txtville = e.Item.FindControl("txtville") as TextBox;
            if (txtville != null)
            {
                ai.AddressCity = txtville.Text;
            }

            // chkShippingAddr
            if (chkShippingAddr != null)
            {
                ai.AddressIsShipping = chkShippingAddr.Checked;
            }

            // chkBillingAddr
            if (chkBillingAddr != null)
            {
                ai.AddressIsBilling = chkBillingAddr.Checked;
            }

            CustomerInfo uc            = ECommerceContext.CurrentCustomer;
            string       mCustomerName = string.Format("{0} {1}", uc.CustomerFirstName, uc.CustomerLastName);
            // Set the properties
            ai.AddressName = string.Format("{0}, {4} {1} - {2} {3}", mCustomerName, ai.AddressLine1, ai.AddressZip, ai.AddressCity, ai.GetStringValue("AddressNumber", string.Empty));
            AddressInfoProvider.SetAddressInfo(ai);

            // Update page here
            ReloadDataAdress();
        }
    }