private void Edit_Click(object sender, RoutedEventArgs e) { //edit the event Event evnt = new Event(); evnt.EventID = evntToEdit.EventID; evnt.EventName = TextBoxEventName.Text.ToString(); evnt.EventPlace = TextBoxPlace.Text.ToString(); try { evnt.DateFrom = new DateTime(int.Parse(TextBoxFromYear.Text.ToString()), int.Parse(TextBoxFromMonth.Text.ToString()), int.Parse(TextBoxFromDay.Text.ToString()), int.Parse(TextBoxFromHour.Text.ToString()), int.Parse(TextBoxFromMinute.Text.ToString()), 0); evnt.DateTo = new DateTime(int.Parse(TextBoxToYear.Text.ToString()), int.Parse(TextBoxToMonth.Text.ToString()), int.Parse(TextBoxToDay.Text.ToString()), int.Parse(TextBoxToHour.Text.ToString()), int.Parse(TextBoxToMinute.Text.ToString()), 0); DatabaseClass databaseClass = new DatabaseClass(); if (databaseClass.EditEvent(evnt)) { MessageBox.Show("Event edited successfully!"); } NavigationService.Navigate(new Uri("/PivotPage1.xaml", UriKind.Relative)); //when navigating to PivotPage1, the UI will // be automaticlally updated } catch (Exception exc) { MessageBox.Show("Error in DateTime format!" + exc.ToString()); } }