コード例 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (InvalidFields() == true)
            {
                MessageBox.Show("Looks like you did not enter all the fields correctly");
                return;
            }

            if (_validator.ValidateBirthdateAndAge(dtDateOfBirth.Value, (int)nudAge.Value) == false)
            {
                MessageBox.Show("The entered birthdate and age does not match!");
                return;
            }

            var employee = CreateEmployee();

            if (_employeeService.GetEmployeeByEmpNo(employee.EmpNo) != null)
            {
                MessageBox.Show("EmpNo has to be unique!");
                return;
            }

            txtDetails.Text = employee.ToString();
            _employeeService.Add(employee);
        }
コード例 #2
0
        public void ValidateBirthdateAndAge_ReturnsTrueIfCorrect()
        {
            var result = _validator.ValidateBirthdateAndAge(_age20, 20);

            Assert.IsTrue(result);
        }