Ejemplo n.º 1
0
 public void Edit()
 {
     try
     {
         AirPlaneCreator creator = null;
         if (allowCreatorCheckBox.Checked)
         {
             creator = new AirPlaneCreator
             {
                 Name           = creatorNameTextBox.Text,
                 Country        = creatorCountryTextBox.Text,
                 FoundationYear = Convert.ToInt32(creatorFoundationYearTextBox.Text),
                 AirPlanesTypes = _planesTypes.ToList()
             };
         }
         _editPlane.Number      = Convert.ToInt32(numberTextBox.Text);
         _editPlane.Mark        = markTextBox.Text;
         _editPlane.Creator     = creator;
         _editPlane.ReleaseYear = Convert.ToInt32(releaseYearTextBox.Text);
         if (_editPlane is PassengerPlane)
         {
             (_editPlane as PassengerPlane).AirlineName = textBoxAirlineName.Text;
             (_editPlane as PassengerPlane).SeatsCount  = Convert.ToInt32(textBoxSeatsCount.Text);
         }
         if (_editPlane is MilitaryPlane)
         {
             (_editPlane as MilitaryPlane).Capacity = Convert.ToInt32(capacityTextBox.Text);
         }
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            AirPlaneCreator creator = null;

            if (allowCreatorCheckBox.Checked)
            {
                creator = new AirPlaneCreator
                {
                    Name           = creatorNameTextBox.Text,
                    Country        = creatorCountryTextBox.Text,
                    AirPlanesTypes = _planesTypes.ToList(),
                    FoundationYear = Convert.ToInt32(creatorFoundationYearTextBox.Text)
                };
            }
            if (passengerPlaneRadioButton.Checked)
            {
                PassengerPlane newPasPlane = new PassengerPlane
                {
                    Number      = Convert.ToInt32(numberTextBox.Text),
                    Mark        = markTextBox.Text,
                    AirlineName = airlineNameTextBox.Text,
                    Creator     = creator,
                    ReleaseYear = Convert.ToInt32(releaseYearTextBox.Text),
                    SeatsCount  = Convert.ToInt32(seatsCountTextBox.Text)
                };
                _planesList.Add(newPasPlane);
            }
            if (militaryPlaneRadioButton.Checked)
            {
                MilitaryPlane newMilPlane = new MilitaryPlane
                {
                    Number      = Convert.ToInt32(numberTextBox.Text),
                    Mark        = markTextBox.Text,
                    Creator     = creator,
                    ReleaseYear = Convert.ToInt32(releaseYearTextBox.Text),
                    Capacity    = Convert.ToInt32(capacityTextBox.Text),
                    CrewMembers = _crewMembers.ToList()
                };
                _planesList.Add(newMilPlane);
            }
            this.Close();
        }