//When the OK button is clicked protected void btnOK_Click(object sender, EventArgs e) { clsStaff StaffMember = new clsStaff(); //capture the data from the text input boxes string firstName = txtFirstName.Text; string lastName = txtLastName.Text; string hourlyRate = txtHourlyRate.Text; string phoneNumber = txtPhoneNumber.Text; string startDate = txtStartDate.Text; //if there are errors if (StaffMember.Valid(firstName, lastName, phoneNumber, hourlyRate, startDate) == false) { //add the error messages to their relevent boxes lblFirstNameError.Text = StaffMember.ValidName(firstName); lblLastNameError.Text = StaffMember.ValidName(lastName); lblHourlyRateError.Text = StaffMember.ValidHourlyRate(hourlyRate); lblPhoneNumberError.Text = StaffMember.ValidPhoneNumber(phoneNumber); lblStartDateError.Text = StaffMember.ValidStartDate(startDate); } //or, store the captured data in an instance of the class else if (StaffMember.Valid(firstName, lastName, phoneNumber, hourlyRate, startDate) == true) { StaffMember.StaffNumber = StaffNumber; StaffMember.FirstName = firstName; StaffMember.LastName = lastName; StaffMember.HourlyRate = decimal.Parse(hourlyRate); StaffMember.IsManager = chkIsManager.Checked; StaffMember.PhoneNumber = phoneNumber; StaffMember.StartDate = DateTime.Parse(startDate); clsStaffCollection StaffList = new clsStaffCollection(); if (StaffNumber == -1) { StaffList.ThisStaff = StaffMember; StaffList.Add(); } else { StaffList.ThisStaff.Find(StaffNumber); StaffList.ThisStaff = StaffMember; StaffList.Update(); } Response.Redirect("StaffList.aspx"); } }
public void LastNameValidExtremeMax() { clsStaff staffMemeber = new clsStaff(); string LastName = "Richardddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"; //100 chars string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreNotEqual(Error, ""); //should error }
public void LastNameValidInvalid() { clsStaff staffMemeber = new clsStaff(); string LastName = "R8chardson"; //Contains a number string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreNotEqual(Error, ""); //should error }
public void LastNameValidMaxMinusOne() { clsStaff staffMemeber = new clsStaff(); string LastName = "Wolfeschlegelsteinhausenbergerdorffwelchevorfjefk"; //49 chars string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreEqual(Error, ""); //should be no error }
public void LastNameValidMid() { clsStaff staffMemeber = new clsStaff(); string LastName = "Wolfeschlegelsteinhausenb"; //25 chars string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreEqual(Error, ""); //should be no error }
public void LastNameValidMaxPlusOne() { clsStaff staffMemeber = new clsStaff(); string LastName = "Wolfeschlegelsteinhausenbergerdorffwelchevordepeufht"; //51 chars string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreNotEqual(Error, ""); //should error }
public void LastNameValidMax() { clsStaff staffMemeber = new clsStaff(); string LastName = "Wolfeschlegelsteinhausenbergerdorffwelchevordgjyte"; //50 chars, part of a real name! string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreEqual(Error, ""); //should be no error }
public void LastNameValidMinPlusOne() { clsStaff staffMemeber = new clsStaff(); string LastName = "Aa"; string Error = ""; Error = staffMemeber.ValidName(LastName); Assert.AreEqual(Error, ""); //should be no error }
public void FirstNameValidInvalid() { clsStaff staffMemeber = new clsStaff(); string FirstName = "Dav9d"; //51 chars string Error = ""; Error = staffMemeber.ValidName(FirstName); Assert.AreNotEqual(Error, ""); //should error }
public void FirstNameValidMin() { clsStaff staffMemeber = new clsStaff(); string FirstName = "A"; string Error = ""; Error = staffMemeber.ValidName(FirstName); Assert.AreEqual(Error, ""); //should be no error }