コード例 #1
0
        private void RegisterCustomer()
        {
            string salutation = ProfileControl.salutation;
            string email      = ProfileControl.email;

            bool infoIsAllGood = true;

            if (salutation == AppLogic.GetString("createaccount.aspx.81", AppLogic.GetCurrentSkinID(), Customer.Current.LocaleSetting, true))
            {
                salutation = String.Empty;
            }

            if (!AppLogic.AppConfigBool("AllowCustomerDuplicateEMailAddresses") && Customer.EmailInUse(email, ThisCustomer.CustomerCode))
            {
                errorSummary.DisplayErrorMessage("Email is already used by another customer");
                infoIsAllGood = false;
            }

            if (infoIsAllGood)
            {
                #region Customer Profile
                string contactNumber = ProfileControl.contactNumber;
                ThisCustomer.Salutation = salutation;
                ThisCustomer.FirstName  = ProfileControl.firstName;
                ThisCustomer.LastName   = ProfileControl.lastName;
                ThisCustomer.EMail      = email;
                ThisCustomer.Password   = ProfileControl.password;
                ThisCustomer.Phone      = contactNumber;

                ThisCustomer.IsOKToEMail = chkProductUpdates.Checked;
                ThisCustomer.IsOver13    = chkOver13.Checked;

                #endregion

                #region Customer Business Type

                if (AppLogic.AppConfigBool("VAT.Enabled") && AppLogic.AppConfigBool("VAT.ShowTaxFieldOnRegistration"))
                {
                    if (BillingAddressControl.businessType.ToLowerInvariant() == Interprise.Framework.Base.Shared.Const.BUSINESS_TYPE_WHOLESALE.ToLower())
                    {
                        ThisCustomer.BusinessType = Customer.BusinessTypes.WholeSale;
                    }
                    if (BillingAddressControl.businessType.ToLowerInvariant() == Interprise.Framework.Base.Shared.Const.BUSINESS_TYPE_RETAIL.ToLower())
                    {
                        ThisCustomer.BusinessType = Customer.BusinessTypes.Retail;
                    }

                    ThisCustomer.TaxNumber = BillingAddressControl.taxNumber;
                }

                #endregion

                #region Customer Billing Address

                var aBillingAddress = Address.New(ThisCustomer, AddressTypes.Billing);

                var parsedBillingCityText = InterpriseHelper.ParseCityText(billingTxtCityStates.Text, BillingAddressControl.state, BillingAddressControl.city);
                aBillingAddress.State = parsedBillingCityText[0];
                aBillingAddress.City  = parsedBillingCityText[1];

                aBillingAddress.Address1   = BillingAddressControl.street;
                aBillingAddress.Country    = BillingAddressControl.country;
                aBillingAddress.PostalCode = BillingAddressControl.postal;

                if (!BillingAddressControl.county.IsNullOrEmptyTrimmed())
                {
                    aBillingAddress.County = BillingAddressControl.county;
                }

                aBillingAddress.FirstName     = ProfileControl.firstName;
                aBillingAddress.LastName      = ProfileControl.lastName;
                aBillingAddress.EMail         = email;
                aBillingAddress.Name          = ProfileControl.accountName;
                aBillingAddress.Company       = ProfileControl.accountName;
                aBillingAddress.ResidenceType = ResidenceTypes.Residential;
                aBillingAddress.Phone         = contactNumber;

                #endregion

                #region Customer Shipping Address

                var aShippingAddress = Address.New(ThisCustomer, AddressTypes.Shipping);

                if (AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"))
                {
                    if (copyBillingInfo.Checked)
                    {
                        aShippingAddress.State      = parsedBillingCityText[0];
                        aShippingAddress.City       = parsedBillingCityText[1];
                        aShippingAddress.Address1   = BillingAddressControl.street;
                        aShippingAddress.Country    = BillingAddressControl.country;
                        aShippingAddress.PostalCode = BillingAddressControl.postal;
                        if (!BillingAddressControl.county.IsNullOrEmptyTrimmed())
                        {
                            aShippingAddress.County = BillingAddressControl.county;
                        }
                    }
                    else
                    {
                        var parsedShippingCityText = InterpriseHelper.ParseCityText(shippingTxtCityStates.Text, ShippingAddressControl.state, ShippingAddressControl.city);
                        aShippingAddress.State      = parsedShippingCityText[0];
                        aShippingAddress.City       = parsedShippingCityText[1];
                        aShippingAddress.Address1   = ShippingAddressControl.street;
                        aShippingAddress.Country    = ShippingAddressControl.country;
                        aShippingAddress.PostalCode = ShippingAddressControl.postal;
                        if (!ShippingAddressControl.county.IsNullOrEmptyTrimmed())
                        {
                            aShippingAddress.County = ShippingAddressControl.county;
                        }
                    }

                    aShippingAddress.FirstName     = ProfileControl.firstName;
                    aShippingAddress.LastName      = ProfileControl.lastName;
                    aShippingAddress.EMail         = email;
                    aShippingAddress.Name          = ProfileControl.accountName;
                    aShippingAddress.Company       = ProfileControl.accountName;
                    aShippingAddress.ResidenceType = InterpriseHelper.ResolveResidenceType(ShippingAddressControl.residenceType);
                    aShippingAddress.Phone         = contactNumber;
                }
                else
                {
                    aShippingAddress = aBillingAddress;
                }

                #endregion

                #region Register Or Checkout

                if (_checkOutMode && _skipRegistration)
                {
                    SkipRegistrationAndCheckout(aBillingAddress, aShippingAddress);
                }
                else
                {
                    ThisCustomer.Register(aBillingAddress, aShippingAddress, _checkOutMode);
                }

                #endregion

                #region Assign Items Shipping / Mail Notification / Redirection

                _cart.ShipAllItemsToThisAddress(ThisCustomer.PrimaryShippingAddress);

                SendEmailNotification(false, email, ProfileControl.firstName, ProfileControl.accountName);
                RedirectToSucceedingPage();

                #endregion
            }
        }