コード例 #1
0
        public void Validate()
        {
            new AddNotifications <FuncionarioEntity>(this)
            .IfLowerOrEqualsThan(Id, 0, "Id must be greater than zero")
            .IfNullOrEmpty(Name, "Name is obligatory")
            .IfNullOrEmpty(Gender, "Gender is obligatory")
            .IfNullOrEmpty(BirthDay.ToString(), "BirthDay is obligatory")
            .IfNullOrEmpty(Salary.ToString(), "Salary is obligatory")
            .IfNullOrEmpty(Level, "Level is obligatory")
            .IfNullOrEmpty(HiringDate.ToString(), "HiringDate is obligatory")
            .IfLengthGreaterThan(Name, 64, "Name must be a maximum of 64 characters")
            .IfLengthGreaterThan(Gender, 1, "Gender must be a maximum of 1 characters")
            .IfGreaterOrEqualsThan(BirthDay, DateTime.Now, "BirthDay must be smaller than today")
            .IfLowerOrEqualsThan(Salary, 800, "Salary must be greater than R$ 800,00")
            .IfLengthGreaterThan(Level, 1, "Level must be a maximum of 1 characters")
            .IfGreaterThan(HiringDate, DateTime.Now, "HiringDate must be less than or equals today");

            if (!new string[] { "F", "M" }.Contains(Gender))
            {
                AddNotification("Gender", "Gender should be M or F");
            }

            if (!new string[] { "J", "P", "S" }.Contains(Level))
            {
                AddNotification("Level", "Level should be J, P or S");
            }
        }
コード例 #2
0
 public Employee(int ID, HiringDate hiringDate, double Salary, SecurityLevel level, Gender gender)
 {
     this.ID     = ID;
     HD          = hiringDate;
     this.Salary = Salary;
     SL          = level;
     this.gender = gender;
 }
コード例 #3
0
ファイル: Employee .cs プロジェクト: Desm0nt/Task6
 public void PrintInfo()
 {
     Console.WriteLine("Name: " + FirstName + " " + LastName
                       + ", Position: " + Position
                       + ", Cabinet: " + Cabinet
                       + ", Hiring Date: " + HiringDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)
                       + ", " + string.Format("Salary: {0:C2}", Salary, CultureInfo.InvariantCulture));
 }
コード例 #4
0
        private bool ValidateInput()
        {
            if (String.IsNullOrEmpty(FirstName) || String.IsNullOrEmpty(LastName) || String.IsNullOrEmpty(ICNumber) || HiringDate.Equals(DateTime.Today) || String.IsNullOrEmpty(Phone) || String.IsNullOrEmpty(Email))
            {
                MessageBox.Show("Rejected request!\nThere are empty fields!", "Error!", MessageBoxButton.OK, MessageBoxImage.Information);
                return(false);
            }

            if (ParseToDate(HiringDate) == DateTime.MinValue)
            {
                MessageBox.Show("Rejected request!\nThere was an error with the Hiring Date input! Please check the format!", "Error!", MessageBoxButton.OK, MessageBoxImage.Information);
                return(false);
            }



            //if (isNumeric(Phone) || ICNumber.Length < 10 || ICNumber.Length > 15)
            //{

            //    MessageBox.Show("Rejected request!\nThere was an error with the Phone Number!", "Error!", MessageBoxButton.OK, MessageBoxImage.Information);
            //    return false;
            //}

            //if (isNumeric(ICNumber) || ICNumber.Length != 13)
            //{
            //    MessageBox.Show("Rejected request!\nThere was an error with the Identity Card Number!", "Error!", MessageBoxButton.OK, MessageBoxImage.Information);
            //    return false;
            //}

            return(true);
        }