public void btnNewAddress_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                var  AddressType = AddressTypeString.TryParseEnum <AddressTypes>();
                int  OriginalRecurringOrderNumber   = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber");
                bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo");

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

                Address thisAddress = new Address();

                thisAddress.ThisCustomer = ThisCustomer;
                thisAddress.CustomerCode = ThisCustomer.CustomerCode;

                thisAddress.Name          = ctrlAddress.AccountName;
                thisAddress.Address1      = ctrlAddress.Address;
                thisAddress.City          = ctrlAddress.City;
                thisAddress.State         = ctrlAddress.State;
                thisAddress.PostalCode    = ctrlAddress.PostalCode;
                thisAddress.Country       = ctrlAddress.CountryCode;
                thisAddress.Phone         = ctrlAddress.PhoneNumber;
                thisAddress.County        = ctrlAddress.County;
                thisAddress.ResidenceType = ctrlAddress.ResidenceType;

                if (!CheckToValidate(thisAddress, AddressType))
                {
                    switch (AddressType)
                    {
                    case AddressTypes.Shared:

                        InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary);
                        InterpriseHelper.AddCustomerShipTo(thisAddress);
                        break;

                    case AddressTypes.Billing:

                        InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary);
                        break;

                    case AddressTypes.Shipping:

                        InterpriseHelper.AddCustomerShipTo(thisAddress);
                        break;
                    }

                    Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}", checkOutMode.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL)));
                }
            }
        }
Пример #2
0
        public void btnNewAddress_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                var  AddressType = AddressTypeString.TryParseEnum <AddressTypes>();
                int  OriginalRecurringOrderNumber   = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber");
                bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo");

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

                //changes for mobile design
                var thisAddress = ctrlAddress.ExtractAddress(ThisCustomer);
                thisAddress.CustomerCode = ThisCustomer.CustomerCode;
                thisAddress.Name         = ctrlAddress.AccountName;

                if (!CheckToValidate(thisAddress, AddressType))
                {
                    switch (AddressType)
                    {
                    case AddressTypes.Shared:

                        InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary);
                        InterpriseHelper.AddCustomerShipTo(thisAddress);
                        break;

                    case AddressTypes.Billing:

                        InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary);
                        break;

                    case AddressTypes.Shipping:

                        InterpriseHelper.AddCustomerShipTo(thisAddress);
                        break;
                    }

                    string url = "selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}".FormatWith(checkOutMode.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL));
                    Response.Redirect(url);
                }
            }
        }
        public void btnNewAddress_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                var  AddressType = AddressTypeString.TryParseEnum <AddressTypes>();
                int  OriginalRecurringOrderNumber   = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber");
                bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo");

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

                Address thisAddress = new Address();

                thisAddress.ThisCustomer = ThisCustomer;
                thisAddress.CustomerCode = ThisCustomer.CustomerCode;


                string bCityStates = txtCityStates.Text;
                string city        = string.Empty;
                string state       = string.Empty;

                if (!string.IsNullOrEmpty(bCityStates))
                {
                    var _cityState = bCityStates.Split(',');

                    if (_cityState.Length > 1)
                    {
                        state = _cityState[0].Trim();
                        city  = _cityState[1].Trim();
                    }
                    else
                    {
                        city  = _cityState[0].Trim();
                        state = string.Empty;
                    }
                }
                else
                {
                    state = AddressControl.state;
                    city  = AddressControl.city;
                }

                thisAddress.Name       = txtContactName.Text;
                thisAddress.Address1   = AddressControl.street;
                thisAddress.City       = city;
                thisAddress.State      = state;
                thisAddress.PostalCode = AddressControl.postal;
                thisAddress.Country    = AddressControl.country;
                thisAddress.Phone      = txtContactNumber.Text;

                if (AppLogic.AppConfigBool("Address.ShowCounty"))
                {
                    thisAddress.County = AddressControl.county;
                }

                switch (AddressType)
                {
                case AddressTypes.Shared:

                    thisAddress.ResidenceType = ResidenceTypes.Residential;

                    InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary);
                    InterpriseHelper.AddCustomerShipTo(thisAddress);

                    break;

                case AddressTypes.Billing:

                    thisAddress.ResidenceType = ResidenceTypes.Residential;
                    InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary);


                    break;

                case AddressTypes.Shipping:

                    if (AddressControl.residenceType == ResidenceTypes.Residential.ToString())
                    {
                        thisAddress.ResidenceType = ResidenceTypes.Residential;
                    }
                    else
                    {
                        thisAddress.ResidenceType = ResidenceTypes.Commercial;
                    }

                    InterpriseHelper.AddCustomerShipTo(thisAddress);

                    break;
                }

                AppLogic.SavePostalCode(thisAddress);
                Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}", checkOutMode.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL)));
            }
        }