Ejemplo n.º 1
0
        private void BtCreateRelaClick1(object sender, EventArgs e)
        {
            var contactToEdit = (Contact) cbContactToAddDetail.SelectedItem;

            if (CheckSaveRelativeButton() && cbContactToAddDetail.SelectedItem != null)
            {
                var relativeToAdd = new Relative
                                        {
                                            FirstName = tbxRelaName.Text,
                                            Surname = tbxRelaSurname.Text,
                                            DateOfBirth = dtpRelDateOfBirth.Value.Date,
                                            Relation =
                                                (Relative.RelativeType)
                                                Enum.Parse(typeof (Relative.RelativeType),
                                                           cbxRelType.SelectedItem.ToString())
                                        };
                var birthDay = new Birthday(relativeToAdd) {DateTimeStart = dtpRelDateOfBirth.Value.Date};
                Controller.AddBirthdayGreetings(birthDay);
                contactToEdit.Relatives.Add(relativeToAdd);
                lbxRelatives.DataSource = null;
                lbxRelatives.DataSource = contactToEdit.Relatives.ToList();
                errorProvider.Clear();
                ClearAddDetails();
            }

            else
                errorProvider.SetError(btCreateRela,
                                       "Must Select or Create Contact" + Environment.NewLine + "and fill in all fields");
            FileManager.SaveContacts();
            FileManager.SaveBirthdays();
        }
Ejemplo n.º 2
0
 internal static void AddBirthdayGreetings(Birthday birthday)
 {
     if (BirthdayGreetings.Where(day => day.WhosBirthday == birthday.WhosBirthday).Count() < 1)
         BirthdayGreetings.Add(birthday);
 }