Пример #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 };
            }
        }
Пример #2
0
 private void Add_ModifyAirline_Load(object sender, EventArgs e)
 {
     lbl_info.Text = "";
     if (this.id == 0)
     {
         this.lb_title.Text = "Add airline";
         this.btn_add.Text  = "Add";
     }
     else if (this.id != 0)
     {
         this.lb_title.Text = "Modify airline";
         this.btn_add.Text  = "Save";
         Airline_companyDao airlineDao           = new Airline_companyDaoImplements();
         Airline_company.Airline_company airline = airlineDao.getAirlineDataForModification(this.id);
         this.tb_name.Text      = airline.Name;
         this.tb_country.Text   = airline.Country;
         this.tb_address.Text   = airline.Address;
         this.tb_email.Text     = airline.Email;
         this.tb_telephone.Text = airline.Telephone;
     }
 }
 public void editAirline(Airline_company airline)
 {
     DB.DBConnection db = new DB.DBConnection();
     db.editAirline(airline);
 }
Пример #4
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (this.id == 0)
            {
                lbl_info.Text = "";

                if (this.tb_name.Text == "" || this.tb_country.Text == "" || this.tb_address.Text == "")
                {
                    this.lbl_info.Text = "Missing information.";
                    this.lbl_info.Show();
                    return;
                }
                else
                {
                    Airline_company.Airline_companyDao dao = new Airline_company.Airline_companyDaoImplements();
                    string name      = this.tb_name.Text;
                    string country   = this.tb_country.Text;
                    string address   = this.tb_address.Text;
                    string telephone = null;
                    string email     = null;
                    if (this.tb_telephone.Text != "")
                    {
                        telephone = this.tb_telephone.Text;
                    }
                    if (this.tb_email.Text != "")
                    {
                        email = this.tb_email.Text;
                    }
                    Airline_company.Airline_company airline = new Airline_company.Airline_company(name, country, address, telephone, email);
                    dao.addAirline(airline);
                }
            }
            else if (this.id != 0)
            {
                lbl_info.Text = "";

                if (this.tb_name.Text == "" || this.tb_country.Text == "" || this.tb_address.Text == "")
                {
                    this.lbl_info.Text = "Missing information.";
                    this.lbl_info.Show();
                    return;
                }
                else
                {
                    Airline_company.Airline_companyDao dao = new Airline_company.Airline_companyDaoImplements();
                    string name      = this.tb_name.Text;
                    string country   = this.tb_country.Text;
                    string address   = this.tb_address.Text;
                    string telephone = null;
                    string email     = null;
                    if (this.tb_telephone.Text != "")
                    {
                        telephone = this.tb_telephone.Text;
                    }
                    if (this.tb_email.Text != "")
                    {
                        email = this.tb_email.Text;
                    }

                    Airline_company.Airline_company airline = new Airline_company.Airline_company(name, country, address, telephone, email, this.id);
                    dao.editAirline(airline);
                }
            }
            this.Close();
        }