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()
 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;

 if (flag == false)
 return true;
 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";
resultlbl.Text = "Cancel Ticket Sucessfully";
resultlbl.ForeColor = System.Drawing.Color.Red;


Popular posts from this blog

difference between structure and union in C Language

Difference between Linear search and Binary Search in c language

Difference between static and dynamic websites