Beispiel #1
0
        public MainViewModel()
        {
            Database = new AdminDatabase();
            _editModeEnabled = false;
            SelectorViewModel selectorViewModel = new SelectorViewModel(this);

            TabbedView = selectorViewModel;

            //This might need to move so I put it in a region to define it
            #region database_creation
            //the variable that holds the filename from the UI
            //string inputFileName;
            /* get the Path */
            //this gets the directory portion of the file and puts the database file in the server executable location
            //string directoryName = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            //combines the filename with the path
            //string fileName = System.IO.Path.Combine(directoryName, inputFileName);
            //* check if the file exists this isn't needed atm, but we might need it later*/
            //if (File.Exists(fileName))
            //{
            //    File.Delete(fileName);
            //}
            //This is the database creation call.
            //It takes the directory concattonated with the filename as the input
            //Database.CreateNewDatabase(fileName);
            #endregion
        }
        /// <summary>
        /// Initializes a new instance of the FamilyViewModel class.
        /// </summary>
        public FamilyViewModel(SelectorViewModel parent)
        {
            _familyTable = new DataTable();
            _familyTable.Columns.Add("Family ID", typeof (int));
            _familyTable.Columns.Add("Assigned Time", typeof(DateTime));
            _familyTable.Columns.Add("Check In Time", typeof(DateTime));
            _familyTable.Columns.Add("Employee Performing Checkin", typeof(String));
            _familyTable.Columns.Add("No Show?", typeof(Boolean));
            _familyTable.Columns.Add("Notes", typeof(String));

            families = parent.Database.GetFamilies();

            foreach (Family family in families)
            {
                _familyTable.Rows.Add(family.FamilyNumber, family.AssignedTime, family.CheckinTime, family.EmployeeAssignedBy, family.NoShow, family.Notes);
            }

            _personTable = new DataTable();
            _personTable.Columns.Add("Family ID", typeof(int));
            _personTable.Columns.Add("First Name", typeof(String));
            _personTable.Columns.Add("Last Name", typeof(String));
            _personTable.Columns.Add("Type", typeof(PersonType));
            _personTable.Columns.Add("Weight", typeof(Double));
            _personTable.Columns.Add("Notes", typeof(String));

            _famSelectedIndex = 0;

            UpdatePersonTable();
        }
        /// <summary>
        /// Initializes a new instance of the PilotViewModel class.
        /// </summary>
        public PilotViewModel(SelectorViewModel parent)
        {
            _table = new DataTable("Pilot Table");
            _table.Columns.Add("Last Name", typeof(string));
            _table.Columns.Add("First Name", typeof(string));
            _table.Columns.Add("Craft ID", typeof(int));
            _table.Columns.Add("Notes", typeof(string));

            List<Pilot> pilots = parent.Database.GetPilots();

            foreach(Pilot pilot in pilots)
            {
                _table.Rows.Add(pilot.LastName, pilot.FirstName, pilot.CraftId, pilot.Notes);
            }
        }
        /// <summary>
        /// Initializes a new instance of the FlightsViewModel class.
        /// </summary>
        public FlightsViewModel(SelectorViewModel parent)
        {
            _parent = parent;

            _table = new DataTable("Flights Table");
            _table.Columns.Add("Flight Number", typeof(int));
            _table.Columns.Add("Family ID", typeof(int));
            _table.Columns.Add("CraftID", typeof(int));
            _table.Columns.Add("Departure Time", typeof(DateTime));
            _table.Columns.Add("Max Weight", typeof(double));
            _table.Columns.Add("Available Seats", typeof(int));
            _table.Columns.Add("Pilot Check-in Time", typeof(DateTime));
            _table.Columns.Add("Notes", typeof(String));

            List<Flight> flights = parent.Database.GetFlights();

            foreach (Flight flight in flights)
            {
                _table.Rows.Add(flight.FlightNumber, flight.FamilyId, flight.CraftId, flight.DepartureTime,
                    flight.MaxWeight, flight.NumberOfSeats, flight.CheckInTime, flight.Notes);
            }
        }