protected void Page_Load(object sender, EventArgs e) { SessionCleanup(); if (!IsPostBack) { if ((Session["accountID"] == null)) { // go back to the seach accounts page Response.Redirect("~/Accounts/SearchAccount.aspx"); } else { _accountID = Convert.ToInt32(Session["accountID"]); _accountSearched = AccountManager.GetAccountByID(_accountID); // dislay the account details DisplayAccount(_accountSearched); // With the account id, get the address id for the Home Address // from the AccountAddress table _homeAddress.AddressID = AccountAddressManager.GetAddressID(Convert.ToInt32(AddressType.Home), _accountSearched.AccountID); _homeAddress = AddressManager.GetAddressById(_homeAddress.AddressID); DisplayHomeAddress(_homeAddress); // With the account id, get the address id for the Mailing Address // from the AccountAddress table _mailingAddress.AddressID = AccountAddressManager.GetAddressID(Convert.ToInt32(AddressType.Mailing), _accountSearched.AccountID); _mailingAddress = AddressManager.GetAddressById(_mailingAddress.AddressID); DisplayMailingAddress(_mailingAddress); /* Populate the tabs */ //Authorized Members Tab DisplayAuthorizedMembers(_accountSearched); DisplayServiceHistory(_accountSearched); DisplayWaterAnalysis(); DisplayPrepaidWater(); DisplayWTE(); } } }
protected void lnkSave_Command(object sender, CommandEventArgs e) { // Save the new account Account myAccount = null; myAccount = GetAccountDetailsFromForm(); myAccount.AccountID = AccountManager.Save(myAccount); //Save the home address Address myHomeAddress = null; myHomeAddress = GetHomeAddressDetailsFromForm(); myHomeAddress.AddressID = AddressManager.Save(myHomeAddress); //save the mailing address Address myMailingAddress = null; myMailingAddress = GetMailingAddressDetailsFromForm(); myMailingAddress.AddressID = AddressManager.Save(myMailingAddress); //Save the Home address and the new account on the AccountAddress table AccountAddress newAccountAddress = new AccountAddress(); newAccountAddress.AccountID = myAccount.AccountID; newAccountAddress.AddressID = myHomeAddress.AddressID; newAccountAddress.AddressType = Convert.ToInt32(AddressType.Home); AccountAddressManager.AddAccountAddress(newAccountAddress); // Save the Mailing address and new account on the AccountAddress table newAccountAddress.AddressID = myMailingAddress.AddressID; newAccountAddress.AddressType = Convert.ToInt32(AddressType.Mailing); AccountAddressManager.AddAccountAddress(newAccountAddress); Session["accountID"] = null; Session["accountID"] = myAccount.AccountID; Response.Redirect("~/Accounts/ViewAccount.aspx"); }