예제 #1
0
        private void deletePatientBtn_Click(object sender, EventArgs e)
        {
            int    selectedRow   = getSelectedRow(dataGridView1);
            long   currPatientID = (long)dataGridView1.Rows[selectedRow].Cells[0].Value;
            string currFirstName = (string)dataGridView1.Rows[selectedRow].Cells[1].Value;
            string currLastName  = (string)dataGridView1.Rows[selectedRow].Cells[2].Value;
            string message       = String.Format("Möchten sie Patient {0} {1} mit der ID {2} wirklich löschen?", currFirstName, currLastName, currPatientID);

            if (MessageBox.Show(message, "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (fachkonzept.DeletePatient(new Patient()
                {
                    PatientID = currPatientID
                }))
                {
                    patients.RemoveAll(x => x.PatientID == currPatientID);
                    patientBindingSource.ResetBindings(false);
                }
                else
                {
                    MessageBox.Show("Patient konnte nicht gelöscht werden.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }