예제 #1
0
 private void OkButton_Click(object sender, EventArgs e)
 {
     if (ClassSelectComboBox.SelectedItem == null)
     {
         MessageBox.Show("Класс самолёта не выбран");
     }
     else
     {
         try
         {
             if (ClassSelectComboBox.SelectedIndex == 0)
             {
                 PassengerAirliner pasAir = new PassengerAirliner();
                 pasAir.Name = NameBox.Text;
                 if (Convert.ToInt32(PasCapBox.Text) >= 0 && Convert.ToInt32(VarBox.Text) >= 0)
                 {
                     pasAir.PasCap   = Convert.ToInt32(PasCapBox.Text);
                     pasAir.StaffCap = Convert.ToInt32(VarBox.Text);
                     airline.AddPlane(pasAir);
                 }
                 else
                 {
                     MessageBox.Show("Некорректные данные");
                 }
                 mainForm.Refresh(airline);
                 Close();
             }
             else if (ClassSelectComboBox.SelectedIndex == 1)
             {
                 CargoPlane cargoAir = new CargoPlane();
                 cargoAir.Name = NameBox.Text;
                 if (Convert.ToInt32(PasCapBox.Text) >= 0 && Convert.ToInt32(VarBox.Text) >= 0)
                 {
                     cargoAir.PasCap  = Convert.ToInt32(PasCapBox.Text);
                     cargoAir.LoadCap = Convert.ToDouble(VarBox.Text);
                     airline.AddPlane(cargoAir);
                 }
                 else
                 {
                     MessageBox.Show("Некорректные данные");
                 }
                 mainForm.Refresh(airline);
                 Close();
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("Некорректные данные");
         }
     }
 }
예제 #2
0
파일: EditForm.cs 프로젝트: Lursen/Lab6
 private void EditForm_Load(object sender, EventArgs e)
 {
     if (aircraft is PassengerAirliner)
     {
         PassengerAirliner PasAir = (PassengerAirliner)aircraft;
         ClassLabel.Text = "Passenger Airliner";
         NameBox.Text    = aircraft.Name;
         PasCapBox.Text  = aircraft.PasCap.ToString();
         VarLabel.Text   = "Staff Capacity";
         VarBox.Text     = PasAir.StaffCap.ToString();
     }
     else if (aircraft is CargoPlane)
     {
         CargoPlane CargoAir = (CargoPlane)aircraft;
         ClassLabel.Text = "Cargo Plane";
         NameBox.Text    = CargoAir.Name;
         PasCapBox.Text  = CargoAir.PasCap.ToString();
         VarLabel.Text   = "Load Capacity, kg";
         VarBox.Text     = CargoAir.LoadCap.ToString();
     }
 }
예제 #3
0
파일: EditForm.cs 프로젝트: Lursen/Lab6
 private void OkButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (aircraft is PassengerAirliner)
         {
             PassengerAirliner PasAir = (PassengerAirliner)aircraft;
             PasAir.Name = NameBox.Text;
             if (Convert.ToInt32(PasCapBox.Text) >= 0 && Convert.ToInt32(VarBox.Text) >= 0)
             {
                 PasAir.PasCap   = Convert.ToInt32(PasCapBox.Text);
                 PasAir.StaffCap = Convert.ToInt32(VarBox.Text);
             }
             else
             {
                 MessageBox.Show("Введены некорректные данные");
             }
         }
         else if (aircraft is CargoPlane)
         {
             CargoPlane CargoAir = (CargoPlane)aircraft;
             CargoAir.Name = NameBox.Text;
             if (Convert.ToInt32(PasCapBox.Text) >= 0 && Convert.ToInt32(VarBox.Text) >= 0)
             {
                 CargoAir.PasCap  = Convert.ToInt32(PasCapBox.Text);
                 CargoAir.LoadCap = Convert.ToInt32(VarBox.Text);
             }
             else
             {
                 MessageBox.Show("Введены некорректные данные");
             }
         }
         refForm.Refresh(airline);
         Close();
     }
     catch (FormatException)
     {
         MessageBox.Show("Введены некорректные данные");
     }
 }