예제 #1
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");
        }
    }
예제 #2
0
        public void LastNameValidExtremeMax()
        {
            clsStaff staffMemeber = new clsStaff();
            string   LastName     = "Richardddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"; //100 chars
            string   Error        = "";

            Error = staffMemeber.ValidName(LastName);
            Assert.AreNotEqual(Error, ""); //should error
        }
예제 #3
0
        public void LastNameValidInvalid()
        {
            clsStaff staffMemeber = new clsStaff();
            string   LastName     = "R8chardson"; //Contains a number
            string   Error        = "";

            Error = staffMemeber.ValidName(LastName);
            Assert.AreNotEqual(Error, ""); //should error
        }
예제 #4
0
        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
        }
예제 #5
0
        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
        }
예제 #6
0
        public void LastNameValidMaxPlusOne()
        {
            clsStaff staffMemeber = new clsStaff();
            string   LastName     = "Wolfeschlegelsteinhausenbergerdorffwelchevordepeufht"; //51 chars
            string   Error        = "";

            Error = staffMemeber.ValidName(LastName);
            Assert.AreNotEqual(Error, ""); //should error
        }
예제 #7
0
        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
        }
예제 #8
0
        public void LastNameValidMinPlusOne()
        {
            clsStaff staffMemeber = new clsStaff();
            string   LastName     = "Aa";
            string   Error        = "";

            Error = staffMemeber.ValidName(LastName);
            Assert.AreEqual(Error, ""); //should be no error
        }
예제 #9
0
        public void FirstNameValidInvalid()
        {
            clsStaff staffMemeber = new clsStaff();
            string   FirstName    = "Dav9d"; //51 chars
            string   Error        = "";

            Error = staffMemeber.ValidName(FirstName);
            Assert.AreNotEqual(Error, ""); //should error
        }
예제 #10
0
        public void FirstNameValidMin()
        {
            clsStaff staffMemeber = new clsStaff();
            string   FirstName    = "A";
            string   Error        = "";

            Error = staffMemeber.ValidName(FirstName);
            Assert.AreEqual(Error, ""); //should be no error
        }