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;
                    }
                }
            }
        }
Пример #2
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();
                }
            }
        }