示例#1
0
        protected void LoginButton(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string hashedPswd = HashPassword.ApplyHash(txtModalCustPassword.Text);

                //string custEmail = String.Format("{0}", Request.Form["email_modal"]);
                //string custPassword = String.Format("{0}", Request.Form["password_modal"]);

                Customers custLogin = new Customers(txtModalCustEmail.Text, hashedPswd);

                string output = CustomersDB.GetCustomerLogin(custLogin);

                if (output == "1")
                {
                    Session["custEmail"] = txtModalCustEmail.Text;
                    Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());
                    Session["customerId"] = (int)loggedCustomer.CustomerId;

                    Response.Redirect("CustomerRegistration.aspx");
                }
                else
                {
                    Control loginFail = FindControl("LoginFailure");
                    loginFail.Visible = true;
                    string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Login failed, please check your credentials.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                }
            }
        }
示例#2
0
        protected void DBANotActivated_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string activationStatus = CustomersDB.isActivated(txtModalCustEmail.Text);

            if (activationStatus == "No")
            {
                args.IsValid = false;
                Control loginFail = FindControl("LoginFailure");
                loginFail.Visible = true;
                string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Registration incomplete. Please activate your account (see instructions sent to your email)' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
            }
            else if (activationStatus == "")
            {
                args.IsValid = false;
                Control loginFail = FindControl("LoginFailure");
                loginFail.Visible = true;
                string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Login failed, please check your credentials.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
            }
            else
            {
                args.IsValid = true;
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlControl loginIcon  = (HtmlControl)Page.FindControl("mainBtnLogin");
            HtmlControl loggedIcon = (HtmlControl)Page.FindControl("custLogged");

            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            if (Session["custEmail"] != null)
            {
                loggedIcon.Visible = true;
                loginIcon.Visible  = false;

                try
                {
                    customerLogged.Text = "Welcome " + CustomersDB.confirmLogin(Session["custEmail"].ToString());
                }
                catch (Exception)
                {
                    ExceptionScript();
                }
            }
            else
            {
                loggedIcon.Visible = false;
                loginIcon.Visible  = true;
            }

            if (!this.IsPostBack)
            {
                string activationCode = !string.IsNullOrEmpty(Request.QueryString["ActivationCode"]) ? Request.QueryString["ActivationCode"] : Guid.Empty.ToString();

                string custEmail = CustomersDB.GetEmailbyActivationCode(activationCode);

                try
                {
                    int count = CustomersDB.deleteConfirmation(activationCode);
                    if (count == 1)
                    {
                        activationConfirmation.Text = "Activation successful.";
                        activationMessage.Text      = "You have successfully activated your account. You can now login and book your next vacation!";

                        try
                        {
                            CustomersDB.updateActivationStatus(custEmail);
                        }
                        catch (Exception)
                        {
                            ExceptionScript();
                        }
                    }
                    else
                    {
                        activationConfirmation.Text = "Activation unsuccessful. Please contact an agent at Travel Experts.";
                    }
                }
                catch (Exception)
                {
                    ExceptionScript();
                }
            }
        }
示例#4
0
        /*Confirmation page to render if a confirmation that the customer has registered to Travel Experts
         * Lead Programmer: Mo Sagnia
         * Date: 11th February 2018
         */
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlControl loginIcon  = (HtmlControl)Page.FindControl("mainBtnLogin");
            HtmlControl loggedIcon = (HtmlControl)Page.FindControl("custLogged");

            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            if (Session["custEmail"] != null)
            {
                loggedIcon.Visible = true;
                loginIcon.Visible  = false;

                try
                {
                    customerLogged.Text = "Welcome " + CustomersDB.confirmLogin(Session["custEmail"].ToString());
                }
                catch (Exception)
                {
                    Control loginFail = FindControl("LoginFailure");
                    loginFail.Visible = true;
                    string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='An error occured while attempting to process your information. Please contact travel experts.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                }
            }
            else
            {
                loggedIcon.Visible = false;
                loginIcon.Visible  = true;
            }
        }
示例#5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());

                Customers updatedCustomer = new Customers(txtCustFirstName.Text, txtCustLastName.Text, txtCustAddress.Text, txtCustCity.Text, ddlCustProv.Text, txtCustPostal.Text, txtCustCountry.Text, FormatePhoneNo.ApplyFormatting(txtCustHomePhone.Text), FormatePhoneNo.ApplyFormatting(txtCustBusPhone.Text), txtCustEmail.Text);

                try
                {
                    bool updateSuccessful = CustomersDB.UpdateCustomer(loggedCustomer, updatedCustomer);
                    if (updateSuccessful)
                    {
                        Control loginSuccess = FindControl("LoginSuccess");
                        loginSuccess.Visible = true;
                        customerLogged.Text  = "Welcome " + txtCustFirstName.Text;
                        string script = @"document.getElementById('" + LoginSuccess.ClientID + "').innerHTML='Update successful.' ;setTimeout(function(){document.getElementById('" + LoginSuccess.ClientID + "').style.display='none';},5000);";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Show status", script, true);
                    }
                    else
                    {
                        Control loginFail = FindControl("LoginFailure");
                        loginFail.Visible = true;
                        string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Unable to update information.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Show status", script, true);
                    }
                }
                catch (Exception)
                {
                    ExceptionScript();
                }
            }
        }
        /*Confirmation page to render if a confirmation that the customer has registered to Travel Experts
         * Lead Programmer: Mo Sagnia
         * Date: 11th February 2018
         */
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlControl loginIcon  = (HtmlControl)Page.FindControl("mainBtnLogin");
            HtmlControl loggedIcon = (HtmlControl)Page.FindControl("custLogged");

            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            if (Session["custEmail"] != null)
            {
                loggedIcon.Visible = true;
                loginIcon.Visible  = false;

                try
                {
                    customerLogged.Text = "Welcome " + CustomersDB.confirmLogin(Session["custEmail"].ToString());
                }
                catch (Exception)
                {
                    Control loginFail = FindControl("LoginFailure");
                    loginFail.Visible = true;
                    string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='An error occured while attempting to process your information. Please contact travel experts.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                }
            }
            else
            {
                loggedIcon.Visible = false;
                loginIcon.Visible  = true;
            }

            string defaultEmail_Assigned = Application["defaultEmail"].ToString();

            defaultEmail.Text = "Congratulations! You successfully registered to Travel Experts. Please make note of the following email address that has been assigned to you: " + defaultEmail_Assigned + ". Use that email address to login to your account.";
        }
示例#7
0
 protected void btnUpdtPswd_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Customers loggedCustomer      = new Customers(Session["custEmail"].ToString(), HashPassword.ApplyHash(txtOldCustPassword.Text));
         Customers updatedPswdCustomer = new Customers(Session["custEmail"].ToString(), HashPassword.ApplyHash(txtNewCustPassword.Text));
         try
         {
             bool updatePswdSuccessful = CustomersDB.UpdateCustomerPassword(loggedCustomer, updatedPswdCustomer);
             if (updatePswdSuccessful)
             {
                 Control loginSuccess = FindControl("LoginSuccess");
                 loginSuccess.Visible = true;
                 string script = @"document.getElementById('" + LoginSuccess.ClientID + "').innerHTML='Password update successful.' ;setTimeout(function(){document.getElementById('" + LoginSuccess.ClientID + "').style.display='none';},5000);";
                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Show status", script, true);
             }
             else
             {
                 Control loginFail = FindControl("LoginFailure");
                 loginFail.Visible = true;
                 string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Unable to update password.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "Show status", script, true);
             }
         }
         catch (Exception)
         {
             ExceptionScript();
         }
     }
 }
示例#8
0
        protected void LoginButton(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string hashedPswd = HashPassword.ApplyHash(txtModalCustPassword.Text);
                // string custEmail = String.Format("{0}", Request.Form["email_modal"]);
                // string custPassword = String.Format("{0}", Request.Form["password_modal"]);

                Customers custLogin = new Customers(txtModalCustEmail.Text, hashedPswd);

                string output = CustomersDB.GetCustomerLogin(custLogin);

                if (output == "1")
                {
                    Session["custEmail"] = txtModalCustEmail.Text;
                    Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());
                    Session["customerId"] = (int)loggedCustomer.CustomerId;

                    Response.Redirect("ItemsBought.aspx");
                }
                else
                {
                    Response.Write("Login Failed");
                }
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlControl loginIcon  = (HtmlControl)Page.FindControl("mainBtnLogin");
            HtmlControl loggedIcon = (HtmlControl)Page.FindControl("custLogged");

            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            if (Session["custEmail"] != null)
            {
                loggedIcon.Visible = true;
                loginIcon.Visible  = false;

                try
                {
                    customerLogged.Text = "Welcome " + CustomersDB.confirmLogin(Session["custEmail"].ToString());
                }
                catch (Exception)
                {
                    ExceptionScript();
                }
            }
            else
            {
                loggedIcon.Visible = false;
                loginIcon.Visible  = true;
            }

            if (!IsPostBack)
            {
                try
                {
                    Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());
                    txtCustFirstName.Text    = loggedCustomer.CustFirstName;
                    txtCustLastName.Text     = loggedCustomer.CustLastName;
                    txtCustAddress.Text      = loggedCustomer.CustAddress;
                    txtCustCity.Text         = loggedCustomer.CustCity;
                    ddlCustProv.Text         = loggedCustomer.CustProv;
                    txtCustPostal.Text       = loggedCustomer.CustPostal;
                    txtCustHomePhone.Text    = loggedCustomer.CustHomePhone;
                    txtCustBusPhone.Text     = loggedCustomer.CustBusPhone;
                    txtUnconfirmedEmail.Text = loggedCustomer.CustEmail;
                    txtCustEmail.Text        = loggedCustomer.CustEmail;
                    customerLogged.Text      = "Welcome " + txtCustFirstName.Text;
                }
                catch
                {
                    ExceptionScript();
                }
            }
        }
示例#10
0
        protected void DBPasswordValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Customers isPasswordCorrect = CustomersDB.GetCustomerbyPassword(HashPassword.ApplyHash(txtOldCustPassword.Text));

            if (isPasswordCorrect == null)
            {
                args.IsValid = false;
                Control loginFail = FindControl("LoginFailure");
                loginFail.Visible = true;
                string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Unable to update password.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
            }
            else
            {
                args.IsValid = true;
            }
        }
        protected void validateEmailDB_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Customers isEmailExisting = CustomersDB.GetCustomerbyEmail(txtCustEmail.Text);

            if (isEmailExisting == null)
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;

                Control loginFail = FindControl("LoginFailure");
                loginFail.Visible = true;
                string script = @"document.getElementById('" + LoginFailure.ClientID + "').innerHTML='Unable to register. A customer with that email address already exists.' ;setTimeout(function(){document.getElementById('" + LoginFailure.ClientID + "').style.display='none';},5000);";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
            }
        }
示例#12
0
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     try
     {
         Customers loggedCustomer = CustomersDB.GetCustomerbyEmail(Session["custEmail"].ToString());
         txtCustFirstName.Text    = loggedCustomer.CustFirstName;
         txtCustLastName.Text     = loggedCustomer.CustLastName;
         txtCustAddress.Text      = loggedCustomer.CustAddress;
         txtCustCity.Text         = loggedCustomer.CustCity;
         ddlCustProv.Text         = loggedCustomer.CustProv;
         txtCustPostal.Text       = loggedCustomer.CustPostal;
         txtCustHomePhone.Text    = loggedCustomer.CustHomePhone;
         txtCustBusPhone.Text     = loggedCustomer.CustBusPhone;
         txtUnconfirmedEmail.Text = loggedCustomer.CustEmail;
         txtCustEmail.Text        = loggedCustomer.CustEmail;
     }
     catch
     {
         ExceptionScript();
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string hashedPswd = HashPassword.ApplyHash(txtCustPassword.Text);

                if (txtCustEmail.Text != "")
                {
                    Customers cust = new Customers(txtCustFirstName.Text, txtCustLastName.Text, txtCustAddress.Text, txtCustCity.Text, ddlCustProv.Text, txtCustPostal.Text, txtCustCountry.Text, FormatePhoneNo.ApplyFormatting(txtCustHomePhone.Text), FormatePhoneNo.ApplyFormatting(txtCustBusPhone.Text), txtCustEmail.Text, hashedPswd, "No");
                    try
                    {
                        int insertCustId = CustomersDB.AddCustomer(cust);
                        SendActivationEmail(txtCustEmail.Text);
                        Response.Redirect("ConfirmationPage.aspx");
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    string defaultEmail = "defaultemail" + CustomersDB.AssignEmailNo() + "@travelexperts.com";
                    Application["defaultEmail"] = defaultEmail;

                    Customers cust = new Customers(txtCustFirstName.Text, txtCustLastName.Text, txtCustAddress.Text, txtCustCity.Text, ddlCustProv.Text, txtCustPostal.Text, txtCustCountry.Text, FormatePhoneNo.ApplyFormatting(txtCustHomePhone.Text), FormatePhoneNo.ApplyFormatting(txtCustBusPhone.Text), defaultEmail, hashedPswd, "Yes");
                    try
                    {
                        int insertCustId = CustomersDB.AddCustomer(cust);
                        Response.Redirect("ConfirmationPageNoEmail.aspx");
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }