Ejemplo n.º 1
0
        private void Button26_Click(object sender, EventArgs e)
        {
            Land landToQuery =
                SelectObjectForm.selectObject("Wähle Land", Data.Laender.ToList()) as Land;

            if (landToQuery == null)
            {
                return;
            }

            Console.WriteLine("List People living in country " + landToQuery.Name);
            var personen =
                (
                    from stadt in landToQuery.Staedte
                    from einw in stadt.Einwohner
                    orderby einw.Familienname
                    select einw
                )
                .Distinct();

            foreach (Person person in personen)
            {
                Console.WriteLine(person.getFullname());
            }
        }
Ejemplo n.º 2
0
        private void Button23_Click(object sender, EventArgs e)
        {
            Fluss flussToDelete =
                SelectObjectForm.selectObject("Lösche Fluss", Data.Fluesse) as Fluss;

            if (flussToDelete == null)
            {
                return;
            }

            Data.Fluesse.Remove(flussToDelete);
            Data.SaveChanges();
        }
Ejemplo n.º 3
0
        private void Button15_Click(object sender, EventArgs e)
        {
            Stadt stadtToDelete =
                SelectObjectForm.selectObject("Lösche Stadt", Data.Staedte) as Stadt;

            if (stadtToDelete == null)
            {
                return;
            }

            Data.Staedte.Remove(stadtToDelete);
            Data.SaveChanges();
        }
Ejemplo n.º 4
0
        private void Button19_Click(object sender, EventArgs e)
        {
            Land landToDelete =
                SelectObjectForm.selectObject("Lösche Land", Data.Laender) as Land;

            if (landToDelete == null)
            {
                return;
            }

            Data.Laender.Remove(landToDelete);
            Data.SaveChanges();
        }
Ejemplo n.º 5
0
        private void Button11_Click(object sender, EventArgs e)
        {
            Person personToDelete =
                SelectObjectForm.selectObject("Lösche Person", Data.People) as Person;

            if (personToDelete == null)
            {
                return;
            }

            Data.People.Remove(personToDelete);
            Data.SaveChanges();
        }
Ejemplo n.º 6
0
        public static IEnumerable <object> selectObjects
            (string caption,
            IEnumerable <object> elementList)
        {
            SelectObjectForm form = new SelectObjectForm();

            form.Text        = caption;
            form.Elements    = elementList;
            form.MultiSelect = true;
            DialogResult res = form.ShowDialog();

            if (res != DialogResult.OK)
            {
                return(null);
            }
            return(form.Elements);
        }
Ejemplo n.º 7
0
        public static object selectObject
            (string caption,
            IEnumerable <object> elementList)
        {
            SelectObjectForm form = new SelectObjectForm();

            form.Text        = caption;
            form.Elements    = elementList;
            form.MultiSelect = false;
            DialogResult res = form.ShowDialog();

            if (res != DialogResult.OK)
            {
                return(null);
            }
            return(form.Elements.FirstOrDefault());
        }
Ejemplo n.º 8
0
 private void Button22_Click(object sender, EventArgs e)
 {
     try
     {
         Fluss flussToUpdate =
             SelectObjectForm.selectObject("Ändere Fluß", Data.Laender) as Fluss;
         if (flussToUpdate == null)
         {
             return;
         }
         FlussForm.updateFluss(Data, flussToUpdate);
         Data.SaveChanges();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Ejemplo n.º 9
0
 private void Button18_Click(object sender, EventArgs e)
 {
     try
     {
         Land landToUpdate =
             SelectObjectForm.selectObject("Ändere Land", Data.Laender) as Land;
         if (landToUpdate == null)
         {
             return;
         }
         LandForm.updateLand(Data, landToUpdate);
         Data.SaveChanges();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Ejemplo n.º 10
0
 private void Button14_Click(object sender, EventArgs e)
 {
     try
     {
         Stadt stadtToUpdate =
             SelectObjectForm.selectObject("Ändere Person", Data.Staedte) as Stadt;
         if (stadtToUpdate == null)
         {
             return;
         }
         StadtForm.updateStadt(Data, stadtToUpdate);
         Data.SaveChanges();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Ejemplo n.º 11
0
 private void Button10_Click(object sender, EventArgs e)
 {
     try
     {
         Person personToUpdate =
             SelectObjectForm.selectObject("Ändere Person", Data.People) as Person;
         if (personToUpdate == null)
         {
             return;
         }
         PersonForm.updatePerson(Data, personToUpdate);
         Data.SaveChanges();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Ejemplo n.º 12
0
        private void Button28_Click(object sender, EventArgs e)
        {
            Land landToQuery =
                SelectObjectForm.selectObject("Land wählen ...", Data.Laender.ToList()) as Land;

            if (landToQuery == null)
            {
                return;
            }

            var staedteToExclude =
                SelectObjectForm.selectObjects("Städte wählen",
                                               landToQuery.Staedte.ToList()
                                               ).Select(o => o as Stadt).Where(p => p != null).ToList();

            Console.WriteLine("Auszuschließende Städte");
            staedteToExclude.ToList().ForEach(Console.WriteLine);

            var otherStaedte =
                (from stadt in landToQuery.Staedte
                 where !staedteToExclude.Any(s => s == stadt)
                 select stadt
                ).ToArray();


            Console.WriteLine("Restliche Städte");
            otherStaedte.ToList().ForEach(Console.WriteLine);

            var persons =
                (
                    from stadt in otherStaedte
                    from einw in stadt.Einwohner
                    orderby einw.Familienname
                    select einw)
                .Distinct();

            Console.WriteLine("Bewohner der restlichen Städte");
            persons.ToList().ForEach(Console.WriteLine);
        }
Ejemplo n.º 13
0
        private void Button27_Click(object sender, EventArgs e)
        {
            Fluss flussToQuery =
                SelectObjectForm.selectObject("Wähle Fluß", Data.Fluesse) as Fluss;

            if (flussToQuery == null)
            {
                return;
            }

            var staedte =
                from stadt in flussToQuery.Durchfließt
                select stadt;

            foreach (var stadt in staedte)
            {
                Console.WriteLine(stadt.getDescription());
            }

            Console.WriteLine("List People living next to first river");


            var personen =
                (
                    from person in Data.People
                    where person.WohntIn.Any(
                        wi => wi.LiegtAn.Any(
                            la => la == Data.Fluesse.FirstOrDefault()))
                    orderby person.Familienname ascending
                    select person
                )
                .Distinct();


            foreach (var person in personen)
            {
                Console.WriteLine(person.getFullname());
            }
        }