-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default2.aspx.cs
55 lines (50 loc) · 1.59 KB
/
Default2.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] years = new string[19];
int counter = 0;
for (int i = 1995; i < 2014; i++)
{
years[counter] = i.ToString();
counter++;
}
ddYears.DataSource = years.ToList();
ddYears.DataBind();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
AutomartEntities ae = new AutomartEntities();
Person p = new Person();
p.LastName = txtLastName.Text;
p.FirstName = txtFirstName.Text;
ae.People.Add(p);
vehicle v = new vehicle();
v.Person = p;
v.VehicleMake = txtMake.Text;
v.LicenseNumber = txtLicense.Text;
v.VehicleYear = ddYears.SelectedItem.ToString();
ae.vehicles.Add(v);
Random rand = new Random();
int passcode = rand.Next(1000000, 9999999);
PasswordHash ph = new PasswordHash();
byte[] hashed = ph.HashIt(txtPassword.Text, passcode.ToString());
RegisteredCustomer rc = new RegisteredCustomer();
rc.Person = p;
rc.Email = txtEmail.Text;
rc.CustomerPassCode = passcode;
rc.CustomerPassword = txtPassword.Text;
rc.CustomerHashedPassword = hashed;
ae.RegisteredCustomers.Add(rc);
ae.SaveChanges();
}
}