private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            model1 = new Model1Container();
            person = model1.Persons.First(o => o.Id == Person_Id);

            LoadPerson(person);
            LoadMaterials(person);
        }
Пример #2
0
 public void AddChild(Person child)
 {
     this.children.Add(child);
 }
Пример #3
0
 public void AddParent(Person parent)
 {
     this.parents.Add(parent);
 }
Пример #4
0
 public static void AddMember(Person person)
 {
     FamilyMembers.Add(person);
 }
Пример #5
0
        public static void GetRelationship(String Name, String relationType)
        {
            Person person = FamilyMembers.Find(r => r.Name == Name);

            if (person == null)
            {
                Console.WriteLine("PERSON_NOT_FOUND");
                return;
            }

            switch (relationType)
            {
            case "Siblings":
            case "Sibling":
            {
                List <String> siblings = person.Sibling(null);
                if (siblings == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s siblings are - ");
                    foreach (String name in siblings)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Maternal-Aunt":
            {
                List <String> aunts = person.MaternalAunt();
                if (aunts == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Maternal-aunts are - ");
                    foreach (String name in aunts)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Paternal-Uncle":
            {
                List <String> uncles = person.PaternalUncle();
                if (uncles == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Paternal-Uncle are - ");
                    foreach (String name in uncles)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Maternal-Uncle":
            {
                List <String> uncles = person.MaternalUncle();
                if (uncles == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Maternal-Uncle are - ");
                    foreach (String name in uncles)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Paternal-Aunt":
            {
                List <String> aunts = person.PaternalAunt();
                if (aunts == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Paternal-Aunts are - ");
                    foreach (String name in aunts)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Sister-In-Law":
            {
                Person        spouse = person.Spouse();
                List <String> sil    = new List <String>();
                if (spouse != null)
                {
                    sil = spouse.Sibling("Female");
                }


                List <String> brothers = person.Sibling("Male");
                foreach (String brother in brothers)
                {
                    Person bro  = FamilyMembers.Find(r => r.Name == brother);
                    Person wife = bro.Spouse();
                    sil.Add(wife.Name);
                }


                Console.WriteLine(person.Name + "'s Sister-in-laws are - ");
                foreach (String name in sil)
                {
                    Console.WriteLine(name);
                }

                break;
            }

            case "Brother-In-Law":
            {
                Person        spouse = person.Spouse();
                List <String> bil    = new List <String>();
                if (spouse != null)
                {
                    bil = spouse.Sibling("Male");
                }

                List <String> sisters = person.Sibling("Female");
                foreach (String sister in sisters)
                {
                    Person sis     = FamilyMembers.Find(r => r.Name == sister);
                    Person husband = sis.Spouse();
                    bil.Add(husband.Name);
                }


                Console.WriteLine(person.Name + "'s Brother-in-laws are - ");
                foreach (String name in bil)
                {
                    Console.WriteLine(name);
                }

                break;
            }

            case "Son":
            {
                List <String> sons = person.Children("Male");
                if (sons == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Sons are - ");
                    foreach (String name in sons)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Daughter":
            {
                List <String> daughters = person.Children("Female");
                if (daughters == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Daughters are - ");
                    foreach (String name in daughters)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }
            }

            //Console.ReadLine();
        }
Пример #6
0
 /// <summary>
 /// Создание нового объекта Person.
 /// </summary>
 /// <param name="id">Исходное значение свойства Id.</param>
 public static Person CreatePerson(global::System.Int32 id)
 {
     Person person = new Person();
     person.Id = id;
     return person;
 }
Пример #7
0
 /// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet Persons. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddToPersons(Person person)
 {
     base.AddObject("Persons", person);
 }
        private void LoadMaterials(Person p)
        {
            materialsDataGrid.ItemsSource = p.Materials.Select(o => new { Id = o.Id, Название = o.Name, Описание = o.Description, Data = o.Data, }).ToList();

            string path = Environment.CurrentDirectory + "\\tmp_materials";
            Directory.CreateDirectory(path);
            DirectoryInfo dinfo = new DirectoryInfo(path);
            dinfo.Attributes = FileAttributes.Directory | FileAttributes.Hidden | FileAttributes.System;
            dinfo.Create();
        }
        private void LoadPerson(Person p)
        {
            genderComboBox.Items.Add("?");
            genderComboBox.Items.Add("Мужской");
            genderComboBox.Items.Add("Женский");

            surnameTextBox.Text = p.Surname;
            nameTextBox.Text = p.Name;
            patronymicTextBox.Text = p.Patronymic;
            birthDateTextBox.Text = p.BirthDate;
            placeOfBirthTextBox.Text = p.PlaceOfBirth;
            deathDateTextBox.Text = p.DeathDate;
            causeOfDeathTextBox.Text = p.CauseOfDeath;
            placeOfDeathTextBox.Text = p.PlaceOfDeath;
            nationalityTextBox.Text = p.Nationality;
            physiqueTextBox.Text = p.Physique;
            mentalHealthTextBox.Text = p.MentalHealth;
            religionTextBox.Text = p.Religion;
            politicalViewsTextBox.Text = p.PoliticalViews;
            educationTextBox.Text = p.Education;
            rankTextBox.Text = p.Rank;
            rewardsTextBox.Text = p.Rewards;
            financialPositionTextBox.Text = p.FinancialPosition;
            genderComboBox.SelectedIndex = Convert.ToInt32(p.Gender);

            if (model1.Persons.First(o => o.Id == p.Id).Materials.Where(o => o.MaterialType_Id == 1).Count() > 0)
            {
                Material photo = p.Materials.First(o => o.MaterialType_Id == 1);
                MemoryStream byteStream = new MemoryStream(photo.Data);
                BitmapImage image = new BitmapImage();
                image.BeginInit();
                image.StreamSource = byteStream;
                image.EndInit();
                image1.Source = image;
                image1.Tag = "db";
            }
            else
            {
                Image _image = new Image();
                string packUri = "";
                
                switch (genderComboBox.SelectedIndex)
                {
                    case 0:
                        packUri = "pack://application:,,,/FamilyTree;component/Images/unknown.png";
                        break;
                    case 1:
                        packUri = "pack://application:,,,/FamilyTree;component/Images/man.png";
                        break;
                    case 2:
                        packUri = "pack://application:,,,/FamilyTree;component/Images/woman.png";
                        break;
                }
                _image.Source = new ImageSourceConverter().ConvertFromString(packUri) as ImageSource;
                image1.Source = _image.Source;
            }
        }
Пример #10
0
 private void addPersonButton_Click(object sender, RoutedEventArgs e)
 {
     EditPersonWindow editPersonWindow1 = new EditPersonWindow();
     Person p = new Person();
     //editPersonWindow1.
     model1.Persons.AddObject(p);
     //model1.Projects.First().Persons.Add(p);
 }