public IEnumerable <TreatmentRoomBO> GetAvailableRooms(TreatmentRoomBO room)
        {
            try
            {
                using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString))
                {
                    if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed)
                    {
                        objHmsDataContext.Connection.Open();
                    }

                    //List<TreatmentRoomBO> treatmentRoom = objHmsDataContext.TreatmentRoom_Records
                    //    .Where(t => (t.DateOfJoin != room.date && t.IsBooked == false))
                    //    .Select(t => new TreatmentRoomBO
                    //{
                    //    patient_ID = t.Patient_ID,
                    //    timings    = Convert.ToString(t.Timings),
                    //    isBooked   = t.IsBooked,
                    //    date       = t.DateOfJoin,
                    //    room_ID    = t.Room_ID
                    //}).ToList();


                    List <TreatmentRoomBO> treatmentRoomRec          = objHmsDataContext.ExecuteQuery <TreatmentRoomBO>("SELECT Room_ID, Appointment_ID, DateOfJoin,IsBooked,Patient_ID FROM TreatmentRoom_Records WHERE Room_ID IN( SELECT MAX (Room_ID) FROM TreatmentRoom_Records GROUP BY Room_ID)").ToList();
                    List <TreatmentRoomBO> treatmentRoomRecRemove    = new List <TreatmentRoomBO>();
                    List <TreatmentRoomBO> treatmentRoomRecRemoveNew = new List <TreatmentRoomBO>();
                    foreach (var r in treatmentRoomRec)
                    {
                        if (r.DateOfJoin == room.date)
                        {
                            treatmentRoomRecRemove.Add(r);
                        }
                    }
                    foreach (var r in treatmentRoomRecRemove)
                    {
                        if (r.isBooked == true)
                        {
                            treatmentRoomRecRemoveNew.Add(r);
                        }
                    }
                    foreach (var r  in treatmentRoomRecRemoveNew)
                    {
                        treatmentRoomRec = treatmentRoomRec.Where(rr => rr.room_ID != r.room_ID).ToList();

                        //treatmentRoomRec = treatmentRoomRec.;
                    }

                    return(treatmentRoomRec);
                }
            }
            catch (Exception e)
            {
                IEnumerable <TreatmentRoomBO> trmntRoomBO = null;
                return(trmntRoomBO);
            }
        }
        public IEnumerable <TreatmentRoomBO> GetAllTreatmentRoomRecs()
        {
            try
            {
                using (HospitalManagementSystemDataContext objHmsDataContext = new HospitalManagementSystemDataContext(Utils.ConnectionString))
                {
                    if (objHmsDataContext.Connection.State == System.Data.ConnectionState.Closed)
                    {
                        objHmsDataContext.Connection.Open();
                    }

                    //IEnumerable<TreatmentRoomBO> treatmentRoom = objHmsDataContext.TreatmentRoom_Records.Join(objHmsDataContext.Patients,
                    //    t => t.Patient_ID,
                    //    p => p.Patient_ID,
                    //    (t, p) => new TreatmentRoomBO
                    //    {
                    //        patient_ID = t.Patient_ID,
                    //        timings = Convert.ToString(t.Timings),
                    //        isBooked = t.IsBooked,
                    //        date = t.DateOfJoin,
                    //        room_ID = t.Room_ID,
                    //        PatientFirstName = p.First_Name,
                    //        appointment_ID = t.Appointment_ID
                    //    }).ToArray();

                    List <TreatmentRoomBO> treatmentRoomRec = objHmsDataContext.ExecuteQuery <TreatmentRoomBO>("SELECT Room_ID, Appointment_ID, DateOfJoin,IsBooked,Patient_ID  FROM TreatmentRoom_Records WHERE Room_ID IN( SELECT MAX (Room_ID) FROM TreatmentRoom_Records GROUP BY Room_ID)").ToList();

                    foreach (var t in treatmentRoomRec)
                    {
                        t.PatientFirstName = objHmsDataContext.Patients.Where(p => p.Patient_ID == t.patient_ID).Select(p => p.First_Name).First();
                        t.timings          = "09:00";
                        t.date             = t.DateOfJoin;
                    }

                    return(treatmentRoomRec);
                }
            }
            catch (Exception e)
            {
                IEnumerable <TreatmentRoomBO> trmntRoomBO = null;
                return(trmntRoomBO);
            }
        }