Exemple #1
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();
        }