private void cmbTask_SelectionChanged(object sender, SelectionChangedEventArgs e) { //If the user selects a different task, load the correct information try { cmbTask.Text = cmbTask.SelectedItem.ToString(); //Take selected item from list and return the task object for information Task SelectedTask = ModelView.taskFromName(cmbTask.Text); try { txtTaskName.Text = SelectedTask.TaskName; txtTaskDescription.Text = SelectedTask.TaskDescription; txtTaskLength.Text = SelectedTask.TaskLength.ToString(); } catch (Exception) { //If this is the first time SelectedTask will be null Trace.WriteLine("Error loading selected task"); } } catch (Exception) { Trace.WriteLine("Error loading combo box items for cmbTask"); } }
private void btnSaveTaskChanges_Click(object sender, RoutedEventArgs e) { //If user clicks save, edit task accordingly DatabaseHandler.editTask(txtTaskName.Text, txtTaskDescription.Text, Convert.ToInt32(txtTaskLength.Text), ModelView.taskFromName(cmbTask.Text)); }