Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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.");
            }
        }
Ejemplo n.º 3
0
        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.");
            }
        }
Ejemplo n.º 4
0
        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.");
            }
        }