public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of the test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.StaffID = 123; TestItem.FullName = "Full Name"; TestItem.Salary = 7.78; TestItem.DateOfJoining = DateTime.Now.Date; TestItem.Position = "staff"; TestItem.FullTime = true; TestItem.Active = true; //set thisStaff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void DeleteMethodOK() { clsStaffCollection allStaff = new clsStaffCollection(); clsStaff test = new clsStaff(); int primaryKey = 0; test.active = true; test.EmployeeNo = 10; test.first_name = "Joe"; test.last_name = "Bloggs"; test.salary = 15000; allStaff.thisStaff = test; primaryKey = allStaff.Add(); test.EmployeeNo = primaryKey; allStaff.thisStaff.find(primaryKey); allStaff.delete(); Boolean Found = allStaff.thisStaff.find(primaryKey); Assert.IsFalse(Found); }
public void UpdateMethodOK() { clsStaffCollection AllStaff = new clsStaffCollection(); clsStaff TestItem = new clsStaff(); Int32 PrimaryKey = 0; TestItem.StaffID = 1; TestItem.StaffName = "Matthew Smith"; TestItem.StaffAddress = "15 Somewhere Road"; TestItem.StartDate = DateTime.Now.Date; TestItem.Salary = 13500; TestItem.Manager = true; AllStaff.ThisStaff = TestItem; PrimaryKey = AllStaff.Add(); TestItem.StaffID = PrimaryKey; TestItem.StaffID = 2; TestItem.StaffName = "Caitlin Smith"; TestItem.StaffAddress = "10 Anywhere else"; TestItem.StartDate = DateTime.Now.Date; TestItem.Salary = 10000.50; TestItem.Manager = false; AllStaff.ThisStaff = TestItem; AllStaff.Update(); AllStaff.ThisStaff.Find(PrimaryKey); Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void UpdateMethod() { //create and instance of the class clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Email = "*****@*****.**"; TestItem.Name = "George Hamilton"; TestItem.Password = "******"; //set thisStaff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //modify the test data TestItem.Email = "*****@*****.**"; TestItem.Name = "Tom Fisherman"; TestItem.Password = "******"; //set the record based on the new test data AllStaff.ThisStaff = TestItem; //update the record AllStaff.Update(); //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see ThisStaff matches the test data Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the priamry key Int32 PrimaryKey = 0; //set its properties TestItem.StaffNo = 1; TestItem.Title = "Mr"; TestItem.FirstName = "John"; TestItem.LastName = "Taylor"; TestItem.DateOfBirth = DateTime.Now.Date.AddYears(-16); TestItem.Address1 = "18 Some Street"; TestItem.Address2 = "36 Some Street"; TestItem.City = "Leicester"; TestItem.PostCode = "LE2 9AK"; //assign the data to the property AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the tst data TestItem.StaffNo = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of the test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Citizen = true; TestItem.StaffID = 1; TestItem.StaffFirstName = "Lucy"; TestItem.StaffLastName = "James"; TestItem.Gender = "Female"; TestItem.DateOfBirth = DateTime.Now.Date; TestItem.NINo = "AA 12 34 56 C"; TestItem.PhoneNo = "07038320312"; TestItem.Address = "Grove road"; TestItem.PostCode = "MK438SS"; //set ThisAddress to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //tyest to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
//function for adding new records void Add() { //create an instance of the staff Book clsStaffCollection StaffBook = new clsStaffCollection(); //validate the data on the web form string Error = StaffBook.ThisStaff.Valid(txtStaffEmail.Text, txtStaffName.Text, txtStaffPassword.Text); //if the data is ok then add it to the object if (Error == "") { //get the data entered by the user StaffBook.ThisStaff.Email = txtStaffEmail.Text; StaffBook.ThisStaff.Name = txtStaffName.Text; StaffBook.ThisStaff.Password = txtStaffPassword.Text; //add the record StaffBook.Add(); //all done so redirect back to the main page Response.Redirect("StaffList.aspx"); } else { //report the error lblError.Text = "There were problems with the data entered " + Error; } }
public void UpdateMethodOK() { clsStaffCollection AllStaff = new clsStaffCollection(); clsStaff TestItem = new clsStaff(); Int32 PrimaryKey = 0; //setting properties TestItem.StaffId = 7357; TestItem.FirstName = "Joe"; TestItem.LastName = "Bennet"; TestItem.EmailAddress = "*****@*****.**"; TestItem.HomeAddress = "101 Joe Ln, LE1 101"; TestItem.StartDate = DateTime.Now.Date; TestItem.IsWorking = true; //setting ThisStaffMember to the test data AllStaff.ThisStaffMember = TestItem; //adding the record PrimaryKey = AllStaff.Add(); TestItem.StaffId = PrimaryKey; //modifying the test data TestItem.FirstName = "Jack"; TestItem.LastName = "Deck"; TestItem.EmailAddress = "*****@*****.**"; TestItem.HomeAddress = "102 Jack Ln, LE1 102"; TestItem.StartDate = DateTime.Now.Date; TestItem.IsWorking = false; //setting the record based on the new test data AllStaff.ThisStaffMember = TestItem; //updating the record AllStaff.Update(); //fiding the record AllStaff.ThisStaffMember.Find(PrimaryKey); //testing Assert.AreEqual(AllStaff.ThisStaffMember, TestItem); }
public void DeleteMethodOK() { clsStaffCollection AllStaff = new clsStaffCollection(); clsStaff TestItem = new clsStaff(); Int32 PrimaryKey = 0; //setting properties TestItem.FirstName = "Jason"; TestItem.LastName = "Pratchet"; TestItem.EmailAddress = "*****@*****.**"; TestItem.HomeAddress = "303 Pratt Ln, LE1 303"; TestItem.StartDate = DateTime.Now.Date; TestItem.IsWorking = true; //setting ThisStaffMember to the test data AllStaff.ThisStaffMember = TestItem; //adding the record PrimaryKey = AllStaff.Add(); //setting the primary key of the test data TestItem.StaffId = PrimaryKey; //finding the record AllStaff.ThisStaffMember.Find(PrimaryKey); //deleting the record AllStaff.Delete(); //finding the record again Boolean Found = AllStaff.ThisStaffMember.Find(PrimaryKey); Assert.IsFalse(Found); }
public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Active = true; TestItem.StaffNo = 1; TestItem.CountyNo = 1; TestItem.StaffFirstName = "Sally"; TestItem.StaffLastName = "Gomery"; TestItem.AddressLine = "8 Hillbilly State"; TestItem.PostCode = "HG6 8SH"; TestItem.PhoneNo = "07563856402"; //set ThisAddress to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffNo = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
void Add() { //create an instance of the address book clsStaffCollection Staff = new clsStaffCollection(); //validate the data on the web form String Error = Staff.ThisStaff.Valid(txtTitle.Text, txtFirstName.Text, txtLastName.Text, txtDateOfBirth.Text, txtAddress1.Text, txtAddress2.Text, txtCity.Text, txtPostCode.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user Staff.ThisStaff.Title = txtTitle.Text; Staff.ThisStaff.FirstName = txtFirstName.Text; Staff.ThisStaff.LastName = txtLastName.Text; Staff.ThisStaff.DateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text); Staff.ThisStaff.Address1 = txtAddress1.Text; Staff.ThisStaff.Address2 = txtAddress2.Text; Staff.ThisStaff.City = txtCity.Text; Staff.ThisStaff.PostCode = txtPostCode.Text; //add the record Staff.Add(); //all done so redirect back to the main page Response.Redirect("StaffList.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
public void DeleteMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Employer = true; TestItem.StaffID = 1; TestItem.StaffName = "Name"; TestItem.StaffSalary = 30000; TestItem.StaffEmailAddress = "*****@*****.**"; TestItem.StaffDOB = DateTime.Parse("23/03/1999"); //set ThisStaff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key to test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //delete the record AllStaff.Delete(); //now find the record Boolean Found = AllStaff.ThisStaff.Find(PrimaryKey); //test to see the record was not found Assert.IsFalse(Found); }
public void AddMethodOK() { //create an instance of the class clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set the propertiess TestItem.Employer = true; TestItem.StaffID = 1; TestItem.StaffName = "Name"; TestItem.StaffSalary = 30000; TestItem.StaffEmailAddress = "*****@*****.**"; TestItem.StaffDOB = DateTime.Parse("23/03/1999"); //set ThisStaff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllRecords = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.StaffID = 1; TestItem.FullName = "Rookaya Dokrat"; TestItem.StaffPwd = "default!"; TestItem.DateOfBirth = Convert.ToDateTime("15/12/1998"); TestItem.Salary = 9.50M; TestItem.FullTime = false; //Set ThisRecord to the test data AllRecords.ThisRecord = TestItem; //Add the record PrimaryKey = AllRecords.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllRecords.ThisRecord.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllRecords.ThisRecord, TestItem); }
public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaffs = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its prperties TestItem.StaffID = 1; TestItem.StaffNumber = "P1622604"; TestItem.FirstName = "Zihao"; TestItem.LastName = "Zhang"; TestItem.Gender = "Male"; TestItem.Position = "Cleaner"; TestItem.Password = "******"; TestItem.Attendence = 98.6; TestItem.Address = "Leicester"; TestItem.PhoneNumber = "+12345678"; //set ThisStaff to the test data AllStaffs.ThisStaff = TestItem; //add the record PrimaryKey = AllStaffs.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaffs.ThisStaff.Search(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStaffs.ThisStaff, TestItem); }
public void AddMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create an item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set it's properties TestItem.Active = true; TestItem.StaffID = 1; TestItem.StaffName = "Hamzah"; TestItem.StaffAddress = "1 Leicester Road"; TestItem.StaffTelNumber = "07871740971"; TestItem.DateJoined = DateTime.Now.Date; //assign the data to the property AllStaff.ThisStaff = TestItem; //find the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
// function for adding new staff members void Add() { // create an instance of the staff collection clsStaffCollection StaffMember = new clsStaffCollection(); // validate the data Boolean OK = StaffMember.ThisMember.Valid(txtFirstName.Text, txtLastName.Text, txtAddress.Text, txtEmail.Text, txtPostcode.Text, txtContactNo.Text, txtDOB.Text, txtDateJoined.Text); // if the data is OK then add it to the object if (OK == true) { // get the data entered by the user StaffMember.ThisMember.StaffFirstName = txtFirstName.Text; StaffMember.ThisMember.StaffLastName = txtLastName.Text; StaffMember.ThisMember.StaffAddress = txtAddress.Text; StaffMember.ThisMember.StaffEmailAddress = txtEmail.Text; StaffMember.ThisMember.StaffPostCode = txtPostcode.Text; StaffMember.ThisMember.StaffContactNo = txtContactNo.Text; StaffMember.ThisMember.StaffDOB = Convert.ToDateTime(txtDOB.Text); StaffMember.ThisMember.StaffDateJoined = Convert.ToDateTime(txtDateJoined.Text); // add the new staff member StaffMember.Add(); } else { // report an error lblError.Text = "There were problems with the data entered"; } }
void Add() { //create an instance of the address book clsStaffCollection StaffSystem = new clsStaffCollection(); //validate the data on the web form String Error = StaffSystem.ThisStaff.Valid(txtEnrolmentDate.Text, txtDepartment.Text, txtJobTitle.Text, txtName.Text, txtExtension.Text, txtPhoneNo.Text, txtHomeAddress.Text, txtPostcode.Text, txtCity.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user StaffSystem.ThisStaff.EnrolmentDate = Convert.ToDateTime(txtEnrolmentDate.Text); StaffSystem.ThisStaff.Department = txtDepartment.Text; StaffSystem.ThisStaff.JobTitle = txtJobTitle.Text; StaffSystem.ThisStaff.Name = txtName.Text; StaffSystem.ThisStaff.Extension = txtExtension.Text; StaffSystem.ThisStaff.PhoneNo = txtPhoneNo.Text; StaffSystem.ThisStaff.HomeAddress = txtHomeAddress.Text; StaffSystem.ThisStaff.Postcode = txtPostcode.Text; StaffSystem.ThisStaff.City = txtCity.Text; StaffSystem.ThisStaff.Available = chkAvailable.Checked; //add the record StaffSystem.Add(); //all done so redirect back to the main page Response.Redirect("Default.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
public void DeleteMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set it's propertites TestItem.Citizen = true; TestItem.StaffID = 1; TestItem.StaffFirstName = "Lucy"; TestItem.StaffLastName = "James"; TestItem.Gender = "Female"; TestItem.DateOfBirth = DateTime.Now.Date; TestItem.NINo = "AA 12 34 56 C"; TestItem.PhoneNo = "07038320312"; TestItem.Address = "Grove road"; TestItem.PostCode = "MK438SS"; //set ThisOrder to the test data AllStaff.ThisStaff = TestItem; PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //delete the record AllStaff.Delete(); //now find the record Boolean Found = AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void UpdateMethodOK() { clsStaffCollection AllStaff = new clsStaffCollection(); clsStaff TestItem = new clsStaff(); Int32 PrimaryKey = 0; //set properties TestItem.staffid = 1; TestItem.name = "Joe Bloggs"; TestItem.phoneNumber = "01234567891"; TestItem.salary = 25000.24; TestItem.joinedDate = DateTime.Now.Date; TestItem.admin = true; AllStaff.ThisStaff = TestItem; PrimaryKey = AllStaff.Add(); TestItem.staffid = PrimaryKey; //set properties (updated) TestItem.staffid = 3; TestItem.name = "Bloggs Joe"; TestItem.phoneNumber = "19876543210"; TestItem.salary = 15000.99; TestItem.joinedDate = DateTime.Now.Date; TestItem.admin = false; AllStaff.ThisStaff = TestItem; AllStaff.Update(); AllStaff.ThisStaff.Find(PrimaryKey); Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void DeleteMethod() { //create and instance of the class clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.StaffID = 1; TestItem.Email = "*****@*****.**"; TestItem.Name = "George Hamilton"; TestItem.Password = "******"; //set thisStaff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //delete the record AllStaff.Delete(); //now find the record Boolean Found = AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void AddMethodOk() { // Create new instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); // creat the item of test data clsStaff TestItem = new clsStaff(); // Var to store primary key Int32 PrimaryKey = 0; // set its properties TestItem.IsWorking = true; TestItem.FullName = "Natasha Longboy"; TestItem.HourlyWage = 7.5; TestItem.PhoneNumber = "07759188504"; TestItem.DateOfBirth = Convert.ToDateTime("09 / 03 / 1986"); // Set ThisStaff to the test data AllStaff.ThisStaff = TestItem; // add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffId = PrimaryKey; // find the record AllStaff.ThisStaff.Find(PrimaryKey); // Test to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void AddMethod() { //create and instance of the class clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.StaffID = 1; TestItem.Email = "*****@*****.**"; TestItem.Name = "George Hamilton"; TestItem.Password = "******"; //set thisStaff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
public void DeleteMethodOK() { // create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); // create the item of test data clsStaff TestItem = new clsStaff(); // var to store the primary key Int32 PrimaryKey = 0; // set its properties TestItem.IsWorking = true; TestItem.FullName = "Natasha Longboy"; TestItem.HourlyWage = 7.5; TestItem.PhoneNumber = "07759188504"; TestItem.DateOfBirth = Convert.ToDateTime("09 / 03 / 1986"); //set this staff to test data AllStaff.ThisStaff = TestItem; // add the record PrimaryKey = AllStaff.Add(); // set the primary key of the test data TestItem.StaffId = PrimaryKey; // find the record AllStaff.ThisStaff.Find(PrimaryKey); // delete the record AllStaff.Delete(); // try to find the record Boolean Found = AllStaff.ThisStaff.Find(PrimaryKey); // test to see that the record was not found Assert.IsFalse(Found); }
public void UpdateMehtodOK() { clsStaffCollection allStaff = new clsStaffCollection(); clsStaff staff = new clsStaff(); Int32 PrimaryKey = 0; staff.active = true; staff.first_name = "Test"; staff.last_name = "Test"; staff.salary = 15000; allStaff.thisStaff = staff; PrimaryKey = allStaff.Add(); staff.EmployeeNo = PrimaryKey; staff.active = false; staff.first_name = "test2"; staff.last_name = "test2"; staff.salary = 100000; allStaff.thisStaff = staff; allStaff.update(); allStaff.thisStaff.find(PrimaryKey); Assert.AreEqual(allStaff.thisStaff, staff); }
public void DeleteMethodOK() { clsStaffCollection AllStaff = new clsStaffCollection(); clsStaff TestItem = new clsStaff(); int PrimaryKey = 0; TestItem.FirstName = "Add-Method-Test"; TestItem.LastName = "Testing-Add-Method"; TestItem.StartDate = DateTime.Parse("2018-01-01"); TestItem.PhoneNumber = "07492278399"; TestItem.HourlyRate = 8.90M; AllStaff.ThisStaff = TestItem; PrimaryKey = AllStaff.Add(); TestItem.StaffNumber = PrimaryKey; AllStaff.ThisStaff.Find(PrimaryKey); AllStaff.Delete(); bool Found = AllStaff.ThisStaff.Find(PrimaryKey); Assert.IsFalse(Found); }
//function for adding new records void Add() { //create an instance of the staff clsStaffCollection StaffSystem = new clsStaffCollection(); //validate the data on the web forms String Error = StaffSystem.ThisStaff.Valid(txtCounty.Text, txtStreet.Text, txtPostcode.Text, txtDOB.Text, txtFirstName.Text, txtLastName.Text, txtGender.Text, txtTelephone.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user StaffSystem.ThisStaff.County = txtCounty.Text; StaffSystem.ThisStaff.FirstName = txtFirstName.Text; StaffSystem.ThisStaff.LastName = txtLastName.Text; StaffSystem.ThisStaff.Gender = txtGender.Text; StaffSystem.ThisStaff.DateOfBirth = txtDOB.Text; StaffSystem.ThisStaff.Street = txtStreet.Text; StaffSystem.ThisStaff.PostCode = txtPostcode.Text; StaffSystem.ThisStaff.Telephone = Convert.ToInt32(txtTelephone.Text); StaffSystem.ThisStaff.Active = Active.Checked; //add the record StaffSystem.Add(); //all done so redirect back to the main page Response.Redirect("DefaultStaff.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered" + Error; } }
public void UpdateMethodOK() { clsStaffCollection AllStaff = new clsStaffCollection(); clsStaff TestItem = new clsStaff(); int PrimaryKey = 0; TestItem.FirstName = "should-never-show-in-database"; TestItem.LastName = "because-by-end-of-test-should-change"; TestItem.StartDate = DateTime.Parse("2018-01-01"); TestItem.PhoneNumber = "07492278399"; TestItem.HourlyRate = 8.90M; AllStaff.ThisStaff = TestItem; PrimaryKey = AllStaff.Add(); TestItem.StaffNumber = PrimaryKey; TestItem.FirstName = "this-is-ok"; TestItem.LastName = "update-method-tested"; TestItem.StartDate = DateTime.Parse("2019-01-01"); TestItem.PhoneNumber = "07492278310"; TestItem.HourlyRate = 9.90M; AllStaff.ThisStaff = TestItem; AllStaff.Update(); AllStaff.ThisStaff.Find(PrimaryKey); Assert.AreEqual(AllStaff.ThisStaff, TestItem); }
//function for adding new staff records void Add() { clsStaff AStaff = new clsStaff(); clsStaffCollection StaffList = new clsStaffCollection(); String Error = AStaff.Valid(txtFirstName.Text, txtLastName.Text, txtDOB.Text, txtDOH.Text, ddlRole.SelectedIndex, txtPostcode.Text, txtCity.Text, txtStreet.Text, txtHouseNo.Text, txtEmail.Text, txtPhone.Text); if (Error == "") { StaffList.ThisStaff.staffRoleId = ddlRole.SelectedIndex; StaffList.ThisStaff.firstName = txtFirstName.Text; StaffList.ThisStaff.lastName = txtLastName.Text; StaffList.ThisStaff.dateOfBirth = Convert.ToDateTime(txtDOB.Text); StaffList.ThisStaff.dateOfHire = Convert.ToDateTime(txtDOH.Text); StaffList.ThisStaff.postCode = txtPostcode.Text; StaffList.ThisStaff.cityOfResidence = txtCity.Text; StaffList.ThisStaff.streetName = txtStreet.Text; StaffList.ThisStaff.houseNumber = txtHouseNo.Text; StaffList.ThisStaff.contactEmail = txtEmail.Text; StaffList.ThisStaff.contactPhoneNo = txtPhone.Text; StaffList.ThisStaff.onHoliday = chkHoliday.Checked; StaffList.Add(); Response.Redirect("StaffList.aspx"); } else { lblError.Text = "There were problems with the data entered:<br /><br />" + Error; } }
public void DeleteMethodOK() { //create an instance of the class we want to create clsStaffCollection AllStaff = new clsStaffCollection(); //create the item of test data clsStaff TestItem = new clsStaff(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.StaffID = 200; TestItem.FullName = "Full Name"; TestItem.Salary = 7.78; TestItem.DateOfJoining = DateTime.Now.Date; TestItem.Position = "staff"; TestItem.FullTime = true; TestItem.Active = true; //set this staff to the test data AllStaff.ThisStaff = TestItem; //add the record PrimaryKey = AllStaff.Add(); //set the primary key of the test data TestItem.StaffID = PrimaryKey; //find the record AllStaff.ThisStaff.Find(PrimaryKey); //delete the record AllStaff.Delete(); //now find the record Boolean Found = AllStaff.ThisStaff.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }