コード例 #1
0
    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;
        }
    }