Exemplo n.º 1
0
        /// <summary>
        /// Method deletes selected patient and update patient's list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuPatientDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Czy napewno chcesz usunąć wszystkie dane pacjenta, " + client.FirstName + " " + client.LastName + " ?", "Potwierdzenie", MessageBoxButton.YesNo, MessageBoxImage.Information);

            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    client.Delete();
                    mainWindow.ClientList.Remove(client);
                    mainWindow.MyDataGridFind.Items.Refresh();

                    List <AppointmentModel> aList = mainWindow.AppointmentList.FindAll(a => a.ClientID == client.ID);
                    foreach (AppointmentModel a in aList)
                    {
                        mainWindow.AppointmentList.Remove(a);
                    }
                    mainWindow.MyDataGridApp.Items.Refresh();

                    if (mainWindow.ClientList.Count == 0)
                    {
                        mainWindow.clearFindForm();
                        mainWindow.enableFindForm(true);
                    }
                    client = null;
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Błąd!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }