/// <summary> /// Create a new Person object. /// </summary> /// <param name="personkey">Initial value of the Personkey property.</param> /// <param name="lastName">Initial value of the LastName property.</param> public static Person CreatePerson(global::System.Int32 personkey, global::System.String lastName) { Person person = new Person(); person.Personkey = personkey; person.LastName = lastName; return person; }
/// <summary> /// Deprecated Method for adding a new object to the People EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPeople(Person person) { base.AddObject("People", person); }
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"); } }
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."; } }
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."; } }