private void saveAnnouncement()
 {
     if (txtTitle.Text.Trim() != "")
     {
         if (Announcement.deleteAnnouncement(selectedAnnouncement, false) == 0 && Announcement.addAnnouncementToDatabase(new Announcement(
                                                                                                                             Environment.UserName.Substring(0, 1).ToUpper() + Environment.UserName.Substring(1, Environment.UserName.Length - 1),
                                                                                                                             txtTitle.Text,
                                                                                                                             DateTime.Now.ToShortDateString(),
                                                                                                                             DateTime.Now.ToShortTimeString(),
                                                                                                                             datePicker.Text,
                                                                                                                             txtLocation.Text,
                                                                                                                             txtDescription.Text,
                                                                                                                             cmbSubject.Text), false) == 0)
         {
             MessageBox.Show("Announcement saved successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
             Close();
         }
         else
         {
             MessageBox.Show("Error adding announcement", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         MessageBox.Show("Announcement must have a title.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 2
0
 private void deleteAnnouncement()
 {
     if (dataGridAnnouncements.SelectedItem != null)
     {
         MessageBoxResult msgResult = MessageBox.Show("Are you sure you want to remove this announcement?", "Are You Sure?", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (msgResult == MessageBoxResult.Yes)
         {
             Announcement.deleteAnnouncement((Announcement)dataGridAnnouncements.SelectedItem, true);
             refreshAnnouncements();
         }
     }
     else
     {
         MessageBox.Show("Please select an announcement to remove", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }