Пример #1
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }

            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID = ThisCustomer.CustomerID;
                    anyAddress.NickName   = ctrlNewAddress.NickName;
                    anyAddress.FirstName  = ctrlNewAddress.FirstName;
                    anyAddress.LastName   = ctrlNewAddress.LastName;
                    anyAddress.Company    = ctrlNewAddress.Company;
                    anyAddress.Address1   = ctrlNewAddress.Address1;
                    anyAddress.Address2   = ctrlNewAddress.Address2;
                    anyAddress.Suite      = ctrlNewAddress.Suite;
                    anyAddress.City       = ctrlNewAddress.City;
                    anyAddress.State      = ctrlNewAddress.State;
                    anyAddress.Zip        = ctrlNewAddress.ZipCode;
                    anyAddress.Country    = ctrlNewAddress.Country;
                    anyAddress.Phone      = ctrlNewAddress.PhoneNumber;
                    //anyAddress.ResidenceType = (ResidenceTypes)addressType;
                    anyAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlNewAddress.ResidenceType, true);

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }
                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String validateResult = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        validateResult = "address.validation.errormsg".StringResource() + validateResult;

                        if (validateResult != AppLogic.ro_OK)
                        {
                            Session["ErrorMsgLabelText"] = System.Web.HttpUtility.HtmlEncode(validateResult);
                        }
                        else
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Length > 0, "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");
                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }
Пример #2
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }

            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AddressTypes addressType = AddressMode;
                bool         AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") &&
                                                              !AppLogic.AppConfigBool("SkipShippingOnCheckout");

                if (!AllowShipToDifferentThanBillTo)
                {
                    //Shipping and Billing address must be the same so save both
                    addressType = AddressTypes.Billing | AddressTypes.Shipping;
                }

                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID    = ThisCustomer.CustomerID;
                    anyAddress.NickName      = ctrlNewAddress.NickName;
                    anyAddress.FirstName     = ctrlNewAddress.FirstName;
                    anyAddress.LastName      = ctrlNewAddress.LastName;
                    anyAddress.Company       = ctrlNewAddress.Company;
                    anyAddress.Address1      = ctrlNewAddress.Address1;
                    anyAddress.Address2      = ctrlNewAddress.Address2;
                    anyAddress.Suite         = ctrlNewAddress.Suite;
                    anyAddress.City          = ctrlNewAddress.City;
                    anyAddress.State         = ctrlNewAddress.State;
                    anyAddress.Zip           = ctrlNewAddress.ZipCode;
                    anyAddress.Country       = ctrlNewAddress.Country;
                    anyAddress.Phone         = ctrlNewAddress.PhoneNumber;
                    anyAddress.ResidenceType = (ResidenceTypes)addressType;

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }

                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String VerifyResult        = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        bool   verifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);

                        if (verifyAddressPrompt)
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING") != "", "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");

                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }
Пример #3
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }
            //LovelyEcom Add
            string  VerifyResult0       = string.Empty;
            Address StandardizedAddress = null;

            lbAddressError.Text = "";
            if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
            {
                Address Verifyaddress = new Address();
                Verifyaddress.Address1 = ctrlNewAddress.Address1;
                Verifyaddress.Address2 = ctrlNewAddress.Address2;
                Verifyaddress.City     = ctrlNewAddress.City;
                Verifyaddress.State    = ctrlNewAddress.State;
                Verifyaddress.Zip      = ctrlNewAddress.ZipCode;

                VerifyResult0 = AddressValidation.RunValidate(Verifyaddress, out StandardizedAddress);

                if (VerifyResult0 != AppLogic.ro_OK)
                {
                    lbAddressError.Text += VerifyResult0; //lovely Ecom Added
                    return;
                }
            }
            //LovelyEcom end
            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID = ThisCustomer.CustomerID;
                    anyAddress.NickName   = ctrlNewAddress.NickName;
                    anyAddress.FirstName  = ctrlNewAddress.FirstName;
                    anyAddress.LastName   = ctrlNewAddress.LastName;
                    anyAddress.Company    = ctrlNewAddress.Company;
                    anyAddress.Address1   = ctrlNewAddress.Address1;
                    anyAddress.Address2   = ctrlNewAddress.Address2;
                    anyAddress.Suite      = ctrlNewAddress.Suite;
                    anyAddress.City       = ctrlNewAddress.City;
                    anyAddress.State      = ctrlNewAddress.State;
                    anyAddress.Zip        = ctrlNewAddress.ZipCode;
                    anyAddress.Country    = ctrlNewAddress.Country;
                    anyAddress.Phone      = ctrlNewAddress.PhoneNumber;
                    //anyAddress.ResidenceType = (ResidenceTypes)addressType;
                    anyAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlNewAddress.ResidenceType, true);

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }

                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String VerifyResult        = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        bool   verifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);

                        if (verifyAddressPrompt)
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING") != "", "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");

                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }