private void submitBookTicketBtn_Click(object sender, EventArgs e) { Bookticket bt = new Bookticket(); bt.BookTicketId = textBox21.Text; bt.PassengerId = textBox22.Text; bt.PassengerUsername = textBox23.Text; bt.Airplane = airplaneLabel.Text; bt.Source = fromComboBox.Text; bt.Destination = toComboBox.Text; bt.Departure = dateTimePicker1.Text; bt.Arrival = dateTimePicker2.Text; bt.Cost = Convert.ToInt32(costLabel.Text); bt.Seats = seatLabel.Text; BookTicketRepository btRepo = new BookTicketRepository(); if (btRepo.Insert(bt)) { MessageBox.Show("Ticket Booked"); } else { MessageBox.Show("Error adding ticket"); } }
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { BookTicketRepository bkRepo = new BookTicketRepository(); AllUsersRepository userRepo = new AllUsersRepository(); if (e.RowIndex >= 0) { AllUsers u = userRepo.GetUserById(passId); DataGridViewRow row = bookTicketGridView.Rows[e.RowIndex]; int x = bkRepo.TicketCount(); int y; y = x + 2; Console.WriteLine(passId + " " + u.UserId + " " + u.UserName + " " + u.UserFullName + " - " + x); this.bookTicketTabs.SelectTab(1); flightIdLabel.Text = row.Cells["FlightId"].Value.ToString(); airplaneLabel.Text = row.Cells["AirlineName"].Value.ToString(); ticketIdLabel.Text = y.ToString(); passengerIdLabel.Text = passId.ToString(); passengerFullNameLabel.Text = u.UserFullName; usernameLabel.Text = u.UserName; sourceLabel.Text = row.Cells["Source"].Value.ToString(); destinationLabel.Text = row.Cells["Destination"].Value.ToString(); departureLabel.Text = row.Cells["Departure"].Value.ToString(); costLabel.Text = row.Cells["Cost"].Value.ToString(); } }
private void button1_Click(object sender, EventArgs e) { //cancel ticket btn BookTicketRepository btRepo = new BookTicketRepository(); int tId = Convert.ToInt32(textBox1.Text); if (btRepo.CancelTicketByPassenger(userID, tId)) { MessageBox.Show("Ticket Cancel Successful."); } else { MessageBox.Show("Error In Ticket Cancel."); } }
private void loadBookedFilghts_Click(object sender, EventArgs e) { Repository.BookTicket bt = new Repository.BookTicket(); BookTicketRepository btRepo = new BookTicketRepository(); List <Repository.BookTicket> btList = btRepo.GetTicket(userId); Console.WriteLine(btList.Count); if (btList.Count == 0) { MessageBox.Show("You Have Not Booked Any Ticket. \nPlease Book a Ticket First."); } else { dataGridView2.DataSource = btList; } }
private void loadBookedFilghts_Click(object sender, EventArgs e) { Bookticket bt = new Bookticket(); BookTicketRepository btRepo = new BookTicketRepository(); string text = passengerSearchTextBox.Text; if (text == "") { List <Bookticket> btList = btRepo.GetAllTickets(); dataGridView2.DataSource = btList; } else { Bookticket b2 = btRepo.GetTicket(text); List <Bookticket> btList = new List <Bookticket>(); btList.Add(b2); dataGridView2.DataSource = btList; } }
private void submitBookTicketBtn_Click(object sender, EventArgs e) { Repository.BookTicket bt = new Repository.BookTicket(); BookTicketRepository bookRepo = new BookTicketRepository(); BookedSeatRepository bsRepo = new BookedSeatRepository(); BookedSeats bs = new BookedSeats(); bs.BookTicketId = Convert.ToInt32(ticketIdLabel.Text); bs.FlightId = Convert.ToInt32(flightIdLabel.Text); bs.Seats = seatLabel.Text; bt.FlightId = Convert.ToInt32(flightIdLabel.Text); bt.PassengerId = Convert.ToInt32(passengerIdLabel.Text); bt.BookTicketId = Convert.ToInt32(ticketIdLabel.Text); bt.PassengerUsername = usernameLabel.Text; bt.PassengerFullName = passengerFullNameLabel.Text; bt.Airplane = airplaneLabel.Text; bt.Source = sourceLabel.Text; bt.Destination = destinationLabel.Text; bt.Departure = departureLabel.Text; bt.Cost = Convert.ToInt32(costLabel.Text); bt.Seats = seatLabel.Text; if (bookRepo.Insert(bt) && bsRepo.Insert(bs)) { MessageBox.Show("Ticket Booked"); this.bookTicketTabs.SelectTab(0); Clear(); } else { MessageBox.Show("Error adding ticket"); } }