private void cancelButton_Click(object sender, EventArgs e) { Form info = new PersonalInformationForm(people, person); this.Hide(); info.ShowDialog(); //this.Close(); }
private void viewButton_Click(object sender, EventArgs e) { if (relationshipListBox.SelectedIndex != -1) { PersonalInformationForm view = new PersonalInformationForm(people, ((PersonRelationship)relationshipListBox.SelectedItem).person); view.ShowDialog(); this.Close(); } }
public void viewDetails(Person p) { PersonalInformationForm details = new PersonalInformationForm(people, p); this.Hide(); details.ShowDialog(); //this.Close(); }
private void infoButton_Click(object sender, EventArgs e) { if (personListBox.SelectedIndex != -1) { Form f1 = new PersonalInformationForm(people, (Person)personListBox.SelectedItem); this.Hide(); f1.Show(); } }
private void saveButton_Click(object sender, EventArgs e) { //validate that birth is not in the future if (DateTime.Compare(birthCalendar.Value, DateTime.Today) > 0) { MessageBox.Show("The birth date cannot be a future date.", "Date Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //validate that death is not in the future if (DateTime.Compare(deathCalendar.Value, DateTime.Today) > 0) { MessageBox.Show("The death date cannot be a future date.", "Date Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //validate birth date versus death date if (DateTime.Compare(birthCalendar.Value, deathCalendar.Value) > 0) { MessageBox.Show("The birth date must be earlier than or the same as the death date.", "Date Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //validate death date versus burial date if (DateTime.Compare(deathCalendar.Value, burialCalendar.Value) > 0) { MessageBox.Show("The death date must be earlier than or the same as the burial date.", "Date Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //validate that first name is present if (firstNameTextBox.Text.Equals("") || firstNameTextBox.Text.Trim().Equals("")) { firstNameTextBox.Text = ""; MessageBox.Show("The first name is a required field.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //validate that last name is present if (lastNameTextBox.Text.Equals("") || lastNameTextBox.Text.Trim().Equals("")) { lastNameTextBox.Text = ""; MessageBox.Show("The last name is a required field.", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (person == null) { person = new Person(); people.Add(person); } person.profilePicturePath = filePath; //name box fields person.firstName = firstNameTextBox.Text; person.middleName = middleNameTextBox.Text; person.lastName = lastNameTextBox.Text; //birth box fields person.birthKnown = birthKnownCheckBox.Checked; person.birthDate = birthCalendar.Value; person.birthPlace = birthPlaceTextBox.Text; person.birthCertificateNumber = birthCertificateTextBox.Text; //sex string sex = ""; bool isChecked = maleRadioButton.Checked; if (isChecked) { sex = maleRadioButton.Text; } else { isChecked = femaleRadioButton.Checked; if (isChecked) { sex = femaleRadioButton.Text; } else { sex = "Unknown"; } } person.sex = sex; //death group fields if (deadCheckBox.Checked) { person.dead = true; person.deathKnown = deathKnownCheckBox.Checked; person.deathDate = deathCalendar.Value; person.deathPlace = deathPlaceTextBox.Text; person.deathCertificateNumber = deathCertificateTextBox.Text; person.causeOfDeath = causeOfDeathTextBox.Text; } else { person.dead = false; person.buried = false; person.deathDate = DateTime.MinValue; person.deathPlace = ""; person.deathCertificateNumber = ""; person.causeOfDeath = ""; person.burialDate = DateTime.MinValue; person.burialPlace = ""; person.cemetery = ""; } //burial group fields if (buriedCheckBox.Checked) { person.buried = true; person.burialKnown = burialKnownCheckBox.Checked; person.burialDate = burialCalendar.Value; person.burialPlace = burialPlaceTextBox.Text; person.cemetery = cemetaryTextBox.Text; } else { person.buried = false; person.burialDate = DateTime.MinValue; person.burialPlace = ""; person.cemetery = ""; } //additional information fields person.socialSecurityNumber = ssnTextBox.Text; //military service person.militaryService = militaryListBox.Items.Cast <string>().ToList(); //profession person.profession = professionListBox.Items.Cast <string>().ToList(); //notes person.notes = noteListBox.Items.Cast <string>().ToList(); //questions person.questions = questionListBox.Items.Cast <string>().ToList(); foreach (string s in Directory.GetFiles(@"../../PersonFiles/")) { File.Delete(s); } if (!people.Contains(person)) { people.Add(person); } //save to file foreach (Person p in people) { FileStream fs = File.Create(@"../../PersonFiles/" + p.firstName + p.lastName + ".gt"); StreamWriter sw = new StreamWriter(fs); sw.Write(p.id + "\n"); sw.Write(p.firstName + "\n"); sw.Write(p.middleName + "\n"); sw.Write(p.lastName + "\n"); sw.Write(p.sex + "\n"); //try //{ // File.Copy(p.profilePicturePath, @"../../Images/" + p.firstName + p.lastName + ".png", true); // sw.Write(@"../../Images/" + p.firstName + p.lastName + "ProfilePicture" + "\n"); //} //catch (Exception ex) //empty file yada yada yada //{ // sw.Write(p.profilePicturePath + "\n"); //} sw.Write(p.profilePicturePath + "\n"); sw.Write(p.birthPlace + "\n"); sw.Write(p.deathPlace + "\n"); sw.Write(p.burialPlace + "\n"); sw.Write(p.cemetery + "\n"); sw.Write(p.socialSecurityNumber + "\n"); sw.Write(p.causeOfDeath + "\n"); sw.Write(p.birthCertificateNumber + "\n"); sw.Write(p.deathCertificateNumber + "\n"); sw.Write(p.birthKnown + "\n"); sw.Write(p.deathKnown + "\n"); sw.Write(p.burialKnown + "\n"); sw.Write(p.birthDate + "\n"); sw.Write(p.deathDate + "\n"); sw.Write(p.burialDate + "\n"); sw.Write(p.dead + "\n"); sw.Write(p.buried + "\n"); foreach (string s in p.militaryService) { sw.Write(s); } sw.Write("\n"); foreach (string s in p.profession) { sw.Write(s); } sw.Write("\n"); foreach (string s in p.notes) { sw.Write(s); } sw.Write("\n"); foreach (string s in p.questions) { sw.Write(s); } sw.Write("\n"); foreach (Relationship r in p.relationships) { sw.Write(r.type + "," + r.id + ","); } sw.Write("\n"); sw.Close(); fs.Close(); } Form newPerson = new PersonalInformationForm(people, person); this.Hide(); newPerson.ShowDialog(); //this.Close(); }