public bool isFound(String firstName, String lastName) { var context = new FabrikamEntities(); var query = from c in context.Students where c.FirstName == firstNameTB.Text && c.LastName == lastNameTB.Text select c; return(query.Any()); }
public void addRow(String firstName, String lastName) { var context = new FabrikamEntities(); if (!String.IsNullOrEmpty(firstNameTB.Text) && !String.IsNullOrEmpty(lastNameTB.Text)) { Student newStud = new Student() { FirstName = firstNameTB.Text, LastName = lastNameTB.Text, Major = majorCB.Text }; context.Students.Add(newStud); context.SaveChanges(); } else { MessageBox.Show("You must enter a first and last name."); } }
public void findRow(String firstName, String lastName) { var context = new FabrikamEntities(); var query = from c in context.Students where c.FirstName == firstNameTB.Text && c.LastName == lastNameTB.Text select c; if (!String.IsNullOrEmpty(firstNameTB.Text) && !String.IsNullOrEmpty(lastNameTB.Text)) { foreach (var Student in query) { majorCB.Text = Student.Major; } } else { MessageBox.Show("You must specify the exact first and last element of the entity you want to find."); } }
public void deleteRow(String firstName, String lastName) { var context = new FabrikamEntities(); var query = from c in context.Students where c.FirstName == firstNameTB.Text && c.LastName == lastNameTB.Text select c; if (!String.IsNullOrEmpty(firstNameTB.Text) && !String.IsNullOrEmpty(lastNameTB.Text)) { foreach (var Student in query) { context.Students.Remove(Student); } context.SaveChanges(); } else { MessageBox.Show("You must specify the exact FirstName and LastName of the entity you'd like to delete."); } }