Exemplo n.º 1
0
        //Changes the start or end date of a reservation
        public int ChangeReservation(int reservationNumber, DateTime startDate, DateTime endDate)
        {
            e errCode = e.success;

            if (Validation.invalidRes(reservationNumber))
            {
                errCode = e.invalidRes;
            }
            else if (Validation.activeRes(reservationNumber))
            {
                errCode = e.activeRes;
            }
            else if (Validation.sBeforeToday(startDate))
            {
                errCode = e.sBeforeToday;
            }
            else if (Validation.sAfterEnd(startDate, endDate))
            {
                errCode = e.sAfterEnd;
            }
            else
            {
                ReservationDB resDB = new ReservationDB();
                if (!resDB.Update(reservationNumber, startDate, endDate))
                {
                    errCode = e.updateFail;
                }
            }

            return(Convert.ToInt16(errCode));
        }
Exemplo n.º 2
0
        public List <Reservation> ListReservations()
        {
            ReservationDB resDB = new ReservationDB();
            DataTable     data  = resDB.GetReservationWithOwnerNumbers();

            return(GetReservations(data));
        }
Exemplo n.º 3
0
        //Cancels a reservation
        public int CancelReservation(int reservationNumber)
        {
            e errCode = e.success;

            if (Validation.invalidRes(reservationNumber))
            {
                errCode = e.invalidRes;
            }
            if (Validation.activeRes(reservationNumber))
            {
                errCode = e.activeRes;
            }
            else
            {
                ReservationDB  resDB = new ReservationDB();
                PetReservation pr    = new PetReservation();
                Discount       d     = new Discount();
                d.removeDiscount(reservationNumber);
                pr.RemoveEntireRes(reservationNumber);
                if (!resDB.Delete(reservationNumber))
                {
                    errCode = e.deleteFail;
                }
            }

            return(Convert.ToInt16(errCode));
        }
Exemplo n.º 4
0
        public static int deleteDogFromReservation(int reservationNumber, int petNumber)
        {
            Search search = new HawkeyehvkBLL.Search();

            if (!search.validateReservationNumber(reservationNumber))// check reservation number
            {
                return(1);
            }
            else if (!search.validatePetNumber(petNumber))// check pet number
            {
                return(2);
            }
            else if (!ReservationDB.isDogInReservation(reservationNumber, petNumber))// check that dog is in reservation
            {
                return(3);
            }
            else if (isReservationActive(reservationNumber))//check is res is active
            {
                return(4);
            }
            else
            {
                // before running check if the reservation is going from 3 to 2 dogs in order to remove the discount
                int count = PetReservation.listPetRes(reservationNumber).Count;
                if (count == 3)
                {
                    Discount.deleteReservationDiscount(2, reservationNumber);
                }
                return(ReservationDB.deleteDogFromReservationDB(reservationNumber, petNumber));
            }
        }
Exemplo n.º 5
0
        public static int updateReservation(int resNum, DateTime startDate, DateTime endDate, int petNumber, int runNumber)
        {
            ReservationDB db    = new ReservationDB();
            Search        check = new Search();

            if (check.validateReservationNumber(resNum))
            {
                if (check.validatePetNumber(petNumber) == false)
                {
                    return(-10);
                }
                //return -11 Start Date In the past
                if (startDate < DateTime.Now)
                {
                    return(-11);
                }
                //return -12 Start Date After end date
                if (startDate > endDate)
                {
                    return(-12);
                }
                //return -13 Dog has reservation for all or part of period
                if (check.validateConflictingReservations(petNumber, startDate, endDate) == false)
                {
                    return(-13);
                }
                //return -14 No Run Available

                if (Run.checkRunAvailability(startDate, endDate, check.getPetSize(petNumber)) <= 0)
                {
                    return(-14);
                }
                //return -15 Insert Failed
                if (Reservation.updateReservation(resNum, startDate, endDate, petNumber, runNumber) == 1)
                {
                    return(1);
                }
                else
                {
                    return(-15);
                }


                //return -1 if expired or missing Vaccinations
                int count = PetVaccination.checkVaccinations(petNumber, endDate);
                if (count == -1)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(-2);
            }
        }
Exemplo n.º 6
0
        //crée une nouvelle reservation
        public static int NewReservation(String NameClient, String FirstNameClient, DateTime CheckIn, DateTime CheckOut, int idRoom, int PriceIncreased)
        {
            int IdReservation = ReservationDB.NewReservation(NameClient, FirstNameClient, CheckIn, CheckOut);

            RoomReservationManager.NewRoomReservation(IdReservation, idRoom, PriceIncreased);

            return(IdReservation);
        }
        /// <summary>
        /// Delete a reservation:
        ///     1. delete all RoomReservation
        ///     2. delete Reservation
        ///     3. delete Client
        /// </summary>
        public static void DeleteReservation(int idReservation)
        {
            Reservation reservation = ReservationDB.GetReservation(idReservation);

            ReservationDB.DeleteRoomReservation(idReservation);

            ReservationDB.DeleteReservation(idReservation);

            ClientDB.DeleteClient(reservation.Client.IdClient);
        }
Exemplo n.º 8
0
        //resCancaled
        //Makes a reservation for a dog alone in a run
        public List <int> AddReservation(int petNumber, DateTime startDate, DateTime endDate)
        {
            e          errCode   = e.success;
            int        resNumber = -1;
            List <int> retVals   = new List <int>();

            if (Validation.sBeforeToday(startDate))
            {
                errCode = e.sBeforeToday;
            }
            else if (Validation.sAfterEnd(startDate, endDate))
            {
                errCode = e.sAfterEnd;
            }
            else if (Validation.invalidPet(petNumber))
            {
                errCode = e.invalidPet;
            }
            else if (Validation.runUnavailable(startDate, endDate, petNumber))
            {
                errCode = e.runUnavailable;
            }
            else if (Validation.alreadyReserved(startDate, endDate, petNumber))
            {
                errCode = e.alreadyReserved;
            }
            else
            {
                ReservationDB resDB = new ReservationDB();
                resNumber = resDB.Add(startDate, endDate);

                if (resNumber < 0)
                {
                    errCode = e.insertFail;
                }
                else
                {
                    if (AddToReservation(resNumber, petNumber) < -10)
                    {
                        errCode = e.insertFail;
                    }
                    else
                    {
                        if (ListExpOrMissVaccs(petNumber, endDate).Count != 0)
                        {
                            errCode = e.vaccInvalid;
                        }
                    }
                }
            }
            retVals.Add(Convert.ToInt16(errCode));
            retVals.Add(resNumber);

            return(retVals);
        }
Exemplo n.º 9
0
        public static List <Run> listAvailableRuns(DateTime start, DateTime end)
        {
            List <Run>    runs = new List <Run>();
            ReservationDB db   = new ReservationDB();

            foreach (DataRow row in db.listAvailableRunsDB(start, end).Tables["hvk_runsAvail"].Rows)
            {
                runs.Add(convertToRun(row));
            }
            return(runs);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Check data before inserting into database
        /// </summary>
        public static int AddReservation(string firstName, string lastName, DateTime arrival, DateTime departure, int[] roomIds)
        {
            //Insert the reservation
            int idClient = ClientDB.AddClient(firstName, lastName);

            int idReservation = ReservationDB.AddReservation(arrival, departure, idClient);

            foreach (int roomId in roomIds)
            {
                ReservationDB.AddRoomReservation(idReservation, roomId);
            }

            return(idReservation);
        }
Exemplo n.º 11
0
        public static bool IsExistIsCorrect(string firstname, string lastname, int idReservation)
        {
            Reservation reservation = ReservationDB.GetReservation(idReservation);

            if (!reservation.Client.Firstname.Equals(firstname))
            {
                return(false);
            }

            if (!reservation.Client.Lastname.Equals(lastname))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        public static Reservation getReservation(int resNum)
        {
            ReservationDB db  = new ReservationDB();
            DataSet       ds  = db.getReservationDB(resNum);
            Reservation   res = fillReservationModified(ds)[0];

            ReservedService rs = new ReservedService();

            res.petReservationList.ForEach(delegate(PetReservation pres) {
                List <ReservedService> ser = rs.listReservedService(pres.petResNumber);
                if (ser.Count != 0)
                {
                    pres.serviceList = rs.listReservedService(pres.petResNumber);
                }
            });
            return(res);
        }
Exemplo n.º 13
0
        public static int cancelReservation(int reservationNumber)
        {
            Search search = new HawkeyehvkBLL.Search();

            // check reservation number
            if (!search.validateReservationNumber(reservationNumber))// check reservation number
            {
                return(1);
            }
            else if (isReservationActive(reservationNumber))
            {
                return(4);
            }
            else
            {
                return(ReservationDB.cancelReservationDB(reservationNumber));
            }
        }
Exemplo n.º 14
0
        public ReservationController()
        {
            //***instantiate the EmployeeDB object to communicate with the database
            reservationDB = new ReservationDB();
            reservations  = reservationDB.AllReservations;
            reservation   = new Reservation();

            reservedRooms = new bool[31, 5];
            for (int x = 0; x < 31; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    reservedRooms[x, y] = false;
                }
            }

            determineBookedRooms();
        }
Exemplo n.º 15
0
        public static int addToReservation(int reservationNumber, int petNumber)
        {
            ReservationDB db     = new ReservationDB();
            Search        search = new Search();

            try
            {
                if (!search.validatePetNumber(petNumber))
                {
                    return(-1);
                }
                else if (!search.validateReservationNumber(reservationNumber))
                {
                    return(-2);
                }
                else if (Search.validateOwnerForPet(reservationNumber, petNumber) < 0)
                {
                    return(-4);
                }
                else if (search.validateReservationForPet(petNumber, reservationNumber))
                {
                    return(-3);
                }


                // add discount if we are adding a third pet reservation
                int count = PetReservation.listPetRes(reservationNumber).Count;
                if (count == 2)
                {
                    Discount.addReservationDiscount(2, reservationNumber);
                }

                db.addToReservationDB(reservationNumber, petNumber);
                return(1);
            }
            catch
            {
                //Exception msg goes here
                return(-4);
            }
        }
Exemplo n.º 16
0
        public static List <Reservation> listReservations()
        {
            ReservationDB db = new ReservationDB();
            DataSet       ds = db.listResevationsDB();

            List <Reservation> reservationList = fillReservationModified(ds);

            ReservedService rs = new ReservedService();

            reservationList.ForEach(delegate(Reservation res) {
                res.petReservationList.ForEach(delegate(PetReservation pres) {
                    List <ReservedService> ser = rs.listReservedService(pres.petResNumber);
                    if (ser.Count != 0)
                    {
                        pres.serviceList = rs.listReservedService(pres.petResNumber);
                    }
                });
            });

            return(reservationList);
        }
Exemplo n.º 17
0
        public static int changeReservation(int reservationNumber, DateTime startDate, DateTime endDate)
        {
            Search search = new HawkeyehvkBLL.Search();

            if (!search.validateReservationNumber(reservationNumber))// check reservation number
            {
                return(1);
            }
            else if (startDate > endDate)     // check that dates are in a valid order
            {
                return(2);
            }
            List <Pet> pets      = Pet.listPetsByReservation(reservationNumber);
            int        largeDogs = 0;

            foreach (Pet pet in pets)
            {
                if (pet.size == 'L')
                {
                    largeDogs++;
                }
            }
            // check that there are available runs

            if (Run.checkRunAvailability(startDate, endDate, 'L') < largeDogs ||
                Run.checkRunAvailability(startDate, endDate, 'R') < pets.Count)
            {
                return(3);
            }
            // change the res dates
            try
            {
                ReservationDB db = new ReservationDB();
                db.changeReservationDB(reservationNumber, startDate, endDate);
            } catch
            {
                return(4);
            }
            return(0);
        }
Exemplo n.º 18
0
 // Appelle la requête qui permet d'ajouter une réservation à la table
 public static int AddReservation(DateTime dateReservation, string clientFirstname, string clientLastname, DateTime dateStart, DateTime dateEnd, decimal totalPrice)
 {
     return(ReservationDB.AddReservation(dateReservation, clientFirstname, clientLastname, dateStart, dateEnd, totalPrice));
 }
Exemplo n.º 19
0
 //SUpprime une réservation en fonction d'un id
 public static void DeleteReservationRoom(int IdReservation)
 {
     RoomReservationDB.DeleteReservationRoom(IdReservation);
     ReservationDB.DeleteReservation(IdReservation);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Return a reservation, selected with id
 /// </summary>
 public static Reservation GetReservation(int idReservation)
 {
     return(ReservationDB.GetReservation(idReservation));
 }
Exemplo n.º 21
0
 public VisualisationPage()
 {
     InitializeComponent();
     reservationDB = new ReservationDB();
     populate();
 }
Exemplo n.º 22
0
 //recupère une réservation en fonction du nom, de l'id de la reservation et du prenom
 public static Reservation GetReservationByIdName(int idReservation, String FirstName, String LastName)
 {
     return(ReservationDB.GetReservationByIdName(idReservation, FirstName, LastName));
 }
Exemplo n.º 23
0
 // Appelle la requête qui permet de supprimer une réservation de la table (en fonction de son identifiant en paramètre)
 public static void RemoveReservation(int idReservation)
 {
     ReservationDB.RemoveReservation(idReservation);
 }
Exemplo n.º 24
0
 public static bool CancelReservationFromId(int IdReservation)
 {
     return(ReservationDB.CancelReservationFromId(IdReservation));
 }
Exemplo n.º 25
0
 public static Reservation GetReservationsFromId(int idRes)
 {
     return(ReservationDB.GetReservationsFromId(idRes));
 }
Exemplo n.º 26
0
 public static List <Reservation> GetReservationsFromUserId(int idUser)
 {
     return(ReservationDB.GetReservationsFromUserId(idUser));
 }
Exemplo n.º 27
0
 public static int SaveReservation(Reservation reservation)
 {
     return(ReservationDB.SaveReservation(reservation));
 }
Exemplo n.º 28
0
 // Appelle la requête qui permet de vérifier l'existence d'une réservation dans la table
 public static Boolean LoginReservation(int idReservation, string firstname, string lastname)
 {
     return(ReservationDB.LoginReservation(idReservation, firstname, lastname));
 }
Exemplo n.º 29
0
 //recupère toutes les réservations
 public static List <Reservation> GetAllReservation()
 {
     return(ReservationDB.GetAllReservation());
 }