//Mark task as done private void DoneButton_Click(object sender, RoutedEventArgs e) { try { List <int> selectedID = new List <int>(); if (ToDoList.ItemsSource == thingsToDos) { foreach (object record in ToDoList.SelectedItems) { selectedID.Add(Convert.ToInt16(thingsToDos[ToDoList.Items.IndexOf(record)].ID)); } } else if (ToDoList.ItemsSource == daylyToDos) { foreach (object record in ToDoList.SelectedItems) { selectedID.Add(Convert.ToInt16(daylyToDos[ToDoList.Items.IndexOf(record)].ID)); } } if (selectedID.Count() != 0) { foreach (int i in selectedID) { DataAccessToDo changeStatus = new DataAccessToDo(); changeStatus.MarkAsDone(i.ToString()); } } MessageBox.Show("Status Changed!"); selectedID = null; InitializeStartList(); } catch { MessageBox.Show("Cant connect to DB"); } finally { InitializeStartList(); } }
/* * //Check in DB records for actual month * private void CheckRecordsForMounth() * { * string year = ClndOfStuff.DisplayDate.ToString("yyyy"); * string month = ClndOfStuff.DisplayDate.ToString("MM"); * * DataAccessToDo accessToDo = new DataAccessToDo(); * thingsToDos = accessToDo.GetToDosMonth(year, month); * ToDoList.ItemsSource = thingsToDos; * } */ //Actual task list after initialize page private void InitializeStartList() { string year = ClndOfStuff.DisplayDate.ToString("yyyy"); string month = ClndOfStuff.DisplayDate.ToString("MM"); DataAccessToDo accessToDo = new DataAccessToDo(); thingsToDos = accessToDo.GetToDosMonth(year, month); if (ToDoList.ItemsSource == daylyToDos) { LoadTasksDayly(selectedDay); } else { ToDoList.ItemsSource = thingsToDos; } HighliteDatesOnCalendar(); }