public void UpdateTable()
        {
            reservationTable.Clear();
            reservationTable = DBFacade.GetReservations();

            for (int i = 0; i < reservationTable.Rows.Count; i++)
            {
                Guid ID = Guid.Parse(reservationTable.Rows[i]["ID"].ToString());

                Guid   flightID = Guid.Parse(reservationTable.Rows[i]["FlightID"].ToString());
                Flight flight   = ServiceFactory.GetFlights().GetFlightByID(flightID);

                Guid      passengerID = Guid.Parse(reservationTable.Rows[i]["PassengerID"].ToString());
                Passenger passenger   = ServiceFactory.GetPassengers().GetPassengerByID(passengerID);

                Guid  staffID = Guid.Parse(reservationTable.Rows[i]["StaffID"].ToString());
                Staff staff   = ServiceFactory.GetStaffs().GetStaffByID(staffID);

                DateTime reservationTime = DateTime.Parse(reservationTable.Rows[i]["ReservationTime"].ToString());

                String cancelTimeStr           = reservationTable.Rows[i]["cancelTime"].ToString();
                Nullable <DateTime> cancelTime = null;
                if (!cancelTimeStr.Equals(""))
                {
                    cancelTime = DateTime.Parse(cancelTimeStr);
                }

                uint seatNumber = uint.Parse(reservationTable.Rows[i]["SeatNumber"].ToString());

                ReservationState state = Utilities.StringToReservationState(reservationTable.Rows[i]["State"].ToString());


                reservations.Add(new Reservation(ID, flight, passenger, staff, seatNumber, reservationTime, state, cancelTime));
            }
        }
        public void UpdateFlight(Guid flightID, FlightState newState, Nullable <DateTime> newActualDepartureDate, Nullable <DateTime> newActualArrivalDate)
        {
            Flight f = ServiceFactory.GetFlights().GetFlightByID(flightID);

            f.flightState         = newState;
            f.actualArrivalDate   = newActualArrivalDate;
            f.actualDepartureDate = newActualDepartureDate;

            DBFacade.UpdateFlight(flightID, newState.ToString(), newActualDepartureDate, newActualArrivalDate);
            MessageBox.Show(" بروزرسانی با موفقیت اضافه شد");
        }
        public void AddAirplane(String name, Guid companyID, uint capacity)
        {
            Airplane airplane = new Airplane(name, capacity);

            ServiceFactory.GetAirplanes().AddAirplane(airplane);

            Guid airplaneID = DBFacade.InsertAirplaneAndReturnID(name, companyID, capacity);

            airplane.ID = airplaneID;
            MessageBox.Show("هواپیما با موفقیت اضافه شد");
        }
        public void AddAirport(String name, Location location)
        {
            Airport airport = new Airport(name, location);

            ServiceFactory.GetAirports().AddAirport(airport);

            Guid airportID = DBFacade.InsertAirportAndReturnID(name, location);

            airport.SetID(airportID);
            MessageBox.Show("فرودگاه با موفقیت اضافه شد");
        }
        public void AddCompany(String name)
        {
            Company company = new Company(name);

            ServiceFactory.GetCompanies().AddCompany(company);

            Guid companyID = DBFacade.InsertCompanyAndReturnID(name);

            company.SetID(companyID);
            MessageBox.Show("شرکت با موفقیت اضافه شد");
        }
        private Passenger CreateAndInsertPassenger(String fName, String lName, uint age, Gender gender, String nationalCode)
        {
            Passenger passenger = new Passenger(fName, lName, age, gender, nationalCode);

            ServiceFactory.GetPassengers().AddPassenger(passenger);

            Guid passengerID = DBFacade.InsertPassengerAndReturnID(fName, lName, age, gender.ToString(), nationalCode);

            passenger.SetID(passengerID);

            return(passenger);
        }
Exemple #7
0
        public void UpdateTable()
        {
            companies.Clear();

            companyTable = DBFacade.GetCompanies();

            for (int i = 0; i < companyTable.Rows.Count; i++)
            {
                Guid   ID   = Guid.Parse(companyTable.Rows[i]["ID"].ToString());
                String name = companyTable.Rows[i]["Name"].ToString();
                companies.Add(new Company(ID, name));
            }
        }
        public void UpdateTable()
        {
            staffTable.Clear();
            staffTable = DBFacade.GetStaffs();
            for (int i = 0; i < staffTable.Rows.Count; i++)
            {
                Guid   ID    = Guid.Parse(staffTable.Rows[i]["ID"].ToString());
                String fName = staffTable.Rows[i]["FirstName"].ToString();
                String lName = staffTable.Rows[i]["LastName"].ToString();
                Rank   rank  = Utilities.StringToRank(staffTable.Rows[i]["Rank"].ToString());

                staffs.Add(Utilities.CreateStaff(rank, fName, lName, ID));
            }
        }
        public void UpdateTable()
        {
            planeTable.Clear();

            planeTable = DBFacade.GetAirplanes();
            for (int i = 0; i < planeTable.Rows.Count; i++)
            {
                Guid   ID       = Guid.Parse(planeTable.Rows[i]["ID"].ToString());
                uint   capacity = uint.Parse(planeTable.Rows[i]["capacity"].ToString());
                String name     = planeTable.Rows[i]["name"].ToString();

                planes.Add(new Airplane(ID, name, capacity));
            }
        }
        public void UpdateTable()
        {
            flightTable.Clear();
            flightTable = DBFacade.GetFlights();

            AllAirplanes allPlanes   = ServiceFactory.GetAirplanes();
            AllAirports  allAirports = ServiceFactory.GetAirports();

            for (int i = 0; i < flightTable.Rows.Count; i++)
            {
                Guid ID = Guid.Parse(flightTable.Rows[i]["ID"].ToString());

                Guid     planeID  = Guid.Parse(flightTable.Rows[i]["planeID"].ToString());
                Airplane airplane = allPlanes.GetPlaneByID(planeID);

                Guid    originID = Guid.Parse(flightTable.Rows[i]["originAirportID"].ToString());
                Airport origin   = allAirports.GetAirportByID(originID);

                Guid    destinationID = Guid.Parse(flightTable.Rows[i]["destinationAirportID"].ToString());
                Airport destination   = allAirports.GetAirportByID(destinationID);

                DateTime arrivalDate   = DateTime.Parse(flightTable.Rows[i]["arrivalDate"].ToString());
                DateTime departureDate = DateTime.Parse(flightTable.Rows[i]["departureDate"].ToString());

                String actualArrivalDateStr           = flightTable.Rows[i]["actualArrivalDate"].ToString();
                Nullable <DateTime> actualArrivalDate = null;
                if (!actualArrivalDateStr.Equals(""))
                {
                    actualArrivalDate = DateTime.Parse(actualArrivalDateStr);
                }



                String actualDepartureDateStr           = flightTable.Rows[i]["actualDepartureDate"].ToString();
                Nullable <DateTime> actualDepartureDate = null;
                if (!actualDepartureDateStr.Equals(""))
                {
                    actualDepartureDate = DateTime.Parse(actualDepartureDateStr);
                }


                String      flightStateStr = flightTable.Rows[i]["State"].ToString();
                FlightState flightState    = Utilities.StringToFlightState(flightStateStr);

                uint cost = uint.Parse(flightTable.Rows[i]["Cost"].ToString());

                flights.Add(new Flight(ID, airplane, origin, destination, departureDate, arrivalDate, actualDepartureDate, actualArrivalDate, flightState, cost));
            }
        }
        public void AddFlight(Guid planeID, Guid originAirportID, Guid destinationAirportID, DateTime departureDate, DateTime arrivalDate, uint cost)
        {
            Airport origin      = ServiceFactory.GetAirports().GetAirportByID(originAirportID);
            Airport destination = ServiceFactory.GetAirports().GetAirportByID(destinationAirportID);

            Airplane plane = ServiceFactory.GetAirplanes().GetPlaneByID(planeID);

            Flight flight = new Flight(plane, origin, destination, departureDate, arrivalDate, cost);

            ServiceFactory.GetFlights().AddFlight(flight);

            Guid flightID = DBFacade.InsertFlightAndReturnID(planeID, originAirportID, destinationAirportID, departureDate, arrivalDate, cost);

            flight.SetID(flightID);
            MessageBox.Show("پرواز با موفقیت اضافه شد");
        }
Exemple #12
0
        public void UpdateTable()
        {
            passengers.Clear();
            passengerTable = DBFacade.GetPassengers();
            for (int i = 0; i < passengerTable.Rows.Count; i++)
            {
                Guid   ID           = Guid.Parse(passengerTable.Rows[i]["ID"].ToString());
                string fName        = passengerTable.Rows[i]["FirstName"].ToString();
                string lName        = passengerTable.Rows[i]["LastName"].ToString();
                uint   age          = uint.Parse(passengerTable.Rows[i]["Age"].ToString());
                Gender gender       = Utilities.StringToGender(passengerTable.Rows[i]["Gender"].ToString());
                string nationalCode = passengerTable.Rows[i]["NationalCode"].ToString();

                passengers.Add(new Passenger(ID, fName, lName, age, gender, nationalCode));
            }
        }
        public void UpdateTable()
        {
            airports.Clear();
            airpotTable = DBFacade.GetAirports();
            for (int i = 0; i < airpotTable.Rows.Count; i++)
            {
                Guid ID = Guid.Parse(airpotTable.Rows[i]["ID"].ToString());

                String name = airpotTable.Rows[i]["name"].ToString();

                String   country  = airpotTable.Rows[i]["country"].ToString();
                String   city     = airpotTable.Rows[i]["city"].ToString();
                Location location = new Location(country, city);

                airports.Add(new Airport(ID, name, location));
            }
        }
        public void AddStaff(String username, String password, String fName, String lName, Rank rank)
        {
            Staff staff = Utilities.CreateStaff(rank, fName, lName);

            ServiceFactory.GetStaffs().AddStaff(staff);

            Nullable <Guid> staffID = DBFacade.InsertNewUserAndReturnStaffID(username, password, fName, lName, rank.ToString());

            if (staffID != null)
            {
                staff.SetID((Guid)staffID);
                MessageBox.Show("کاربر با موفقیت اضافه شد");
            }
            else
            {
                MessageBox.Show("خطا در ثبت");
            }
        }
        private void CreateAndInsertReservation(Flight flight, Passenger passenger, Staff salesman, uint seatNumber)
        {
            //TODO: I must set time to time inserted in DB
            Reservation reservation = new Reservation(flight, passenger, salesman, seatNumber, new DateTime(), ReservationState.Resereved, null);

            ServiceFactory.GetReservations().AddReservation(reservation);

            Nullable <Guid> reservationID = DBFacade.InsertReservationAndReturnID(flight.GetID(), passenger.GetID(), currentStaff.GetID(), seatNumber);

            if (reservationID != null)
            {
                reservation.SetID((Guid)reservationID);
                MessageBox.Show("رزرو با موافقیت انجام شد");
            }
            else
            {
                MessageBox.Show("خطا در رزرو");
            }
        }
        public List <bool> GetSeatsFlag(Guid flightID)
        {
            Flight f = ServiceFactory.GetFlights().GetFlightByID(flightID);

            uint        flightCapacity = f.airplane.capacity;
            List <uint> freeSeats      = DBFacade.GetFreeSeats(flightID);

            List <bool> seatsFlag = new List <bool>((int)flightCapacity);

            for (int i = 0; i < flightCapacity; ++i)
            {
                seatsFlag.Add(false);
                foreach (uint j in freeSeats)
                {
                    if (j == i + 1)
                    {
                        seatsFlag[i] = true;
                        break;
                    }
                }
            }

            return(seatsFlag);
        }
        public void CancelReservation(Guid reservationID)
        {
            //ServiceFactory.GetReserations().RemoveReservationByID(reservationID);

            DBFacade.CancelReservation(reservationID);
        }
 public bool IsUserValid(String username, String password)
 {
     return(DBFacade.IsUserValid(username, password));
 }
 private void CreateAndSetStaff(String username)
 {
     currentStaff = DBFacade.GetStaffByUsername(username);
 }