Пример #1
0
        public void HourlyRateValidInvalid()
        {
            clsStaff staffMemeber = new clsStaff();
            string   HourlyRate   = "David";
            string   Error        = "";

            Error = staffMemeber.ValidHourlyRate(HourlyRate);
            Assert.AreNotEqual(Error, ""); //should error
        }
Пример #2
0
        public void HourlyRateValidMax()
        {
            clsStaff staffMemeber = new clsStaff();
            string   HourlyRate   = (Decimal.MaxValue).ToString();;
            string   Error        = "";

            Error = staffMemeber.ValidHourlyRate(HourlyRate);
            Assert.AreEqual(Error, ""); //should be no error
        }
Пример #3
0
        public void HourlyRateValidMinPlusOne()
        {
            clsStaff staffMemeber = new clsStaff();
            string   HourlyRate   = "1";
            string   Error        = "";

            Error = staffMemeber.ValidHourlyRate(HourlyRate);
            Assert.AreEqual(Error, ""); //should be no error
        }
Пример #4
0
        public void HourlyRateValidExtremeMin()
        {
            clsStaff staffMemeber = new clsStaff();
            string   HourlyRate   = "-10000";
            string   Error        = "";

            Error = staffMemeber.ValidHourlyRate(HourlyRate);
            Assert.AreNotEqual(Error, ""); //should error
        }
Пример #5
0
        public void HourlyRateValidExtremeMax()
        {
            clsStaff staffMemeber = new clsStaff();
            string   HourlyRate   = "7902281625142643375935439503360000";
            //Greatly exceeds the max value of a decimal
            string Error = "";

            Error = staffMemeber.ValidHourlyRate(HourlyRate);
            Assert.AreNotEqual(Error, ""); //should error
        }
Пример #6
0
        public void HourlyRateValidMaxPlusOne()
        {
            clsStaff staffMemeber = new clsStaff();
            string   HourlyRate   = "79228162514264337593543950336";
            //max value of a decial + 1. Too annoying to try and actually store, for obvious reasons
            string Error = "";

            Error = staffMemeber.ValidHourlyRate(HourlyRate);
            Assert.AreNotEqual(Error, ""); //should error
        }
Пример #7
0
    //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");
        }
    }