コード例 #1
0
        public static void writeToFileReservation(ReservationManager rm)
        {
            int         numResos = rm.getNumReservations();
            Reservation temp;
            string      fileName = "reservationData.txt";
            string      path     = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), @"Data\", fileName);

            StreamWriter sw = new StreamWriter(path);

            sw.WriteLine(numResos);
            for (int x = 0; x < numResos; x++)
            {
                temp = rm.getReservationAtPosition(x);
                sw.WriteLine(temp.getID());
                sw.WriteLine(temp.getDate());
                sw.WriteLine(temp.getEvent().getEventId());
                sw.WriteLine(temp.getEvent().getEventName());
                sw.WriteLine(temp.getEvent().getVenue());
                sw.WriteLine(temp.getEvent().getEventDate().getDay());
                sw.WriteLine(temp.getEvent().getEventDate().getMonth());
                sw.WriteLine(temp.getEvent().getEventDate().getYear());
                sw.WriteLine(temp.getEvent().getEventDate().getHour());
                sw.WriteLine(temp.getEvent().getEventDate().getMinute());
                sw.WriteLine(temp.getEvent().getMaxAttendees());
                sw.WriteLine(temp.getCustomer().getId());
                sw.WriteLine(temp.getCustomer().getFirstName());
                sw.WriteLine(temp.getCustomer().getLastName());
                sw.WriteLine(temp.getCustomer().getPhone());
                sw.WriteLine(temp.getCustomer().getNumBookings());
            }
            sw.Flush();
            sw.Close();
        }
コード例 #2
0
 private void MainMenuScreen_Load(object sender, EventArgs e)
 {
     eventMan   = FileUtilities.loadFromFileEvent();
     custMan    = FileUtilities.loadFromFileCustomer();
     resMan     = FileUtilities.loadFromFileReservation();
     eventCoord = new EventCoordinator(custMan, eventMan, resMan);
 }
コード例 #3
0
        //event coordinator is created by taking already created managers
        public static EventCoordinator loadFromFilesCoordinator()
        {
            CustomerManager    custMan    = FileUtilities.loadFromFileCustomer();
            EventManager       eventMan   = FileUtilities.loadFromFileEvent();
            ReservationManager resMan     = FileUtilities.loadFromFileReservation();
            EventCoordinator   eventCoord = new EventCoordinator(custMan, eventMan, resMan);

            return(eventCoord);
        }
コード例 #4
0
        public static ReservationManager loadFromFileReservation()
        {
            ReservationManager rm = new ReservationManager(500, 100);
            int          numResos, resoId, eventDay, eventMonth, eventYear, eventHour, eventMinute, eventMaxAttendees, eventId, custId, custBookings;
            string       eventName, eventVenue, resDate, custFName, custLName, custPhone;
            Date         eventDate;
            StreamReader sr;

            string fileName = "reservationData.txt";
            string path     = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), @"Data\", fileName);

            if (File.Exists(path))
            {
                sr = new StreamReader(path);
            }
            else
            {
                return(rm);
            }

            if (sr.ReadLine() == null)
            {
                StreamWriter sw = new StreamWriter(path);
                sw.WriteLine("0");
            }

            sr.DiscardBufferedData();
            sr.BaseStream.Position = 0;
            numResos = Convert.ToInt32(sr.ReadLine());
            for (int x = 0; x < numResos; x++)
            {
                resoId            = Convert.ToInt32(sr.ReadLine());
                resDate           = sr.ReadLine();
                eventId           = Convert.ToInt32(sr.ReadLine());
                eventName         = sr.ReadLine();
                eventVenue        = sr.ReadLine();
                eventDay          = Convert.ToInt32(sr.ReadLine());
                eventMonth        = Convert.ToInt32(sr.ReadLine());
                eventYear         = Convert.ToInt32(sr.ReadLine());
                eventHour         = Convert.ToInt32(sr.ReadLine());
                eventMinute       = Convert.ToInt32(sr.ReadLine());
                eventDate         = new Date(eventDay, eventMonth, eventYear, eventHour, eventMinute);
                eventMaxAttendees = Convert.ToInt32(sr.ReadLine());
                custId            = Convert.ToInt32(sr.ReadLine());
                custFName         = sr.ReadLine();
                custLName         = sr.ReadLine();
                custPhone         = sr.ReadLine();
                custBookings      = Convert.ToInt32(sr.ReadLine());
                Event    resEvent    = new Event(eventId, eventName, eventVenue, eventDate, eventMaxAttendees);
                Customer resCustomer = new Customer(custId, custFName, custLName, custPhone, custBookings);
                rm.addReservation(resoId, resDate, resEvent, resCustomer);
            }
            sr.Close();
            return(rm);
        }
コード例 #5
0
 public EventCoordinator(int custIdSeed, int maxCust, int eventIdSeed, int maxEvents, int resIdSeed, int maxRes)
 {
     custMan  = new CustomerManager(custIdSeed, maxCust);
     eventMan = new EventManager(eventIdSeed, maxEvents);
     resMan   = new ReservationManager(resIdSeed, maxRes);
 }
コード例 #6
0
 public EventCoordinator(CustomerManager custMan, EventManager eventMan, ReservationManager resMan)
 {
     this.custMan  = custMan;
     this.eventMan = eventMan;
     this.resMan   = resMan;
 }
コード例 #7
0
 public EventCoordinator(CustomerManager custMan, int eventIdSeed, int maxEvents, int resIdSeed, int maxRes)
 {
     this.custMan  = custMan;
     this.eventMan = new EventManager(eventIdSeed, maxEvents);
     this.resMan   = new ReservationManager(resIdSeed, maxRes);
 }