I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
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.
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; }
Comments
Post a Comment