//fill user information in from user id login page protected void FindUser(string userID) { dsAccounts dsFindUserName = myBusinessLayer.FindUser(userID); if (dsFindUserName.tblCustomers.Rows.Count > 0) { //setting textboxes txtUserName.Text = dsFindUserName.tblCustomers[0].UserName; txtCity.Text = dsFindUserName.tblCustomers[0].City; txtState.Text = dsFindUserName.tblCustomers[0].State; txtFavoriteLanguage.Text = dsFindUserName.tblCustomers[0].FavoriteLanguage; txtLeastFavoriteLanguage.Text = dsFindUserName.tblCustomers[0].LeastFavoriteLanguage; txtLastProgramDate.Text = dsFindUserName.tblCustomers[0].LastProgramDate; customerID.Text = dsFindUserName.tblCustomers[0].CustomerID.ToString(); Master.UserFeedBack.Text = "Record Found"; } else { //result message error Master.UserFeedBack.Text = "No records were found!"; } }
protected void fillFields() { dsUsers dsFindUser; //Call Session Username from previous page String SessionUsername; SessionUsername = (string)(Session["SessionUsername"]); txtUsername.Text = SessionUsername; //Fill User Information using session's username string tempPath = Server.MapPath("~/App_Data/"); clsBusinessLayer businessLayerObj = new clsBusinessLayer(tempPath); bool NewUser; NewUser = (bool)(Session["NewUser"]); try { dsFindUser = businessLayerObj.FindUser(SessionUsername); //returning users will get all information filled if (NewUser == false) { txtUsername.Text = dsFindUser.tblUsers[0].Username; txtCity.Text = dsFindUser.tblUsers[0].City; txtState.Text = dsFindUser.tblUsers[0].State; txtFavProgram.Text = dsFindUser.tblUsers[0].FavoriteLanguage; txtLeastProgram.Text = dsFindUser.tblUsers[0].LeastFavoriteLanguage; txtDate.Text = dsFindUser.tblUsers[0].LastProgramDate; txtUserID.Text = Convert.ToString(dsFindUser.tblUsers[0].UserID); Session["SessionID"] = dsFindUser.tblUsers[0].UserID; //BindApplicationGridView(UserID); BindApplicationGridView(txtUsername.Text); Master.UserFeedBack.Text = "Information Found"; } //new users will only have username and userID filled else { txtUsername.Text = dsFindUser.tblUsers[0].Username; txtUserID.Text = Convert.ToString(dsFindUser.tblUsers[0].UserID); Master.UserFeedBack.Text = "Fill in information and Update."; } } catch (Exception error) { string message = "Something went wrong..."; Master.UserFeedBack.Text = message + error.Message; } }
/// find user method // finds the user by their last name. protected void btnFind_Click(object sender, EventArgs e) { dsProgramaholics dsFindLastName = myBusinessLayer.FindUser(txtLastName.Text); // go through records if (dsFindLastName.tblUserDetails.Rows.Count > 0) { txtFirstName.Text = dsFindLastName.tblUserDetails[0].FName; txtLastName.Text = dsFindLastName.tblUserDetails[0].LName; txtEmail.Text = dsFindLastName.tblUserDetails[0].Email; txtPassword.Text = dsFindLastName.tblUserDetails[0].Pwd; txtStreet.Text = dsFindLastName.tblUserDetails[0].Street; txtCity.Text = dsFindLastName.tblUserDetails[0].City; txtState.Text = dsFindLastName.tblUserDetails[0].State; } else { // no user found Master.UserFeedBack.Text = "No records found!"; } }
protected void btnCreate_Click(object sender, EventArgs e) { //Get Username Length int UsernameLength = txtUsername.Text.Length; //Get Password Length int PasswordLength = txtPassword.Text.Length; //Get Usernames from Database dsUsers dsFindUser; string tempPath = Server.MapPath("~/App_Data/"); clsBusinessLayer businessLayerObj = new clsBusinessLayer(tempPath); dsFindUser = businessLayerObj.FindUser(txtUsername.Text); //Check if username already exists if (dsFindUser.tblUsers.Rows.Count > 0) { Master.UserFeedBack.Text = "Username has already been used. Please try a different Username."; } //Check Username Length else if (UsernameLength < 5 || UsernameLength > 12) { Master.UserFeedBack.Text = "Username must be between 5 and 12 characters in length."; } //Check Password Length else if (PasswordLength < 6 || PasswordLength > 12) { Master.UserFeedBack.Text = "Passwords must be between 6 and 12 characters in length."; } else { Session["NewUser"] = true; Session["SessionUsername"] = txtUsername.Text; myBusinessLayer.InsertUser(txtUsername.Text, txtPassword.Text); Response.Redirect("~/pgUserDetails.aspx"); } }
// Pull data from table associated with selected Username protected void btnFindUsername_Click(object sender, EventArgs e) { // Creates new database for use in click event dsAccounts dsFindUsername = myBusinessLayer.FindCustomer(txtSearch.Text); dsAccounts dsFindUser = myBusinessLayer.FindUser(txtSearch.Text); // If applicable, gives one of the below outputs // If username on AccountDetails page matches UserID from tblUsers // Can update details for that user if (dsFindUsername.tblCustomers.Rows.Count > 0 || dsFindUser.tblUsers.Rows.Count > 0 || lblCurrentUser.Text.Contains("systemAdmin")) { // If the Username and their data is found then it is pulled and user is informed the record has been found txtUsername.Text = dsFindUsername.tblCustomers[0].UserID; txtFirstName.Text = dsFindUsername.tblCustomers[0].FirstName; txtLastName.Text = dsFindUsername.tblCustomers[0].LastName; txtEmail.Text = dsFindUsername.tblCustomers[0].Email; txtLine1.Text = dsFindUsername.tblCustomers[0].Address1; txtLine2.Text = dsFindUsername.tblCustomers[0].Address2; txtCity.Text = dsFindUsername.tblCustomers[0].City; txtState.Text = dsFindUsername.tblCustomers[0].State; txtPhone.Text = dsFindUsername.tblCustomers[0].PhoneNumber; customerID.Text = dsFindUsername.tblCustomers[0].CustomerID.ToString(); IDforUserID.Text = dsFindUser.tblUsers[0].ID.ToString(); Master.UserFeedBack.Text = "Found " + txtUsername.Text + ", " + lblCurrentUser.Text + "!"; lblCurrentUser.Text = "systemAdmin"; lblCustList.Visible = true; gvCustomerList.Visible = true; lblSearch.Visible = true; txtSearch.Visible = true; btnFindUsername.Visible = true; txtUsername.Enabled = false; txtSearch.Enabled = true; btnFindUsername.Enabled = true; btnDelete.Enabled = true; btnDelete.Visible = true; if (txtUsername.Text.Contains("systemAdmin")) { // If the Username and their data is found then it is pulled and user is informed the record has been found txtUsername.Text = dsFindUsername.tblCustomers[0].UserID; txtFirstName.Text = dsFindUsername.tblCustomers[0].FirstName; txtLastName.Text = dsFindUsername.tblCustomers[0].LastName; txtEmail.Text = dsFindUsername.tblCustomers[0].Email; txtLine1.Text = dsFindUsername.tblCustomers[0].Address1; txtLine2.Text = dsFindUsername.tblCustomers[0].Address2; txtCity.Text = dsFindUsername.tblCustomers[0].City; txtState.Text = dsFindUsername.tblCustomers[0].State; txtPhone.Text = dsFindUsername.tblCustomers[0].PhoneNumber; customerID.Text = dsFindUsername.tblCustomers[0].CustomerID.ToString(); IDforUserID.Text = dsFindUser.tblUsers[0].ID.ToString(); Master.UserFeedBack.Text = "Found admin " + txtUsername.Text + ", " + lblCurrentUser.Text + "!"; lblCustList.Visible = true; gvCustomerList.Visible = true; lblSearch.Visible = true; txtSearch.Visible = true; btnFindUsername.Visible = true; txtUsername.Enabled = false; txtSearch.Enabled = true; btnFindUsername.Enabled = true; btnDelete.Enabled = false; btnDelete.Visible = false; } } else { // Output message if no matching data is found Master.UserFeedBack.Text = "No records were found."; lblCustList.Visible = true; gvCustomerList.Visible = true; lblSearch.Visible = true; txtSearch.Visible = true; btnFindUsername.Visible = true; txtUsername.Enabled = false; txtSearch.Enabled = true; btnFindUsername.Enabled = true; btnDelete.Enabled = false; btnDelete.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { Master.AboutUs.Visible = false; Master.AccountDetails.Visible = false; Master.Checkout.Visible = false; Master.FAQ.Visible = false; Master.HomePage.Visible = false; Master.Login.Visible = false; Master.OrderReview.Visible = false; Master.AboutUs.Enabled = false; Master.AccountDetails.Enabled = false; Master.Checkout.Enabled = false; Master.FAQ.Enabled = false; Master.HomePage.Enabled = false; Master.Login.Enabled = false; Master.OrderReview.Enabled = false; Master.UserFeedBack.Text = "Fill out the form below to create your account."; // Update GridView BindCustomerGridView(); // Add data to myBusinessLayer myBusinessLayer = new clsBusinessLayer(Server.MapPath("~/App_Data/")); lblCustID.Visible = false; customerID.Visible = false; ID.Visible = false; lblCustList.Visible = false; gvCustomerList.Visible = false; txtUsername.Enabled = true; txtSearch.Enabled = false; btnFindUsername.Enabled = false; btnDelete.Enabled = false; btnDelete.Visible = false; lblSearch.Visible = false; txtSearch.Visible = false; btnFindUsername.Visible = false; // If applicable, gives one of the below outputs // If username on AccountDetails page matches UserID from tblUsers // Can update details for that user try { if (PreviousPage.IsCrossPagePostBack) { lblCurrentUser.Text = PreviousPage.CurrentUser.Text; txtUsername.Text = PreviousPage.User.Text; // Creates new database for use in click event dsAccounts dsLoadDetails = myBusinessLayer.FindCustomer(txtUsername.Text); dsAccounts dsLoadUser = myBusinessLayer.FindUser(txtUsername.Text); // Checks session credentials with database bool isUser = myBusinessLayer.CheckUsername(Session, txtUsername.Text); if (isUser || dsLoadDetails.tblCustomers.Rows.Count > 0 || dsLoadUser.tblUsers.Rows.Count > 0) { // If the Username and their data is found then it is pulled and user is informed the record has been found txtUsername.Text = dsLoadDetails.tblCustomers[0].UserID; txtFirstName.Text = dsLoadDetails.tblCustomers[0].FirstName; txtLastName.Text = dsLoadDetails.tblCustomers[0].LastName; txtEmail.Text = dsLoadDetails.tblCustomers[0].Email; txtLine1.Text = dsLoadDetails.tblCustomers[0].Address1; txtLine2.Text = dsLoadDetails.tblCustomers[0].Address2; txtCity.Text = dsLoadDetails.tblCustomers[0].City; txtState.Text = dsLoadDetails.tblCustomers[0].State; txtPhone.Text = dsLoadDetails.tblCustomers[0].PhoneNumber; customerID.Text = dsLoadDetails.tblCustomers[0].CustomerID.ToString(); ID.Text = dsLoadUser.tblUsers[0].ID.ToString(); Master.AboutUs.Visible = true; Master.AccountDetails.Visible = true; Master.Checkout.Visible = true; Master.FAQ.Visible = true; Master.HomePage.Visible = true; Master.Login.Visible = true; Master.OrderReview.Visible = false; Master.AboutUs.Enabled = true; Master.AccountDetails.Enabled = true; Master.Checkout.Enabled = true; Master.FAQ.Enabled = true; Master.HomePage.Enabled = true; Master.Login.Enabled = true; Master.OrderReview.Enabled = false; txtUsername.Enabled = false; txtSearch.Enabled = false; btnFindUsername.Enabled = false; lblCustList.Visible = false; gvCustomerList.Visible = false; lblSearch.Visible = false; txtSearch.Visible = false; btnFindUsername.Visible = false; btnDelete.Enabled = true; btnDelete.Visible = true; // Output message if match data is found Master.UserFeedBack.Text = "Welcome back " + txtUsername.Text + "!"; if (PreviousPage.User.Text.Contains("systemAdmin")) { lblCustList.Visible = true; gvCustomerList.Visible = true; lblSearch.Visible = true; txtSearch.Visible = true; btnFindUsername.Visible = true; txtUsername.Enabled = false; txtSearch.Enabled = true; btnFindUsername.Enabled = true; btnDelete.Enabled = false; btnDelete.Visible = false; Master.OrderReview.Visible = true; lblCurrentUser.Text = "systemAdmin"; // Output message if match data is found Master.UserFeedBack.Text = "Welcome back " + txtUsername.Text + "!"; if (txtSearch.Text.Contains("Create") || txtSearch.Text.Contains("create")) { Master.OrderReview.Visible = true; lblCurrentUser.Text = "systemAdmin"; // Output message if match data is found Master.UserFeedBack.Text = "Welcome back " + txtUsername.Text + "!"; } } } else { ID.Text = "0"; // Output message if no matching data is found Master.UserFeedBack.Text = "Fill out the form below to create your account."; } } } catch (Exception error) { Master.UserFeedBack.Text = error.Message; } foreach (ListItem li in rblCCType.Items) { //add margin as css style li.Attributes.CssStyle.Add("margin-left", "75px"); } }