Ejemplo n.º 1
0
        protected void gvReservations_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "CancelReservation")
            {
                Customer    CustLoginID = (Customer)Session["login"];
                CustomerDAO CustomerDAO = new CustomerDAO(CustLoginID.CustomerId, CustLoginID.Password);

                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = gvReservations.Rows[index];
                CustomerDAO.CancelVehicleReservation(row.Cells[0].Text);

                //re populate grid view here
                ReservationDAO ReservationDAO = new ReservationDAO(CustLoginID.CustomerId, CustLoginID.Password);

                gvReservations.DataSource         = ReservationDAO.GetReservations();
                gvReservations.Columns[0].Visible = true;
                gvReservations.DataBind();
                gvReservations.Columns[0].Visible = false;
            }

            if (gvReservations.Rows.Count == 0)
            {
                lblNoReservations.Visible = true;
                gvReservations.Visible    = false;
            }
            else
            {
                lblNoReservations.Visible = false;
                gvReservations.Visible    = true;
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            /********************************************************************
             * // If you do not want to use CLIMenu, you can remove the following
             *********************************************************************/
            // Create any DAOs needed here, and then pass them into main menu...

            IParkDAO        parkDAO        = new ParkDAO(connectionString);
            ICampgroundDAO  campgroundDAO  = new CampgroundDAO(connectionString);
            IReservationDAO reservationDAO = new ReservationDAO(connectionString);
            ISiteDAO        siteDAO        = new SiteDAO(connectionString);


            MainMenu mainMenu = new MainMenu(parkDAO, campgroundDAO, reservationDAO, siteDAO);  // You'll probably be adding daos to the constructor

            // Run the menu.
            mainMenu.Run();
        }
Ejemplo n.º 3
0
 private void btnCheckCondition_Click(object sender, EventArgs e)
 {
     if (txtCopyNumber.Text != "")
     {
         if (CopyDAO.CheckCondition(int.Parse(txtCopyNumber.Text)) == 0)
         {
             MessageBox.Show("This book is available.");
             btnBorrow.Enabled = true;
         }
         else if (CopyDAO.CheckCondition(int.Parse(txtCopyNumber.Text)) == 2)
         {
             if (ReservationDAO.GetFirstReservation(CopyDAO.GetCopy(int.Parse(txtCopyNumber.Text)).BookNumber).MemberNumber
                 == int.Parse(txtMemberCode.Text))
             {
                 check = 1;
                 MessageBox.Show("This copy is available.");
                 btnBorrow.Enabled = true;
             }
             else
             {
                 MessageBox.Show("This copy is not available.");
             }
         }
         else
         {
             display(2);
             MessageBox.Show("Copy Number is invalid or This book is not available.");
         }
     }
     else
     {
         MessageBox.Show("Copy Code can not be blank.");
     }
 }
Ejemplo n.º 4
0
 public void Setup()
 {
     trans    = new TransactionScope();
     venueDAO = new VenueDAO(connectionString);
     spaceDAO = new SpacesDAO(connectionString);
     resDAO   = new ReservationDAO(connectionString);
 }
Ejemplo n.º 5
0
        public void CheckAvailability_Test()
        {
            // ARRANGE
            int      venue_id       = 267;
            int      numOfAttendees = 80;
            DateTime start_date     = new DateTime(2020, 10, 25);
            int      numOfDays      = 2;

            IReserveDAO reservation = new ReservationDAO(connectionString);
            bool        found       = false;

            // ACT
            IList <Reservation> reservations = reservation.CheckAvailability(venue_id, numOfAttendees, start_date, numOfDays);

            foreach (Reservation reserve in reservations)
            {
                if (reserve.space_id == 999)
                {
                    found = true;
                    break;
                }
            }

            // ASSERT
            Assert.IsTrue(found);
        }
Ejemplo n.º 6
0
        public void GetReservationsTests()
        {
            ReservationDAO      dao          = new ReservationDAO(connectionString); //arrange
            IList <Reservation> reservations = dao.GetReservations();                //act

            Assert.AreEqual(1, reservations.Count);                                  //assert
        }
Ejemplo n.º 7
0
        private void btnReturn_Click(object sender, EventArgs e)
        {
            CirculatedCopy cc = new CirculatedCopy();

            cc.CirculatedCopyId = Convert.ToInt32(dgvBorrowedBooks.Rows[rowIndex].Cells["circulatedCopyId"].Value);
            cc.ReturnedDate     = dtpReturnedDate.Value;
            cc.FineAmount       = double.Parse(txtFineAmount.Text);
            CirculatedCopyDAO.Update(cc);

            Copy c = CopyDAO.GetCopy(Convert.ToInt32(dgvBorrowedBooks.Rows[rowIndex].Cells["copyNumber"].Value));

            if (ReservationDAO.GetFirstReservation(c.BookNumber) != null)
            {
                c.Type = 2;
            }
            else
            {
                c.Type = 0;
            }
            CopyDAO.UpdateType(c);

            view(int.Parse(txtMemberCode.Text));
            MessageBox.Show("Return Successful.");
            btnReturn.Enabled      = false;
            txtFineAmount.Text     = "";
            btnConfirmFine.Enabled = false;
        }
Ejemplo n.º 8
0
 public UserInterface(string connectionString)
 {
     this.connectionString = connectionString;
     venueDAO = new VenueDAO(connectionString);
     spaceDAO = new SpacesDAO(connectionString);
     resDAO   = new ReservationDAO(connectionString);
 }
Ejemplo n.º 9
0
        // GET: Reservations/ReservationsList
        public ActionResult ReservationsList()
        {
            //implement reservationDAO to get list + datatables w edit and delete

            var list = ReservationDAO.GetReservations();

            return(View(list));
        }
Ejemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _reservationDAO = new ReservationDAO();
     if (!IsPostBack)
     {
         resInfo.Visible = false;
     }
 }
        private void MakeReservationInterface(Site site, string name, DateTime arrivalDate, DateTime departureDate)
        {
            ReservationDAO dao            = new ReservationDAO(_connectionString);
            int            confirmationId = dao.MakeReservation(site, name, arrivalDate, departureDate);

            Console.WriteLine($"The reservation has been made and the confirmation id is {confirmationId.ToString()}");
            Console.WriteLine($"Press any key to return to the previous screen...");
            Console.ReadKey();
        }
Ejemplo n.º 12
0
        public ActionResult Book(Reservations reservations)
        {
            ReservationDAO.Create(reservations);
            if (!ModelState.IsValid)
            {
                return(View("ReservationsList", reservations));
            }

            return(RedirectToAction("ReservationsList"));
        }
Ejemplo n.º 13
0
        public new ActionResult Profile()
        {
            string username = (string)Session["username"];

            ViewBag.borrower     = BorrowerDAO.GetBorrowerByUsername(username);
            ViewBag.reservations = ReservationDAO.GetReservationByUsername(username);
            ViewBag.reviews      = ReviewDAO.GetReviewByUsername(username);
            ViewBag.message      = "";
            return(View());
        }
Ejemplo n.º 14
0
        void start()
        {
            ReservationDAO reservationDAO = new ReservationDAO();

            foreach (Reservation reservation in reservationDAO.GetAll())
            {
                Console.WriteLine(reservation);
            }

            Console.ReadKey();
        }
Ejemplo n.º 15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _userDao        = new UserDao();
     _reservationDAO = new ReservationDAO();
     if (!IsPostBack)
     {
         ReservationGrid.DataSource = _reservationDAO.ReadAll(Status.Reserved);
         ReservationGrid.DataBind();
         Name.Text = _userDao.GetUserById(int.Parse(Context.User.Identity.Name)).FirstName;
     }
 }
Ejemplo n.º 16
0
        public void makeReservationTest()
        {
            string         Camp           = "Camp Blue";
            DateTime       StartDate      = new DateTime(2020, 1, 2);
            DateTime       EndDate        = new DateTime(2020, 1, 3);
            CampsiteDAO    campsiteDAO    = new CampsiteDAO(connectionString);
            IList <Site>   sites          = campsiteDAO.GetAvailableSitesOnCampground(Camp, StartDate, EndDate);
            ReservationDAO reservationDAO = new ReservationDAO(connectionString);
            int            confirmationNo = reservationDAO.makeReservation(sites[0], "John Brown", StartDate, EndDate);

            Assert.IsTrue(confirmationNo > newreservation_id);
        }
        private int MakingTheRes(string reservationName, int siteReserved, string arrivalDate, string departureDate)
        {
            Reservation newReservation = new Reservation();
            newReservation.Name = reservationName;
            newReservation.Site_Id = siteReserved;
            newReservation.From_Date = arrivalDate;
            newReservation.To_Date = departureDate;
            //newReservation.Create_Date = DateTime.Now.ToString();

            int confirmationNumber = ReservationDAO.MakeReservation(newReservation);

            return confirmationNumber;
        }
Ejemplo n.º 18
0
        public async Task <bool> Create(Reservation Reservation)
        {
            ReservationDAO ReservationDAO = new ReservationDAO();

            ReservationDAO.Id       = Reservation.Id;
            ReservationDAO.TableId  = Reservation.TableId;
            ReservationDAO.Date     = Reservation.Date;
            ReservationDAO.StatusId = Reservation.StatusId;
            DataContext.Reservation.Add(ReservationDAO);
            await DataContext.SaveChangesAsync();

            Reservation.Id = ReservationDAO.Id;
            return(true);
        }
Ejemplo n.º 19
0
        private void btnReserve_Click(object sender, EventArgs e)
        {
            Reservation r = new Reservation();

            r.MemberNumber = int.Parse(txtMemberCode.Text);
            r.BookNumber   = int.Parse(txtBookNumber.Text);
            r.Date         = dtpDate.Value;
            r.Status       = false;
            ReservationDAO.Insert(r);
            view(int.Parse(txtMemberCode.Text));
            txtBookNumber.Text    = "";
            txtBookNumber.Enabled = false;
            btnCRC.Enabled        = false;
            btnReserve.Enabled    = false;
        }
Ejemplo n.º 20
0
        //POST: api/Reservation
        public void Post([FromBody] JObject value)
        {
            DateTime startdate    = (DateTime)value.GetValue("reservation_startdate");
            DateTime enddate      = (DateTime)value.GetValue("reservation_enddate");
            bool     floating     = (bool)value.GetValue("reservation_floating");
            bool     confirmation = (bool)value.GetValue("reservation_confirmation");
            bool     paid         = (bool)value.GetValue("reservation_paid");
            DateTime date         = (DateTime)value.GetValue("reservation_date");
            int      nbAdulte     = (int)value.GetValue("reservation_nbAdulte");
            int      nbEnfant     = (int)value.GetValue("reservation_nbEnfant");
            bool     electricity  = (bool)value.GetValue("reservation_electricity");
            bool     car          = (bool)value.GetValue("reservation_car");

            ReservationDAO.add(new Reservation(startdate, enddate, floating, confirmation, paid, date, nbAdulte, nbEnfant, electricity, car));
        }
Ejemplo n.º 21
0
        public async Task <bool> Update(Reservation Reservation)
        {
            ReservationDAO ReservationDAO = DataContext.Reservation.Where(x => x.Id == Reservation.Id).FirstOrDefault();

            if (ReservationDAO == null)
            {
                return(false);
            }
            ReservationDAO.Id       = Reservation.Id;
            ReservationDAO.TableId  = Reservation.TableId;
            ReservationDAO.Date     = Reservation.Date;
            ReservationDAO.StatusId = Reservation.StatusId;
            await DataContext.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 22
0
        public ActionResult Transact(FormCollection form)
        {
            string   username   = form["username"];
            string   isbn       = form["isbn"];
            DateTime createdAt  = DateTime.Now;
            int      days       = int.Parse(form["renting-days"]);
            DateTime dueDate    = createdAt.AddDays(days);
            float    amount     = Utils.GetAmountBasedOnRentingDays()[days];
            bool     isInserted = ReservationDAO.InsertReservation(username, isbn, createdAt, dueDate, amount);

            if (isInserted)
            {
                ReservationDAO.IncreaseBookRentedCount(isbn);
                TempData["rentSuccess"] = true;
            }
            return(RedirectToAction("ViewBook", "ViewBook", new { isbn = isbn, rented = ViewBag.rentSuccess }));
        }
Ejemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FormsAuthenticationTicket cookie = FormsAuthentication.Decrypt(HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName].Value);

            _reservationDao            = new ReservationDAO();
            ReservationGrid.DataSource = _reservationDao.GetReservationsByUserId(int.Parse(cookie.Name));
            ReservationGrid.DataBind();
            _userDao = new UserDao();
            foreach (GridViewRow r in ReservationGrid.Rows)
            {
                if (_reservationDao.GetReservationByReservationId(r.Cells[1].Text).Status != Status.Reserved)
                {
                    r.Cells[0].Controls.Clear();
                }
                Name.Text = _userDao.GetUserById(int.Parse(Context.User.Identity.Name)).FirstName;
            }
        }
Ejemplo n.º 24
0
        public void AddReservationTests()
        {
            //Arrange, Act, Assert
            ReservationDAO dao = new ReservationDAO(connectionString);

            Reservation reservation = new Reservation()
            {
                SiteId     = newSiteId,
                Name       = "No-Name Family Reservation",
                FromDate   = DateTime.Today.AddDays(14),
                ToDate     = DateTime.Today.AddDays(21),
                CreateDate = DateTime.Today
            };

            int expectedResult = dao.AddReservation(reservation);

            Assert.AreEqual(newReservationId + 1, expectedResult);
        }
Ejemplo n.º 25
0
        public void MakeReservation_Test()
        {
            // ARRANGE
            IReserveDAO reservation = new ReservationDAO(connectionString);

            int      venue_id       = 267;
            int      numOfAttendees = 1;
            DateTime start_date     = new DateTime(2020, 10, 25);
            int      numOfDays      = 1;
            int      intUserSpaceID = 999;
            string   userName       = "******";

            // ACT
            int count = reservation.MakeReservation(venue_id, numOfAttendees, start_date, numOfDays, intUserSpaceID, userName);

            // ASSERT
            Assert.AreEqual(1, count);
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("NationalParksConnection");

            IParkDAO        parkDAO        = new ParkDAO(connectionString);
            IReservationDAO reservationDAO = new ReservationDAO(connectionString);
            ICampgroundDAO  campgroundDAO  = new CampgroundDAO(connectionString);

            NationalParkCLI application = new NationalParkCLI(parkDAO, reservationDAO, campgroundDAO);

            application.RunCLI();
        }
Ejemplo n.º 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _reservationDao = new ReservationDAO();
            for (int i = 0; i < 3; i++)
            {
                foreach (String itemName in _reservationDao.GetAvailableItems((Course)i))
                {
                    Item item = _reservationDao.GetItemByName(itemName);
                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Attributes.Add("class", "itemDiv");
                    HtmlGenericControl name = new HtmlGenericControl("p");
                    name.Attributes.Add("class", "item");
                    name.InnerText = item.Name;
                    HtmlGenericControl category = new HtmlGenericControl("p");
                    category.Attributes.Add("class", "category");
                    category.InnerText = item.Category.ToString();
                    HtmlGenericControl desc = new HtmlGenericControl("p");
                    desc.Attributes.Add("class", "desc");
                    desc.InnerText = item.Description;
                    div.Controls.Add(name);
                    div.Controls.Add(category);
                    div.Controls.Add(desc);
                    switch (i)
                    {
                    case 0:
                        appCont.Controls.Add(div);
                        break;

                    case 1:
                        mainCont.Controls.Add(div);
                        break;

                    case 2:
                        dessCont.Controls.Add(div);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Ejemplo n.º 28
0
        private void btnBorrow_Click(object sender, EventArgs e)
        {
            if (dtpBorrowed.Value < dtpDue.Value)
            {
                CirculatedCopy cc = new CirculatedCopy();
                cc.CopyNumber   = int.Parse(txtCopyNumber.Text);
                cc.MemberNumber = int.Parse(txtMemberCode.Text);
                cc.BorrowedDate = dtpBorrowed.Value;
                cc.DueDate      = dtpDue.Value;

                if (CirculatedCopyDAO.Add(cc))
                {
                    Copy c = CopyDAO.GetCopy(int.Parse(txtCopyNumber.Text));
                    c.Type = 1;
                    CopyDAO.UpdateType(c);
                    display(2);
                    view(int.Parse(txtMemberCode.Text));
                    MessageBox.Show("Add Successful.");

                    if (check == 1)
                    {
                        Reservation r = ReservationDAO.GetFirstReservation(c.BookNumber);
                        r.Status = true;
                        ReservationDAO.UpdateStatus(r);
                    }

                    if (dgvBorrowedBooks.Rows.Count >= 5)
                    {
                        display(0);
                        MessageBox.Show("The number of borrowed books is 5. You can not borrow anymore book.");
                    }
                }
                else
                {
                    MessageBox.Show("Error.");
                }
            }
            else
            {
                MessageBox.Show("Borrowed date has to be smaller than Due date.");
            }
        }
Ejemplo n.º 29
0
        public ActionResult Profile(FormCollection f)
        {
            string username = (string)Session["username"];
            string name     = f["fullname"];
            string email    = f["email"];
            double deposit  = Convert.ToDouble(f["deposit"]);

            if (BorrowerDAO.UpdateBorrower(name, username, email, deposit) > 0)
            {
                ViewBag.borrower     = BorrowerDAO.GetBorrowerByUsername(username);
                ViewBag.reservations = ReservationDAO.GetReservationByUsername(username);
                ViewBag.message      = "Update Successful!";
            }
            else
            {
                ViewBag.message = "Update Failed!";
            }

            return(View());
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            IParkDAO        parkDAO        = new ParkDAO(connectionString);
            ICampgroundDAO  campgroundDAO  = new CampgroundDAO(connectionString);
            ISiteDAO        siteDAO        = new SiteDAO(connectionString);
            IReservationDAO reservationDAO = new ReservationDAO(connectionString);

            MainMenuCLI menu = new MainMenuCLI(parkDAO, campgroundDAO, siteDAO, reservationDAO);

            menu.Run();
        }