-->

Tuesday, April 7, 2015

Cancel Ticket in ASP.NET c#

Cancel Ticket in ASP.NET c#

For cancel the ticket, first to learn how to book the ticket. In similar ways you can check your reserved ticket. In this example, i will delete the entry one by one. First to check the ticket, which is available in the table. Only those ticket will be removed, which is related to loggedIn user.

 private bool checkseat()
 {
 con.Open();
 cmd.CommandText = "select seatno from [Booking] where date=@ldate and userId=@userid12";
 cmd.Parameters.AddWithValue("@ldate", ticketbooking.Text);
 cmd.Parameters.AddWithValue("@userid12", 1);
 cmd.Connection = con;
 SqlDataReader rd = cmd.ExecuteReader();
 while (rd.Read())
 {


 if (rd["seatno"].ToString() == ticketnotxt.Text)
 {
 flag = false;
 break;
 }


 }
 rd.Dispose();
 if (flag == false)
 return true;
 else
 return false;
 }
In this example first to get the seat_no with where clause. Resultant value will be compared to the text box value, if match then delete the table. If match the data with reader then code return true.  Now, you can easily remove the ticket.


Cancel Ticket in ASP.NET c#


if (checkseat() == true)
{

cmd.CommandText = "delete from [Booking] where seatno=@seaatno11 and userid=@userid11 and date=@date11";
cmd.Parameters.AddWithValue("@seaatno11",tktno);
cmd.Parameters.AddWithValue("@userid11",1);
cmd.Parameters.AddWithValue("@date11",tktdate);
cmd.ExecuteNonQuery();
resultlbl.Text = "Cancel Ticket Sucessfully";
resultlbl.ForeColor = System.Drawing.Color.Red;
}

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved