Beispiel #1
0
        public bool SearchBefore(AllocateRoom allocate)
        {
            Query   = "select endtime from RoomAllocation where Room=" + allocate.Rooms + " AND day='" + allocate.Day + "' AND StartTime<='" + allocate.TimeFrom + "'";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.ExecuteNonQuery();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                string   temp      = Reader["endtime"].ToString();
                DateTime endTime   = DateTime.Parse(temp);
                DateTime startTime = DateTime.Parse(allocate.TimeFrom);

                int minutes = (int)(startTime.Subtract(endTime).TotalMinutes);
                if (minutes < 0)
                {
                    Reader.Close();
                    Connection.Close();
                    return(true);
                }
            }
            Reader.Close();
            Connection.Close();
            return(false);
        }
Beispiel #2
0
 public ActionResult AllocateRoom(AllocateRoom allocate)
 {
     ViewBag.Departments = departmentManager.ViewDepartment();
     ViewBag.Rooms       = aCourseManager.GetAllRooms();
     ViewBag.Result      = aCourseManager.AllocateRoom(allocate);
     return(View());
 }
Beispiel #3
0
        public List <AllocateRoom> GetByDay(string day, int roomId)
        {
            string query = " SELECT * FROM AllocateRoom WHERE Day = '" + day + "' AND RoomId = '" + roomId + "' AND Assign = 'assigned' ";

            Connection.Open();
            Command.CommandText = query;

            SqlDataReader       reader      = Command.ExecuteReader();
            List <AllocateRoom> getAllRooms = new List <AllocateRoom>();

            while (reader.Read())
            {
                AllocateRoom getRoom = new AllocateRoom()
                {
                    Id           = (int)reader["Id"],
                    DepartmentId = (int)reader["DepartmentId"],
                    CourseId     = (int)reader["CourseId"],
                    RoomId       = (int)reader["RoomId"],
                    Day          = reader["Day"].ToString(),
                    FromHour     = (int)reader["FromHour"],
                    FromMin      = (int)reader["FromMin"],
                    FromFormat   = reader["FromFormat"].ToString(),
                    ToHour       = (int)reader["ToHour"],
                    ToMin        = (int)reader["ToMin"],
                    ToFormat     = reader["ToFormat"].ToString()
                };

                getAllRooms.Add(getRoom);
            }

            Connection.Close();
            reader.Close();

            return(getAllRooms);
        }
Beispiel #4
0
 public ActionResult AddAllocatedRoom(AllocateRoom allocateRoom)
 {
     ViewBag.Department = new SelectList(db.Departments.ToList().OrderBy(s => s.Id), "Id", "Name");
     ViewBag.Course     = new SelectList(db.Courses.ToList().OrderBy(s => s.Id), "Id", "Name");
     ViewBag.Room       = new SelectList(db.Rooms.ToList().OrderBy(s => s.Id), "Id", "RoomNo");
     ViewBag.Day        = new SelectList(db.Days.ToList().OrderBy(s => s.Id), "Id", "Name");
     try
     {
         if (ModelState.IsValid)
         {
             if (!db.AllocateRooms.Any(t => t.TimeTo == allocateRoom.TimeTo && t.TimeFrom == allocateRoom.TimeFrom &&
                                       t.RoomId == allocateRoom.RoomId))
             {
                 allocateRoom.IsActive = false;
                 db.AllocateRooms.Add(allocateRoom);
                 db.SaveChanges();
                 Session["success_div"] = "true";
                 Session["success_msg"] = "Insert Successfully.";
                 return(RedirectToAction("IndexAllocateRoom"));
             }
             else
             {
                 Session["success_div"] = "true";
                 Session["success_msg"] = "Email is not unique.";
                 return(RedirectToAction("AddAllocatedRoom"));
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
     return(RedirectToAction("IndexAllocateRoom"));
 }
        public bool IsRoomFree(AllocateRoom allocateRoom)
        {
            Query =
                "SELECT * FROM  ClassRoom  WHERE RoomId=@RoomId AND DayId=@DayId";


            Command = new SqlCommand(Query, Connection);

            Command.Parameters.Clear();

            Command.Parameters.Add("RoomId", SqlDbType.Int);
            Command.Parameters["RoomId"].Value = allocateRoom.RoomId;

            Command.Parameters.Add("DayId", SqlDbType.Int);
            Command.Parameters["DayId"].Value = allocateRoom.DayId;

            Connection.Open();

            Reader = Command.ExecuteReader();
            bool hasRow = true;

            while (Reader.Read())
            {
                if (Convert.ToDateTime(Reader["ToTime"]) > Convert.ToDateTime(allocateRoom.FromTime) &&
                    Convert.ToDateTime(allocateRoom.ToTime) > Convert.ToDateTime(Reader["FromTime"]) && Reader["Status"].ToString() == "Allocate")
                {
                    hasRow = false;
                }
            }
            Reader.Close();
            Connection.Close();
            return(hasRow);
        }
        public int SetRoomAllocationInformation(AllocateRoom allocateRoom)
        {
            int    fromHour      = allocateRoom.FromTime.Hour;
            int    fromMinute    = allocateRoom.FromTime.Minute;
            double fromTimeForDB = Convert.ToDouble(fromHour + "." + fromMinute);

            int    toHour      = allocateRoom.ToTime.Hour;
            int    toMinute    = allocateRoom.ToTime.Minute;
            double toTimeForDB = Convert.ToDouble(toHour + "." + toMinute);

            string timeForView = GetTimeForView(allocateRoom);


            int result = 0;

            if (allocateRoomGateway.IsTimeExist(fromTimeForDB, toTimeForDB, allocateRoom.Day, allocateRoom.RoomNo))
            {
                result = 1;
            }
            else if (allocateRoomGateway.SetRoomAllocationInformation(allocateRoom, fromTimeForDB, toTimeForDB, timeForView))
            {
                result = 2;
                //result = "The Room Allocation Information Successfully saved";
            }
            else
            {
                result = 3;
                //result = "There is some error while entering data into database";
            }

            return(result);
        }
Beispiel #7
0
        public ActionResult DeleteAllocatedRoomConfirmed(int id)
        {
            AllocateRoom allocateRoom = db.AllocateRooms.Find(id);

            db.AllocateRooms.Remove(allocateRoom ?? throw new InvalidOperationException());
            db.SaveChanges();
            return(RedirectToAction("IndexAllocateRoom"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AllocateRoom allocateroom = db.AllocateRooms.Find(id);

            db.AllocateRooms.Remove(allocateroom);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Allocate(AllocateRoom allocateRoom)
        {
            ViewBag.Departments = allocateRoomManager.GetAllDepartments();
            //ViewBag.Courses = allocateRoomManager.GetAllCourses();
            ViewBag.Rooms = allocateRoomManager.GetAllRooms();
            ViewBag.Days  = allocateRoomManager.GetAllDays();

            ViewBag.Message = allocateRoomManager.Allocate(allocateRoom);
            return(View());
        }
        public AllocateRoom Save(AllocateRoom allocateRoom)
        {
            AllocateRoom room = IsRoomAvailable(allocateRoom);

            if (room == null)
            {
                _allocateClassroomGateway.Save(allocateRoom);
                return(null);
            }

            return(room);
        }
        public ActionResult Create([Bind(Include = "Id,DepartmentId,CourseId,RoomId,DayId,From,To")] AllocateRoom allocateroom)
        {
            if (ModelState.IsValid)
            {
                db.AllocateRooms.Add(allocateroom);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DayId        = new SelectList(db.Days, "Id", "Name", allocateroom.DayId);
            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "Code", allocateroom.DepartmentId);
            ViewBag.RoomId       = new SelectList(db.Rooms, "Id", "Name", allocateroom.RoomId);
            return(View(allocateroom));
        }
Beispiel #12
0
        public bool Save(AllocateRoom allocateRoom)
        {
            string query = "INSERT INTO AllocateRoom (DepartmentId,CourseId,RoomId,Day,FromHour,FromMin,FromFormat,ToHour,ToMin,ToFormat,Assign) VALUES ('" + allocateRoom.DepartmentId + "','" + allocateRoom.CourseId + "','" + allocateRoom.RoomId + "','" + allocateRoom.Day + "','" + allocateRoom.FromHour + "','" + allocateRoom.FromMin + "'," +
                           "'" + allocateRoom.FromFormat + "','" + allocateRoom.ToHour + "','" + allocateRoom.ToMin + "','" + allocateRoom.ToFormat + "','assigned')";

            Connection.Open();
            Command.CommandText = query;

            int rowsEffected = Command.ExecuteNonQuery();

            Connection.Close();

            return(rowsEffected > 0);
        }
        // GET: /AllocateRoom/Edit/5
        //public ActionResult Edit(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    AllocateRoom allocateroom = db.AllocateRooms.Find(id);
        //    if (allocateroom == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    ViewBag.CourseId = new SelectList(db.Courses, "Id", "Code", allocateroom.CourseId);
        //    ViewBag.DayId = new SelectList(db.Days, "Id", "Name", allocateroom.DayId);
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "Code", allocateroom.DepartmentId);
        //    ViewBag.RoomId = new SelectList(db.Rooms, "Id", "Name", allocateroom.RoomId);
        //    return View(allocateroom);
        //}

        // POST: /AllocateRoom/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include="Id,DepartmentId,CourseId,RoomId,DayId,From,To")] AllocateRoom allocateroom)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(allocateroom).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    ViewBag.CourseId = new SelectList(db.Courses, "Id", "Code", allocateroom.CourseId);
        //    ViewBag.DayId = new SelectList(db.Days, "Id", "Name", allocateroom.DayId);
        //    ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "Code", allocateroom.DepartmentId);
        //    ViewBag.RoomId = new SelectList(db.Rooms, "Id", "Name", allocateroom.RoomId);
        //    return View(allocateroom);
        //}

        // GET: /AllocateRoom/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AllocateRoom allocateroom = db.AllocateRooms.Find(id);

            if (allocateroom == null)
            {
                return(HttpNotFound());
            }
            return(View(allocateroom));
        }
Beispiel #14
0
        public ActionResult EditAllocatedRoom(AllocateRoom allocateRoom)
        {
            ViewBag.Department = new SelectList(db.Departments.ToList().OrderBy(s => s.Id), "Id", "Name");
            ViewBag.Course     = new SelectList(db.Courses.ToList().OrderBy(s => s.Id), "Id", "Name");
            ViewBag.Room       = new SelectList(db.Rooms.ToList().OrderBy(s => s.Id), "Id", "RoomNo");
            ViewBag.Day        = new SelectList(db.Days.ToList().OrderBy(s => s.Id), "Id", "Name");

            if (ModelState.IsValid)
            {
                db.Entry(allocateRoom).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("IndexAllocateRoom"));
            }
            return(View(allocateRoom));
        }
Beispiel #15
0
        //room
        public string AllocateRoom(AllocateRoom allocate)
        {
            Query = "INSERT INTO RoomAllocation(Course,Room,Day,StartTime,EndTime) VALUES(@Course,@Rooms,@Day,@TimeFrom,@TimeTo)";

            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();
            Command.Parameters.AddWithValue("Course", allocate.Course);
            Command.Parameters.AddWithValue("Rooms", allocate.Rooms);
            Command.Parameters.AddWithValue("Day", allocate.Day);
            Command.Parameters.AddWithValue("TimeFrom", allocate.TimeFrom);
            Command.Parameters.AddWithValue("TimeTo", allocate.TimeTo);
            Connection.Open();
            Command.ExecuteNonQuery();
            Connection.Close();
            return("Room Allocation Successful");
        }
        //room

        public string AllocateRoom(AllocateRoom allocate)
        {
            if (aCourseGatway.SearchBeetweenTime(allocate))
            {
                return("This time slot is booked");
            }
            if (aCourseGatway.SearchBefore(allocate))
            {
                return("This time slot is booked");
            }
            //if (aCourseGatway.CheckRoomTime(allocate))
            //{

            //}
            return(aCourseGatway.AllocateRoom(allocate));
        }
Beispiel #17
0
        //room

        public string AllocateRoom(AllocateRoom allocate)
        {
            if (aCourseGatway.SearchBeetweenTime(allocate))
            {
                return("Already 1");
            }
            if (aCourseGatway.SearchBefore(allocate))
            {
                return("Already 2");
            }
            //if (aCourseGatway.CheckRoomTime(allocate))
            //{

            //}
            return(aCourseGatway.AllocateRoom(allocate));
        }
Beispiel #18
0
        // GET: UCRMS/Delete/5
        public ActionResult DeleteAllocatedRoom(int?id)
        {
            VM_AllocateRooms ar = new VM_AllocateRooms();

            ViewBag.allocatedRoom = ar.AllocatedRoom(id);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AllocateRoom allocateRoom = db.AllocateRooms.Find(id);

            if (allocateRoom == null)
            {
                return(HttpNotFound());
            }
            return(View(allocateRoom));
        }
        private AllocateRoom IsRoomAvailable(AllocateRoom allocateRoom)
        {
            DateTime fromTime, toTime, fromTime1, toTime1;

            List <AllocateRoom> rooms = GetByDay(allocateRoom.Day, allocateRoom.RoomId);

            if (rooms != null)
            {
                foreach (AllocateRoom room in rooms)
                {
                    string fromHour   = room.FromHour.ToString();
                    string fromMin    = room.FromMin.ToString();
                    string fromFormat = room.FromFormat;
                    string toHour     = room.ToHour.ToString();
                    string toMin      = room.ToMin.ToString();
                    string toFormat   = room.ToFormat;

                    fromTime = DateTime.Parse(fromHour + ":" + fromMin + " " + fromFormat);
                    toTime   = DateTime.Parse(toHour + ":" + toMin + " " + toFormat);

                    fromTime1 = DateTime.Parse(allocateRoom.FromHour + ":" + allocateRoom.FromMin + " " +
                                               allocateRoom.FromFormat);
                    toTime1 = DateTime.Parse(allocateRoom.ToHour + ":" + allocateRoom.ToMin + " " +
                                             allocateRoom.ToFormat);

                    if (fromTime1 > fromTime && toTime > toTime1 && fromTime1 < toTime)
                    {
                        return(room);
                    }
                    else if (fromTime1 > fromTime && toTime > fromTime1 && toTime1 > toTime)
                    {
                        return(room);
                    }

                    else if (fromTime >= fromTime1 && toTime1 > fromTime && toTime > toTime1)
                    {
                        return(room);
                    }
                    else if (fromTime >= fromTime1 && toTime1 >= toTime)
                    {
                        return(room);
                    }
                }
            }
            return(null);
        }
Beispiel #20
0
        // GET: UCRMS/Edit/5
        public ActionResult EditAllocatedRoom(int?id)
        {
            ViewBag.Department = new SelectList(db.Departments.ToList().OrderBy(s => s.Id), "Id", "Name");
            ViewBag.Course     = new SelectList(db.Courses.ToList().OrderBy(s => s.Id), "Id", "Name");
            ViewBag.Room       = new SelectList(db.Rooms.ToList().OrderBy(s => s.Id), "Id", "RoomNo");
            ViewBag.Day        = new SelectList(db.Days.ToList().OrderBy(s => s.Id), "Id", "Name");

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AllocateRoom allocate = db.AllocateRooms.Find(id);

            if (allocate == null)
            {
                return(HttpNotFound());
            }
            return(View(allocate));
        }
        public string Allocate(AllocateRoom allocateRoom)
        {
            int rowAffected = 0;

            if (allocateRoomGateway.IsRoomFree(allocateRoom) == false)
            {
                return("Room is not Free");
            }
            if (allocateRoomGateway.IsRoomUnAllocate(allocateRoom) > 0)
            {
                return("Update successfully");
            }

            rowAffected = allocateRoomGateway.Allocate(allocateRoom);

            if (rowAffected > 0)
            {
                return("Saved successfully");
            }
            return("Save failed");
        }
Beispiel #22
0
        public bool SetRoomAllocationInformation(AllocateRoom allocateRoom, double fromTimeForDB, double toTimeForDB, string timeForView)
        {
            GenarateConnection();
            using (Connection)
            {
                Connection.Open();
                string query =
                    "insert into AllocateRoom (Department,Course,RoomNumber,Day,FromTime,ToTime,TimeForView,Visible) values (@Department,@Course,@RoomNo,@Day,@FromTime,@ToTime,@TimeForView,@Visible);";

                Command = new SqlCommand(query, Connection);
                Command.Parameters.Clear();

                Command.Parameters.Add("@Department", SqlDbType.Int);
                Command.Parameters["@Department"].Value = allocateRoom.Department;
                Command.Parameters.Add("@Course", SqlDbType.Int);
                Command.Parameters["@Course"].Value = allocateRoom.Course;
                Command.Parameters.Add("@RoomNo", SqlDbType.Int);
                Command.Parameters["@RoomNo"].Value = allocateRoom.RoomNo;
                Command.Parameters.Add("@Day", SqlDbType.Int);
                Command.Parameters["@Day"].Value = allocateRoom.Day;
                Command.Parameters.Add("@FromTime", SqlDbType.Float);
                Command.Parameters["@FromTime"].Value = fromTimeForDB;
                Command.Parameters.Add("@ToTime", SqlDbType.Float);
                Command.Parameters["@ToTime"].Value = toTimeForDB;
                Command.Parameters.Add("@TimeForView", SqlDbType.VarChar);
                Command.Parameters["@TimeForView"].Value = timeForView;
                Command.Parameters.Add("@Visible", SqlDbType.Int);
                Command.Parameters["@Visible"].Value = 1;
                try
                {
                    Command.ExecuteNonQuery();
                    Connection.Close();
                    return(true);
                }
                catch (Exception)
                {
                    throw new Exception("Error While Entering data into database");
                }
            }
        }
        public ActionResult Save(AllocateRoom allocateRoom)
        {
            int result = allocateRoomManager.SetRoomAllocationInformation(allocateRoom);

            //if ( result== 1)
            //{
            //    ViewBag.Message = " Time Conflit with another class. please reallocate time";
            //}
            //else if( result== 2)
            //{
            //    ViewBag.Message =  "The Room Allocation Information Successfully saved";
            //}
            //else
            //{
            //    ViewBag.Message = "There is some error while entering data into database";
            //}
            ViewBag.Message     = result.ToString();
            ViewBag.Departments = allocateRoomManager.GetDepartmentDropdownList();
            ViewBag.Rooms       = allocateRoomManager.GetRoomDropdownList();
            ViewBag.Days        = allocateRoomManager.GetDayDropdownList();
            return(View());
        }
        public ActionResult Index(AllocateRoom allocateRoom)
        {
            PopulateDepartmentList();
            PopulateDefaultCourseList();
            PopulateRoom();
            ViewBag.Days = Day();

            if (ModelState.IsValid)
            {
                bool check = false;
                if (allocateRoom.FromFormat == allocateRoom.ToFormat)
                {
                    if (allocateRoom.FromHour > allocateRoom.ToHour)
                    {
                        check = true;
                    }
                }
                if (!check)
                {
                    AllocateRoom room = _allocateClassroomManager.Save(allocateRoom);

                    if (room == null)
                    {
                        ViewBag.Message = "Scheduled Successfully";
                        ModelState.Clear();
                    }
                    else
                    {
                        ViewBag.Message = "classroom overlapes by " + _courseManager.GetCourseById(room.CourseId).Code;
                    }
                }
                else
                {
                    ViewBag.Message = "Please enter valid class time";
                }
            }

            return(View());
        }
Beispiel #25
0
        //allocation
        public bool SearchBeetweenTime(AllocateRoom allocate)
        {
            //DateTime startTime = DateTime.Parse(allocate.TimeFrom).AddMinutes(DateTime.Parse("0:01 AM").Minute);
            //DateTime temp = DateTime.Parse("0:01 AM");
            //DateTime endTime = DateTime.Parse(allocate.TimeTo);

            //string startTimeS = startTime.TimeOfDay.ToString();
            //string endTimeS = (endTime.Subtract(temp)).ToString();
            Query   = "SELECT * FROM RoomAllocation WHERE Room=" + allocate.Rooms + " AND day='" + allocate.Day + "' AND StartTime>= '" + allocate.TimeFrom + "' and StartTime<'" + allocate.TimeTo + "'";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.ExecuteNonQuery();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                Reader.Close();
                Connection.Close();
                return(true);
            }
            Reader.Close();
            Connection.Close();
            return(false);
        }
        public int IsRoomUnAllocate(AllocateRoom allocateRoom)
        {
            Query = "UPDATE  ClassRoom SET RoomId=@RoomId,DayId=@DayId,FromTime=@FromTime,ToTime=@ToTime,CourseId=@CourseId,DepartmentId=@DepartmentId,Status=@Status WHERE RoomId=@RoomId AND DayId=@DayId AND DepartmentId=@DepartmentId AND FromTime=@FromTime AND ToTime=@ToTime AND Status='UnAllocate'";

            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();

            Command.Parameters.Add("RoomId", SqlDbType.Int);
            Command.Parameters["RoomId"].Value = allocateRoom.RoomId;

            Command.Parameters.Add("DayId", SqlDbType.Int);
            Command.Parameters["DayId"].Value = allocateRoom.DayId;

            Command.Parameters.Add("FromTime", SqlDbType.VarChar);
            Command.Parameters["FromTime"].Value = allocateRoom.FromTime;

            Command.Parameters.Add("ToTime", SqlDbType.VarChar);
            Command.Parameters["ToTime"].Value = allocateRoom.ToTime;

            Command.Parameters.Add("CourseId", SqlDbType.Int);
            Command.Parameters["CourseId"].Value = allocateRoom.CourseId;

            Command.Parameters.Add("DepartmentId", SqlDbType.Int);
            Command.Parameters["DepartmentId"].Value = allocateRoom.DepartmentId;

            Command.Parameters.Add("Status", SqlDbType.VarChar);
            Command.Parameters["Status"].Value = "Allocate";



            Connection.Open();
            int UpdateRowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(UpdateRowAffected);
        }
        public int Allocate(AllocateRoom allocateRoom)
        {
            Query = "INSERT INTO ClassRoom VALUES (@RoomId,@DayId,@FromTime,@ToTime,@CourseId,@DepartmentId,@Status)";

            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();

            Command.Parameters.Add("RoomId", SqlDbType.Int);
            Command.Parameters["RoomId"].Value = allocateRoom.RoomId;

            Command.Parameters.Add("DayId", SqlDbType.Int);
            Command.Parameters["DayId"].Value = allocateRoom.DayId;

            Command.Parameters.Add("FromTime", SqlDbType.VarChar);
            Command.Parameters["FromTime"].Value = allocateRoom.FromTime;

            Command.Parameters.Add("ToTime", SqlDbType.VarChar);
            Command.Parameters["ToTime"].Value = allocateRoom.ToTime;

            Command.Parameters.Add("CourseId", SqlDbType.Int);
            Command.Parameters["CourseId"].Value = allocateRoom.CourseId;

            Command.Parameters.Add("DepartmentId", SqlDbType.Int);
            Command.Parameters["DepartmentId"].Value = allocateRoom.DepartmentId;

            Command.Parameters.Add("Status", SqlDbType.VarChar);
            Command.Parameters["Status"].Value = "Allocate";



            Connection.Open();
            int rowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowAffected);
        }
        public string GetTimeForView(AllocateRoom allocateRoom)
        {
            int    fromHour       = allocateRoom.FromTime.Hour;
            string fromHourString = "";

            if (fromHour > 12)
            {
                fromHour = fromHour - 12;
            }
            if (fromHour < 10)
            {
                fromHourString = "0" + fromHour;
            }
            else
            {
                fromHourString = "" + fromHour;
            }


            int    fromMinute       = allocateRoom.FromTime.Minute;
            string fromMinuteString = "";

            if (fromMinute == 0)
            {
                fromMinuteString = "00";
            }
            else if (fromMinute < 10)
            {
                fromMinuteString = fromMinute + "0";
            }
            else
            {
                fromMinuteString = fromMinute + "";
            }
            string fromTt = allocateRoom.FromTime.ToString("tt", CultureInfo.InvariantCulture);

            if (fromTt.Equals("AM") && fromHour == 0)
            {
                fromHourString = "12";
            }



            int    toHour       = allocateRoom.ToTime.Hour;
            string toHourString = "";

            if (toHour > 12)
            {
                toHour = toHour - 12;
            }
            if (toHour < 10)
            {
                toHourString = "0" + toHour;
            }
            else
            {
                toHourString = "" + toHour;
            }


            int    toMinute       = allocateRoom.ToTime.Minute;
            string toMinuteString = "";

            if (toMinute == 0)
            {
                toMinuteString = "00";
            }
            else if (toMinute < 10)
            {
                toMinuteString = fromMinute + "0";
            }
            else
            {
                toMinuteString = fromMinute + "";
            }
            string ToTt = allocateRoom.ToTime.ToString("tt", CultureInfo.InvariantCulture);

            if (ToTt.Equals("AM") && toHour == 0)
            {
                toHourString = "12";
            }


            string getRoomName = allocateRoomGateway.GetRoomName(allocateRoom.RoomNo);
            string getDayName  = allocateRoomGateway.GetDayName(allocateRoom.Day);

            string fullTimeResult = "R. No : " + getRoomName + " , " + getDayName + " , " + fromHourString + ":" +
                                    fromMinuteString + " " + fromTt + " - " + toHourString + " : " + toMinuteString + " " + ToTt;

            return(fullTimeResult);
        }