/// <summary> /// update /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click_1(object sender, EventArgs e) { ToDoItem ItemToUpdate = (ToDoItem)dgToDos.CurrentRow.DataBoundItem; ToDoItemDB.UpdateDescription(ItemToUpdate.ToDoItemID, txtDescrip.Text); RepopulateToDos(); }
/// <summary> /// DELETE deletes a item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click_1(object sender, EventArgs e) { ToDoItem ItemToDelete = (ToDoItem)dgToDos.CurrentRow.DataBoundItem; ToDoItemDB.Delete(ItemToDelete); RepopulateToDos(); }
/// <summary> /// READ loading/repopulating our data grid /// </summary> private void RepopulateToDos() { this.allToDos = ToDoItemDB.GetAllToDoItems(); dgToDos.DataSource = allToDos; /// hides columns that the user does not need to see. this.dgToDos.Columns["CategoryID"].Visible = false; this.dgToDos.Columns["ToDoItemID"].Visible = false; }
/// <summary> /// create /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddToDo_Click_1(object sender, EventArgs e) { ToDoItem NewToDo = new ToDoItem(null, 1, txtDescrip.Text); bool successOrFail = ToDoItemDB.Create(NewToDo); successChecker(successOrFail); RepopulateToDos(); }