internal LoggedInAirlineFacade(LoginToken <AirlineCompany> token) { LoginToken = token; _ticketDAO = new TicketDAO(); _flightDAO = new FlightDAO(); _airlineDAO = new AirlineDAO(); }
internal AnonymousUserFacade() { LoginToken = null; _airlineDAO = new AirlineDAO(); _flightDAO = new FlightDAO(); _countryDAO = new CountryDAO(); }
private new void InitializeComponent() { panel.Controls.Add(panelChild); panel.Dock = DockStyle.Right; panel.Padding = new Padding(40, 0, 0, 20); panel.BackColor = colors.White1; // DAO AirlineDAO airlineDAO = new AirlineDAO(Enums.Server.MariaDB); BindingSource bindingSource = new BindingSource { DataSource = airlineDAO.GetAllAirlines() }; DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle2.BackColor = colors.White1; dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black; dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.WhiteSmoke; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black; dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; // main controls AddElement(new FlatLabelTitle("Airlines", 0, 0)); AddElement(new FlatButton("Create Airline")); panelChild.Controls[1].Click += new EventHandler(GoToCreate); panelChild.Controls[1].Width = 200; AddElement(new DataGridView { Name = "dgvAirlines", DataSource = bindingSource, Width = 975, ForeColor = colors.Black1, DefaultCellStyle = dataGridViewCellStyle2, ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2, RowsDefaultCellStyle = dataGridViewCellStyle2, RowHeadersDefaultCellStyle = dataGridViewCellStyle2, AllowUserToAddRows = false, AllowUserToDeleteRows = false, AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells, AutoSize = true, BackgroundColor = colors.White1, BorderStyle = System.Windows.Forms.BorderStyle.None, ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single, ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize, GridColor = System.Drawing.SystemColors.Control, RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None, MultiSelect = false, RowHeadersVisible = false, ReadOnly = true, }); }
public static void BrisanjeLeta() { IspisiSveLetove(); Airline airline = PreuzmiLetPoId(); if (airline != null) { AirlineDAO.Delete(airline.Id); } }
private new void InitializeComponent() { panel.Controls.Add(panelChild); panel.Dock = DockStyle.Right; panel.Padding = new Padding(40, 0, 0, 20); panel.BackColor = colors.White1; // Avoid textbox auto focus AddElement(new FlatTextBoxAutoFocus("_")); // Main controls AddElement(new FlatPanelTextBox("Model")); AddElement(new FlatPanelTextBox("ICAO")); AddElement(new FlatPanelTextBox("IATA")); AddElement(new FlatPanelTextBox("Maximun Passengers")); AddElement(new FlatPanelTextBox("Maximun Cargo")); AddElement(new FlatPanelTextBox("Aircraft Registration")); AirlineDAO airlineDAO = new AirlineDAO(Enums.Server.MariaDB); List <string> airlaneNames = airlineDAO.GetAllAirlinesNames(); ComboBox comboBox = new ComboBox { Name = "comboAirline", Width = panelChild.Controls[1].Width, }; foreach (string item in airlaneNames) { comboBox.Items.Add(item); } AddElement(comboBox); AddElement(new FlatLabel("Enabeld", 0, 0)); AddElement(new RadioButton() { Name = "radioEnabledYES", Text = "Yes", Size = new System.Drawing.Size(67, 23), ForeColor = colors.Black1 }); AddElement(new RadioButton() { Name = "radioEnabledNo", Text = "No", Size = new System.Drawing.Size(67, 23), ForeColor = colors.Black1 }); AddElement(new FlatButton("Save")); panelChild.Controls[panelChild.Controls.IndexOfKey("btnSave")].Click += new EventHandler(Save); panelChild.Controls[panelChild.Controls.IndexOfKey("btnSave")].Width = panelChild.Controls[panelChild.Controls.IndexOfKey("btnSave") - 4].Width; }
//metode za unos i brisanje public static void UnesiLiniju() { IspisiSveLetove(); Airline airline = new Airline(); airline.Id = 0; Console.WriteLine("Enter the airline name: "); string aName = Console.ReadLine(); airline.Name = aName; AirplaneUI.IspisiSveAvione(); Console.WriteLine("Choose airplane id you want to fly:"); string aId = Console.ReadLine(); int idAviona; bool provera = IOPomocnaKlasa.ProveraDaLiJeBr(aId); if (provera == true) { idAviona = int.Parse(aId); airline.Airplane = AirplaneDAO.GetAvionById(idAviona); } AirportUI.IspisiSveAerodrome(); Console.WriteLine("Choose id of departure airport:"); string aId1 = Console.ReadLine(); int idAerodromaPoletanje; bool provera1 = IOPomocnaKlasa.ProveraDaLiJeBr(aId1); if (provera1 == true) { idAerodromaPoletanje = int.Parse(aId1); airline.AirportDeparture = AirportDAO.GetAerodromById(idAerodromaPoletanje); } AirportUI.IspisiSveAerodrome(); Console.WriteLine("Choose id of destination airport:"); string aId2 = Console.ReadLine(); int idAerodromaSletanje; bool provera2 = IOPomocnaKlasa.ProveraDaLiJeBr(aId2); if (provera2 == true) { idAerodromaSletanje = int.Parse(aId2); airline.AirportDestination = AirportDAO.GetAerodromById(idAerodromaSletanje); } if (airline.AirportDeparture.Equals(airline.AirportDestination)) { Console.WriteLine("You cannot take off and land at the same airport!"); } else { AirlineDAO.Add(airline); } }
public static void IspisiSveLetove() { List <Airline> airlines = AirlineDAO.GetAll(); Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("\tAll airlines: "); Console.WriteLine("-----------------------------------------------------"); foreach (Airline airline in airlines.OrderBy(x => x.Id)) { Console.WriteLine(airline); Console.WriteLine("-------------------------------------------------"); } }
private void Save(object sender, System.EventArgs e) { try { // Use trim for filelds names RadioButton myRadio = (RadioButton)panelChild.Controls[9]; ComboBox myCombo = (ComboBox)panelChild.Controls[7]; int airlaineID = new AirlineDAO(Enums.Server.MariaDB).GetID(myCombo.SelectedItem.ToString()); Airplane avion = new Airplane { Model = panelChild.Controls[1].Controls[0].Text, ICAO = panelChild.Controls[2].Controls[0].Text, IATA = panelChild.Controls[3].Controls[0].Text, MaxPASS = int.Parse(panelChild.Controls[4].Controls[0].Text), MaxCargo = int.Parse(panelChild.Controls[5].Controls[0].Text), Aircraft = panelChild.Controls[6].Controls[0].Text, AirlineID = airlaineID, Enabled = (myRadio.Checked) ? 1 : 0, }; AirplaneDAO dao = new AirplaneDAO(Enums.Server.MariaDB); dao.Save(avion); // Button is the last child panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false; FlatPanel parentPanel = (FlatPanel)panel.Parent; Control toolbar = parentPanel.Controls[0]; MenuSection menuController = new MenuSection(0); menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Airplanes); PanelAdjustment(); void PanelAdjustment() { parentPanel.Controls[1].Dock = DockStyle.None; toolbar.Controls[0].Width = parentPanel.Width; parentPanel.Controls[1].Top = toolbar.Top + toolbar.Height; parentPanel.Controls[1].Width = parentPanel.Width; parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height; } } catch (Exception) { throw new OperationCanceledException("Wrong filed."); } }
private void Save(object sender, System.EventArgs e) { try { // Use trim for filelds names RadioButton myRadio = (RadioButton)panelChild.Controls[5]; ComboBox myCombo = (ComboBox)panelChild.Controls[3]; int airlaineID = new AirlineDAO(Enums.Server.MariaDB).GetID(myCombo.SelectedItem.ToString()); Pilot piloto = new Pilot { Name = panelChild.Controls[1].Controls[0].Text, Sex = panelChild.Controls[2].Controls[0].Text, PilotStatus = (myRadio.Checked) ? 1 : 0, AirlineID = airlaineID }; PilotDAO dao = new PilotDAO(Enums.Server.MariaDB); dao.Save(piloto); // Button is the last child panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false; FlatPanel parentPanel = (FlatPanel)panel.Parent; Control toolbar = parentPanel.Controls[0]; MenuSection menuController = new MenuSection(0); menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Pilots); PanelAdjustment(); void PanelAdjustment() { parentPanel.Controls[1].Dock = DockStyle.None; toolbar.Controls[0].Width = parentPanel.Width; parentPanel.Controls[1].Top = toolbar.Top + toolbar.Height; parentPanel.Controls[1].Width = parentPanel.Width; parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height; } } catch (Exception) { throw new OperationCanceledException("Wrong filed."); } }
private void Save(object sender, System.EventArgs e) { try { RadioButton myRadio = (RadioButton)panelChild.Controls[7]; Airline aerolinea = new Airline { Name = panelChild.Controls[1].Controls[0].Text, ICAO = panelChild.Controls[2].Controls[0].Text, IATA = panelChild.Controls[3].Controls[0].Text, Country = panelChild.Controls[4].Controls[0].Text, Region = panelChild.Controls[5].Controls[0].Text, AirlineStatus = (myRadio.Checked) ? 1 : 0, AircraftList = "" }; AirlineDAO dao = new AirlineDAO(Enums.Server.MariaDB); dao.Save(aerolinea); // Button is the last child panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false; FlatPanel parentPanel = (FlatPanel)panel.Parent; Control toolbar = parentPanel.Controls[0]; MenuSection menuController = new MenuSection(0); menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Airlines); PanelAdjustment(); void PanelAdjustment() { parentPanel.Controls[1].Dock = DockStyle.None; toolbar.Controls[0].Width = parentPanel.Width; parentPanel.Controls[1].Top = toolbar.Top + toolbar.Height; parentPanel.Controls[1].Width = parentPanel.Width; parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height; } } catch (Exception) { throw new OperationCanceledException("Wrong filed."); } }
private void Save(object sender, System.EventArgs e) { try { ComboBox myCombo = (ComboBox)panelChild.Controls[2]; ComboBox myCombo2 = (ComboBox)panelChild.Controls[12]; ComboBox myCombo3 = (ComboBox)panelChild.Controls[13]; ComboBox myCombo4 = (ComboBox)panelChild.Controls[16]; ComboBox myCombo5 = (ComboBox)panelChild.Controls[18]; ComboBox myCombo6 = (ComboBox)panelChild.Controls[20]; DateTime departureDate = DateTime.Parse(panelChild.Controls[6].Text); DateTime arrivalDate = DateTime.Parse(panelChild.Controls[9].Text); TimeSpan twentyFourHour = new TimeSpan(24, 0, 0); TimeSpan departureHour = TimeSpan.Parse(panelChild.Controls[7].Controls[0].Text); TimeSpan arrivalHour = TimeSpan.Parse(panelChild.Controls[10].Controls[0].Text); TimeSpan flightHour = (departureHour > arrivalHour) ? (twentyFourHour - departureHour) + arrivalHour : arrivalHour - departureHour; AirlineDAO airlineDAO = new AirlineDAO(Server.MariaDB); AirplaneDAO airplaneDAO = new AirplaneDAO(Server.MariaDB); PilotDAO pilotDAO = new PilotDAO(Server.MariaDB); Flight flight = new Flight { Type = myCombo.SelectedItem.ToString(), Origin = panelChild.Controls[3].Controls[0].Text, Destiny = panelChild.Controls[4].Controls[0].Text, DepartureDate = departureDate.ToString(), DepartureHour = departureHour.ToString(), ArrivalDate = arrivalDate.ToString(), ArrivalHour = arrivalHour.ToString(), FlightTime = flightHour.ToString(), Pist = int.Parse(myCombo2.SelectedItem.ToString()), FlightStatus = myCombo3.SelectedItem.ToString(), AirlineID = airlineDAO.GetID(myCombo4.SelectedItem.ToString()), AirplaneID = airplaneDAO.GetID(myCombo5.SelectedItem.ToString()), PilotID = pilotDAO.GetID(myCombo6.SelectedItem.ToString()), }; FlightDAO dao = new FlightDAO(Enums.Server.MariaDB); dao.Save(flight); // Button is the last child panelChild.Controls[panelChild.Controls.Count - 1].Enabled = false; FlatPanel parentPanel = (FlatPanel)panel.Parent; Control toolbar = parentPanel.Controls[0]; MenuSection menuController = new MenuSection(0); menuController.ShowPanel(ref parentPanel, Enums.ItemMenuType.Flight); PanelAdjustment(); void PanelAdjustment() { parentPanel.Controls[1].Dock = DockStyle.None; toolbar.Controls[0].Width = parentPanel.Width; parentPanel.Controls[1].Top = toolbar.Top + toolbar.Height; parentPanel.Controls[1].Width = parentPanel.Width; parentPanel.Controls[1].Height = parentPanel.Height - toolbar.Height; } } catch (Exception error) { MessageBox.Show(error.Message); } }
private new void InitializeComponent() { panel.Controls.Add(panelChild); panel.Dock = DockStyle.Right; panel.Padding = new Padding(40, 0, 0, 20); // Avoid textbox auto focus AddElement(new FlatTextBoxAutoFocus("_")); // Main controls AirlineDAO airlineDAO = new AirlineDAO(Enums.Server.MariaDB); List <string> airlaneNames = airlineDAO.GetAllAirlinesNames(); ComboBox comboBox = new ComboBox { Name = "comboAirline", Width = 222, Height = 600 }; comboBox.Items.Add(Enums.FlightType.Comercial); comboBox.Items.Add(Enums.FlightType.Cargo); comboBox.SelectedIndex = 0; //ComboBox comboBox2 = new ComboBox //{ // Name = "comboFlichtClass", // Width = 222, // Height = 600 //}; //comboBox2.Items.Add(Enums.FlightClass.Economi); //comboBox2.Items.Add(Enums.FlightClass.EconomiPlus); //comboBox2.Items.Add(Enums.FlightClass.Executive); //comboBox2.Items.Add(Enums.FlightClass.FirstClass); //comboBox2.Items.Add(Enums.FlightClass.Turist); //comboBox2.SelectedIndex = 0; ComboBox comboPist = new ComboBox { Name = "comboPist", Width = 222, Height = 600 }; List <int> pistIDList = new PistDAO(Server.MariaDB).GetAllID(); foreach (int item in pistIDList) { comboPist.Items.Add(item); } comboPist.SelectedIndex = 0; AddElement(new FlatLabel("Flight", 0, 0)); AddElement(comboBox); AddElement(new FlatPanelTextBox("Origin IATA")); AddElement(new FlatPanelTextBox("Destiny IATA")); DateTimePicker dateTimeDeparture = new DateTimePicker() { Name = "dateDeparture", Width = 222, }; DateTimePicker dateTimeArrival = new DateTimePicker() { Name = "dateArrival", Width = 222, }; AddElement(new FlatLabel("Departure Date", 0, 0)); AddElement(dateTimeDeparture); // validation AddElement(new FlatPanelTextBox("Deperture 00:00:00")); AddElement(new FlatLabel("Arrival Date", 0, 0)); AddElement(dateTimeArrival); // validation AddElement(new FlatPanelTextBox("Arrival 00:00:00")); AddElement(new FlatLabel("Pist", 0, 0)); AddElement(comboPist); ComboBox comboStatus = new ComboBox { Name = "comboStatus", Width = 222, Height = 600 }; List <string> flightStatusNames = new FlightStatusDAO(Server.MariaDB).GetAllFlightStatusNames(); foreach (string item in flightStatusNames) { comboStatus.Items.Add(item); } comboStatus.SelectedIndex = 0; AddElement(comboStatus); AddElement(new FlatButton("Save")); panelChild.Controls[panelChild.Controls.IndexOfKey("btnSave")].Click += new EventHandler(Save); panelChild.Controls[panelChild.Controls.IndexOfKey("btnSave")].Width = panelChild.Controls[panelChild.Controls.IndexOfKey("btnSave") - 5].Width; // Second Column int secondColumntX = panelChild.Controls[2].Width + panelChild.Controls[2].Left + 100; int secondColumntY = panelChild.Controls[1].Top; FlatLabel AirlineLabel = new FlatLabel("Airline", secondColumntX, secondColumntY); secondColumntY += AirlineLabel.Height + 16; panelChild.Controls.Add(AirlineLabel); ComboBox comboAirline = new ComboBox { Name = "comboAirline", Width = 222, Height = 600, Top = secondColumntY, Left = panelChild.Controls[2].Width + panelChild.Controls[2].Left + 100, }; List <string> airlineNames = new AirlineDAO(Server.MariaDB).GetAllAirlinesNames(); foreach (string item in airlineNames) { comboAirline.Items.Add(item); } comboAirline.SelectedIndex = 0; panelChild.Controls.Add(comboAirline); secondColumntY += comboAirline.Height + 20; // Airplane FlatLabel AirplaneLabel = new FlatLabel("Airplane", secondColumntX, secondColumntY); secondColumntY += AirplaneLabel.Height + 16; panelChild.Controls.Add(AirplaneLabel); ComboBox comboAircraft = new ComboBox { Name = "comboAircraft", Width = 222, Height = 600, Top = secondColumntY, Left = panelChild.Controls[2].Width + panelChild.Controls[2].Left + 100, }; UpdateAirlineFromAirline(comboAirline.SelectedItem.ToString(), ref comboAircraft); comboAircraft.SelectedIndex = 0; panelChild.Controls.Add(comboAircraft); secondColumntY += comboAircraft.Height + 20; // Pilot FlatLabel PilotLabel = new FlatLabel("Pilot", secondColumntX, secondColumntY); secondColumntY += PilotLabel.Height + 16; panelChild.Controls.Add(PilotLabel); ComboBox comboPilot = new ComboBox { Name = "comboPilot", Width = 222, Height = 600, Top = secondColumntY, Left = panelChild.Controls[2].Width + panelChild.Controls[2].Left + 100, }; UpdatePilotFromAirline(comboAirline.SelectedItem.ToString(), ref comboPilot); if (comboPilot.Items.Count > 0) { comboPilot.SelectedIndex = 0; } panelChild.Controls.Add(comboPilot); secondColumntY += comboAircraft.Height + 20; comboAirline.SelectedIndexChanged += new EventHandler(UpdateAirplaneCombo); comboAirline.SelectedIndexChanged += new EventHandler(UpdatePilotCombo); }
public static Airline PronadjiLetPoId(int id) { Airline airline = AirlineDAO.GetLetById(id); return(airline); }
internal AnonymousUserFacade() { _airlineDAO = new AirlineDAO(); _flightDAO = new FlightDAO(); _countryDAO = new CountryDAO(); }
/// <summary> /// Login for the flight center system /// For anonymous facade username should be null /// </summary> /// <param name="userName">user name</param> /// <param name="password">password</param> /// <param name="login">login token</param> /// <param name="facadeBase">proxy facade</param> public void TryLogin(string userName, string password, out ILogin login, out FacadeBase facadeBase) { login = null; if (userName == null) { facadeBase = new AnonymousUserFacade(); return; } facadeBase = null; UserRepository userRepository = _userRepositoryDAO.GetUserByUserName(userName); if (userRepository == null) { throw new DataNotFoundException($"User {userName} not found. Login failed"); } if (userRepository.UserName == userName && userRepository.Password == password) { switch (userRepository.UserRoleID) { case RolesEnum.admin: Admin admin = new AdminDAO().GetAdminByUserRepositoryID((int)userRepository.ID); login = new LoginToken <Admin>() { TokenUserRepository = userRepository, User = admin }; facadeBase = new LoggedInAdministratorFacade(); break; case RolesEnum.airline: AirlineCompany airlineCompany = new AirlineDAO().GetAirlineCompanyByUserRepositoryID((int)userRepository.ID); login = new LoginToken <AirlineCompany>() { TokenUserRepository = userRepository, User = airlineCompany }; facadeBase = new LoggedInAirlineFacade(); break; case RolesEnum.customer: Customer customer = new CustomerDAO().GetCustomerByUserRepositoryID((int)userRepository.ID); login = new LoginToken <Customer>() { TokenUserRepository = userRepository, User = customer }; facadeBase = new LoggedInCustomerFacade(); break; default: throw new FlightSystemUnexpectedError($"User id {userRepository.ID} in roll {userRepository.UserRoleID} does not exist"); } } else { throw new WrongPasswordException($"User {userName} entered wrong password.Login failed"); } }