/// <summary> /// Displays the TodoEdit form to edit the selected Todo item selected in the TodoList grid. If the Todo item is modified it will be updated /// in the TodoList data model object and grid, as well as marks to be updated in its underlying data source. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEditTodoItem_Click(object sender, EventArgs e) { try { if (gridTodoList.SelectedRows.Count == 0) { return; } DataGridViewRow rowTodoItem = gridTodoList.SelectedRows[0]; TodoItem item = m_TodoList.GetItem((int)rowTodoItem.Cells["TodoID"].Value); frmTodoEdit TodoEditForm = new frmTodoEdit(frmTodoEdit.TodoEditFormType.EditItem, item); if (TodoEditForm.ShowDialog() == DialogResult.OK) { UpdateTodoGridRow(rowTodoItem, item); m_blTodoListModified = true; }//end if } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in btnEditTodoItem_Click function of frmMain form."); } }
/// <summary> /// Adds a new Todo Item to the Todo List data model object and to the TodoList grid. In addition, the TodoList item will be marked to be added /// to the underlying data source. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNewTodoItem_Click(object sender, EventArgs e) { try { TodoItem item = m_TodoList.NewTodoItem(); frmTodoEdit TodoEditForm = new frmTodoEdit(frmTodoEdit.TodoEditFormType.CreateItem, item); if (TodoEditForm.ShowDialog() == DialogResult.OK) { m_TodoList.AddItem(item); AddTodoGridRow(item); m_blTodoListModified = true; }//end if } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in btnNewTodoItem_Click function of frmMain form."); } }