dkeymel: thanks for pointing this out.
The changes you've made below would work however, it'll insert a new address (shipping/billing) record in the DB everytime you go back from checkoutreview.aspx to edit the information.
Try doing the changes below instead:
Create two private void methods in checkout1.aspx.cs and call them BillingAddressInfo & ShippingAddressInfo.
#1
Code:
private void BillingAddressInfo()
{
BillingAddress.LastName = ctrlBillingAddress.LastName;
BillingAddress.FirstName = ctrlBillingAddress.FirstName;
BillingAddress.Phone = ctrlBillingAddress.PhoneNumber;
BillingAddress.Company = ctrlBillingAddress.Company;
BillingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlBillingAddress.ResidenceType, true);//(ResidenceTypes) Convert.ToInt32( ctrlBillingAddress.AddressType);
BillingAddress.Address1 = ctrlBillingAddress.Address1;
BillingAddress.Address2 = ctrlBillingAddress.Address2;
BillingAddress.Suite = ctrlBillingAddress.Suite;
BillingAddress.City = ctrlBillingAddress.City;
BillingAddress.State = ctrlBillingAddress.State;
BillingAddress.Zip = ctrlBillingAddress.ZipCode;
BillingAddress.Country = ctrlBillingAddress.Country;
}
#2
Code:
private void ShippingAddressInfo()
{
ShippingAddress.LastName = ctrlShippingAddress.LastName;
ShippingAddress.FirstName = ctrlShippingAddress.FirstName;
ShippingAddress.Phone = ctrlShippingAddress.PhoneNumber;
ShippingAddress.Company = ctrlShippingAddress.Company;
ShippingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlShippingAddress.ResidenceType, true);//(ResidenceTypes)Convert.ToInt32(ctrlShippingAddress.AddressType);
ShippingAddress.Address1 = ctrlShippingAddress.Address1;
ShippingAddress.Address2 = ctrlShippingAddress.Address2;
ShippingAddress.Suite = ctrlShippingAddress.Suite;
ShippingAddress.City = ctrlShippingAddress.City;
ShippingAddress.State = ctrlShippingAddress.State;
ShippingAddress.Zip = ctrlShippingAddress.ZipCode;
ShippingAddress.Country = ctrlShippingAddress.Country;
}
then, under the ProcessAccount() method, the same line as your changes do the following:
For BillingAddress:
Code:
if (ThisCustomer.PrimaryBillingAddressID == 0)
{
BillingAddress = new Address();
BillingAddressInfo();
BillingAddress.EMail = EMailField;
BillingAddress.InsertDB(ThisCustomer.CustomerID);
BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Billing);
ThisCustomer.PrimaryBillingAddressID = BillingAddress.AddressID;
}
else
{
BillingAddressInfo();
BillingAddress.EMail = EMailField;
BillingAddress.UpdateDB();
}
For ShippingAddress:
Code:
if (AllowShipToDifferentThanBillTo && !AppLogic.AppConfigBool("SkipShippingOnCheckout"))
{
if (ThisCustomer.PrimaryShippingAddressID == 0)
{
ShippingAddress = new Address();
ShippingAddressInfo();
ShippingAddress.EMail = EMailField;
ShippingAddress.InsertDB(ThisCustomer.CustomerID);
ShippingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping);
ThisCustomer.PrimaryShippingAddressID = ShippingAddress.AddressID;
}
else
{
ShippingAddressInfo();
ShippingAddress.EMail = EMailField;
ShippingAddress.UpdateDB();
}
}
Instead of calling the InsertDB() method (which will insert new address record in the DB everytime it's called), we'll use the UpdateDB() instead to only update whatever changes made.