public ScheduleVehicle IsScheduleBooked(VehicleInformation vehicle, DateTime selectedDate, string shift)
 {
     try
     {
         SqlConnectionObj.Open();
         string query = string.Format("SELECT * FROM ScheduleVehicle WHERE VehicleRegNo='{0}' AND Date='{1}' AND Shift='{2}'", vehicle.RegNo, selectedDate, shift);
         SqlCommandObj.CommandText = query;
         SqlDataReader reader = SqlCommandObj.ExecuteReader();
             while (reader.Read())
             {
                 ScheduleVehicle vehicleSchedule = new ScheduleVehicle();
                 vehicleSchedule.Vehicle.RegNo = reader[0].ToString();
                 vehicleSchedule.SelectedDate = (DateTime)reader[1];
                 vehicleSchedule.SelectShift = reader[2].ToString();
                 vehicleSchedule.BookedBy = reader[3].ToString();
                 vehicleSchedule.Address = reader[4].ToString();
                 return vehicleSchedule;
             }
     }
     catch (Exception exceptionObj)
     {
         throw new Exception("Exception occured! In Schedule Booking.",exceptionObj);
     }
     finally
     {
         if (SqlConnectionObj != null && SqlConnectionObj.State == ConnectionState.Open)
         {
             SqlConnectionObj.Close();
         }
     }
     return null;
 }
 public bool IsScheduleBooked(VehicleInformation vehicle, DateTime selectedDate, string shift)
 {
     ScheduleVehicle vehicleSchedule = new ScheduleVehicle();
     vehicleSchedule = scheduleVehicleGateway.IsScheduleBooked(vehicle, selectedDate, shift);
     if(vehicleSchedule!=null)
     {
         string msg = string.Format("This schedule is already booked by : {0}", vehicleSchedule.BookedBy);
         return true;
     }
     return false;
 }