//find last name event protected void btnFindLastName_Click(object sender, EventArgs e) { //passing last name to business layer and returning customer information from data layer dsAccounts dsFindLastName = myBusinessLayer.FindCustomer(txtLastName.Text); //checking all database table rows if (dsFindLastName.tblCustomers.Rows.Count > 0) { //displaying customer information txtFirstName.Text = dsFindLastName.tblCustomers[0].FirstName; txtLastName.Text = dsFindLastName.tblCustomers[0].LastName; txtLine1.Text = dsFindLastName.tblCustomers[0].Address1; txtLine2.Text = dsFindLastName.tblCustomers[0].Address2; txtCity.Text = dsFindLastName.tblCustomers[0].City; txtState.Text = dsFindLastName.tblCustomers[0].State; txtPhone.Text = dsFindLastName.tblCustomers[0].PhoneNumber; customerID.Text = dsFindLastName.tblCustomers[0].CustomerID.ToString(); Master.UserFeedBack.Text = "Record Found"; } else { //result message error Master.UserFeedBack.Text = "No records were found!"; } }//end find last name
protected void Page_Load(object sender, EventArgs e) { Master.UserFeedBack.Text = "Please review the forms and add to desired fields."; 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; panelCart.Visible = true; panelOrder.Visible = false; try { if (PreviousPage.IsCrossPagePostBack) { txtUsername.Text = PreviousPage.CurrentCustomer.Text; lblCurrentUser.Text = txtUsername.Text; dsAccounts dsLoadUser = myBusinessLayer.FindCustomer(txtUsername.Text); dsAccounts dsLoadCredInfo = myBusinessLayer.FindCreditInformation(txtUsername.Text); dsAccounts dsLoadOrderInfo = myBusinessLayer.FindOrders(txtUsername.Text); // Checks session credentials with database bool isUser = myBusinessLayer.CheckUsername(Session, txtUsername.Text); if (isUser || dsLoadUser.tblCustomers.Rows.Count > 0 || dsLoadCredInfo.tblCreditInformation.Rows.Count > 0 || dsLoadOrderInfo.tblOrders.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 = dsLoadUser.tblCustomers[0].UserID; txtFirstName.Text = dsLoadUser.tblCustomers[0].FirstName; txtLastName.Text = dsLoadUser.tblCustomers[0].LastName; txtEmail.Text = dsLoadUser.tblCustomers[0].Email; txtLine1.Text = dsLoadUser.tblCustomers[0].Address1; txtLine2.Text = dsLoadUser.tblCustomers[0].Address2; txtCity.Text = dsLoadUser.tblCustomers[0].City; txtState.Text = dsLoadUser.tblCustomers[0].State; txtPhone.Text = dsLoadUser.tblCustomers[0].PhoneNumber; customerID.Text = dsLoadUser.tblCustomers[0].CustomerID.ToString(); txtCCNumber.Text = dsLoadCredInfo.tblCreditInformation[0].CCNumber; rblCCType.SelectedValue = dsLoadCredInfo.tblCreditInformation[0].CCType; 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 = true; txtUsername.Enabled = false; BindOrdersGridView(); if (txtUsername.Text.Contains("systemAdmin")) { Master.OrderReview.Visible = true; Master.OrderReview.Enabled = true; txtUsername.Enabled = true; } else { Response.Redirect("~/pgLogin.aspx"); } } } } catch (Exception error) { Master.UserFeedBack.Text = error.Message; } }
// 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"); } }