private void Button4_Click(System.Object sender, System.EventArgs e) { DGV.Rows.Clear(); SeatCapacity.Clear(); BookingNo.Clear(); SC2.Clear(); SeatAvailability.Clear(); RadioButton1.Checked = false; RadioButton2.Checked = false; RNo.Text = "Select"; BusSerialNo.Text = "Select"; }
Int32 DisplayBookings(string BookingNoFilter) { //variable to store the bookings table primary key Int32 BookingNo; //var to store the tour name string CustomerNo; //var to store the location string TourNo; //instance of the collection class clsBookingCollection BookingRecord = new clsBookingCollection(); // BookingRecord.ReportByBookingNo(BookingNoFilter); //var to store teh count of records Int32 RecordCount; //var to index the loop Int32 Index = 0; //get the count of records RecordCount = BookingRecord.Count; //clear the list box lstDisplay.Items.Clear(); // while (Index < RecordCount) { //get the primary key BookingNo = BookingRecord.BookingList[Index].BookingNo; //get the customerno CustomerNo = Convert.ToString(BookingRecord.BookingList[Index].CustomerNo); //get the tour no TourNo = Convert.ToString(BookingRecord.BookingList[Index].TourNo); //new entry for listbox with all data together ListItem NewEntry = new ListItem(CustomerNo + " " + TourNo + " ", BookingNo.ToString()); //add the new entry lstDisplay.Items.Add(NewEntry); //index the next record Index++; } //return the count of records found return(RecordCount); }
private void Button3_Click(System.Object sender, System.EventArgs e) { //Try DialogResult res = MessageBox.Show("Do U Want To Cancel Waiting Booking?", "Cancel Booking?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { if (string.IsNullOrEmpty(BookingNo.Text.Trim())) { MessageBox.Show("Give Booking No.."); } else { string CN2 = null; con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=Bus_System;Integrated Security=True"); con.Open(); cmd = new SqlCommand("Select max(CancellationNo) From Cancellation", con); dr = cmd.ExecuteReader(); dr.Read(); if ((!object.ReferenceEquals(dr[0], DBNull.Value))) { t = Convert.ToInt32(dr[0]) + 1; } else { t = 1; } CN2 = t.ToString(); dr.Close(); cmd = new SqlCommand("Select * From APaymentPassenger Where BookingNo=" + BookingNo.Text + "", con); dr = cmd.ExecuteReader(); dr.Read(); string a1 = null; string a2 = null; string a3 = null; string a4 = null; string a5 = null; string a6 = null; string a7 = null; a1 = dr.GetValue(0).ToString(); a2 = dr.GetValue(1).ToString(); a3 = dr.GetValue(2).ToString(); a4 = dr.GetValue(6).ToString(); a5 = dr.GetValue(7).ToString(); a6 = dr.GetValue(8).ToString(); a7 = dr.GetValue(9).ToString(); dr.Close(); cmd = new SqlCommand("Insert Into Cancellation Values(" + CN2 + ",'" + a1 + "','" + a2 + "','" + a3 + "','" + DateAndTime.Today + " " + DateAndTime.TimeOfDay + "','" + a4 + "','" + a5 + "','" + a6 + "','" + a7 + "','" + Strings.Format(Arrivaltime.Value, "hh:MM:ss tt") + "')", con); cmd.ExecuteNonQuery(); cmd = new SqlCommand("Delete From APassengerDetails Where BookingNo=" + BookingNo.Text + "", con); cmd.ExecuteNonQuery(); cmd = new SqlCommand("Delete From APaymentPassenger Where BookingNo=" + BookingNo.Text + "", con); cmd.ExecuteNonQuery(); MessageBox.Show("Done"); con.Close(); DGV.Rows.Clear(); SeatCapacity.Clear(); BookingNo.Clear(); SC2.Clear(); SeatAvailability.Clear(); RadioButton1.Checked = false; RadioButton2.Checked = false; } } else { MessageBox.Show("Not Cancelled"); } //Catch ex As Exception // MsgBox("Nothing Selected..!") //End Try }