//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 
    //find user name event
    protected void btnFindUser_Click(object sender, EventArgs e)
    {
        dsAccounts dsFindUserName = myBusinessLayer.FindUser(txtUserName.Text);

        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!";
        }

    }
    public dsAccounts GetAllCustomers()
    {
        //Connects to the database adapter by selecting all from tblCustomers
        OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter("select * from tblCustomers;", dbConnection);

        //Pulls from the dataset
        dsAccounts myStoreDataSet = new dsAccounts();

        sqlDataAdapter.Fill(myStoreDataSet.tblCustomers);

        //returns myStoreDataSet
        return(myStoreDataSet);
    }
Esempio n. 4
0
    // Method to show all available customers in the database
    public dsAccounts GetAllCustomers()
    {
        // Adapter required to search
        OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter("select * from tblUsers;", dbConnection);

        // Datasets is required to look for the tables and keys of customers
        dsAccounts myStoreDataSet = new dsAccounts();

        sqlDataAdapter.Fill(myStoreDataSet.tblUsers);

        // Finally displays the customers. new customers can be added of course.
        return(myStoreDataSet);
    }
    public dsAccounts FindCustomer(string UserName)
    {
        //Selects LastName from tblCustomers and connects to the database
        string           sqlStmt        = "select * from tblCustomers where UserName like '" + UserName + "'";
        OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection);

        //Stores information to the dsAccounts data set from tblCustomers
        dsAccounts myStoreDataSet = new dsAccounts();

        sqlDataAdapter.Fill(myStoreDataSet.tblCustomers);

        //returns myStoreDataSet
        return(myStoreDataSet);
    }
Esempio n. 6
0
    // Method to find the user's username (not legal name) based on user's query
    public dsAccounts FindUser(string Username)
    {
        // Query is case sensitive and Username is replaced with text from txtUsername
        string           sqlStmt        = "select * from tblUsers where Username like '" + Username + "'";
        OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection);

        // Data adapter fills in the details
        dsAccounts myStoreDataSet = new dsAccounts();

        sqlDataAdapter.Fill(myStoreDataSet.tblUsers);

        // Result will be displayed on AccDetails
        return(myStoreDataSet);
    }
Esempio n. 7
0
        /// <summary>
        /// NMeggos
        /// Retrieve all accounts from the DB.
        /// </summary>
        /// <returns></returns>
        public dsAccounts GetAllCustomers()
        {
            // NMeggos
            // Initiaite an adapter with the query to retrieve all customer.
            OleDbDataAdapter sqlDataAdapter = new OleDbDataAdapter("select * from tblCustomers;",dbConnection);

            // NMeggos Initiate a new instance of dsAccount
            // consuming if any return data from the table.
            dsAccounts myStoreDataSet = new dsAccounts();
            sqlDataAdapter.Fill(myStoreDataSet.tblCustomers);

            // NMeggos
            // Return type for method, should have the data returned from the db call.
            return myStoreDataSet;
        }
    }//end clearinputs 


    //bind customer grid view
    private dsAccounts BindCustomerGridView()
    {
        
        string tempPath = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        dsAccounts customerListing = myBusinessLayer.SelectAllCustomers();

        gvCustomerList.DataSource = customerListing.tblCustomers;

        //binding customer list griedview
        gvCustomerList.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return customerListing;
    }
Esempio n. 9
0
    private dsAccounts BindCustomerGridView()
    {
        // Pulls data from the database for use
        string       tempPath    = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Adds data from the first to the second
        dsAccounts customerListing = myDataLayer.GetAllCustomers();

        // Adds data from the first to the second
        gvCustomerList.DataSource = customerListing.tblCustomers;

        // Caches data collected
        gvCustomerList.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return(customerListing);
    }
    private dsAccounts BindCartGridView()
    {
        // Pulls data from the database for use
        string       tempPath    = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Adds data from the first to the second
        dsAccounts cartListing = myDataLayer.FillCart(lblCurrentCustomer.Text);

        // Adds data from the first to the second
        gvCart.DataSource = cartListing.tblCart;

        // Caches data collected
        gvCart.DataBind();
        Cache.Insert("CustomerDataSet", cartListing);

        return(cartListing);
    }
    private dsAccounts BindCustomerGridView()
    {
        //accesses Accounts.mdb database for the clsDataLayer
        string       tempPath    = Server.MapPath("Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        //retrieve customer listings from data layer in GetAllCustomers() method
        dsAccounts customerListing = myDataLayer.GetAllCustomers();

        //adds information from customerListing in tblCustomers to the grid view
        gvCustomerList.DataSource = customerListing.tblCustomers;

        //data binds gvCustomerList and inserts into the cache
        gvCustomerList.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return(customerListing);
    }
    private dsAccounts BindOrdersGridView()
    {
        // Pulls data from the database for use
        string tempPath = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Adds data from the first to the second
        dsAccounts orderListing = myDataLayer.FillOrders(Username.Text);

        // Adds data from the first to the second
        gvCart.DataSource = orderListing.tblOrders;

        // Caches data collected
        gvCart.DataBind();
        Cache.Insert("CustomerDataSet", orderListing);

        return orderListing;
    }
Esempio n. 13
0
        /// <summary>
        ///     NMeggos
        ///     Retrieve a customer by their last name, returning
        ///     a dataset object to be later used to bind to the client interface.
        /// </summary>
        /// <param name="LastName"></param>
        /// <returns>
        ///     A new instance of dsAccounts based on the criteria returned results from the table.
        /// </returns>
        /// <remarks>
        ///     Make sure the datasets are set to compile under the build action. By default is set to content.
        /// </remarks>
        public dsAccounts FindCustomer(string LastName)
        {
            // NMeggos
            // The following two statements provide the sql build, and the commands for
            // interacting with the DB.
            var sqlStmt = string.Format(@"select * from tblCustomers where LastName like '{0}'", LastName);
            var sqlDataAdapter = new OleDbDataAdapter(sqlStmt, dbConnection);

            // NMeggos
            // Initiate a new instance of dsAccounts used as the return 
            // type for the method. Then fill the dataset with the customer table.
            var myStoreDataSet = new dsAccounts();
            sqlDataAdapter.Fill(myStoreDataSet.tblCustomers);

            // NMeggos
            // return the method data type
            return myStoreDataSet;
        }
    public DataSet GetCustomerXMLFile()
    {
        //creates new instance of DataSet
        DataSet xmlDataSet = new DataSet();

        try
        {
            //Reads XML data from customers.xml file
            xmlDataSet.ReadXml(dataPath + "customers.xml");
        }
        catch (System.IO.FileNotFoundException error)
        {
            //creates listings from the data layer in the GetAllCustomers() method
            dsAccounts customerListing = myDataLayer.GetAllCustomers();
            customerListing.tblCustomers.WriteXml(dataPath + "customers.xml");
            xmlDataSet.ReadXml(dataPath + "customers.xml");
        }

        //returns xmlDataSet
        return(xmlDataSet);
    }
    //Method to display customers in the table
    private dsAccounts BindCustomerGridView()
    {
        // Alternate paths below. Mine is in App_Data.
        // Depending on where you placed your Access database,
        //    one of the following lines may work better:
        //    tempPath = Server.MapPath("Accounts.mdb")
        //    tempPath = Server.MapPath("~/FPDB/Accounts.mdb")
        string       tempPath    = Server.MapPath("~/App_Data/Accounts.mdb");
        clsDataLayer myDataLayer = new clsDataLayer(tempPath);

        // Instance of object to retrieve and return customers
        dsAccounts customerListing = myDataLayer.GetAllCustomers();

        // Proper configuration for the gridview
        gvApps.DataSource = customerListing.tblUsers;

        // Finally bind the data to ensure connectivity
        gvApps.DataBind();
        Cache.Insert("CustomerDataSet", customerListing);

        return(customerListing);
    }
    // Method to display info in the tblUsers.xml
    public DataSet GetCustomerXMLFile()
    {
        // Default data set
        DataSet xmlDataSet = new DataSet();

        // Try-catch statement to return the listings
        try
        {
            // Check for customers.xml within App_Data. Could also be at the top head of folders.
            xmlDataSet.ReadXml(dataPath + "Users.xml");
        }

        // Display errors. Had an error, because I didn't the file was missing.
        catch (System.IO.FileNotFoundException error)
        {
            // Add your comments here
            dsAccounts customerListing = myDataLayer.GetAllCustomers();
            customerListing.tblUsers.WriteXml(dataPath + "Users.xml");
            xmlDataSet.ReadXml(dataPath + "Users.xml");
        }
        // Finally returns the result, the John Smiths' and Jane Does' info.
        return(xmlDataSet);
    }
Esempio n. 17
0
    // 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 btnCheckout_Click(object sender, EventArgs e)
    {
        lblCurrentUser.Text = lblCurrentUser.Text;

        DisableInputs(Page.Controls);

        panelCart.Visible = false;
        panelOrder.Visible = true;

        // Creates new database for use in click event
        dsAccounts dsFindOrders = myBusinessLayer.FindOrder(txtUsername.Text);
        dsAccounts dsFindOrder = myBusinessLayer.FindOrders(txtUsername.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 (dsFindOrder.tblCart.Rows.Count > 0 || dsFindOrders.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
            dsFindOrders.tblOrders[0].Customer = dsFindOrder.tblCart[0].Customer;
            dsFindOrders.tblOrders[0].JobType = dsFindOrder.tblCart[0].JobType;
            dsFindOrders.tblOrders[0].MediaType = dsFindOrder.tblCart[0].MediaType;
            dsFindOrders.tblOrders[0].Message = dsFindOrder.tblCart[0].Message;
            dsFindOrders.tblOrders[0].PaymentOption = chkPaymentOption.Text;

            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;
            }

    }
}
    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;
        }
    }
Esempio n. 20
0
    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");
        }
    }