public bool IsScheduleBooked(VehicleInformation vehicle, DateTime selectedDate, string shift)
 {
     VehicleSchedule vehicleSchedule = new VehicleSchedule();
     vehicleSchedule = _vehicleScheduleGateway.IsScheduleBooked(vehicle, selectedDate, shift);
     if(vehicleSchedule!=null)
     {
         message = string.Format("This schedule is already booked by : {0}", vehicleSchedule.BookedBy);
         return true;
     }
     message = string.Format("New Schedule is saved!");
     return false;
 }
 public VehicleSchedule 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())
             {
                 VehicleSchedule vehicleSchedule = new VehicleSchedule();
                 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;
 }