private void btnClick(object sender, RoutedEventArgs e) { if(sender == btnNewPatient) { //open form to register new patient openRegForm(); async void openRegForm() { //contentdialog mustrun on async method PatientRegistrationForm patRegform = new PatientRegistrationForm(); ContentDialogResult result = await patRegform.ShowAsync(); if(result == ContentDialogResult.Primary) { //add to collection addToCollection( patRegform.patCtrl.patientID, patRegform.patCtrl.lname, patRegform.patCtrl.fname, patRegform.patCtrl.mname, patRegform.patCtrl.gender, patRegform.patCtrl.bday, patRegform.patCtrl.contactNum, patRegform.patCtrl.emailAdd, patRegform.patCtrl.userAddress ); } } } else if(sender == btnSearch) { patCtrl.keyword = txtSearchKeyword.Text; DataTable dtSearchRes = patCtrl.patientSearch(patCtrl); if(dtSearchRes.Rows.Count != 0) { patientCollection.Clear(); foreach (DataRow row in dtSearchRes.Rows) { addToCollection( row["PatientID"].ToString(), row["LastName"].ToString(), row["FirstName"].ToString(), row["MiddleName"].ToString(), row["Gender"].ToString(), row["BirthDate"].ToString(), row["ContactNumber"].ToString(), row["EmailAddress"].ToString(), row["Address"].ToString() ); } } else { patientCollection.Clear(); message("No results found!"); } } }
private void btnClick(object sender, RoutedEventArgs e) { if (sender == btnSearch) { //open patient search this.Hide(); searchForm(); async void searchForm() { PatientSearch search = new PatientSearch(); ContentDialogResult result = await search.ShowAsync(); if (result == ContentDialogResult.Primary || result == ContentDialogResult.Secondary) { var datasrc = search.patCtrl; txtName.Text = datasrc.fname + " " + datasrc.lname; appCtrl.patientID = datasrc.patientID; await this.ShowAsync(); } } } else if (sender == btnNewPatient) { this.Hide(); newPatient(); async void newPatient() { PatientRegistrationForm patRegForm = new PatientRegistrationForm(); ContentDialogResult result = await patRegForm.ShowAsync(); if (result == ContentDialogResult.Primary) { var datasrc = patRegForm.patCtrl; txtName.Text = datasrc.fname + " " + datasrc.lname; appCtrl.patientName = datasrc.patientID; await this.ShowAsync(); } } } }