public void Bind() { if (UserAccount.AccountID > 0) { AccountService service = new AccountService(); Account _account = service.GetByAccountID(UserAccount.AccountID); if (_account != null) { _billingAddress.FirstName = _account.BillingFirstName; _billingAddress.LastName = _account.BillingLastName; _billingAddress.PhoneNumber = _account.BillingPhoneNumber; _billingAddress.Street1 = _account.BillingStreet; _billingAddress.Street2 = _account.BillingStreet1; _billingAddress.StateCode = _account.BillingStateCode; _billingAddress.PostalCode = _account.BillingPostalCode; _billingAddress.EmailId = _account.BillingEmailID; _billingAddress.CompanyName = _account.BillingCompanyName; _billingAddress.City = _account.BillingCity; _shippingAddress.FirstName = _account.ShipFirstName; _shippingAddress.LastName = _account.ShipLastName; _shippingAddress.CompanyName = _account.ShipCompanyName; _shippingAddress.PhoneNumber = _account.ShipPhoneNumber; _shippingAddress.Street1 = _account.ShipStreet; _shippingAddress.Street2 = _account.ShipStreet1; _shippingAddress.City = _account.ShipCity; _shippingAddress.PostalCode = _account.ShipPostalCode; _shippingAddress.StateCode = _account.ShipStateCode; _shippingAddress.EmailId = _account.ShipEmailID; } btnUpdate.Text = "Update"; } else { _billingAddress = new ZNodeAddress(); _shippingAddress = new ZNodeAddress(); btnUpdate.Text = "Create an account"; } //get user's address BillingAddress = _billingAddress; ShippingAddress = _shippingAddress; }
/// <summary> /// Event is raised when the "Update" Button is clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { AccountService accountService = new AccountService(); Account _account = UserAccount; ZNodeUserAccount _userAccount = new ZNodeUserAccount(); if (_account.AccountID == 0) { _userAccount.PortalID = ZNodeConfigManager.SiteConfig.PortalID; _userAccount.BillingAddress = BillingAddress; _userAccount.ShippingAddress = ShippingAddress; _userAccount.AddUserAccount(); int accountID = _userAccount.AccountID; _account = accountService.GetByAccountID(accountID); UserAccount = _account; // ZNode.Libraries.Admin.ProfileAdmin profileAdmin = new ZNode.Libraries.Admin.ProfileAdmin(); HttpContext.Current.Session["ProfileCache"] = profileAdmin.GetByProfileID(_account.ProfileID.Value); } else { //Billing Address _account.BillingFirstName = BillingAddress.FirstName; _account.BillingLastName = BillingAddress.LastName; _account.BillingCompanyName = BillingAddress.CompanyName; _account.BillingStreet = BillingAddress.Street1; _account.BillingStreet1 = BillingAddress.Street2; _account.BillingCity = BillingAddress.City; _account.BillingPostalCode = BillingAddress.PostalCode; _account.BillingStateCode = BillingAddress.StateCode; _account.BillingCountryCode = BillingAddress.CountryCode; _account.BillingEmailID = BillingAddress.EmailId; _account.BillingPhoneNumber = BillingAddress.PhoneNumber; //Shipping Address _account.ShipFirstName = ShippingAddress.FirstName; _account.ShipLastName = ShippingAddress.LastName; _account.ShipCompanyName = ShippingAddress.CompanyName; _account.ShipStreet = ShippingAddress.Street1; _account.ShipStreet1 = ShippingAddress.Street2; _account.ShipCity = ShippingAddress.City; _account.ShipPostalCode = ShippingAddress.PostalCode; _account.ShipStateCode = ShippingAddress.StateCode; _account.ShipCountryCode = ShippingAddress.CountryCode; _account.ShipEmailID = ShippingAddress.EmailId; _account.ShipPhoneNumber = ShippingAddress.PhoneNumber; //Update account accountService.Update(_account); //Set account object to cache object UserAccount = _account; if (_account.UserID.HasValue) { MembershipUser user = Membership.GetUser(_account.UserID.Value); if (user != null) { user.Email = _account.BillingEmailID; Membership.UpdateUser(user); } } } //Triggers parent control event if (ButtonClick != null) { this.ButtonClick(sender, e); } }
/// <summary> /// Occurs when one of the pager buttons is clicked, /// but before the "FoundUsers" GridView control handles the paging operation. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ui_FoundUsers_SelectedIndexChanged(object sender, EventArgs e) { //Retrieve Account Id Label userLogin = ui_FoundUsers.Rows[ui_FoundUsers.SelectedIndex].FindControl("ui_CustomerIdSelect") as Label; AccountService accountService = new AccountService(); Account _account = accountService.GetByAccountID(int.Parse(userLogin.Text)); if (_account != null) { UserAccount = _account;//Set Page session object // ZNode.Libraries.Admin.ProfileAdmin profileAdmin = new ZNode.Libraries.Admin.ProfileAdmin(); HttpContext.Current.Session["ProfileCache"] = profileAdmin.GetByProfileID(_account.ProfileID.Value); } if (SelectedIndexChanged != null) { //Triggers parent control event this.SelectedIndexChanged(sender, e); } }