// edit patient button click private void buttonEdit_Click(object sender, RoutedEventArgs e) { // check patient was chosen in list if (datagridPatiens.SelectedItems.Count <= 0) { return; } // open add patient window with filled fields AddChangePatient addEditWindow = new AddChangePatient(datagridPatiens.SelectedItem as Patient); addEditWindow.Title = "Edit patient"; // update data grid if patient was changed if (addEditWindow.ShowDialog() == true) { // save position to restore int selectedIndex = datagridPatiens.SelectedIndex; fillDataFromDBtoDatagrid(); // focus on the changed patient from saved position datagridPatiens.SelectedIndex = selectedIndex; // scroll patient list to the changed patient datagridPatiens.ScrollIntoView(datagridPatiens.SelectedItem); // popup notification showNotification("The patient was edited"); } }
// add patient button click private void buttonAdd_Click(object sender, RoutedEventArgs e) { // open add patient window AddChangePatient addEditWindow = new AddChangePatient(); addEditWindow.Title = "Add patient"; // update data grid if patient was added if (addEditWindow.ShowDialog() == true) { fillDataFromDBtoDatagrid(); // focus on the added patient datagridPatiens.SelectedIndex = datagridPatiens.Items.Count - 1; // scroll patient list to the added patient datagridPatiens.ScrollIntoView(datagridPatiens.SelectedItem); // popup notification showNotification("The patient was added"); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { AddChangePatient addChangePatient = new AddChangePatient(); addChangePatient.Show(); }