public override string ToString() { string s = "\nFlight: " + flight.getFlightNumber(); s += "\nCustomer name: " + cust.getFirstName() + " " + cust.getLastName(); s += "\nDate of booking: " + date; return(s); }
private void BtnAddBook_Click(object sender, EventArgs e) { int fid, cid; if (int.TryParse(txtFlNum.Text, out fid) && int.TryParse(txtCustId.Text, out cid)) { Customer c = a.getCustomer(cid); Flight f = a.getFlight(fid); a.addBooking(c, f); string name = c.getFirstName() + " " + c.getLastName(); a.addPassenger(f.getFlightNumber(), c.getId(), name); txtFlNum.Text = ""; txtCustId.Text = ""; dgv_Book.DataSource = a.bookingList(); } else { txtMsg.Visible = true; txtMsg.Text = "please select a valid flight and customer"; } }
public bool addBooking(Customer cust, Flight fl) { if (numBookings >= maxBookings) { return(false); } Booking b = new Booking(fl, cust); con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "INSERT into tbl_Bookings (date, flightNumber, customerId,customerName) values ('" + b.getDate() + "','" + fl.getFlightNumber() + "','" + cust.getId() + "','" + cust.getFirstName() + " " + cust.getLastName() + "');"; cmd.ExecuteNonQuery(); con.Close(); return(true); }