Beispiel #1
0
        public void validEmployee(Employee em)
        {
            if (Legal.legalId(em.Id) == false)
            {
                throw new Exception("Employee's ID is not legal!!");
            }

            if (em.firstName.Length < 1 && em.lastName.Length < 1)
            {
                throw new Exception("Employee's name is not legal!!");
            }
            if (Legal.isString(em.city) == false)
            {
                throw new Exception("Employee's address is not legal!!");
            }

            if (Legal.isCellPhone(em.phoneNumber) == false)
            {
                throw new Exception("Employee phone number is not legal!!");
            }
            if (isAdult(em.dateBirth) == false)
            {
                throw new Exception("Employee is too young for working!!");
            }
            if (!bankAcount(em.details))
            {
                throw new Exception("Employee's Bank Acount details are incorrect!!");
            }
            if (em.experience < 1)
            {
                throw new Exception("experience value is not valid!!!");
            }
            else if (em.hoursPerMonth < 1)
            {
                throw new Exception("Number of hours is not valid!!!");
            }
        }
Beispiel #2
0
        public void validEmployee(Employee em)
        {
            String error = "";

            if (em.d == 0)
            {
                error += ("ERROR: please choose degree!!! \n");
            }

            Specialization s = null;

            try
            {
                s = getSpecialization(em.SpecializationNumber);
            }
            catch (Exception e)
            {
                error += (e.Message + "\n");
            }

            if (Legal.legalId(em.Id) == false)
            {
                error += ("Employee's ID is not legal!!\n");
            }

            if (em.firstName == null || em.lastName == null)
            {
                error += ("Employee's name is empty!!\n");
            }

            else if (!Legal.isString(em.firstName) || !Legal.isString(em.lastName))
            {
                error += ("Employee's Name is not legal!!\n");
            }

            if (Legal.isString(em.city) == false)
            {
                error += ("Employee's address is not legal!!\n");
            }

            if (Legal.isCellPhone(em.phoneNumber) == false)
            {
                error += ("Employee phone number is not legal!!\n");
            }
            if (isAdult(em.dateBirth) == false)
            {
                error += ("Employee is too young for working!!\n");
            }
            //if (!bankAcount(em.details))
            //{
            //    error += ("Employee's Bank Acount details are incorrect!!\n");
            //}
            if (em.experience < 0)
            {
                error += ("experience value is not valid!!!\n");
            }
            if (em.hoursPerMonth < 1)
            {
                error += ("Number of hours is not valid!!!\n");
            }
            if (s == null)
            {
                error += ("The employee specialization does'nt exist!!!\n");
            }

            if (error != "")
            {
                throw new Exception(error);
            }
        }