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)));
                }
            }
        }
Esempio n. 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)));
            }
        }
Esempio n. 4
0
        private void PerformPageAccessLogic()
        {
            RequireSecurePage();
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));

            //If current user came from IS, chances are it has no Primary Billing Info!
            if (ThisCustomer.PrimaryBillingAddressID == String.Empty)
            {
                // IS Facade implementation
                string[][] commandSet;
                string[][] parameters;

                var customerGateway = new CustomerDetailDatasetGateway();
                var iseCustomer     = new CustomerDetailFacade(customerGateway);

                // Specific view and stored procedure
                commandSet = new string[][] { new string[] { "CustomerView", "ReadCustomer" } };
                parameters = new string[][] { new string[] { "@CustomerCode", null } };

                // Load it at defined Dataset
                iseCustomer.LoadDataSet(commandSet, parameters, Interprise.Framework.Base.Shared.Enum.ClearType.Specific, Interprise.Framework.Base.Shared.Enum.ConnectionStringType.Online);

                // Retrieve data information, store it at DataRow array
                // Filter the data information based on the Customer Code
                DataRow[] rowsCustomer = customerGateway.Tables["CustomerView"].Select(string.Concat("CustomerCode = '", ThisCustomer.CustomerCode, "'"));

                // It should return 1 record from filtered dataset.
                if (rowsCustomer.Length > 0)
                {
                    // By Default
                    string ResidenceType = "Residential";

                    // Address Class to store address information
                    // retrieve via DataRow array
                    var thisAddress = new Address
                    {
                        CustomerCode = ThisCustomer.CustomerCode,
                        Name         = rowsCustomer[0]["CustomerName"].ToString(),
                        Address1     = rowsCustomer[0]["Address"].ToString(),
                        City         = rowsCustomer[0]["City"].ToString(),
                        State        = rowsCustomer[0]["State"].ToString(),
                        PostalCode   = rowsCustomer[0]["PostalCode"].ToString(),
                        Country      = rowsCustomer[0]["Country"].ToString(),
                        Phone        = rowsCustomer[0]["Telephone"].ToString(),
                        County       = rowsCustomer[0]["County"].ToString()
                    };

                    // set default if null
                    if (!string.IsNullOrEmpty(rowsCustomer[0]["ResidenceType"].ToString()))
                    {
                        ResidenceType = rowsCustomer[0]["ResidenceType"].ToString();
                    }

                    thisAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ResidenceType);

                    // Adding of Customer Billing Address Information
                    InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, true);
                }
                else
                {
                    // If no Record is found
                    // Redirects to address information entry
                    Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=False&addressType=Billing&returnURL=account.aspx");
                }
            }

            ThisCustomer.ValidatePrimaryAddresses();
            SkinImagePath = "skins/skin_" + SkinID.ToString() + "/images/";
        }