private void CmdSlet_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("er du sikker på du vil slette denne aftale", "info", MessageBoxButton.OKCancel, MessageBoxImage.Information); if (result == MessageBoxResult.OK) { if (RegistrationsGrid.SelectedIndex != -1) { AppointmentStudent apstud = RegistrationsGrid.SelectedValue as AppointmentStudent; SQLDB.deleteAppointment(apstud.ID); load(); } } }
private void cmdStop_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("er du sikker på du vil Stoppe denne aftale", "info", MessageBoxButton.OKCancel, MessageBoxImage.Information); if (result == MessageBoxResult.OK) { if (RegistrationsGrid.SelectedIndex != -1) { AppointmentStudent apstud = RegistrationsGrid.SelectedValue as AppointmentStudent; SQLDB.updateAppointment(apstud, dpStopDato.SelectedDate); dpStopDato.SelectedDate = null; load(); } } }
public static void updateAppointment(AppointmentStudent apstud, DateTime?date) { SqlConnection cnn = new SqlConnection(conString); cnn.Open(); SqlCommand cmd; String sql = "Update Appointments set ToDate = @date Where ID = @ID"; cmd = new SqlCommand(sql, cnn); cmd.Parameters.AddWithValue("ID", apstud.ID); if (date == null) { cmd.Parameters.AddWithValue("date", Util.getDateTime()); } else { DateTime d = (DateTime)date; cmd.Parameters.AddWithValue("date", new DateTime(d.Year, d.Month, d.Day)); } cmd.ExecuteNonQuery(); cnn.Close(); }