protected void Button1_Click(object sender, EventArgs e) { /* * A event handler to check tickets using the given values */ string date = TextBox1.Text; string from = TextBox2.Text; string to = TextBox3.Text; int noOfTickets = Convert.ToInt32(TextBox4.Text); string start = null; string end = null; /* * Check if the ticket is available for given date,source,destination,nooftickets */ AirlineSVCReference.Service1Client client = new AirlineSVCReference.Service1Client(); bool isTicketsAvailable = client.isTicketAvailable(date, from, to, noOfTickets, start, end); string[] availableFlightsInfo = client.MatchingFlights(date, from, to, noOfTickets); if (isTicketsAvailable == true) { Label5.Text = "Tickets Available"; StringBuilder sb = new StringBuilder("<table border = '1'>"); /* * Header for table */ sb.AppendFormat("<tr><th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th></tr>", "Date", "Source", "Destination", "Start", "End"); foreach (string flight in availableFlightsInfo) { string[] array = flight.Split(' '); /* * Information for table */ sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>", array[0], array[1], array[2], array[3], array[4]); } sb.Append("</table>"); /* * Get the details and populate it in the placeholder */ var table = sb.ToString(); PlaceHolder1.Controls.Add(new Literal { Text = sb.ToString() }); } else { Label5.Text = "Tickets Unavailable"; } }
protected void Button1_Click(object sender, EventArgs e) { /* * Get the local service reference */ AirlineSVCReference.Service1Client client = new AirlineSVCReference.Service1Client(); bool isCancellationSuccess = client.CancelTicket(TextBox1.Text); /* * Display appropriate message */ if (isCancellationSuccess == true) { Label2.Text = "Status : Cancellation successful"; } else { Label2.Text = "Status : Cancellation failed"; } }
protected void Button1_Click(object sender, EventArgs e) { /* * A event handler to reserve tickets using the given values */ string username = TextBox1.Text; string date = TextBox2.Text; string from = TextBox3.Text; string to = TextBox4.Text; string start = TextBox5.Text; string end = TextBox6.Text; int noOfTickets = Convert.ToInt32(TextBox7.Text); /* * Send the values to the service and get back the response in boolean and * display the status of the reservation accordingly */ AirlineSVCReference.Service1Client client = new AirlineSVCReference.Service1Client(); bool reserveTickets = client.ReserveTickets(username, date, from, to, start, end, noOfTickets); Label8.Text = (reserveTickets == true) ? "Status : Success" : "Status : Failed"; }
protected void Button2_Click(object sender, EventArgs e) { /* * Check if the ticket is available for given date,source,destination,nooftickets */ AirlineSVCReference.Service1Client client = new AirlineSVCReference.Service1Client(); string[] availableFlightsInfo = client.CompleteFlights(); StringBuilder sb = new StringBuilder("<table border = '1'>"); /* * Header for table */ sb.AppendFormat("<tr><th>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th><th>{4}</th></tr>", "Date", "Source", "Destination", "Start", "End"); foreach (string flight in availableFlightsInfo) { string[] array = flight.Split(' '); /* * Information for table */ sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>", array[0], array[1], array[2], array[3], array[4]); } sb.Append("</table>"); /* * Get the details and populate it in the placeholder */ var table = sb.ToString(); PlaceHolder1.Controls.Add(new Literal { Text = sb.ToString() }); }