Example #1
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (ListViewPatient.SelectedItems.Count > 0)
            {
                List <Patient> patientList = new List <Patient>();

                foreach (ListViewItem patient in ListViewPatient.SelectedItems)
                {
                    patientList.Add(new Patient()
                    {
                        FirstName          = patient.SubItems[0].Text,
                        SurName            = patient.SubItems[1].Text,
                        Gender             = patient.SubItems[2].Text,
                        DateOfConsultation = DateTime.Parse(patient.SubItems[3].Text),
                        Diagnosis          = patient.SubItems[4].Text
                    });
                }

                if (_manager.Delete(patientList))
                {
                    MessageBox.Show("Patient/s deleted successfully!");
                    DisplayDataInListView();
                }
                else
                {
                    MessageBox.Show("Patient/s deletion failed!");
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (Program.DeleteConfirm("Do you want delete this patient? The patient's actions also be deleted."))
            {
                PatientManager.Delete(patient); // Veritabanından hasta sil

                MessageBox.Show("Patient successfully deleted!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                Close();
            }
        }
Example #3
0
        public void DeletePatient()
        {
            if (dataGridViewPatients.SelectedRows.Count > 0)
            {
                var ids = new List <int>();

                foreach (DataGridViewRow row in dataGridViewPatients.SelectedRows)
                {
                    ids.Add(Convert.ToInt32(row.Cells[0].Value));
                }

                var messageBoxResult = MessageBox.Show("Are you sure you want to delete?",
                                                       "Confirm Delete.", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (messageBoxResult == DialogResult.Yes)
                {
                    foreach (var id in ids)
                    {
                        var patient          = patientManager.GetById <Patient>(id);
                        var address          = addressManager.GetWithWhereCondition <Address>($"PatientId = {id}").FirstOrDefault();
                        var emergencyContact = emergencyContactManager.GetWithWhereCondition <EmergencyContact>($"PatientId = {id}").FirstOrDefault();
                        var patientArchive   = new PatientArchive();
                        patientArchive.FirstName        = patient.FirstName;
                        patientArchive.LastName         = patient.LastName;
                        patientArchive.Gender           = patient.Gender;
                        patientArchive.BirthDate        = patient.BirthDate;
                        patientArchive.ContactNumber    = patient.ContactNumber;
                        patientArchive.Email            = patient.Email;
                        patientArchive.Occupation       = patient.Occupation;
                        patientArchive.Address          = $"{address.City}, {address.Province}, {address.PostalCode}";
                        patientArchive.EmergencyContact = $"{emergencyContact.FirstName}, {emergencyContact.LastName}, {emergencyContact.ContactNumber}";
                        patientArchiveManager.Add(patientArchive);
                    }

                    if (patientManager.Delete(ids.ToArray()))
                    {
                        MessageBox.Show("Deleted Succesfully");
                        FillDataGridViewPatients();
                        FillDataGridViewPatientArchive();
                    }
                }
            }
        }