예제 #1
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (this.id == 0)
            {
                if (this.tb_name.Text == "" || this.tb_numberOfSeats.Text == "" || this.cb_airlines.Text == "")
                {
                    this.lbl_info.Text = "Missing information.";
                    this.lbl_info.Show();
                    return;
                }
                Airline_company.Airline_companyDao airlineDao = new Airline_company.Airline_companyDaoImplements();

                int airlineId = airlineDao.getAirlineId(this.cb_airlines.Text);
                Airplane.Airplane    plane = new Airplane.Airplane(this.tb_name.Text, this.tb_numberOfSeats.Text, airlineId);
                Airplane.AirplaneDao dao   = new Airplane.AirplaneDaoImplements();
                dao.addAirplane(plane);
            }
            else if (this.id != 0)
            {
                if (this.tb_name.Text == "" || this.tb_numberOfSeats.Text == "" || this.cb_airlines.Text == "")
                {
                    this.lbl_info.Text = "Missing information.";
                    this.lbl_info.Show();
                    return;
                }
                Airline_company.Airline_companyDao airlineDao = new Airline_company.Airline_companyDaoImplements();

                int airlineId = airlineDao.getAirlineId(this.cb_airlines.Text);
                Airplane.Airplane    plane = new Airplane.Airplane(this.id, this.tb_name.Text, Int32.Parse(this.tb_numberOfSeats.Text), airlineId);
                Airplane.AirplaneDao dao   = new Airplane.AirplaneDaoImplements();
                dao.editAirplane(plane);
            }
            this.Close();
        }
예제 #2
0
        private void btn_remove_Click(object sender, EventArgs e)
        {
            int          id   = 0;
            ListViewItem item = new ListViewItem();

            if (this.lv_Main.SelectedItems.Count > 0)
            {
                item = this.lv_Main.SelectedItems[0];
            }
            switch (this.category)
            {
            case "flights":
                Fly.FlyDao fly = new Fly.FlyDaoImplements();
                id = Convert.ToInt32(item.SubItems[0].Text);
                fly.removeFlight(id);

                break;

            case "airlines":
                Airline_company.Airline_companyDao line = new Airline_company.Airline_companyDaoImplements();
                int idLine = Convert.ToInt32(item.SubItems[5].Text);

                line.removeAirline(idLine);
                break;

            case "airplanes":
                Airplane.AirplaneDao air = new Airplane.AirplaneDaoImplements();
                int idPlane = Convert.ToInt32(item.SubItems[3].Text);
                air.removeAirplane(idPlane);
                break;
            }
            this.ReloadListView();
        }
예제 #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            lbl_info.Text = "";

            if (this.tb_destination.Text == "" || this.tb_startPoint.Text == "" || this.dt_pickerDeparture.Value.ToString() == "" || this.dtpicker_Landing.Value.ToString() == "" || this.cb_airline.Text == "")
            {
                this.lbl_info.Text = "Missing information.";
                this.lbl_info.Show();
                return;
            }

            if (this.id == 0)
            {
                Airplane.AirplaneDao airplaneDao = new Airplane.AirplaneDaoImplements();
                Airplane.Airplane    airplane    = airplaneDao.getAirplaneName(this.cb_airline.Text);

                string destination = this.tb_destination.Text;
                string start_point = this.tb_startPoint.Text;

                DateTime departure = this.dt_pickerDeparture.Value;
                DateTime landing   = this.dtpicker_Landing.Value;

                Fly.Fly          newFlight = new Fly.Fly(destination, start_point, departure, landing, airplane.Id);
                FlyDaoImplements fdi       = new FlyDaoImplements();
                fdi.addFlight(newFlight);
            }
            else if (this.id != 0)
            {
                Airplane.AirplaneDao airplaneDao = new Airplane.AirplaneDaoImplements();
                Airplane.Airplane    airplane    = airplaneDao.getAirplaneName(this.cb_airline.Text);

                string destination = this.tb_destination.Text;
                string start_point = this.tb_startPoint.Text;

                DateTime departure = this.dt_pickerDeparture.Value;
                DateTime landing   = this.dtpicker_Landing.Value;

                Fly.Fly          newFlight = new Fly.Fly(this.id, destination, start_point, departure, landing, airplane.Id);
                FlyDaoImplements fdi       = new FlyDaoImplements();
                fdi.editFlight(newFlight);
            }
            this.Close();
        }
예제 #4
0
        private void AddFlightForm_Load(object sender, EventArgs e)
        {
            if (this.id == 0)
            {
                this.lb_title.Text = "Add flight";
                this.btn_add.Text  = "Add";
            }
            else if (this.id != 0)
            {
                this.lb_title.Text = "Modify flight";
                this.btn_add.Text  = "Save";
            }

            Airplane.AirplaneDao     airplaneDao = new Airplane.AirplaneDaoImplements();
            List <Airplane.Airplane> airplanes   = airplaneDao.getAllAirplanes();

            foreach (Airplane.Airplane s in airplanes)
            {
                this.cb_airline.Items.Add(s.Name);
            }
        }