Exemplo n.º 1
0
        public static string getgroupfromage(string DOB)
        {
            int    months    = calculateAge(DOB);
            string groupName = "";
            //calculate group
            Database db = new Database();

            db.connect();
            GroupDB       gdb   = new GroupDB(db);
            List <string> names = gdb.getgroupnames();

            if (months < 19)
            {
                groupName = names[0];
            }
            else if (months >= 18 && months <= 30)
            {
                groupName = names[1];
            }
            else if (months >= 30 && months <= 48)
            {
                groupName = names[2];
            }
            else
            {
                MessageBox.Show("Error - Invalid group name");
                return("");
            }
            return(groupName);
        }
Exemplo n.º 2
0
        public static bool CheckAvalability(DateTime currentDate, Database db, string DOB, List <Kid> kids, List <Booking> bookings)
        {
            string    group         = getgroupfromage(DOB);
            BookingDB bookDB        = new BookingDB(db);
            int       groupID       = bookDB.getgroupID(group);
            int       bookingscount = bookDB.GetBookingSlot(currentDate, groupID);

            int counter = 0;

            foreach (Kid kid in kids)
            {
                if (kids.Count - 1 == counter)
                {
                    break;
                }
                group = getgroupfromage(DOB);
                int newgroupID = bookDB.getgroupID(group);
                if (newgroupID == groupID)
                {
                    List <DateTime> mondays = bookings[counter].Mondays;
                    if (mondays.Contains(currentDate))
                    {
                        bookingscount++;
                    }
                }
                counter++;
            }

            bool    overbooked = false;
            GroupDB gdb        = new GroupDB(db);

            if (groupID == 1)
            {
                if (bookingscount > gdb.getANum())
                {
                    overbooked = true;
                }
            }
            else if (groupID == 2)
            {
                if (bookingscount > gdb.getBNum())
                {
                    overbooked = true;
                }
            }
            else if (groupID == 3)
            {
                if (bookingscount > gdb.getCNum())
                {
                    overbooked = true;
                }
            }
            return(overbooked);
        }