Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //This code uses the ADO.Net DataEntities to pull the location and service information from the Automart database
            //and bind the info to the corresponding datalists on the Default.aspx page
            AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

            var loc = from l in ame.Locations
                      orderby l.LocationName
                      select new { l.LocationName, l.LocationAddress, l.LocationCity, l.LocationState, l.LocationZip };

            LocationsDL.DataSource = loc.ToList();
            LocationsDL.DataBind();

            var serv = from s in ame.AutoServices
                       orderby s.ServiceName
                       select new { s.ServiceName, s.ServicePrice };

            ServicesDL.DataSource = serv.ToList();
            ServicesDL.DataBind();
        }

        catch (Exception ex)
        {
            Session["error"] = ex.Message;
            Response.Redirect("Default6.aspx");
        }
    }
Пример #2
0
    //On page load, this code will populate the datalists on Default.aspx with the selected information from the Automart database using  AutomartEntities.
    protected void Page_Load(object sender, EventArgs e)
    {
        AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

        var loc = from l in ame.Locations
                  orderby l.LocationName
                  select new { l.LocationName, l.LocationAddress, l.LocationCity, l.LocationState, l.LocationZip };

        LocationsDL.DataSource = loc.ToList();
        LocationsDL.DataBind();

        var serv = from s in ame.AutoServices
                   orderby s.ServiceName
                   select new { s.ServiceName, s.ServicePrice };

        ServicesDL.DataSource = serv.ToList();
        ServicesDL.DataBind();
    }
Пример #3
0
    //On page load, this code will populate the datalists on Default.aspx with the selected information from the Automart database using  AutomartEntities.
    protected void Page_Load(object sender, EventArgs e)
    {
        AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

        var loc = from l in ame.Locations
                  orderby l.LocationName
                  select new { l.LocationName, l.LocationAddress, l.LocationCity, l.LocationState, l.LocationZip };

        LocationsDL.DataSource = loc.ToList();
        LocationsDL.DataBind();

        var serv = from s in ame.AutoServices
                   orderby s.ServiceName
                   select new { s.ServiceName, s.ServicePrice };

        ServicesDL.DataSource = serv.ToList();
        ServicesDL.DataBind();
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //The code on this page calls on the "person" session to retrieve the Person Key of the logged-in user, then uses that key to retrieve the necessary customer data from the Automart database to populate the information displayed on Default5.aspx
        try
        {
            if (Session["person"] != null)
            {
                int personKey = (int)Session["person"];

                //This section of code uses ADO to retrieve the user's name and email address using the GetCustomer class
                GetCustomer gc = new GetCustomer(personKey);

                string customerName = null;
                DataSet ds = gc.GetName();

                foreach (DataRow row in ds.Tables["Customer"].Rows)
                {
                    customerName = row["FirstName"].ToString() + " " + row["LastName"].ToString();
                }

                WelcomeLbl.Text = "Welcome " + customerName + "!";

                string customerEmail = null;
                DataSet ds2 = gc.GetEmail();

                foreach (DataRow row in ds2.Tables["RegisteredCustomer"].Rows)
                {
                    customerEmail = row["Email"].ToString();
                }

                EmailLbl.Text = "Your registered email address is: " + customerEmail + ".";

               //From here, Ado.Net Data Entities is used to select vehicle and service information for the logged in user and bind
               // that information to the corresponding datalist on Default5.aspx
               AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

                var veh = from v in ame.vehicles
                          where v.PersonKey == personKey
                          orderby v.VehicleId
                          select new { v.VehicleId, v.LicenseNumber, v.VehicleMake, v.VehicleYear};

                VehicleDL.DataSource = veh.ToList();
                VehicleDL.DataBind();

                var num = (from n in ame.VehicleServices
                           where n.vehicle.PersonKey == personKey
                           select n).Count();

                if (num == 0)
                {
                    NoHistoryLbl.Text = "You have no auto service history with AutoMart.";
                    NoHistoryLbl2.Text = "You have no auto service history with AutoMart.";
                }

                var ser = from s in ame.VehicleServices
                          where s.vehicle.PersonKey == personKey
                          orderby s.VehicleID
                          select new { s.VehicleServiceID, s.VehicleID, s.LocationID, s.ServiceDate, s.ServiceTime };

                ServiceDL.DataSource = ser.ToList();
                ServiceDL.DataBind();

                var det = from d in ame.VehicleServiceDetails
                          where d.VehicleService.vehicle.PersonKey == personKey
                          orderby d.VehicleServiceID
                          select new { d.VehicleServiceID, d.AutoServiceID, d.serviceNotes};

                DetailsDL.DataSource = det.ToList();
                DetailsDL.DataBind();

                var loc = from l in ame.Locations
                          orderby l.LocationID
                          select new { l.LocationID, l.LocationName};

                LocationIdDL.DataSource = loc.ToList();
                LocationIdDL.DataBind();

                var auto = from a in ame.AutoServices
                           orderby a.AutoServiceID
                           select new {a.AutoServiceID, a.ServiceName};

                AutoServiceDL.DataSource = auto.ToList();
                AutoServiceDL.DataBind();
            }
            else
            {
                Response.Redirect("Default2.aspx", false);
            }
        }

        catch (Exception ex)
        {
            Session["error"] = ex.Message;
            Response.Redirect("Default6.aspx");
        }
    }
Пример #5
0
    protected void SubmitBtn_Click(object sender, EventArgs e)
    {
        try
        {
            // Form Validation - Checks for blank required fields and password matching
            if (FirstNameTxt.Text == "")
            {
                FNErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {
                FNErrorLbl.Text = "";
            }

            if (LastNameTxt.Text == "")
            {
                LNErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {
                LNErrorLbl.Text = "";
            }

            if (EmailTxt.Text == "")
            {
                EMErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {
                EMErrorLbl.Text = "";
            }

            if (LicenseTxt.Text == "")
            {
                LPErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {
                LPErrorLbl.Text = "";
            }

            if (PasswordTxt.Text == "")
            {
                PWErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {
                PWErrorLbl.Text = "";
            }

            if (PasswordConfirmTxt.Text == "")
            {
                PWCErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {
                PWCErrorLbl.Text = "";
            }

            if (PasswordTxt.Text != PasswordConfirmTxt.Text)
            {
                PWErrorLbl.Text  = "* Passwords Must Match";
                PWCErrorLbl.Text = "* Passwords Must Match";
                return;
            }
            else
            {
                PWErrorLbl.Text  = "";
                PWCErrorLbl.Text = "";
            }
            // End Form Validation

            // Writes user-entered information into the AutoMart database using the AutoMartEntities ADO.Net Data Entities Component then redirects to Default3.aspx
            AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

            AutomartModel.Person p = new AutomartModel.Person();
            p.FirstName = FirstNameTxt.Text;
            p.LastName  = LastNameTxt.Text;
            ame.People.AddObject(p);

            AutomartModel.RegisteredCustomer rc = new AutomartModel.RegisteredCustomer();
            rc.Email            = EmailTxt.Text;
            rc.CustomerPassword = PasswordTxt.Text;
            ame.RegisteredCustomers.AddObject(rc);

            AutomartModel.vehicle v = new AutomartModel.vehicle();
            v.LicenseNumber = LicenseTxt.Text;
            v.VehicleMake   = MakeTxt.Text;
            v.VehicleYear   = YearTxt.Text;
            ame.vehicles.AddObject(v);

            ame.SaveChanges();

            Response.Redirect("Default3.aspx");
        }

        catch
        {
            ErrorLbl.Text = "Registration failed. Please check your entries and try again.";
        }
    }
Пример #6
0
    protected void SubmitBtn_Click(object sender, EventArgs e)
    {
        // Form Validation - Checks for blank required fields and password matching using C# code
            if (LastNameTxt.Text == "")
            {
                LNErrorLbl.Text = "* Required Field";
                return;
            }
            else { LNErrorLbl.Text = ""; }

            if (EmailTxt.Text == "")
            {
                EMErrorLbl.Text = "* Required Field";
                return;
            }
            else { EMErrorLbl.Text = ""; }

            if (LicenseTxt.Text == "")
            {
                LPErrorLbl.Text = "* Required Field";
                return;
            }
            else { LPErrorLbl.Text = ""; }

            if (PasswordTxt.Text == "")
            {
                PWErrorLbl.Text = "* Required Field";
                return;
            }
            else { PWErrorLbl.Text = ""; }

            if (PasswordConfirmTxt.Text == "")
            {
                PWCErrorLbl.Text = "* Required Field";
                return;
            }
            else { PWCErrorLbl.Text = ""; }

            if (PasswordTxt.Text != PasswordConfirmTxt.Text)
            {
                PWErrorLbl.Text = "* Passwords Must Match";
                PWCErrorLbl.Text = "* Passwords Must Match";
                return;
            }
            else
            {
                PWErrorLbl.Text = "";
                PWCErrorLbl.Text = "";
            }
            // End Form Validation

            // This code uses the ADO.Net Data Entities to collect user-entered registration information and enter it into the Automart database, then redirect the user to a thank you page

            try
            {
                AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

                AutomartModel.Person p = new AutomartModel.Person();
                p.FirstName = FirstNameTxt.Text;
                p.LastName = LastNameTxt.Text;
                ame.People.AddObject(p);

                AutomartModel.RegisteredCustomer rc = new AutomartModel.RegisteredCustomer();
                rc.Email = EmailTxt.Text;
                rc.CustomerPassword = PasswordTxt.Text;
                ame.RegisteredCustomers.AddObject(rc);

                AutomartModel.vehicle v = new AutomartModel.vehicle();
                v.LicenseNumber = LicenseTxt.Text;
                v.VehicleMake = MakeTxt.Text;
                v.VehicleYear = YearTxt.Text;
                ame.vehicles.AddObject(v);

                ame.SaveChanges();

                Response.Redirect("Default4.aspx", false);
            }
            catch (Exception ex)
            {
                Session["error"] = ex.Message;
                Response.Redirect("Default6.aspx");
            }
    }
Пример #7
0
    protected void SubmitBtn_Click(object sender, EventArgs e)
    {
        try
        {
            // Form Validation - Checks for blank required fields and password matching
            if (FirstNameTxt.Text == "")
            {
                FNErrorLbl.Text = "* Required Field";
                return;
            }
            else
            {FNErrorLbl.Text = "";}

            if (LastNameTxt.Text == "")
            {
                LNErrorLbl.Text = "* Required Field";
                return;
            }
            else {LNErrorLbl.Text = "";}

            if (EmailTxt.Text == "")
            {
                EMErrorLbl.Text = "* Required Field";
                return;
            }
            else {EMErrorLbl.Text = "";}

            if (LicenseTxt.Text == "")
            {
                LPErrorLbl.Text = "* Required Field";
                return;
            }
            else { LPErrorLbl.Text = ""; }

            if (PasswordTxt.Text == "")
            {
                PWErrorLbl.Text = "* Required Field";
                return;
            }
            else { PWErrorLbl.Text = ""; }

            if (PasswordConfirmTxt.Text == "")
            {
                PWCErrorLbl.Text = "* Required Field";
                return;
            }
            else { PWCErrorLbl.Text = ""; }

            if (PasswordTxt.Text != PasswordConfirmTxt.Text)
            {
                PWErrorLbl.Text = "* Passwords Must Match";
                PWCErrorLbl.Text = "* Passwords Must Match";
                return;
            }
            else
            {
                PWErrorLbl.Text = "";
                PWCErrorLbl.Text = "";
            }
            // End Form Validation

            // Writes user-entered information into the AutoMart database using the AutoMartEntities ADO.Net Data Entities Component then redirects to Default3.aspx
            AutomartModel.AutomartEntities ame = new AutomartModel.AutomartEntities();

            AutomartModel.Person p = new AutomartModel.Person();
            p.FirstName = FirstNameTxt.Text;
            p.LastName = LastNameTxt.Text;
            ame.People.AddObject(p);

            AutomartModel.RegisteredCustomer rc = new AutomartModel.RegisteredCustomer();
            rc.Email = EmailTxt.Text;
            rc.CustomerPassword = PasswordTxt.Text;
            ame.RegisteredCustomers.AddObject(rc);

            AutomartModel.vehicle v = new AutomartModel.vehicle();
            v.LicenseNumber = LicenseTxt.Text;
            v.VehicleMake = MakeTxt.Text;
            v.VehicleYear = YearTxt.Text;
            ame.vehicles.AddObject(v);

            ame.SaveChanges();

            Response.Redirect("Default3.aspx");
        }

        catch
        {
            ErrorLbl.Text = "Registration failed. Please check your entries and try again.";
        }
    }