Exemplo n.º 1
0
        private void AddEmergencyContact_Click(object sender, EventArgs e)
        {
            EmergencyContactAdd ad = new EmergencyContactAdd(_student);

            ad.ShowDialog();
            if (ad.DialogResult == DialogResult.OK)
            {
                DataBase db = new EmergencyContactData();
                _student.EmergencyContacts = db.GetList(_student.PersonId).ConvertAll(x => x as EmergencyContact);
                PopulateEmergencyContacts();
            }
        }
Exemplo n.º 2
0
        private void RemoveEmergencyContact_Click(object sender, EventArgs e)
        {
            int rowindex = dgEmergencyContacts.CurrentCell.RowIndex;
            int studentEmergencyContactId = (int)dgEmergencyContacts.Rows[rowindex].Cells[0].Value;
            EmergencyContact ec           = _student.EmergencyContacts.Find(x => x.StudentEmergencyContactId == studentEmergencyContactId);

            if (ec != null)
            {
                if (MessageBox.Show("Are you sure you want to remove emergency contact '" + ec.FullName + "' from this student?", "Remove Emergency Contact", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    DataBase db = new EmergencyContactData();
                    db.Remove(new Person(), studentEmergencyContactId);
                    _student.EmergencyContacts = db.GetList(_student.PersonId).ConvertAll(x => x as EmergencyContact);
                    PopulateEmergencyContacts();
                }
            }
        }