private void SaveShippingAddress()
        {
            int     addressId = AlwaysConvert.ToInt(AddressId.Value);
            Address address   = AddressDataSource.Load(addressId);

            if (address == null)
            {
                address      = new Address();
                address.User = _User;
            }

            address.FirstName   = FirstName.Text;
            address.LastName    = LastName.Text;
            address.Company     = Company.Text;
            address.Address1    = Address1.Text;
            address.Address2    = Address2.Text;
            address.City        = City.Text;
            address.Province    = Province.Text;
            address.PostalCode  = PostalCode.Text;
            address.CountryCode = CountryCode.Items[CountryCode.SelectedIndex].Value;
            address.Phone       = Phone.Text;
            address.Fax         = Fax.Text;
            address.Residence   = (Residence.SelectedIndex == 0);
            address.Save();
            AddressId.Value = address.Id.ToString();
        }
        protected BasketShipment GetShipment(int warehouseId, int addressId, bool create)
        {
            Basket    basket    = _Basket;
            Warehouse warehouse = WarehouseDataSource.Load(warehouseId);
            Address   address   = AddressDataSource.Load(addressId);

            foreach (BasketShipment shipment in basket.Shipments)
            {
                if ((shipment.Warehouse.Id == warehouseId) || (shipment.Warehouse.Id == 0))
                {
                    if ((shipment.Address.Id == addressId) || (shipment.Address.Id == 0))
                    {
                        shipment.Warehouse = warehouse;
                        shipment.Address   = address;
                        return(shipment);
                    }
                }
            }
            if (!create)
            {
                return(null);
            }

            //IF WE COME THIS FAR, AN EXISTING SHIPMENT WAS NOT AVAILABLE
            //ADD A NEW SHIPMENT
            BasketShipment newShipment = new BasketShipment();

            newShipment.Basket    = basket;
            newShipment.Warehouse = warehouse;
            newShipment.Address   = address;
            basket.Shipments.Add(newShipment);
            newShipment.Save();
            return(newShipment);
        }
예제 #3
0
 public AddressTableData(Wallet wallet = null, NSTableView tableView = null)
 {
     Wallet     = wallet;
     TableView  = tableView;
     DataSource = new AddressDataSource(this);
     Delegate   = new AddressDelegate(this);
 }
        private void BindShippingAddresses(bool clearExistingItems = false)
        {
            // BIND (OR RE-BIND) SHIPPING ADDRESSES
            string itemText;

            if (clearExistingItems)
            {
                ShippingAddressList.Items.Clear();
            }

            // ADD ADDRESSES FROM USER ADDRESS BOOK
            IList <Address> userAddresses = AddressDataSource.LoadForUser(_userId);

            foreach (Address address in userAddresses)
            {
                itemText = GetAddressItemText(address.FirstName, address.LastName, address.Address1, address.City, address.PostalCode, address.Province, address.CountryCode);
                if (ShippingAddressList.Items.FindByText(itemText) == null)
                {
                    if (address.Id == _User.PrimaryAddressId)
                    {
                        continue;
                    }
                    ShippingAddressList.Items.Add(new ListItem(itemText, address.Id.ToString()));
                }
            }

            ShippingAddressList.Items.Add(new ListItem("Add New Address..", "-1"));
        }
예제 #5
0
        protected void SetFormattedShipAddress(int addressId)
        {
            Address addr = AddressDataSource.Load(addressId);

            if (addr != null)
            {
                SetFormattedShipAddress(addr);
            }
        }
        protected void DeleteAddressButton_Click(object sender, EventArgs e)
        {
            int addressId = AlwaysConvert.ToInt(ShippingAddressList.SelectedValue);

            if (addressId > 0)
            {
                AddressDataSource.Delete(addressId);
                BindShippingAddresses(true);
            }
        }
예제 #7
0
        protected void AddressList_SelectedIndexChanged(object sender, EventArgs e)
        {
            var address = AddressDataSource.Load(AlwaysConvert.ToInt(AddressList.SelectedValue));

            BindShippingMethods(address, true);

            trUseExistingAddress.Visible     = true;
            trAddressList.Visible            = true;
            ShippingAddressTextPanel.Visible = true;
            trShippingAddress.Visible        = false;
        }
        protected void BindShippingAddresses(DropDownList shippingAddress)
        {
            // keep selected value
            string selectedValue = AddressList.SelectedItem.Value;

            // BIND (OR RE-BIND) SHIPPING ADDRESSES
            string itemText;

            // ADD SHIP TO ADDRESSES
            foreach (OrderShipment shipment in _Order.Shipments)
            {
                itemText = GetAddressItemText(shipment.ShipToFirstName, shipment.ShipToLastName, shipment.ShipToAddress1, shipment.ShipToCity);
                if (shippingAddress.Items.FindByText(itemText) == null)
                {
                    shippingAddress.Items.Add(new ListItem(itemText, "S_" + shipment.Id));
                }
            }

            // ADD ADDRESSES FROM USER ADDRESS BOOK
            IList <Address> userAddresses = AddressDataSource.LoadForUser(_Order.UserId);

            foreach (Address address in userAddresses)
            {
                itemText = GetAddressItemText(address.FirstName, address.LastName, address.Address1, address.City);
                if (shippingAddress.Items.FindByText(itemText) == null)
                {
                    shippingAddress.Items.Add(new ListItem(itemText, address.Id.ToString()));
                }
            }

            // ADD ORDER BILL TO ADDRESS
            itemText = GetAddressItemText(_Order.BillToFirstName, _Order.BillToLastName, _Order.BillToAddress1, _Order.BillToCity);
            if (shippingAddress.Items.FindByText(itemText) == null)
            {
                shippingAddress.Items.Insert(0, new ListItem(itemText, "B_" + _Order.Id));
            }

            // restore selected value
            int selectedAddressId = AlwaysConvert.ToInt(selectedValue);

            if (selectedAddressId > 0)
            {
                ListItem item = AddressList.Items.FindByValue(selectedValue);
                AddressList.SelectedItem.Selected = false;
                item.Selected = true;
            }
        }
        protected void DoLoad(bool external)
        {
            _address = AddressDataSource.Load(AddressId);
            if (_address == null)
            {
                _address = new Address();
            }

            if (!string.IsNullOrEmpty(ValidationGroupName))
            {
                EmailAddressValid.ValidationGroup         = ValidationGroupName;
                FirstNameRequired.ValidationGroup         = ValidationGroupName;
                LastNameRequired.ValidationGroup          = ValidationGroupName;
                Address1Required.ValidationGroup          = ValidationGroupName;
                CityRequired.ValidationGroup              = ValidationGroupName;
                PostalCodeRequired.ValidationGroup        = ValidationGroupName;
                Province2Invalid.ValidationGroup          = ValidationGroupName;
                Province2Required.ValidationGroup         = ValidationGroupName;
                TelephoneRequired.ValidationGroup         = ValidationGroupName;
                SaveButton.ValidationGroup                = ValidationGroupName;
                RegisterValidationSummary.ValidationGroup = ValidationGroupName;

                // PASSWORD FIELDS
                PasswordRequired.ValidationGroup        = ValidationGroupName;
                ConfirmPasswordRequired.ValidationGroup = ValidationGroupName;
                PasswordCompare.ValidationGroup         = ValidationGroupName;
                DuplicateEmailValidator.ValidationGroup = ValidationGroupName;
                InvalidRegistration.ValidationGroup     = ValidationGroupName;
            }

            if (!Page.IsPostBack || external)
            {
                Country.DataSource = CountryDataSource.LoadAll();
                Country.DataBind();
                InitAddressForm();
            }
            // handle create account options

            CreateAccountUpdatePanel.Visible = AbleContext.Current.User.IsAnonymousOrGuest;
            if (CreateAccountUpdatePanel.Visible)
            {
                ShowPasswordPolicy();
            }
        }
        private void BindAddress()
        {
            //INIT ADDRESS
            int     addressId = AlwaysConvert.ToInt(AddressId.Value);
            Address address   = AddressDataSource.Load(addressId);

            if (address != null)
            {
                FirstName.Text  = address.FirstName;
                LastName.Text   = address.LastName;
                Company.Text    = address.Company;
                Address1.Text   = address.Address1;
                Address2.Text   = address.Address2;
                City.Text       = address.City;
                Province.Text   = address.Province;
                PostalCode.Text = address.PostalCode;
                ListItem selectedCountry = CountryCode.Items.FindByValue(AbleContext.Current.Store.DefaultWarehouse.CountryCode);
                if (!String.IsNullOrEmpty(address.CountryCode))
                {
                    selectedCountry = CountryCode.Items.FindByValue(address.CountryCode.ToString());
                }
                if (selectedCountry != null)
                {
                    CountryCode.SelectedIndex = CountryCode.Items.IndexOf(selectedCountry);
                }
                Phone.Text = address.Phone;
                Fax.Text   = address.Fax;
                Residence.SelectedIndex = (address.Residence ? 0 : 1);
            }
            else
            {
                string countryCode = _User.PrimaryAddress != null ? _User.PrimaryAddress.CountryCode : string.Empty;
                if (string.IsNullOrEmpty(countryCode))
                {
                    countryCode = AbleContext.Current.Store.DefaultWarehouse.CountryCode;
                }
                ListItem selectedCountry = CountryCode.Items.FindByValue(countryCode);
                if (selectedCountry != null)
                {
                    CountryCode.SelectedIndex = CountryCode.Items.IndexOf(selectedCountry);
                }
            }
        }
예제 #11
0
        void CheckedOut(object sender, CheckedOutEventArgs e)
        {
            CheckoutResponse response = e.CheckoutResponse;

            if (response.Success)
            {
                // STOP TRACKING THE ANONYMOUS USER
                Session["CreateOrder_AnonUserId"] = null;

                // CREATE / LINK USER ACCOUNT IF NEEDED
                if (RegisterPanel.Visible && CreateAccount.Checked)
                {
                    if (_ExistingUser == null)
                    {
                        // THERE IS NO EXISTING ACCOUNT, SO CREATE A NEW USER
                        string email = _User.PrimaryAddress.Email;
                        _User.UserName   = email;
                        _User.Email      = email;
                        _User.IsApproved = true;
                        _User.Save();
                        _User.SetPassword(Password.Text);
                        _User.Passwords[0].ForceExpiration = ForceExpiration.Checked;
                        _User.Save();
                    }
                    else
                    {
                        // THERE IS AN EXISTING USER, SO MIGRATE THIS ORDER
                        OrderDataSource.UpdateUser(_UserId, _ExistingUser.Id);
                        AddressDataSource.UpdateUser(_UserId, _ExistingUser.Id);
                    }
                }

                // REDIRECT TO THE FINAL ORDER
                Response.Redirect("~/Admin/Orders/ViewOrder.aspx?OrderNumber=" + response.Order.OrderNumber);
            }
            else
            {
                // SHOW ERRORS TO CUSTOMER
                WarningMessageList.DataSource = e.CheckoutResponse.WarningMessages;
                WarningMessageList.DataBind();
            }
        }
예제 #12
0
        protected void BindShippingAddresses(DropDownList shippingAddress)
        {
            // BIND (OR RE-BIND) SHIPPING ADDRESSES
            string itemText;

            // ADD SHIP TO ADDRESSES
            foreach (OrderShipment shipment in _Order.Shipments)
            {
                itemText = GetAddressItemText(shipment.ShipToFirstName, shipment.ShipToLastName, shipment.ShipToAddress1, shipment.ShipToCity);
                if (shippingAddress.Items.FindByText(itemText) == null)
                {
                    shippingAddress.Items.Add(new ListItem(itemText, "S_" + shipment.Id));
                }
            }

            // ADD ADDRESSES FROM USER ADDRESS BOOK
            IList <Address> userAddresses = AddressDataSource.LoadForUser(_Order.UserId);

            foreach (Address address in userAddresses)
            {
                itemText = GetAddressItemText(address.FirstName, address.LastName, address.Address1, address.City);
                if (shippingAddress.Items.FindByText(itemText) == null)
                {
                    shippingAddress.Items.Add(new ListItem(itemText, address.Id.ToString()));
                }
            }

            // ADD ORDER BILL TO ADDRESS
            itemText = GetAddressItemText(_Order.BillToFirstName, _Order.BillToLastName, _Order.BillToAddress1, _Order.BillToCity);
            if (shippingAddress.Items.FindByText(itemText) == null)
            {
                shippingAddress.Items.Insert(0, new ListItem(itemText, "B_" + _Order.Id));
            }

            // ADD NEW ITEM
            shippingAddress.Items.Add(new ListItem("Add new..."));
        }
        private void SetAddress(OrderShipment newShipment)
        {
            string selectedValue = AddressList.SelectedItem.Value;

            //USE EXISTING ADDRESS
            if (selectedValue.StartsWith("B_"))
            {
                //USE ORDER BILLING ADDRESS
                newShipment.ShipToFirstName   = _Order.BillToFirstName;
                newShipment.ShipToLastName    = _Order.BillToLastName;
                newShipment.ShipToAddress1    = _Order.BillToAddress1;
                newShipment.ShipToAddress2    = _Order.BillToAddress2;
                newShipment.ShipToCity        = _Order.BillToCity;
                newShipment.ShipToProvince    = _Order.BillToProvince;
                newShipment.ShipToPostalCode  = _Order.BillToPostalCode;
                newShipment.ShipToCountryCode = _Order.BillToCountryCode;
                newShipment.ShipToPhone       = _Order.BillToPhone;
                newShipment.ShipToCompany     = _Order.BillToCompany;
                newShipment.ShipToFax         = _Order.BillToFax;
                newShipment.ShipToResidence   = true;
            }
            else if (selectedValue.StartsWith("S_"))
            {
                //USE SHIPPING ADDRESS
                int shipmentId = AlwaysConvert.ToInt(AddressList.SelectedItem.Value.Split('_')[1]);
                int index      = _Order.Shipments.IndexOf(shipmentId);
                if (index > -1)
                {
                    OrderShipment shipment = _Order.Shipments[index];
                    newShipment.ShipToFirstName   = shipment.ShipToFirstName;
                    newShipment.ShipToLastName    = shipment.ShipToLastName;
                    newShipment.ShipToAddress1    = shipment.ShipToAddress1;
                    newShipment.ShipToAddress2    = shipment.ShipToAddress2;
                    newShipment.ShipToCity        = shipment.ShipToCity;
                    newShipment.ShipToProvince    = shipment.ShipToProvince;
                    newShipment.ShipToPostalCode  = shipment.ShipToPostalCode;
                    newShipment.ShipToCountryCode = shipment.ShipToCountryCode;
                    newShipment.ShipToPhone       = shipment.ShipToPhone;
                    newShipment.ShipToCompany     = shipment.ShipToCompany;
                    newShipment.ShipToFax         = shipment.ShipToFax;
                    newShipment.ShipToResidence   = shipment.ShipToResidence;
                }
            }
            else
            {
                //USE ADDRESS FROM ADDRESS BOOK
                int     addressId = AlwaysConvert.ToInt(selectedValue);
                Address address   = AddressDataSource.Load(addressId);
                newShipment.ShipToFirstName   = address.FirstName;
                newShipment.ShipToLastName    = address.LastName;
                newShipment.ShipToAddress1    = address.Address1;
                newShipment.ShipToAddress2    = address.Address2;
                newShipment.ShipToCity        = address.City;
                newShipment.ShipToProvince    = address.Province;
                newShipment.ShipToPostalCode  = address.PostalCode;
                newShipment.ShipToCountryCode = address.CountryCode;
                newShipment.ShipToPhone       = address.Phone;
                newShipment.ShipToCompany     = address.Company;
                newShipment.ShipToFax         = address.Fax;
                newShipment.ShipToResidence   = address.Residence;
            }
        }
예제 #14
0
		public AddressTableData(Wallet wallet = null, NSTableView tableView = null) {
			Wallet = wallet;
			TableView = tableView;
			DataSource = new AddressDataSource(this);
			Delegate = new AddressDelegate(this);
		}