private async void DetailsBtn_Click(object sender, RoutedEventArgs e) { try { DeleteBtn.IsEnabled = false; DetailsBtn.IsEnabled = false; ExitBtn.IsEnabled = false; object admission = AdmissionsListBox.SelectedItem; int? id = ((Admission)admission)?.Id; if (!id.HasValue) { throw new ArgumentException($"{nameof(id)} is incorrect"); } DetalilsAdmissionForm form = await DetalilsAdmissionForm.CreateAsyncDetailsAdmissionForm(((Admission)admission)); form.ShowDialog(); admissions.Remove((Admission)admission); var adm = (Admission)admission; adm.DischargeDate = SingletoneObj.DischargeDate; admissions.Add(adm); } catch (Exception ex) { StatusLabel.Content = "Status: " + ex.Message; } finally { DeleteBtn.IsEnabled = true; DetailsBtn.IsEnabled = true; ExitBtn.IsEnabled = true; } }
public static async Task <DetalilsAdmissionForm> CreateAsyncDetailsAdmissionForm(Admission admission) { DetalilsAdmissionForm form = new DetalilsAdmissionForm(); await form.InitializeAsync(admission); selectedAdmission = admission; return(form); }