示例#1
0
        private void DOB_Focused(object sender, FocusEventArgs e)
        {
            string entryText = (sender as Entry)?.Text;

            if (DateTime.TryParseExact(entryText, "MM/dd/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out _))
            {
                DOB.Text = entryText;
            }
            else
            {
                ((NewAssessmentViewModel)this.BindingContext).DOBIsValid = false;
                DOBStackLayout.BackgroundColor = DOB.BackgroundColor = Color.White;
                DOB.Text                      = "";
                DOB.TextColor                 = Colors.LightGrayColor;
                DOB.FontAttributes            = FontAttributes.None;
                DOBFrame.BorderColor          = Color.FromHex("#898D8D");
                DOBImageFrame.BackgroundColor = Color.FromHex("147cbd");
                DOBImageFrame.BorderColor     = Color.FromHex("#898D8D");

                switch (((NewAssessmentViewModel)this.BindingContext).EnrollmentDateIsValid)
                {
                case true when _enrollmentErrorMsgShown:
                    EnrollmentDate.Focus();
                    break;

                case true:
                    RefreshEnrollmentErrorStack();
                    break;
                }
            }
        }
示例#2
0
        public Insert()
        {
            InitializeComponent();


            SetEnrollmentDate();

            dateBox.Text = EnrollmentDate.ToString();
        }
示例#3
0
        private Difficulty CalculateRideLevel() // Uses the list of rides to find out what the member's RideLevel is, then returns it as a Difficulty enum
        {
            int difficultyEasy   = 0;           // Variables used for counting
            int difficultyNormal = 0;           //   how many rides of specific
            int difficultyHard   = 0;           //   difficulties the member
            int difficultyExpert = 0;           //   has been a part of

            foreach (Ride ride in Rides)        // Runs through each ride in the IReadOnlyList and adds +1 to the corresponding variable based on the Ride's difficulty
            {
                switch (ride.Route.Difficulty)
                {
                case Difficulty.Easy:
                    difficultyEasy++;
                    break;

                case Difficulty.Normal:
                    difficultyNormal++;
                    break;

                case Difficulty.Hard:
                    difficultyHard++;
                    break;

                case Difficulty.Expert:
                    difficultyExpert++;
                    break;

                default:
                    break;
                }
            }

            //int timeAsMember = (DateTime.Today - EnrollmentDate.Date).; // Uses the EnrollmentDate and DateTime.Today to calculate how many days the Member has been a member for

            // Returns a difficulty based on different criteria
            if (Rides.Count >= 30 && difficultyHard >= 10 && EnrollmentDate.AddYears(1) <= DateTime.Today)// If the member has been on 30 rides, where at least 10 are of difficulty hard AND has been a member for at least a year, the method returns Difficulty.Expert
            {
                return(Difficulty.Expert);
            }
            else if (Rides.Count >= 12 && difficultyNormal >= 5) // If the member has been on 12 rides where at least 5 are of difficulty normal, the method returns Difficulty.Hard
            {
                return(Difficulty.Hard);
            }
            else if (Rides.Count >= 5) // If the member has been on 5 rides, the method returns Difficulty.Easy
            {
                return(Difficulty.Normal);
            }
            else // In every other case, the method returns Difficulty.Easy
            {
                return(Difficulty.Easy);
            }
        }