/// <summary> /// Event-handler for click event of Transporation button. This will create a new tranport object and /// calls the transport constructor to add new details fo transport /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTransportation_Click(object sender, EventArgs e) { int ticketPrice = 0; //if all fields are validated continue with adding new transportaion info if (ValidateInputFields() == true && ValidatePrice(out ticketPrice) == true) { m_transport = new Transport(ticketPrice); //assign the values m_transport.TransportationNumber = txtNumber.Text; Stations fromStaion = (Stations)Enum.Parse(typeof(Stations), (string)cmbFrom.SelectedItem); m_transport.FromStation = fromStaion; Stations toStation = (Stations)Enum.Parse(typeof(Stations), (string)cmbTo.SelectedItem); m_transport.ToStation = toStation; DateTime time = (DateTime)timeTransportation.Value; m_transport.Time = time; m_transport.PriceAdult = ticketPrice; UpdateGUI(); this.DialogResult = DialogResult.OK; } }
/// <summary> /// Adds a new transport object to details arraylist /// </summary> /// <param name="transport">transport object</param> /// <returns>true if new detail is added , false otherwise</returns> public bool AddTransport(Transport transport) { if (CheckTransporst()) { m_transportDetails.Add(transport); return true; } else return false; }