Esempio n. 1
0
    public void WriteCustomer(Customer c)
    {
        string sqlPerson = "Insert into Person(PersonLastName, PersonFirstName,PersonUserName,PersonPlainPassword,Personpasskey,PersonUserPassword,PersonEntryDate) Values(@LastName, @FirstName, @UserName, @PlainPassword, @Passcode, @HashedPassword, @EntryDate)";
        string sqlPersonAddress = "Insert into PersonAddress(Street, Apartment, City, State, Zip, Personkey) " + "Values(@Street, @Apartment, @City, @State, @Zip, ident_Current('Person'))";

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

        SqlCommand personCmd = new SqlCommand(sqlPerson, connect);
        personCmd.Parameters.AddWithValue("@FirstName", c.FirstName);
        personCmd.Parameters.AddWithValue("@LastName", c.LastName);
        personCmd.Parameters.AddWithValue("@UserName", c.Email);
        personCmd.Parameters.AddWithValue("@PlainPassword", c.PlainPassword);
        personCmd.Parameters.AddWithValue("@Passcode", Passcode);
        personCmd.Parameters.AddWithValue("@HashedPassword", ph.HashIt(c.PlainPassword.ToString(), Passcode.ToString()));
        personCmd.Parameters.AddWithValue("@EntryDate", DateTime.Now);

        SqlCommand addressCmd = new SqlCommand(sqlPersonAddress, connect);
        addressCmd.Parameters.AddWithValue("@Street", c.Street);
        addressCmd.Parameters.AddWithValue("@Apartment", c.Apartment);
        addressCmd.Parameters.AddWithValue("@City", c.City);
        addressCmd.Parameters.AddWithValue("@State", c.State);
        addressCmd.Parameters.AddWithValue("@Zip", c.Zip);

        connect.Open();
        personCmd.ExecuteNonQuery();
        addressCmd.ExecuteNonQuery();
        connect.Close();
    }
Esempio n. 2
0
    public void WriteCustomer(Customer c)
    {
        string sqlPerson = "Insert into Person (LastName, FirstName) Values (@LastName, @FirstName)";
        string sqlVehicle = "Insert into Customer.Vehicle (LicenseNumber, VehicleMake, VehicleYear, PersonKey) " + "Values(@License, @Make, @Year, ident_Current('Person'))";
        string sqlRegisteredCustomer = "Insert into Customer.RegisteredCustomer(Email, CustomerPasscode, " + "CustomerPassword, CustomerHashedPassword, PersonKey) " + "Values(@Email, @Passcode, @password, @hashedpass, ident_Current('Person'))";

        SqlCommand personCmd = new SqlCommand(sqlPerson, connect);
        personCmd.Parameters.AddWithValue("@LastName", c.LastName);
        personCmd.Parameters.AddWithValue("@FirstName", c.FirstName);

        SqlCommand vehicleCmd = new SqlCommand(sqlVehicle, connect);
        vehicleCmd.Parameters.AddWithValue("@License", c.LicenseNumber);
        vehicleCmd.Parameters.AddWithValue("@Make", c.VehicleMake);
        vehicleCmd.Parameters.AddWithValue("@Year", c.VehicleYear);

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

        SqlCommand regCustomerCmd = new SqlCommand(sqlRegisteredCustomer, connect);
        regCustomerCmd.Parameters.AddWithValue("@Email", c.Email);
        regCustomerCmd.Parameters.AddWithValue("@Passcode", passcode);
        regCustomerCmd.Parameters.AddWithValue("@Password", c.PlainPassword);
        regCustomerCmd.Parameters.AddWithValue("@hashedPass", ph.HashIt(c.PlainPassword, passcode.ToString()));

        connect.Open();
        personCmd.ExecuteNonQuery();
        vehicleCmd.ExecuteNonQuery();
        regCustomerCmd.ExecuteNonQuery();
        connect.Close();
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {

        //get the passcode
        PasscodeGenerator pg = new PasscodeGenerator();
        int passcode = pg.GetPasscode();
        //initialize customer and vehicle

        Customer c = new Customer();

        Vehicle v = new Vehicle();
        //initialize PasswordHash
        PasswordHash ph = new PasswordHash();

        //Assign the values from the textboxes
        //to the classes
        c.LastName = txtLastName.Text;
        c.FirstName = txtFirstName.Text;
        c.email = txtEmail.Text;
        c.password = txtPassword.Text;
        c.passcode = passcode;
        //get the hashed password
        c.PasswordHash = ph.Hashit(txtPassword.Text, passcode.ToString());
        c.apartment = txtApt.Text;
        c.state = txtState.Text;
        c.street = txtStreet.Text;
        c.zip = txtZip.Text;
        c.city = txtCity.Text;
        c.phone = txtPhone.Text;






       // v.License = txtLicense.Text;
        //v.Make = txtMake.Text;
      //  v.Year = txtYear.Text;
        try
        {
            //try to write to the database
            Registrations r = new Registrations(c);
            lblResult.Text = "Thank you for registering";
            LinkButton1.Visible = true;
        }
        catch (Exception ex)
        {
            //if it fails show the error
            lblError.Text = ex.ToString();
        }
    }
Esempio n. 4
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {

            CommunityAssistEntities ce = new CommunityAssistEntities();

            Person p = new Person();
            p.PersonFirstName = txtFirstName.Text;
            p.PersonLastName = txtLastName.Text;
            p.PersonUsername = txtEmail.Text;

            p.PersonPlainPassword = txtConfirm.Text;

            PasscodeGenerator pg = new PasscodeGenerator();
            int passcode = pg.GetPasscode();
            PasswordHash ph = new PasswordHash();
            p.Personpasskey = passcode;
            p.PersonUserPassword = ph.Hashit(txtConfirm.Text, passcode.ToString());

            ce.People.Add(p);

            //vehicle v = new vehicle();
            //v.LicenseNumber = txtLicense.Text;
            //v.VehicleMake = txtMake.Text;
            //v.VehicleYear = ddYear.SelectedItem.ToString();
            //v.Person = p;
            //ce.vehicles.Add(v);

            //PasscodeGenerator pg = new PasscodeGenerator();
            //int passcode = pg.GetPasscode();

            //PasswordHash ph = new PasswordHash();
            //RegisteredCustomer rc = new RegisteredCustomer();
            //rc.Person = p;
            //rc.Email = txtEmail.Text;
            //rc.CustomerPassCode = passcode;
            //rc.CustomerPassword = txtConfirm.Text;
            //rc.CustomerHashedPassword = ph.Hashit(txtConfirm.Text, passcode.ToString());

            //ce.Person.Add(p);
            ce.SaveChanges();
            Response.Redirect("Welcome.aspx");

        }
        catch (Exception ex)
        {
            lblResult.Text = ex.Message;
        }
    }
Esempio n. 5
0
    private SqlCommand WriteRegisteredCustomer()
    {
        PasscodeGenerator pg = new PasscodeGenerator();
        PasswordHash ph = new PasswordHash();
        int passcode = pg.GetPasscode();

        string sqlRegisteredCustomer = "Insert into Customer.RegisteredCustomer(Email, Passcode, CustomerPassword, CustomerHashedPassword, PErsonKey) " +
           "Values(@Email, @Passcode, @Password, @Hashedpass, identCurrent('Person'))";
        SqlCommand regCustomerCmd = new SqlCommand(sqlRegisteredCustomer, connect);
        regCustomerCmd.Parameters.AddWithValue("@Email", c.Email);
        regCustomerCmd.Parameters.AddWithValue("@Passcode", pg.GetPasscode());
        regCustomerCmd.Parameters.AddWithValue("@Password", c.Password);
        regCustomerCmd.Parameters.AddWithValue("@hashedPass", ph.HashIt(c.Password.ToString(), passcode.ToString()));

        return regCustomerCmd;
    }
    public void WriteCustomer(Customer c)
    {
        string sqlPerson = "Insert into Person (PersonLastName, PersonFirstName, PersonUsername, Personpasskey, PersonPlainPassword, " +
            "PersonUserPassword) Values (@LastName, @FirstName, @Email, @Passcode, @password, @hashedpass)";

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

        SqlCommand personCmd = new SqlCommand(sqlPerson, connect);
        personCmd.Parameters.AddWithValue("@LastName", c.LastName);
        personCmd.Parameters.AddWithValue("@FirstName", c.FirstName);
        personCmd.Parameters.AddWithValue("@Email", c.Email);
        personCmd.Parameters.AddWithValue("@Passcode", passcode);
        personCmd.Parameters.AddWithValue("@Password", c.PlainPassword);
        personCmd.Parameters.AddWithValue("@hashedPass", ph.HashIt(c.PlainPassword, passcode.ToString()));

        connect.Open();
        personCmd.ExecuteNonQuery();
        connect.Close();
    }
Esempio n. 7
0
    public void WriteCustomer(Customer c)
    {
        this.c = c;

        SqlTransaction tran = null;

        SqlCommand pCmd = WritePerson();
        SqlCommand vCmd = WriteVehicle();
        SqlCommand rCmd = WriteRegisteredCustomer();


        connect.Open();
        try
        {
            tran             = connect.BeginTransaction();
            pCmd.Transaction = tran;
            vCmd.Transaction = tran;
            rCmd.Transaction = tran;
            pCmd.ExecuteNonQuery();
            vCmd.ExecuteNonQuery();
            rCmd.ExecuteNonQuery();
            tran.Commit();
        }
        catch (Exception ex)
        {
            tran.Rollback();
            throw ex;
        }
        finally
        {
            connect.Close();
        }


        PasscodeGenerator pg = new PasscodeGenerator();
        PasswordHash      ph = new PasswordHash();
        int passcode         = pg.GetPasscode();
    }
Esempio n. 8
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        //get the passcode
        PasscodeGenerator pg = new PasscodeGenerator();
        int passcode         = pg.GetPasscode();
        //initialize customer and vehicle

        Customer c = new Customer();

        Vehicle v = new Vehicle();
        //initialize PasswordHash
        PasswordHash ph = new PasswordHash();

        //Assign the values from the textboxes
        //to the classes
        c.LastName  = txtLastName.Text;
        c.FirstName = txtFirstName.Text;
        c.email     = txtEmail.Text;
        c.password  = txtPassword.Text;
        c.passcode  = passcode;
        //get the hashed password
        c.PasswordHash = ph.HashIt(txtPassword.Text, passcode.ToString());
        v.License      = txtLicense.Text;
        v.Make         = txtMake.Text;
        v.Year         = txtYear.Text;
        try
        {
            //try to write to the database
            Registration r = new Registration(c, v);
            lblResult.Text      = "Thank you for registering";
            LinkButton1.Visible = true;
        }
        catch (Exception ex)
        {
            //if it fails show the error
            lblError.Text = ex.ToString();
        }
    }
Esempio n. 9
0
    public void WriteCustomer(Customer c)
    {
        string sqlPerson  = "Insert into Person (LastName, Firstname) Values(@LastName, @FirstName)";
        string sqlVehicle = " Insert into Customer.Vehicle(LicenseNumber, VehicleMake, VehicleYear, PersonKey) " +
                            "Values(@License, @Make, @Year, ident_Current('Person'))";
        string sqlRegisteredCustomer =
            "Insert into Customer.RegisteredCustomer(Email,CustomerPasscode, "
            + "CustomerPassword, CustomerHashedPassword, PersonKey) "
            + "Values(@email, @Passcode, @password, @hashedpass, ident_Current('Person'))";

        SqlCommand personCmd = new SqlCommand(sqlPerson, connect);

        personCmd.Parameters.AddWithValue("@LastName", c.LastName);
        personCmd.Parameters.AddWithValue("@FirstName", c.FirstName);

        SqlCommand vehicleCmd = new SqlCommand(sqlVehicle, connect);

        vehicleCmd.Parameters.AddWithValue("@License", c.LicenseNumber);
        vehicleCmd.Parameters.AddWithValue("@Make", c.VehicleMake);
        vehicleCmd.Parameters.AddWithValue("@Year", c.VehicleYear);

        PasscodeGenerator pg      = new PasscodeGenerator();
        PasswordHash      ph      = new PasswordHash();
        int        passcode       = pg.GetPasscode();
        SqlCommand regCustomerCmd = new SqlCommand(sqlRegisteredCustomer, connect);

        regCustomerCmd.Parameters.AddWithValue("@Email", c.Email);
        regCustomerCmd.Parameters.AddWithValue("@Passcode", passcode);
        regCustomerCmd.Parameters.AddWithValue("@password", c.PlainPassword);
        regCustomerCmd.Parameters.AddWithValue("@hashedPass", ph.HashIt(c.PlainPassword.ToString(), passcode.ToString()));


        connect.Open();
        personCmd.ExecuteNonQuery();
        vehicleCmd.ExecuteNonQuery();
        regCustomerCmd.ExecuteNonQuery();
        connect.Close();
    }
Esempio n. 10
0
    public void WriteCustomer(Customer c)
    {
        this.c = c;

        SqlTransaction tran = null;

        SqlCommand pCmd = WritePerson();
        SqlCommand vCmd = WriteVehicle();
        SqlCommand rCmd = WriteRegisteredCustomer();

        connect.Open();
        try
        {
            tran = connect.BeginTransaction();
            pCmd.Transaction = tran;
            vCmd.Transaction = tran;
            rCmd.Transaction = tran;
            pCmd.ExecuteNonQuery();
            vCmd.ExecuteNonQuery();
            rCmd.ExecuteNonQuery();
            tran.Commit();
        }
        catch (Exception ex)
        {
            tran.Rollback();
            throw ex;
        }
        finally
        {
            connect.Close();
        }

        PasscodeGenerator pg = new PasscodeGenerator();
        PasswordHash ph = new PasswordHash();
        int passcode = pg.GetPasscode();
    }
Esempio n. 11
0
    /*   Cannot insert explicit value for identity column in table 'Person' when IDENTITY_INSERT is set to OFF.   */
    private SqlCommand WritePerson()
    {
        PasscodeGenerator pg = new PasscodeGenerator();
        PasswordHash ph = new PasswordHash();
        int passcode = pg.GetPasscode();

        string sqlPerson = "Insert into Person ( PersonLastName, PersonFirstName, PersonUsername,Personpasskey, PersonUserPassword) Values (@LastName, @FirstName, @passcode, @password, @hashedpass)";
        SqlCommand personCmd = new SqlCommand(sqlPerson, connect);
        personCmd.Parameters.AddWithValue("@LastName", p.lastName);
        personCmd.Parameters.AddWithValue("@FirstName", p.firstName);
        personCmd.Parameters.AddWithValue("@Email", p.email);
           personCmd.Parameters.AddWithValue("@Passcode", passcode.ToString());
           personCmd.Parameters.AddWithValue("@password", p.passWord.ToString());
           personCmd.Parameters.AddWithValue("@hashedPass", ph.HashIt(p.PlainPassword, passcode.ToString()));
         /*Cannot insert explicit value for identity column in table 'Person' when IDENTITY_INSERT is set to OFF. */

        return personCmd;
    }