protected void btnLogin_Click(object sender, EventArgs e)
    {
        // Create new instant of the BusinessLayer
        clsBusinessLayer myBusinessLayer = new clsBusinessLayer(Server.MapPath("~/App_Data/"));

        // Checks session credentials with database
        bool isValid = myBusinessLayer.CheckUserCredentials(Session, txtUserID.Text, txtPassword.Text);

        // Checks session credentials with database
        bool isValidUser = myBusinessLayer.CheckUsername(Session, txtUserID.Text);

        // If the user is in the database then they proceed
        if (txtUserID.Text == null || txtUserID.Text == String.Empty || txtPassword.Text == null || txtPassword.Text == String.Empty)
        {
            Response.Redirect("~/pgLogin.aspx");

            if (isValid)
            {
                lblCurrentUser.Text = User.Text;
            }
        }

        else if (Convert.ToBoolean(Session["LockedSession"]))
        {
            Master.UserFeedBack.Text = "Account is disabled. Contact System Administrator";

            // Hide login button
            btnLogin.Visible = false;
        }

        else
        {
            Master.UserFeedBack.Text = "The User ID and/or Password supplied is incorrect. Please try again!";
        }
    }
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        lblCurrentUser.Text = lblCurrentUser.Text;

        // Checks session credentials with database
        bool isUser = myBusinessLayer.CheckUsername(Session, txtUsername.Text);

        if (isUser)
        {
            // Updates data to results
            string results = myBusinessLayer.UpdateCustomer(txtUsername.Text, txtFirstName.Text, txtLastName.Text, txtEmail.Text, txtLine1.Text, txtLine2.Text, txtCity.Text, txtState.Text, txtPhone.Text, Convert.ToInt32(customerID.Text));

            // Update the results for the updateForm method
            updateForm(results);

            lblProceed.Visible  = true;
            lblProceed.Text     = "Click the link below to proceed to the landing page.";
            lbtnProceed.Visible = true;
            lbtnProceed.Enabled = true;

            btnConfirm.Visible = false;
            btnConfirm.Enabled = false;
            btnCancel.Visible  = false;
            btnCancel.Enabled  = false;
        }

        else
        {
            // Add data to results
            myBusinessLayer.InsertCustomer(txtUsername.Text, txtFirstName.Text, txtLastName.Text, txtEmail.Text, txtLine1.Text, txtLine2.Text, txtCity.Text, txtState.Text, txtPhone.Text, Convert.ToInt32(ID.Text));

            IDforUserID.Text = "0";
            ID.Text          = "0";

            // Add data to results
            myBusinessLayer.InsertUser(txtUsername.Text, txtPassword.Text, Convert.ToInt32(IDforUserID.Text));

            // Output message if no matching data is found
            Master.UserFeedBack.Text = "Welcome to the family, " + txtUsername.Text + "!";

            // Clear fields
            ClearInputs(Page.Controls);

            lblProceed.Visible  = true;
            lblProceed.Text     = "Click the link below to proceed to the landing page.";
            lbtnProceed.Visible = true;
            lbtnProceed.Enabled = true;

            btnConfirm.Visible = false;
            btnConfirm.Enabled = false;
            btnCancel.Visible  = false;
            btnCancel.Enabled  = 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. 4
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");
        }
    }