public void RemoveBoat(BoatReservation b)
    {
        switch (b.ReservationBoatType)
        {
        case BoatType.Kayak:
            if (RegularSlots.Contains(b))
            {
                RegularSlots.Remove(b);
            }
            break;

        case BoatType.Canoe:
            if (RegularSlots.Contains(b))
            {
                RegularSlots.Remove(b);
            }
            else
            {
                if (CanoeSlots.Contains(b))
                {
                    CanoeSlots.Remove(b);
                    if (RegularSlots.Where(fb => fb.ReservationBoatType == BoatType.Canoe).Count() > 0)
                    {
                        //Move Reservation From Regular to Canoe Only With Opening
                        BoatReservation mv = RegularSlots.FindLast(fb => fb.ReservationBoatType == BoatType.Canoe);
                        RegularSlots.Remove(mv);
                        CanoeSlots.Add(mv);
                    }
                }
            }
            break;
        }
    }
        public bool UpdateCheckingStatus(BoatReservation BoatReservation)
        {
            if (BoatReservation.PresentlyChekdin)
            {// participant is already inside the  lake.
                return(false);
            }

            MySqlCommand command = new MySqlCommand("UPDATE BOATRESERVATION SET PRESENTLYCHECKEDIN = 'YES' WHERE EVENTID = " + BoatReservation.EventID, connection);

            try
            {
                connection.Open();
                command.ExecuteNonQuery();
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Error Occured.");
            }
            finally
            {
                connection.Close();
            }

            return(true);
        }
Пример #3
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            if (RFIDTagNr != null)
            {
                lbChekingStatus.Text = "";
                lbReservStatus.Text  = "";
                lbRFIDStatus.Text    = "";

                Visitor visitor = GetVisitor(RFIDTagNr);

                if (visitor != null)
                {// retrieved visitor details
                    BoatReservation reserv = GetAReservation(visitor);
                    if (reserv != null)
                    {     // reservation found for this participant
                        if (UpdateStatus(reserv))
                        { // participant has checked in
                            lbChekingStatus.Text = "CheckedIn.";
                        }
                        else
                        {
                            lbChekingStatus.Text = "The visitor is already checked into lake.";
                        }
                    }
                    else
                    {
                        lbReservStatus.Text = "No reservation found ";
                    }
                }
                else
                {
                    lbReservStatus.Text = "visitor is not found in the database.";
                }
            }
        }
        public BoatReservation GetReservation(int EventID, int BoatID)
        {
            MySqlCommand    command         = new MySqlCommand("SELECT * FROM BOATRESERVATION WHERE EVENTID = " + EventID + " AND BOATID = " + BoatID + "", connection);
            BoatReservation BoatReservation = null;

            try
            {
                connection.Open();
                MySqlDataReader r = command.ExecuteReader();

                bool x = r.Read();

                if (r["EVENTID"] == DBNull.Value)
                {
                    EventID = 0; // the participant doesn't have a reservation.
                }
                else
                {
                    EventID = Convert.ToInt32(r["EVENTID"]);
                }

                if (r["BOATID"] == DBNull.Value) // DBNull.Value for (null) values
                {
                    BoatID = 0;                  // the participant doesn't have a reservation.
                }
                else
                {
                    BoatID = Convert.ToInt32(r["BOATID"]);
                }

                bool CurrentlyCheckedIn;
                if (r["PRESENTLYCHECKEDIN"].ToString() == "YES")
                {
                    CurrentlyCheckedIn = true;
                }
                else
                {
                    CurrentlyCheckedIn = false;
                }

                return(BoatReservation = new BoatReservation(EventID, BoatID, CurrentlyCheckedIn)); // reservation found.
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            finally
            {
                connection.Close();
            }

            return(BoatReservation); // no reservation
        }
    public bool AddBoat(BoatReservation b)
    {
        bool boatAdded = false;

        switch (b.ReservationBoatType)
        {
        case BoatType.Canoe:
            if (CanoeSlots.Count() < 4)
            {
                CanoeSlots.Add(b);
                boatAdded = true;
            }
            else
            {
                var reg = RegularSlots.Sum(x => Convert.ToInt16(x.ReservationBoatType));
                if (reg <= 10)
                {
                    RegularSlots.Add(b);
                    boatAdded = true;
                }
            }
            break;

        case BoatType.Kayak:
        {
            var reg = RegularSlots.Sum(x => Convert.ToInt16(x.ReservationBoatType));
            if (reg <= 11)
            {
                RegularSlots.Add(b);
                boatAdded = true;
            }
        }
        break;
        }

        return(boatAdded);
    }
Пример #6
0
        private bool UpdateStatus(BoatReservation reserv)
        {
            BoatReservation_DH reservData = new BoatReservation_DH();

            return(reservData.UpdateCheckingStatus(reserv));
        }