protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Account re = (Account)Session["account"];
                this.drRegion.DataSource    = RegionDAO.getAllRegion();
                this.drRegion.DataTextField = "name";
                Area r = re.Areax;
                this.drRegion.DataValueField = "id";
                this.drRegion.SelectedValue  = r.ID.ToString();
                this.drRegion.DataBind();

                this.drSite.DataSource     = SiteDAO.getAllSite();
                this.drSite.DataTextField  = "name";
                this.drSite.DataValueField = "id";
                Model.Theart th = re.Thearts;
                this.drSite.SelectedValue = th.ID.ToString();
                this.drSite.DataBind();

                this.txtName.Text     = re.Name;
                this.txtPhone.Text    = re.Phone;
                this.txtEmail.Text    = re.Gmail;
                this.txtUsername.Text = re.UserName;
                this.txtPass.Text     = re.PassWord;
                this.txtNgaySinh.Text = re.DOB.ToString();
                if (re.Gender)
                {
                    this.rdMale.Checked = true;
                }
                else
                {
                    this.rdFemale.Checked = true;
                }
            }
        }
Esempio 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();
        }
        public void GetSitesTests()
        {
            SiteDAO      dao   = new SiteDAO(connectionString); //arrange
            IList <Site> sites = dao.GetSites();                //act

            Assert.AreEqual(4, sites.Count);                    //assert
        }
        public void SearchReservationTest_StartsBeforeEndsAfter_ReturnsNone()
        {
            //Arrange
            var     arriveDate = new DateTime(2020, 02, 20);
            var     departDate = new DateTime(2020, 02, 25);
            SiteDAO dao        = new SiteDAO(ConnectionString);
            //Act
            IList <Site> sites = dao.SearchReservation(CampGroundId, arriveDate, departDate);

            //Assert
            Assert.AreEqual(0, sites.Count);
        }
        public void SearchReservationTest_DatesAlreadyUsed_ReturnsNone()
        {
            //Arrange
            var     arriveDate = new DateTime(2015, 02, 21);
            var     departDate = new DateTime(2015, 02, 24);
            SiteDAO dao        = new SiteDAO(ConnectionString);
            //Act
            IList <Site> sites = dao.SearchReservation(CampGroundId, arriveDate, departDate);

            //Assert
            Assert.AreEqual(0, sites.Count);
        }
        public void SearchReservationTest_ReturnsListOfSites()
        {
            //Arrange
            var     arriveDate = new DateTime(2020, 08, 20);
            var     departDate = new DateTime(2020, 08, 24);
            SiteDAO dao        = new SiteDAO(ConnectionString);
            //Act
            IList <Site> sites = dao.SearchReservation(CampGroundId, arriveDate, departDate);

            //Assert
            Assert.AreEqual(1, sites.Count);
        }
        public void HasAvailableSitesTests()
        {
            SiteDAO dao = new SiteDAO(connectionString); //arrange

            //Site is available
            bool isAvailable = dao.HasAvailableSites(newCampgroundId, Convert.ToDateTime("2021/01/01"), Convert.ToDateTime("2021/05/01")); //act

            Assert.IsTrue(isAvailable);

            //No sites available
            isAvailable = dao.HasAvailableSites(newCampgroundId, DateTime.Now, DateTime.Now); //act
            Assert.IsTrue(isAvailable);
        }
        public void GetTop5AvailableSitesTests()
        {
            SiteDAO dao = new SiteDAO(connectionString); //arrange

            //Date conflict with 1 of 4 sites
            IList <Site> sites = dao.GetTop5AvailableSites(newCampgroundId, DateTime.Now, DateTime.Now); //act

            Assert.AreEqual(3, sites.Count);                                                             //assert

            //Fully available date
            sites = dao.GetTop5AvailableSites(newCampgroundId, Convert.ToDateTime("2021/01/01"), Convert.ToDateTime("2021/05/01")); //act
            Assert.AreEqual(4, sites.Count);                                                                                        //assert
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.drRegion.DataSource     = RegionDAO.getAllRegion();
                this.drRegion.DataTextField  = "name";
                this.drRegion.DataValueField = "id";
                this.drRegion.SelectedIndex  = 0;
                this.drRegion.DataBind();

                this.drSite.DataSource     = SiteDAO.getAllSite();
                this.drSite.DataTextField  = "name";
                this.drSite.DataValueField = "id";
                this.drSite.SelectedIndex  = 0;
                this.drSite.DataBind();
            }
        }
Esempio n. 10
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();
        }
 private int GetAvailableSites(int campgroundId, string arrivalDate, string departureDate, int park_id, int totalStay)
 {
     IList<Site> sites = SiteDAO.ReturnAvailableSites(campgroundId, arrivalDate, departureDate);
     IList<Campground> campgrounds = CampgroundDAO.GetCampgroundByParkId(park_id);
     decimal totalCost = 0;
     foreach (Campground campground in campgrounds)
     {
        totalCost = (decimal)(totalStay) * campground.Daily_Fee;
         
     }
     int sitesCount = sites.Count;
     if (sitesCount == 0)
     {
         return sitesCount;
     }
     Console.WriteLine(Site.GetHeader());
     foreach (Site site in sites)
     {
         
         Console.WriteLine($"{site}{totalCost:C}");
         
     }
     return sitesCount;
 }
        private void SearchForReservationInterface(Campground selectedCamp)
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("What is the arrival date? ");
                DateTime arrivalDate = CLIHelper.GetDateTime("Enter in year-month-day format.");

                Console.WriteLine("What is the departure date?");
                DateTime depatureDate = CLIHelper.GetDateTime("Enter in year-month-day format.");

                SiteDAO dao = new SiteDAO(_connectionString);
                try
                {
                    IList <Site> sites = dao.GetTop5Sites(selectedCamp, arrivalDate, depatureDate);



                    if (sites.Count > 0)
                    {
                        Console.Clear();

                        Console.WriteLine($"Results Matching Your Search Criteria");
                        Console.WriteLine("Site No.".PadRight(15) + "Max Occup.".PadRight(15) +
                                          "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) +
                                          "Utility".PadRight(15) + "Cost");

                        Dictionary <int, Site> siteDict = new Dictionary <int, Site>();
                        int siteCount = 0;


                        foreach (Site s in sites)
                        {
                            Console.WriteLine($"{++siteCount}) " +
                                              $"{s.SiteNumber.ToString().PadRight(15)}" +
                                              $"{s.MaxOccupancy.ToString().PadRight(15)}" +
                                              $"{s.AccessibleString.PadRight(15)}" +
                                              $"{s.MaxRVString.PadRight(15)}" +
                                              $"{s.UtilitiesString.PadRight(15)}" +
                                              $"{selectedCamp.DailyFee.ToString("C")}");


                            siteDict.Add(siteCount, s);
                        }
                        Console.WriteLine();
                        int selection = CLIHelper.GetSingleInteger("Which site should be reserved(enter 0 to cancel) ", 0, sites.Count);
                        Console.WriteLine();

                        if (selection == 0)
                        {
                            exit = true;
                        }
                        else
                        {
                            //ReservationDAO  = new ReservationDAO(_connectionString);
                            string name = CLIHelper.GetString("What name should the reservation be made under? ");
                            MakeReservationInterface(siteDict[selection], name, arrivalDate, depatureDate);
                            exit = true;
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("****** NO RESULTS ******");
                        Console.WriteLine("");
                        Console.ReadKey();
                        exit = true;
                    }
                }
                catch
                {
                    Console.Clear();
                    Console.WriteLine("Something went wrong with the Dates you entered... try again.");
                }
            }
        }
        private void SearchForReservationInterface(Campground selectedCamp)
        {
            bool     exit = false;
            SiteDAO  dao  = new SiteDAO(_connectionString);
            DateTime arrivalDate;
            DateTime depatureDate;

            while (!exit)
            {
                try
                {
                    Console.WriteLine("What is the arrival date? yyyy-mm-dd ");
                    arrivalDate = Convert.ToDateTime(Console.ReadLine());

                    Console.WriteLine("What is the departure date? yyyy-mm-dd");
                    depatureDate = Convert.ToDateTime(Console.ReadLine());

                    if (depatureDate > arrivalDate && (depatureDate - arrivalDate).TotalDays > 0 && arrivalDate > DateTime.Today)
                    {
                        IList <Site> sites = dao.GetTop5Sites(selectedCamp.CampgroundId, arrivalDate, depatureDate);


                        Console.Clear();

                        Console.WriteLine($"Results Matching Your Search Criteria");
                        Console.WriteLine("Site No.".PadRight(15) + "Max Occup.".PadRight(15) +
                                          "Accessible?".PadRight(15) + "Max RV Length".PadRight(15) +
                                          "Utility".PadRight(15) + "Cost");

                        Dictionary <int, Site> siteDict = new Dictionary <int, Site>();
                        int siteCount = 0;

                        foreach (Site s in sites)
                        {
                            Console.WriteLine($"{++siteCount}) " +
                                              $"{s.SiteNumber.ToString().PadRight(15)}" +
                                              $"{s.MaxOccupancy.ToString().PadRight(15)}" +
                                              $"{s.AccessibleString.PadRight(15)}" +
                                              $"{s.MaxRVString.PadRight(15)}" +
                                              $"{s.UtilitiesString.PadRight(15)}" +
                                              $"{(selectedCamp.DailyFee * (decimal)(depatureDate - arrivalDate).TotalDays).ToString("C")}");


                            siteDict.Add(siteCount, s);
                        }
                        Console.WriteLine();
                        int selection = CLIHelper.GetSingleInteger("Which site should be reserved(enter 0 to cancel) ", 0, sites.Count);
                        Console.WriteLine();

                        if (selection != 0)
                        {
                            //ReservationDAO  = new ReservationDAO(_connectionString);
                            string name = CLIHelper.GetString("What name should the reservation be made under? ");
                            MakeReservationInterface(siteDict[selection], name, arrivalDate, depatureDate);
                        }
                        exit = true;
                    }
                    else
                    {
                        NoResults(exit);
                    }
                }
                catch
                {
                    Console.WriteLine("Something went wrong with the Dates or Name you entered... try again.");
                }
            }
        }
Esempio n. 14
0
 public AccessRightsManagementService(string context)
 {
     _cooperatorDAO = new CooperatorDAO(context);
     _siteDAO       = new SiteDAO(context);
 }