protected void btnYes_Click(object sender, EventArgs e) { //create a new instance of the address book clsReportsCollection ReportsBook = new clsReportsCollection(); //find the record to delete ReportsBook.ThisReport.Find(EmployeeId); //delete the record ReportsBook.Delete(); //redirect back to the main page Response.Redirect("5ReportsList.aspx"); }
public void DeleteMethodOK() { clsReportsCollection AllReports = new clsReportsCollection(); //create the item of test data clsReports TestItem = new clsReports(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.ProfitOrLoss = true; TestItem.EmployeeId = 2; TestItem.DateAdded = DateTime.Now.Date; TestItem.EmployeeName = "Akshay"; TestItem.Expenses = 200; TestItem.Total = 1000; //set ThisReport to the test data AllReports.ThisReport = TestItem; //add the record PrimaryKey = AllReports.Add(); //set the primary key of the test data TestItem.EmployeeId = PrimaryKey; //find the record AllReports.ThisReport.Find(PrimaryKey); //delete the record AllReports.Delete(); //now find the record Boolean Found = AllReports.ThisReport.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }