Exemple #1
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        try
        {
            MembershipUser user = Membership.CreateUser(UsernameTextbox.Text, PasswordTextbox.Text, EmailAddressTextbox.Text);

            aspnet_Users newUser = new aspnet_Users();
            newUser.UserName = user.UserName;
            newUser.FirstName = FirstNameTextbox.Text;
            newUser.LastName = LastNameTextbox.Text;
            newUser.CustomerAddress = AddressTextbox.Text;
            newUser.City = CityTextbox.Text;
            newUser.Province = ProvinceTextbox.Text;
            newUser.PostalCode = PostalCodeTextbox.Text;
            newUser.PhoneNumber = PhoneNumberTextbox.Text;

            newUser.Approved = false;

            Brentwood.UpdateCustomer(newUser, EmailAddressTextbox.Text);

            FormMessage.Text = "Your account has been successfully created! You may now login to review or modify your information.";
            FormMessage.ForeColor = Color.Blue;

            Roles.AddUserToRole(newUser.UserName, "Customer");
        }
        catch (Exception ex)
        {
            if (ex.Message == "The password supplied is invalid.  Passwords must conform to the password strength requirements configured for the default provider.")
                FormMessage.Text = "Password must be at least 6 alphanumeric characters long";
            else
                FormMessage.Text = ex.Message;

            FormMessage.ForeColor = Color.Red;
        }
    }
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        aspnet_Users item = new aspnet_Users();
        item.UserId = Guid.Parse(CustomerView.DataKey.Value.ToString());
        item.UserName = CustomerView.Rows[0].Cells[1].Text.Trim();
        item.FirstName = (CustomerView.Rows[2].Cells[1].Controls[1] as TextBox).Text.Trim();
        item.LastName = (CustomerView.Rows[3].Cells[1].FindControl("LastNameTextbox") as TextBox).Text.Trim();
        item.CustomerAddress = (CustomerView.Rows[4].Cells[1].FindControl("AddressTextbox") as TextBox).Text.Trim();
        item.City = (CustomerView.Rows[5].Cells[1].FindControl("CityTextbox") as TextBox).Text.Trim();
        item.Province = (CustomerView.Rows[6].FindControl("ProvinceTextbox") as TextBox).Text.Trim();
        item.PostalCode = (CustomerView.Rows[7].FindControl("PostalCodeTextbox") as TextBox).Text.Trim();
        item.PhoneNumber = (CustomerView.Rows[8].FindControl("PhoneNumberTextbox") as TextBox).Text.Trim();
        item.CompanyID = int.Parse((CustomerView.Rows[10].FindControl("CompanyList") as DropDownList).SelectedValue);
        string email = (CustomerView.Rows[9].FindControl("EmailTextbox") as TextBox).Text.Trim();
        if (item.CompanyID == -1)
            item.CompanyID = null;
        item.IsAdmin = (CustomerView.Rows[11].FindControl("IsAdminCheckbox") as CheckBox).Checked;

        item.Approved = true;

        try
        {
            Roles.AddUserToRole(item.UserName, "Approved Customer");
            Brentwood.UpdateCustomer(item, email);
            FormMessage.Text = "Customer successfully approved!";
            FormMessage.ForeColor = Color.Black;
        }
        catch (Exception ex)
        {
            FormMessage.ForeColor = Color.Red;
            FormMessage.Text = ex.Message;
        }
    }
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        aspnet_Users user = new aspnet_Users();
        user.UserName = User.Identity.Name;
        user.FirstName = FirstNameTextbox.Text.Trim();
        user.LastName = LastNameTextbox.Text.Trim();
        user.CustomerAddress = AddressTextbox.Text.Trim();
        user.City = CityTextbox.Text.Trim();
        user.Province = ProvinceTextbox.Text.Trim().ToUpper();
        user.PostalCode = PostalTextbox.Text.Trim().ToUpper();
        user.PhoneNumber = PhoneTextbox.Text.Trim();

        if (NewPassTextbox.Text != "")
        {
            MembershipUser muser = Membership.GetUser(User.Identity.Name);
            muser.ChangePassword(OldPassTextbox.Text, NewPassTextbox.Text);
        }

        try
        {
            user.Approved = Brentwood.LookupCustomerByUsername(User.Identity.Name).Approved;
            Brentwood.UpdateCustomer(user, EmailTextbox.Text);
            FormMessage.Text = "Account successfully updated!";
            FormMessage.ForeColor = Color.Blue;
        }
        catch (Exception ex)
        {
            FormMessage.Text = ex.Message;
            FormMessage.ForeColor = Color.Red;
        }
    }
 private void BindData(aspnet_Users user)
 {
     UsernameLabel.Text = user.UserName;
     FirstNameTextbox.Text = user.FirstName;
     LastNameTextbox.Text = user.LastName;
     AddressTextbox.Text = user.CustomerAddress;
     CityTextbox.Text = user.City;
     ProvinceTextbox.Text = user.Province;
     PostalTextbox.Text = user.PostalCode;
     PhoneTextbox.Text = user.PhoneNumber;
     EmailTextbox.Text = Membership.GetUser(User.Identity.Name).Email;
 }
Exemple #5
0
 protected void CustomersGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         aspnet_Users item = new aspnet_Users();
         item.UserId = Guid.Parse(CustomersGridView.DataKeys[e.RowIndex].Value.ToString());
         item.UserName = CustomersGridView.Rows[e.RowIndex].Cells[2].Text.Trim();
         Brentwood.ArchiveCustomer(item);
         List<CustomerControlCookie> data = CustomerUtils.ToCookieClass(Brentwood.ListCustomers());
         CustomersGridView.DataSource = data;
         CustomersGridView.DataBind();
     }
     catch (Exception ex)
     {
         FormMessage.Text = ex.Message;
         FormMessage.ForeColor = Color.Red;
     }
 }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        try
        {
            MembershipUser user = Membership.CreateUser(UsernameTextbox.Text, PasswordTextbox.Text, EmailAddressTextbox.Text);

            if (ApprovedCheckbox.Checked)
            {
                Roles.AddUsersToRole(new string[] { UsernameTextbox.Text }, "Customer");
                Roles.AddUsersToRole(new string[] { UsernameTextbox.Text }, "Approved Customer");
            }
            else
                Roles.AddUsersToRole(new string[] { UsernameTextbox.Text }, "Customer");

            aspnet_Users newUser = new aspnet_Users();
            newUser.UserName = user.UserName;
            newUser.FirstName = FirstNameTextbox.Text;
            newUser.LastName = LastNameTextbox.Text;
            newUser.CustomerAddress = AddressTextbox.Text;
            newUser.City = CityTextbox.Text;
            newUser.Province = ProvinceTextbox.Text;
            newUser.PostalCode = PostalCodeTextbox.Text;
            newUser.PhoneNumber = PhoneNumberTextbox.Text;

            if (CompanyDropdown.SelectedValue != "-1")
                newUser.CompanyID = int.Parse(CompanyDropdown.SelectedValue);

            newUser.Approved = ApprovedCheckbox.Checked;

            Brentwood.UpdateCustomer(newUser, EmailAddressTextbox.Text);

            FormMessage.Text = "Customer account successfully created!";
            FormMessage.ForeColor = Color.Blue;
        }
        catch (Exception ex)
        {
            if (ex.Message == "The password supplied is invalid.  Passwords must conform to the password strength requirements configured for the default provider.")
                FormMessage.Text = "Password must be at least 6 alphanumeric characters long";
            else
                FormMessage.Text = ex.Message;

            FormMessage.ForeColor = Color.Red;
        }
    }
Exemple #7
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        try
        {
            MembershipUser user = Membership.CreateUser(UsernameTextbox.Text, PasswordTextbox.Text, EmailAddressTextbox.Text);

            aspnet_Users newUser = new aspnet_Users();
            newUser.UserName = user.UserName;
            newUser.FirstName = FirstNameTextbox.Text;
            newUser.LastName = LastNameTextbox.Text;
            newUser.CustomerAddress = AddressTextbox.Text;
            newUser.City = CityTextbox.Text;
            newUser.Province = ProvinceTextbox.Text;
            newUser.PostalCode = PostalCodeTextbox.Text;
            newUser.PhoneNumber = PhoneNumberTextbox.Text;
            newUser.Approved = true;

            if (AdminCheckbox.Checked)
                Brentwood.MakeCustomerAdmin(Guid.Parse(user.ProviderUserKey.ToString()));

            Brentwood.UpdateCustomer(newUser, EmailAddressTextbox.Text);
            Brentwood.AddUserToCompany(newUser.UserName, (Brentwood.GetCompanyByCustomerId(Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()))).CompanyID);

            FormMessage.Text = "Your account has been successfully created!";
            FormMessage.ForeColor = Color.Blue;

            Roles.AddUserToRole(newUser.UserName, "Customer");
        }
        catch (Exception ex)
        {
            if (ex.Message == "The password supplied is invalid.  Passwords must conform to the password strength requirements configured for the default provider.")
                FormMessage.Text = "Password must be at least 6 alphanumeric characters long";
            else
                FormMessage.Text = ex.Message;

            FormMessage.ForeColor = Color.Red;
        }
    }
 /// <summary>
 /// Create a new aspnet_Users object.
 /// </summary>
 /// <param name="applicationId">Initial value of the ApplicationId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="loweredUserName">Initial value of the LoweredUserName property.</param>
 /// <param name="isAnonymous">Initial value of the IsAnonymous property.</param>
 /// <param name="lastActivityDate">Initial value of the LastActivityDate property.</param>
 public static aspnet_Users Createaspnet_Users(global::System.Guid applicationId, global::System.Guid userId, global::System.String userName, global::System.String loweredUserName, global::System.Boolean isAnonymous, global::System.DateTime lastActivityDate)
 {
     aspnet_Users aspnet_Users = new aspnet_Users();
     aspnet_Users.ApplicationId = applicationId;
     aspnet_Users.UserId = userId;
     aspnet_Users.UserName = userName;
     aspnet_Users.LoweredUserName = loweredUserName;
     aspnet_Users.IsAnonymous = isAnonymous;
     aspnet_Users.LastActivityDate = lastActivityDate;
     return aspnet_Users;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the aspnet_Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToaspnet_Users(aspnet_Users aspnet_Users)
 {
     base.AddObject("aspnet_Users", aspnet_Users);
 }
Exemple #10
0
 public static int ArchiveCustomer(aspnet_Users item)
 {
     return (new Entities()).aspnet_Users_ArchiveCustomer(item.UserId);
 }
Exemple #11
0
 public static int UpdateCustomer(aspnet_Users item, string email)
 {
     return (new Entities()).aspnet_Users_UpdateCustomer(item.UserName, item.FirstName,
         item.LastName, item.CustomerAddress, item.City, item.Province, item.PostalCode, item.PhoneNumber,
         item.CompanyID, item.Approved, email);
 }
    protected void UpdateButton_Click(object sender, EventArgs e)
    {
        aspnet_Users item = new aspnet_Users();
        item.UserId = Guid.Parse(CustomerView.DataKey.Value.ToString());
        item.UserName = CustomerView.Rows[0].Cells[1].Text.Trim();
        item.FirstName = (CustomerView.Rows[2].Cells[1].Controls[1] as TextBox).Text.Trim();
        item.LastName = (CustomerView.Rows[3].Cells[1].FindControl("LastNameTextbox") as TextBox).Text.Trim();
        item.CustomerAddress = (CustomerView.Rows[4].Cells[1].FindControl("AddressTextbox") as TextBox).Text.Trim();
        item.City = (CustomerView.Rows[5].Cells[1].FindControl("CityTextbox") as TextBox).Text.Trim();
        item.Province = (CustomerView.Rows[6].FindControl("ProvinceTextbox") as TextBox).Text.Trim();
        item.PostalCode = (CustomerView.Rows[7].FindControl("PostalCodeTextbox") as TextBox).Text.Trim();
        item.PhoneNumber = (CustomerView.Rows[8].FindControl("PhoneNumberTextbox") as TextBox).Text.Trim();
        item.CompanyID = int.Parse((CustomerView.Rows[10].FindControl("CompanyList") as DropDownList).SelectedValue);
        string email = (CustomerView.Rows[9].FindControl("EmailTextbox") as TextBox).Text.Trim();
        if (item.CompanyID == -1)
            item.CompanyID = null;
        item.Approved = (CustomerView.Rows[12].FindControl("ApprovedCheckbox") as CheckBox).Checked;

        try
        {
            Brentwood.UpdateCustomer(item, email);

            if ((CustomerView.Rows[14].FindControl("NewPassTextbox") as TextBox).Text.Trim() != "")
                Membership.GetUser(item.UserName).ChangePassword((CustomerView.Rows[13].FindControl("OldPassTextbox") as TextBox).Text.Trim(), (CustomerView.Rows[13].FindControl("NewPassTextbox") as TextBox).Text.Trim());

            if ((CustomerView.Rows[11].FindControl("IsAdminCheckbox") as CheckBox).Checked)
                Brentwood.MakeCustomerAdmin(item.UserId);
            else
                Brentwood.MakeCustomerNotAdmin(item.UserId);

            FormMessage.Text = "Customer account successfully updated!";
            FormMessage.ForeColor = Color.Black;
        }
        catch (Exception ex)
        {
            FormMessage.ForeColor = Color.Red;
            FormMessage.Text = ex.Message;
        }
    }