Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Runs when page is loaded
        //Sets CustomerNo from session object and displays user's saved name at the top
        CustomerNo = Convert.ToInt32(Session["CustomerNo"]);
        clsCustomerCollection Customers = new clsCustomerCollection();

        Customers.Find(CustomerNo);
        lblTitle.Text         = "Hello " + Customers.ThisCustomer.FirstName + " " + Customers.ThisCustomer.LastName;
        Session["CustomerNo"] = Customers.ThisCustomer.CustomerNo;
        Session["Mode"]       = "CustomerView";
    }
    string update()
    {
        //Function to add a customer to the clsCustomerCollection list and then call a function to modify that customer's existing details in the DB
        //If it fails, an error is displayed
        String Error = "";
        clsCustomerCollection PreCustomers = new clsCustomerCollection();
        clsCustomerCollection Customers    = new clsCustomerCollection();

        PreCustomers.FindEMail(txtEmail.Text);
        Customers.Find(CustomerNo);
        if (PreCustomers.ThisCustomer.EMail != null && PreCustomers.ThisCustomer.EMail != Customers.ThisCustomer.EMail)
        {
            Error = Error + "EMail already in use </br>";
        }

        Error = Error + Customers.ThisCustomer.Valid(txtHouseNo.Text, txtHouseCounty.Text, txtPostcode.Text, txtHouseStreet.Text, txtEmail.Text, txtFirstName.Text, txtLastName.Text, txtPhoneNo.Text, txtPassword.Text, txtPasswordConfirm.Text); if (Error == "")
        {
            Customers.Find(CustomerNo);
            Customers.ThisCustomer.HouseNo     = Convert.ToInt32(txtHouseNo.Text);
            Customers.ThisCustomer.PhoneNo     = txtPhoneNo.Text;
            Customers.ThisCustomer.FirstName   = txtFirstName.Text;
            Customers.ThisCustomer.LastName    = txtLastName.Text;
            Customers.ThisCustomer.PostCode    = txtPostcode.Text;
            Customers.ThisCustomer.HouseCounty = txtHouseCounty.Text;
            Customers.ThisCustomer.HouseStreet = txtHouseStreet.Text;
            Customers.ThisCustomer.EMail       = txtEmail.Text;
            Customers.ThisCustomer.Password    = Customers.GetHashPassword(txtPassword.Text);//Hash password before adding
            Customers.Update();
            Session["CustomerNo"] = Customers.ThisCustomer.CustomerNo;
            Response.Redirect(RedirectURL);
            return(Error);
        }
        else
        {
            lblError.Text = Error;//Display errors
            return(Error);
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     //Called upon page load
     //Sets customer number to whatever was passed in the session object, as well as a session object that depends on which page the user originated from
     //so that they can be redirected to the correct page
     CustomerNo = Convert.ToInt32(Session["CustomerNo"]);
     Mode       = Convert.ToString(Session["Mode"]);
     if (CustomerNo != -1)
     {
         if (IsPostBack == false)
         {
             lblTitle.Text = "Change account details";
             clsCustomerCollection Customers = new clsCustomerCollection();
             Customers.Find(CustomerNo);
             txtHouseNo.Text     = Convert.ToString(Customers.ThisCustomer.HouseNo);
             txtPhoneNo.Text     = Customers.ThisCustomer.PhoneNo;
             txtFirstName.Text   = Customers.ThisCustomer.FirstName;
             txtLastName.Text    = Customers.ThisCustomer.LastName;
             txtPostcode.Text    = Customers.ThisCustomer.PostCode;
             txtHouseCounty.Text = Customers.ThisCustomer.HouseCounty;
             txtHouseStreet.Text = Customers.ThisCustomer.HouseStreet;
             txtEmail.Text       = Customers.ThisCustomer.EMail;
         }
     }
     else
     {
         lblTitle.Text = "Register";
     }
     if (Mode == "StaffView")
     {
         RedirectURL = "StaffMenu.aspx";
     }
     if (Mode == "CustomerView")
     {
         RedirectURL = "CustomerMenu.aspx";
     }
     if (Mode == "GuestView")
     {
         RedirectURL = "Login.aspx";
     }
     //if (IsPostBack == false) {  }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Runs when the page is loaded, checks session object for CustomerNo
        //If no CustomerNo provided, it will redirect to prevent crashes/incorrect deletion
        //Redirects when yes/no are pressed depend on where the user originated from (CustomerMenu.aspx, Default.aspx)
        CustomerNo  = Convert.ToInt32(Session["CustomerNo"]);
        RedirectURL = Convert.ToString(Session["Mode"]);
        if (Session["CustomerNo"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        clsCustomerCollection Customers = new clsCustomerCollection();

        Customers.Find(CustomerNo);
        lblDelete.Text = "Are you sure you want to delete account " + Customers.ThisCustomer.EMail;
        if (Convert.ToString(Session["Mode"]) == "StaffView")
        {
            RedirectURL = "StaffMenu.aspx";
        }
        else
        {
            RedirectURL = "CustomerMenu.aspx";
        }
    }