public PersonalDataEditor()
 {
     InitializeComponent();
     Data = new PersonalData();
     LoadExisting();
     LoadConfiguration();
 }
        public static void SavePerson(PersonalData personalData, string language)
        {
            string name = personalData.Name;
            string dir  = LocalFolder + "/" + language + "/" + name;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            List <string> data = new List <string>();

            data.Add("Jméno=" + name);
            data.Add("Věk=" + personalData.Age);
            data.Add("Pohlaví=" + personalData.Sex);
            data.Add("Status=" + personalData.Job);

            if (personalData.Photo != null)
            {
                try
                {
                    personalData.Photo.Save(dir + "/photo.jpg");
                }
                catch { }
            }

            File.WriteAllLines(dir + "/data.txt", data.ToArray());
            File.WriteAllText(dir + "/info.txt", personalData.PersonalInfo);
        }
        public void LoadPerson(PersonalData person)
        {
            Data         = person;
            NameBox.Text = person.Name;
            AgeBox.Value = person.Age;

            switch (SexBox.SelectedText.ToLower())
            {
            case "male":
                SexBox.SelectedItem = 0;
                break;

            case "female":
                SexBox.SelectedItem = 1;
                break;
            }

            JobBox.Text  = person.Job;
            InfoBox.Text = person.PersonalInfo;

            if (person.Photo != null)
            {
                PersonPhoto.Image = person.Photo;
            }
        }
 private void JobBox_TextChanged(object sender, EventArgs e)
 {
     if (Data == null)
     {
         Data = new PersonalData();
     }
     Data.Job = JobBox.Text;
 }
 private void AgeBox_ValueChanged(object sender, EventArgs e)
 {
     if (Data == null)
     {
         Data = new PersonalData();
     }
     Data.Age = (int)AgeBox.Value;
 }
 private void SexBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (Data == null)
     {
         Data = new PersonalData();
     }
     Data.Sex = SexBox.Text;
 }
        public static PersonalData LoadPerson(string folderPath)
        {
            PersonalData person = null;

            if (Directory.Exists(folderPath))
            {
                string name = folderPath.Replace(LocalFolder, "");
                if (File.Exists(folderPath + "/data.txt"))
                {
                    person = new PersonalData();

                    List <string> data = File.ReadAllLines(folderPath + "/data.txt").ToList();

                    foreach (string line in data)
                    {
                        if (line.StartsWith("Jméno="))
                        {
                            person.Name = line.Replace("Jméno=", "");
                        }

                        if (line.StartsWith("Věk="))
                        {
                            person.Age = int.Parse(line.Replace("Věk=", ""));
                        }

                        if (line.StartsWith("Status="))
                        {
                            person.Job = line.Replace("Status=", "");
                        }

                        if (line.StartsWith("Pohlaví="))
                        {
                            person.Sex = line.Replace("Pohlaví=", "");
                        }
                    }

                    if (File.Exists(folderPath + "/info.txt"))
                    {
                        person.PersonalInfo = File.ReadAllText(folderPath + "/info.txt");
                    }

                    if (File.Exists(folderPath + "/photo.jpg"))
                    {
                        person.Photo = Image.FromFile(folderPath + "/photo.jpg");
                    }
                }
            }

            return(person);
        }
Beispiel #8
0
        public void AddPerson(PersonalData personData)
        {
            if (personData == null)
            {
                return;
            }

            if (Database == null)
            {
                Database = new Dictionary <string, PersonalData>();
            }

            if (Database.ContainsKey(personData.Name))
            {
                return;
            }
            Database.Add(personData.Name, personData);
        }
Beispiel #9
0
 public void LoadPerson(PersonalData personData)
 {
     Data    = personData;
     Visible = true;
     UpdateControls();
 }
 private void NewBtn_Click(object sender, EventArgs e)
 {
     Data = new PersonalData();
 }
Beispiel #11
0
 public void ShowMatchedPerson(PersonalData personalData)
 {
     PersonList.Rows.Add(personalData.Name, personalData.Age, personalData.Sex, personalData.Job);
 }
Beispiel #12
0
 public void LoadPerson(PersonalData personData)
 {
     PersonBox.LoadPerson(personData);
 }