예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["person"] != null)
        {
            int pK = (int)Session["person"];
            int vhId = 0;
            CustomerName cn = new CustomerName(pK);
            lblName.Text = cn.CustomerNameFetch();

            CustomerHistory ch = new CustomerHistory(pK);
            lblYear.Text = ch.VehicleYearFetch();
            lblMake.Text = ch.VehicleMakeFetch();
            vhId = ch.VehicleIdFetch();

     
            AutomartEntities ae = new AutomartEntities();
            var servdate = from s in ae.VehicleServiceDetails
                          where s.VehicleService.VehicleID == vhId 
                          orderby s.VehicleService.ServiceDate
                          select new {s.VehicleService.ServiceDate,               
                                      s.AutoService.ServiceName, 
                                      s.AutoService.ServicePrice };
                dlHistory.DataSource = servdate.ToList();
                dlHistory.DataBind();

              
   


        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if(Session["person"] != null)
        {
            AutomartEntities ae = new AutomartEntities();
            int pk = (int)Session["person"];
            var customer = from c in ae.vehicles
                        where c.PersonKey == pk
                        select new
                        {
                            c.Person.LastName,
                            c.Person.FirstName,
                            c.LicenseNumber,
                            c.VehicleMake,
                            c.VehicleYear
                        };
            foreach (var p in customer)
            {
                lblWelcome.Text = "Welcome! " + p.FirstName + " " + p.LastName + ".";
            }

            GridView1.DataSource = customer.ToList();
            GridView1.DataBind();
        }
        else
        {
            Response.Redirect("Default.aspx");
        }
    }
예제 #3
0
    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();
    }
예제 #4
0
    private void RegisterVehicle()
    {
        //here again we initiate the automart entities object
        AutomartEntities ae = new AutomartEntities();

        try
        {
            int vID = 0;
            //We call the AddNewVehicle procedure and pass its parameters
            //from the text boxes. They really should be validated
            //first
            ae.usp_AddNewVehicle(txtLastName.Text, txtFirstName.Text, txtLicense.Text, txtMake.Text, txtYear.Text);
            var lic = ae.usp_GetVehicleandCustomerInfo(txtLicense.Text);

            foreach (var l in lic)
            {
                vID = l.VehicleID;
                //Write the vehicleID to a session variable
                Session["VehicleID"] = vID;
            }

            lblResult.Text = "Saved";
        }
        catch (Exception ex)
        {
            lblResult.Text = ex.Message;
        }
    }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
       AutomartEntities ae = new AutomartEntities();
        var serv = from s in ae.AutoServices
                   orderby s.ServiceName
                   select new {s.ServiceName, s.ServicePrice};
        DataList1.DataSource = serv.ToList();
        DataList1.DataBind();

        var loc = from l in ae.Locations
                  orderby l.LocationName
                  select new { l.LocationName, l.LocationAddress, l.LocationCity, l.LocationState };
        DataList2.DataSource = loc.ToList();
        DataList2.DataBind(); 
    }
    protected void txtSubmit_Click(object sender, EventArgs e)
    {
    int isErrors=Validator();
        if (isErrors == 0)
        {
            try
            {
                AutomartEntities ae = new AutomartEntities();

                Person p = new Person();
                 p.LastName = txtLastName.Text;
                 p.FirstName = txtFirstName.Text;
                 ae.People.Add(p);

                RegisteredCustomer rc = new RegisteredCustomer();
                rc.Person = p;
                rc.Email = txtEmail.Text;
                rc.CustomerPassword = txtConfirmPassword.Text;
                ae.RegisteredCustomers.Add(rc);

                vehicle v = new vehicle();
                v.Person = p;
                v.LicenseNumber = txtLicense.Text;
                v.VehicleMake = txtMake.Text;
                v.VehicleYear = txtYear.Text;
                ae.vehicles.Add(v); 

                ae.SaveChanges();

                Response.Redirect("ConfirmationPage.aspx");
               }
               catch (ArgumentNullException en)
              {
                string msg = en.Message;
                CreateAlert(msg);
               }
              catch (Exception ex)
              {

                string msg = ex.Message;
                CreateAlert(msg);
            }
        }//end if
  }
예제 #7
0
    public int ValidateLogin()
    {
        int pKey = 0;
        AutomartEntities ae = new AutomartEntities();

        var loginData = from p in ae.RegisteredCustomers
                        where p.Email.Equals(userName)
                        select new
                        {
                            p.CustomerPassCode,
                            p.CustomerHashedPassword,
                            p.PersonKey
                        };
        int passcode = 0;
        byte[]hashed = null;
        int personKey = 0;

        //if (loginData != null)
        //{
            foreach (var ld in loginData)
            {
                passcode = (int)ld.CustomerPassCode;
                hashed = (byte[])ld.CustomerHashedPassword;
                personKey = (int)ld.PersonKey;
            }

            PasswordHash ph = new PasswordHash();
            if (passcode != 0)
            {
                byte[] generatedPassword = ph.HashIt(password, passcode.ToString());

                if (hashed != null)
                {
                    if (generatedPassword.SequenceEqual(hashed))
                    {
                        pKey = personKey;
                    }//end inner if
                }//end hashed if
            }//end outer if, passcode
        return pKey;
    }