Ejemplo n.º 1
0
        private void AddModifyAirplane_Load(object sender, EventArgs e)
        {
            lbl_info.Text = "";
            Airline_company.Airline_companyDao     airlinesDao = new Airline_company.Airline_companyDaoImplements();
            List <Airline_company.Airline_company> airlines    = airlinesDao.getAllAirlinesData();

            foreach (Airline_company.Airline_company s in airlines)
            {
                this.cb_airlines.Items.Add(new { Text = s.Name, Value = s.Id });
            }
            this.cb_airlines.DisplayMember = "Text";
            this.cb_airlines.ValueMember   = "Value";

            if (this.id == 0)
            {
                lbl_title.Text = "Add airplane";
                btn_add.Text   = "Add";
            }
            else if (this.id != 0)
            {
                lbl_title.Text = "Modify airplane";
                btn_add.Text   = "Save";

                AirplaneDao       airplaneDao = new AirplaneDaoImplements();
                Airplane.Airplane airplane    = airplaneDao.getAirplane(this.id);

                this.tb_name.Text = airplane.Name;

                Airline_company.Airline_company ac = airlinesDao.getAirlineDataForModification(airplane.Airline_company_id);

                this.tb_numberOfSeats.Text    = airplane.Number_of_seats.ToString();
                this.cb_airlines.SelectedItem = new { Text = ac.Name, Value = ac.Id };
            }
        }
Ejemplo n.º 2
0
        private void ReloadListView()
        {
            if (this.selectedNode == "")
            {
                return;
            }

            this.btn_add.Enabled    = false;
            this.btn_remove.Enabled = false;
            this.btn_modify.Enabled = false;

            List <Fly.Fly> listOfFlights = new List <Fly.Fly>();
            ListViewItem   lvi           = new ListViewItem();
            AirplaneDao    airplaneDao   = new AirplaneDaoImplements();

            switch (this.selectedNode)
            {
            case "Flights":
                FlyDao         flightsDao = new FlyDaoImplements();
                List <Fly.Fly> list       = flightsDao.getAllFlights();

                this.btn_add.Enabled = true;
                this.category        = "flights";

                lv_Main.Columns.Clear();
                lv_Main.Items.Clear();
                lv_Main.Columns.Add("id", 0);
                lv_Main.Columns.Add("Destination", 100);
                lv_Main.Columns.Add("Start point", 100);
                lv_Main.Columns.Add("Departure time", 90);
                lv_Main.Columns.Add("Landing time", 90);
                lv_Main.Columns.Add("Airplane", 90);

                foreach (Fly.Fly item in list)
                {
                    Airplane.Airplane airplane = airplaneDao.getAirplane(item.Airplane_id);
                    lvi = new ListViewItem(new[] { item.Id.ToString(), item.Destination, item.Start_point, Convert.ToString(item.Departure_time), Convert.ToString(item.Landing_time), airplane.Name });
                    lv_Main.Items.Add(lvi);
                }

                break;

            case "Airlines":

                this.btn_add.Enabled = true;
                this.category        = "airlines";

                Airline_companyDao airlinesDao = new Airline_companyDaoImplements();
                List <Airline_company.Airline_company> airlines = airlinesDao.getAllAirlinesData();
                lv_Main.Columns.Clear();
                lv_Main.Items.Clear();
                lv_Main.Columns.Add("Name", 90);
                lv_Main.Columns.Add("Country");
                lv_Main.Columns.Add("Address");
                lv_Main.Columns.Add("Telephone", 70);
                lv_Main.Columns.Add("Email");
                lv_Main.Columns.Add("id", 0);
                foreach (Airline_company.Airline_company item in airlines)
                {
                    lvi = new ListViewItem(new[] { item.Name, item.Country, item.Address, Convert.ToString(item.Telephone), Convert.ToString(item.Email), Convert.ToString(item.Id) });
                    lv_Main.Items.Add(lvi);
                }

                break;

            case "Airplanes":

                this.btn_add.Enabled = true;
                this.category        = "airplanes";

                lv_Main.Columns.Clear();
                lv_Main.Items.Clear();
                lv_Main.Columns.Add("Name", 100);
                lv_Main.Columns.Add("Number of seats", 100);
                lv_Main.Columns.Add("Airline", 100);
                lv_Main.Columns.Add("id", 0);


                List <Airplane.Airplane> airplanes = airplaneDao.getAllAirplanes();
                string airlineName = "";
                Airline_company.Airline_companyDao airline = new Airline_company.Airline_companyDaoImplements();
                foreach (Airplane.Airplane planes in airplanes)
                {
                    airlineName = airline.getAirline(planes.Airline_company_id);
                    lvi         = new ListViewItem(new[] { planes.Name, planes.Number_of_seats.ToString(), airlineName, planes.Id.ToString() });
                    lv_Main.Items.Add(lvi);
                }

                break;
            }
        }