Esempio n. 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            NewContributor ncont = new NewContributor();

            ncont.firstName         = txtFirstName.Text;
            ncont.lastName          = txtLastName.Text;
            ncont.email             = txtEmail.Text;
            ncont.streetAddress     = txtAddress.Text;
            ncont.city              = txtCity.Text;
            ncont.state             = txtState.Text;
            ncont.postalCode        = txtPostalCode.Text;
            ncont.homePhone         = txtHomePhone.Text;
            ncont.plainTextPassword = txtPassword.Text;

            Session["newCont"] = ncont;

            Response.Redirect("ConfirmRegisterInfo.aspx");
        }
        catch (Exception ex)
        {
            lblError.Text = "unable either to create session variable NewContributor or assign values to session variable" +
                            ex.Message;
        }
    }
Esempio n. 2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //NewContributor ncont = new NewContributor();
        NewContributor ncont = (NewContributor)Session["newCont"];
        //ncont.lastname = txtLastName.Text;
        //ncont.firstname = txtFirstName.Text;
        //ncont.email = txtEmail.Text;
        //ncont.streetAddress = txtAddress.Text;
        //ncont.city = txtCity.Text;
        //ncont.state = txtState.Text;
        //ncont.homePhone = txtHomePhone.Text;
        //ncont.PlainPassword = txtPWordConfirm.Text;

        ManageContributor manageCont = new ManageContributor();

        //try{
        manageCont.WriteContributor(ncont);
        lblError.Text = "Thanks for registering";
        //}catch(Exception ex){
        //lblError.Text = ex.Message;
        //}

        //lblError.Text = "Thanks for registering";

        Response.Redirect("loginOrRegister.aspx");
    }
Esempio n. 3
0
    /*private SqlCommand WritePerson()
     * {
     * string sqlPerson = "Insert into Person (LastName, FirstName) Values (@LastName, @FirstName)";
     * SqlCommand personCmd = new SqlCommand(sqlPerson, connect);
     * personCmd.Parameters.AddWithValue("@LastName", c.LastName);
     * personCmd.Parameters.AddWithValue("@FirstName", c.FirstName);
     * return personCmd;
     * }*/

    public void WriteContributor(NewContributor ncont)
    {
        //this.cust=c;
        //SqlTransaction tran = null;
        //SqlCommand pCmd = WritePerson();
        string sqlPerson = "Insert into Person (PersonLastName, PersonFirstName, PersonUsername, PersonPlainPassword, Personpasskey, PersonUserPassword) " +
                           "Values (@LastName, @FirstName, @Username, @PlainPW, @PersonPassKey, @PersonUserPassword)";
        string sqlPersonAddress = "Insert into PersonAddress (Street, City, State, Zip, PersonKey) " +
                                  "Values(@Street, @City, @State, @Zip, ident_Current('Person'))";
        //string sqlRegisteredCustomer = "Insert into customer.RegisteredCustomer(Email, CustomerPassCode, CustomerPassword, CustomerHashedPassword, PersonKey) " +
        //"Values(@Email, @Passcode, @password, @hashedpass, ident_Current('Person'))";

        PasscodeGenerator pg = new PasscodeGenerator();
        PasswordHash      ph = new PasswordHash();
        int passcode         = pg.GetPasscode();

        SqlCommand newContributorCmd = new SqlCommand(sqlPerson, connect);

        newContributorCmd.Parameters.AddWithValue("@LastName", ncont.lastName);
        newContributorCmd.Parameters.AddWithValue("@FirstName", ncont.firstName);
        newContributorCmd.Parameters.AddWithValue("@Username", ncont.email);
        newContributorCmd.Parameters.AddWithValue("@PlainPW", ncont.plainTextPassword);
        newContributorCmd.Parameters.AddWithValue("@PersonPassKey", passcode);
        newContributorCmd.Parameters.AddWithValue("@PersonUserPassword", ph.HashIt(ncont.plainTextPassword, passcode.ToString()));

        //SqlCommand regCustomerCmd = new SqlCommand(sqlRegisteredCustomer, connect);
        //regCustomerCmd.Parameters.AddWithValue("@Passcode", passcode);
        //regCustomerCmd.Parameters.AddWithValue("@password", c.PlainPassword);
        //regCustomerCmd.Parameters.AddWithValue("@hashedpass", ph.HashIt(c.PlainPassword, passcode.ToString()));

        SqlCommand personAddressCmd = new SqlCommand(sqlPersonAddress, connect);

        personAddressCmd.Parameters.AddWithValue("@Street", ncont.streetAddress);
        personAddressCmd.Parameters.AddWithValue("@City", ncont.city);
        personAddressCmd.Parameters.AddWithValue("@State", ncont.state);
        personAddressCmd.Parameters.AddWithValue("@Zip", ncont.postalCode);


        connect.Open();
        //try {
        //tran = commenct.BeginTransation();
        //pCmd.Transaction = tran;
        //pCmd.ExecuteNonQuery();
        //tran.Commit();
        newContributorCmd.ExecuteNonQuery();
        personAddressCmd.ExecuteNonQuery();


        //}catch(Exception ex){
        //tran.Rollback();
        //throw ex;
        //}finally{
        connect.Close();
        //}
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["newCont"] != null)
        {
            NewContributor ncont = (NewContributor)Session["newCont"];

            txtFirstName.Text  = ncont.firstName;
            txtLastName.Text   = ncont.lastName;
            txtEmail.Text      = ncont.email;
            txtAddress.Text    = ncont.streetAddress;
            txtCity.Text       = ncont.city;
            txtState.Text      = ncont.state;
            txtPostalCode.Text = ncont.state;
            txtHomePhone.Text  = ncont.homePhone;
        }
        else
        {
            Response.Redirect("Register.aspx");
        }
    }