private void BindAlbums() { DbObjects.Business.User currentUser = Business.BasePage.CurrentUser; rptAlbums.DataSource = currentUser.CustomerAlbums; rptAlbums.DataBind(); }
protected void btnLogIn_Click(object sender, EventArgs e) { lblError.Text = ""; if (DbObjects.Business.User.EmailAddressExists(txtEmailAddress.Text)) { DbObjects.Business.User user = new DbObjects.Business.User(txtEmailAddress.Text); if (user.Password == txtPassword.Text) { CurrentUser = user; FormsAuthentication.SetAuthCookie(user.UserId.ToString(), false); Redirect(user); } else { lblError.Text = "Incorrect password"; return; } } else { lblError.Text = "No account exists for that email address"; return; } }
private void BindCustomer() { DbObjects.Business.User customer = CurrentUser; lblUserId.Text = customer.UserId.ToString(); txtFirstName.Text = customer.FirstName; txtSurname.Text = customer.Surname; txtEmailAddress.Text = customer.EmailAddress; lblDateCreated.Text = customer.DateAdded.ToString("dddd d MMMM yyyy"); }
protected void btnSaveChanges_Click(object sender, EventArgs e) { DbObjects.Business.User customer = CurrentUser; if (String.IsNullOrEmpty(txtFirstName.Text)) { lblError.Text = "Please enter your first name"; mpeError.Show(); return; } if (String.IsNullOrEmpty(txtSurname.Text)) { lblError.Text = "Please enter your surname"; mpeError.Show(); return; } if (txtEmailAddress.Text != customer.EmailAddress) { if (String.IsNullOrEmpty(txtEmailAddress.Text)) { lblError.Text = "Please enter your email address"; mpeError.Show(); return; } if (!(IsEmailAddressValid(txtEmailAddress.Text))) { lblError.Text = "Please enter a valid email address"; mpeError.Show(); return; } if (DbObjects.Business.User.EmailAddressExists(txtEmailAddress.Text)) { lblError.Text = "There is already another customer with that email address"; mpeError.Show(); return; } } customer.FirstName = txtFirstName.Text; customer.Surname = txtSurname.Text; customer.EmailAddress = txtEmailAddress.Text; customer.Save(); BindCustomer(); lblConfirmation.Text = "Successfully saved changes"; }
protected void Page_Load(object sender, EventArgs e) { DbObjects.Business.User currentUser = Business.BasePage.CurrentUser; if (currentUser == null) { Response.Redirect("../../"); } if (!(currentUser.Admin)) { Response.Redirect("../Customer"); } }
private void BindCustomer() { DbObjects.Business.User customer = SelectedCustomer; if (String.IsNullOrEmpty(customer.FullName)) { Master.ThumbnailLabel.Text = "Admin >> <a href=\"Customers.aspx\">Customers</a> >> New Customer"; } else { Master.ThumbnailLabel.Text = "Admin >> <a href=\"Customers.aspx\">Customers</a> >> " + customer.FullName; } rptAlbums.DataSource = customer.CustomerAlbums; rptAlbums.DataBind(); }
private void Redirect(DbObjects.Business.User user) { if (String.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) { if (user.Admin) { Response.Redirect("Admin"); } else { Response.Redirect("Customer"); } } else { Response.Redirect(Request.QueryString["ReturnUrl"]); } }
protected void Page_Load(object sender, EventArgs e) { DbObjects.Business.User currentUser = Business.BasePage.CurrentUser; if (currentUser == null) { Response.Redirect("../../"); } if (currentUser.Admin) { Response.Redirect("../Admin"); } if (!(IsPostBack)) { BindAlbums(); } }
protected void Page_Load(object sender, EventArgs e) { ErrorPageUrl = "ContentErrorPage.aspx"; if (SelectedCustomer == null) { SelectedCustomer = new DbObjects.Business.User(); } else if (SelectedCustomer.IsInDatabase) { SelectedCustomer = new DbObjects.Business.User(SelectedCustomer.UserId); } CustomerImageFolder = "../Customer/Images/" + SelectedCustomer.UserId.ToString() + "/"; if (!(IsPostBack)) { BindCustomer(); } }
protected void btnChangePasswordOk_Click(object sender, EventArgs e) { DbObjects.Business.User customer = CurrentUser; lblChangePasswordError.Text = ""; if (String.IsNullOrEmpty(txtCurrentPassword.Text)) { lblChangePasswordError.Text = "Please enter your current password"; mpeChangePassword.Show(); return; } if (txtCurrentPassword.Text != customer.Password) { lblChangePasswordError.Text = "That is not your current password"; mpeChangePassword.Show(); return; } if (String.IsNullOrEmpty(txtNewPassword.Text)) { lblChangePasswordError.Text = "Please enter your new password"; mpeChangePassword.Show(); return; } if (txtConfirmPassword.Text != txtNewPassword.Text) { lblChangePasswordError.Text = "Passwords to not match"; mpeChangePassword.Show(); return; } customer.Password = txtNewPassword.Text; customer.Save(); lblConfirmation.Text = "Successfully changed password"; }
protected void btnAddCustomer_Click(object sender, EventArgs e) { SelectedCustomer = new DbObjects.Business.User(); Response.Redirect("Customer.aspx"); }
protected void btnSaveChanges_Click(object sender, EventArgs e) { DbObjects.Business.User customer = SelectedCustomer; lblError.Text = ""; if (String.IsNullOrEmpty(txtFirstName.Text)) { lblError.Text = "Please give the customer a first name"; mpeError.Show(); return; } if (String.IsNullOrEmpty(txtSurname.Text)) { lblError.Text = "Please give the customer a surname"; mpeError.Show(); return; } if (String.IsNullOrEmpty(txtEmailAddress.Text)) { lblError.Text = "Please give the customer an email address"; mpeError.Show(); return; } if (!(IsEmailAddressValid(txtEmailAddress.Text))) { lblError.Text = "Please enter a valid email address"; mpeError.Show(); return; } if (DbObjects.Business.User.EmailAddressExists(txtEmailAddress.Text)) { lblError.Text = "There is already another customer with that email address"; mpeError.Show(); return; } if (String.IsNullOrEmpty(txtPassword.Text)) { lblError.Text = "Please give the new customer a password"; mpeError.Show(); return; } if (!(txtPassword.Text == txtConfirmPassword.Text)) { lblError.Text = "Please make sure both passwords match"; mpeError.Show(); return; } customer.FirstName = txtFirstName.Text; customer.Surname = txtSurname.Text; customer.EmailAddress = txtEmailAddress.Text; customer.Password = txtPassword.Text; customer.Save(); BindCustomer(); }