protected void grdAllStaffMembers_RowDeleting(object sender, GridViewDeleteEventArgs e) { Int32 staffMemberId = Convert.ToInt32(((Label)grdAllStaffMembers.Rows[e.RowIndex].FindControl("lblStaffMemberId")).Text); Int32 privilegeLevelId = Convert.ToInt32(((Label)grdAllStaffMembers.Rows[e.RowIndex].FindControl("lblPrivilegeLevelId")).Text); string firstName = ((Label)grdAllStaffMembers.Rows[e.RowIndex].FindControl("lblFirstName")).Text; string lastName = ((Label)grdAllStaffMembers.Rows[e.RowIndex].FindControl("lblLastName")).Text; clsStaffMemberCollection AllStaffMembers = new clsStaffMemberCollection(); AllStaffMembers.ThisStaffMember.StaffMemberId = staffMemberId; AllStaffMembers.ThisStaffMember.FirstName = firstName; AllStaffMembers.ThisStaffMember.LastName = lastName; AllStaffMembers.ThisStaffMember.PrivilegeLevelId = privilegeLevelId; AllStaffMembers.Delete(); LoadStaffMemberData(); }
public void DeleteMethodOk() { clsStaffMemberCollection AllStaffMembers = new clsStaffMemberCollection(); clsStaffMember TestItem = new clsStaffMember(); Int32 primaryKey = 0; TestItem.UserId = 3; TestItem.PrivilegeLevelId = 1; TestItem.FirstName = "Martin"; TestItem.LastName = "Scorsese"; TestItem.Confirmed = true; TestItem.Allowed = true; AllStaffMembers.ThisStaffMember = TestItem; primaryKey = AllStaffMembers.Add(); TestItem.StaffMemberId = primaryKey; AllStaffMembers.ThisStaffMember.Find(primaryKey); AllStaffMembers.Delete(); Boolean found = AllStaffMembers.ThisStaffMember.Find(primaryKey); Assert.IsFalse(found); }