Exemplo n.º 1
0
        public int Save(AllocateClassroom allocateClassroom)
        {
            string from = allocateClassroom.TimeFrom.ToShortTimeString();
            string to   = allocateClassroom.TimeTo.ToShortTimeString();

            string     query   = "INSERT INTO AllocateClassrooms(CourseId,RoomId,DayId,TimeFrom,TimeTo,Status) VALUES(@CourseId,@RoomId,@DayId,'" + from + "','" + to + "',@Status)";
            SqlCommand command = new SqlCommand(query, Connection);

            command.Parameters.Clear();

            command.Parameters.Add("@CourseId", SqlDbType.VarChar);
            command.Parameters["@CourseId"].Value = allocateClassroom.CourseId;

            command.Parameters.Add("@RoomId", SqlDbType.VarChar);
            command.Parameters["@RoomId"].Value = allocateClassroom.RoomId;

            command.Parameters.Add("@DayId", SqlDbType.VarChar);
            command.Parameters["@DayId"].Value = allocateClassroom.DayId;

            command.Parameters.Add("@Status", SqlDbType.VarChar);
            command.Parameters["@Status"].Value = 1;

            Connection.Open();
            int rowsAffected = command.ExecuteNonQuery();

            Connection.Close();

            return(rowsAffected);
        }
        public void IsRoomAllocated(AllocateClassroom allocateClassroom)
        {
            var allcocationList = GetAllAllocationList(allocateClassroom);

            string msg;

            if (allcocationList.Count == 0)
            {
                Message = "";
            }
            else
            {
                bool status = false;
                foreach (var a in allcocationList)
                {
                    if ((allocateClassroom.FromTime >= a.FromTime && allocateClassroom.FromTime < a.ToTime) ||
                        (allocateClassroom.ToTime > a.FromTime && allocateClassroom.ToTime <= a.ToTime))
                    {
                        Message = "Time Clash for room alocation. Please Try another time.";

                        status = true;
                    }
                }

                if (status == false)
                {
                    Message = "";
                }
                else
                {
                    Message = "Time Clash for room alocation. Please Try another time.";
                }
            }
        }
        public ActionResult AllocateClassroom(AllocateClassroom allocateClassroom)
        {
            _allocateClassRoomManager.IsRoomAllocated(allocateClassroom);

            if (_allocateClassRoomManager.Message == "")
            {
                bool result = _allocateClassRoomManager.Save(allocateClassroom);
                if (result)
                {
                    ViewBag.SuccessMessage = "Class Room Allocated Successfully";
                }
                else
                {
                    ViewBag.ErrorMessage = "Class Room Allocation Failed";
                }
            }
            else
            {
                ViewBag.ErrorMessage = _allocateClassRoomManager.Message;
            }



            ViewBag.Department = _departmentManager.GetAllDepartments();
            ViewBag.Classroom  = _classroomManager.GetAllRooms();
            ViewBag.Day        = _dayManager.GetAllDays();
            return(View());
        }
 public ActionResult AllocateClassRoom(AllocateClassroom classroom)
 {
     FillDepartmentDropdown();
     FillRoomDropdown();
     if (ModelState.IsValid)
     {
         if (classroom.FromTime >= classroom.ToTime)
         {
             FlashMessage.Danger("From time should be less than to time");
             ModelState.Clear();
             return(View(classroom));
         }
         if (!_classRoomManager.IsClassRoomAvailable(classroom.Day, classroom.FromTime, classroom.ToTime, classroom.RoomId))
         {
             FlashMessage.Danger($"Class room is not available between {classroom.FromTime.ToShortTimeString()} to {classroom.ToTime.ToShortTimeString()} on {classroom.Day}");
             ModelState.Clear();
             return(View(classroom));
         }
         _classRoomManager.SaveAllocatedClassRoom(classroom);
         FlashMessage.Confirmation("Class room successfully allocated");
         return(RedirectToAction("AllocateClassRoom"));
     }
     FlashMessage.Danger("Some error occured, please check all the input");
     return(View(classroom));
 }
        public bool IsRoomAlreadyAllocated(AllocateClassroom allocateClassroom)
        {
            TimeSpan ftime = allocateClassroom.FromTime.TimeOfDay;
            TimeSpan ttime = allocateClassroom.ToTime.TimeOfDay;

            List <AllocateClassroom> allocateClassrooms = aRoomGateway.IsRoomAlreadyAllocated(allocateClassroom.DayId, allocateClassroom.RoomId);

            foreach (AllocateClassroom classroom in allocateClassrooms)
            {
                TimeSpan aFtime = classroom.FromTime.TimeOfDay;
                TimeSpan aTtime = classroom.ToTime.TimeOfDay;
                if (TimeSpan.Compare(ftime, aFtime) >= 0 && TimeSpan.Compare(ftime, aTtime) < 0)
                {
                    return(true);
                }
                else if (TimeSpan.Compare(ttime, aFtime) > 0 && TimeSpan.Compare(ttime, aTtime) < 0)
                {
                    return(true);
                }
                else if (TimeSpan.Compare(ftime, aFtime) <= 0 && TimeSpan.Compare(ttime, aTtime) > 0)
                {
                    return(true);
                }
                //if (allocateClassroom.FromTime >= classroom.FromTime && allocateClassroom.FromTime<classroom.ToTime)
                //{
                //    return true;
                //}
                //else if (allocateClassroom.ToTime > classroom.FromTime && allocateClassroom.ToTime < classroom.ToTime)
                //{
                //    return true;
                //}
            }
            return(false);
        }
Exemplo n.º 6
0
        public int SaveAllocateClassroomInfo(AllocateClassroom allocateClassroom)
        {
            _query = "INSERT INTO AllocateClassroom(CourseId,RoomId,DayId,AllocateFromDate,AllocateToDate) values(@CourseId, @RoomId,@DayId,@AllocateFromDate,@AllocateToDate)";


            _command = new SqlCommand(_query, _connection);


            TimeSpan time = new TimeSpan();

            time.ToString();
            //cmd.Parameters.AddWithValue("@Date", Convert.ToDateTime(DateTime.Now.ToShortDateString()));
            //cmd.Parameters.AddWithValue("@Time", Convert.ToDateTime(DateTime.Now.ToString("HH:mm:ss")));

            _command.Parameters.AddWithValue("@CourseId", allocateClassroom.CourseId);
            _command.Parameters.AddWithValue("@RoomId", allocateClassroom.RoomId);
            _command.Parameters.AddWithValue("@DayId", allocateClassroom.DayId);
            _command.Parameters.AddWithValue("@AllocateFromDate", allocateClassroom.AllocateFromDate.ToString("HH:mm:ss"));
            _command.Parameters.AddWithValue("@AllocateToDate", Convert.ToDateTime(allocateClassroom.AllocateToDate.ToString("HH:mm:ss")));


            _connection.Open();

            int rowAffect = _command.ExecuteNonQuery();

            _connection.Close();

            return(rowAffect);
        }
Exemplo n.º 7
0
 public ActionResult AllocateClassroom(AllocateClassroom allocateClassroom)
 {
     ViewBag.departments = ClassroomManager.GetAllDepartments();
     ViewBag.rooms       = ClassroomManager.GetAllRooms();
     ViewBag.msg         = ClassroomManager.Save(allocateClassroom);
     return(View());
 }
 public int Save(AllocateClassroom allocate)
 {
     Query = "INSERT INTO AllocateClassroom (DepartmentId, CourseId, RoomId, FromTime, ToTime, Allocate, Day)" +
             " VALUES ('" + allocate.DepartmentId + "','" + allocate.CourseId + "','" + allocate.RoomId + "','"
             + allocate.FromTime + "','" + allocate.ToTime + "','" + allocate.Allocate + "','" + allocate.Day + "')";
     return(GetRowAffect(Query));
 }
Exemplo n.º 9
0
        public List <AllocateClassroom> GetAllAllocationData()
        {
            Qurey   = "SELECT * FROM allocateClassroom where status=@status";
            Command = new SqlCommand(Qurey, Connection);
            Command.Parameters.AddWithValue("@status", "active");
            List <AllocateClassroom> allocateClassrooms = new List <AllocateClassroom>();

            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                AllocateClassroom allocate = new AllocateClassroom();
                allocate.Id           = Convert.ToInt32(Reader["id"]);
                allocate.CourseId     = Convert.ToInt32(Reader["courseId"]);
                allocate.DepartmentId = Convert.ToInt32(Reader["departmentId"]);
                allocate.DayId        = Convert.ToInt32(Reader["dayId"]);
                allocate.RoomId       = Convert.ToInt32(Reader["roomId"]);
                allocate.StartingTime = Reader["fromTime"].ToString();
                allocate.EndingTime   = Reader["toTime"].ToString();
                //allocate.FromTime = Convert.ToDouble(Reader["from"]);
                //allocate.ToTime = Convert.ToDouble(Reader["to"]);

                allocateClassrooms.Add(allocate);
            }
            Reader.Close();
            Connection.Close();
            return(allocateClassrooms);
        }
Exemplo n.º 10
0
        public ActionResult AllocateClassroom(AllocateClassroom allocateClassroom)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string msg;
                    int    rowAffceted = _allocateClassroomManager.SaveAllocateRoomInfo(allocateClassroom);

                    msg = rowAffceted > 0 ? "Course Saved Successfully" : "Course Saved Failed";

                    ViewBag.msg = msg;
                }
                else
                {
                    ViewBag.msg = "Student Information is Not valid";
                }
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }
            finally
            {
                ViewBag.Rooms       = _allocateClassroomManager.GetAllRooms();
                ViewBag.Departments = _departmentManager.GettAllDepartment();
            }



            return(View());
        }
Exemplo n.º 11
0
        public ActionResult AllocateClassrooms(AllocateClassroom allocateClassroom)
        {
            DateTime fromTime = allocateClassroom.FromTime;

            if (fromTime.ToShortTimeString().Count() == 7)
            {
                allocateClassroom.StartingTime = 0 + fromTime.ToShortTimeString();
            }
            else
            {
                allocateClassroom.StartingTime = fromTime.ToShortTimeString();
            }
            DateTime toTime = allocateClassroom.ToTime;

            if (toTime.ToShortTimeString().Count() == 7)
            {
                allocateClassroom.EndingTime = 0 + toTime.ToShortTimeString();
            }
            else
            {
                allocateClassroom.EndingTime = toTime.ToShortTimeString();
            }

            ViewBag.Departments = departmentManager.GetAllDepartments();
            ViewBag.Classrooms  = classroomManager.GetAllClassrooms();
            ViewBag.Days        = classroomManager.GetAllDays();
            if (ModelState.IsValid)
            {
                ViewBag.Message = classroomManager.SaveClassroomAllocation(allocateClassroom);
            }
            return(View());
        }
Exemplo n.º 12
0
        public int SaveAllocateClassRoom(AllocateClassroom aRoom)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            //string queary = "insert into tbl_Student(StudentName,Email,Contact,Dates,Addres,Id)VALUES('" + aStudent.Name + "','" + aStudent.Email + "','" + aStudent.ContactNo + "','" + aStudent.Date + "','" + aStudent.Address + "','" + aStudent.Id + "')";
            string     queary  = "insert into  tbl_Allocateion(Id,CourseName,RoomName,Day,Forms,Tows)values(@id,@course,@room,@day,@fromdate,@todate)";
            SqlCommand command = new SqlCommand(queary, connection);

            command.Parameters.Add("@id", SqlDbType.Int);
            command.Parameters["@id"].Value = aRoom.DepartmentId;

            command.Parameters.Add("@course", SqlDbType.VarChar);
            command.Parameters["@course"].Value = aRoom.CourseName;


            command.Parameters.Add("@room", SqlDbType.VarChar);
            command.Parameters["@room"].Value = aRoom.RoomNo;

            command.Parameters.Add("@day", SqlDbType.VarChar);
            command.Parameters["@day"].Value = aRoom.Day;

            command.Parameters.Add("@fromdate", SqlDbType.Time);
            command.Parameters["@fromdate"].Value = aRoom.From;

            command.Parameters.Add("@todate", SqlDbType.Time);
            command.Parameters["@todate"].Value = aRoom.To;

            connection.Open();

            int roweffected = command.ExecuteNonQuery();

            connection.Close();
            return(roweffected);
        }
Exemplo n.º 13
0
        public AllocateClassroom ifExitsTime(AllocateClassroom room)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            //string queary = "select*from tbl_AllocateCla where id=" + aClassRoom.Department + " and CourseID="+aClassRoom.CourseName+" and RoomId="+aClassRoom.RoomNo+" and DayId="+aClassRoom.Day+" and Froms="+aClassRoom.From+"and Twos="+aClassRoom.To+"";

            string queary = "select*from tbl_Allocateion";

            SqlCommand command = new SqlCommand(queary, connection);

            connection.Open();

            SqlDataReader reader = command.ExecuteReader();

            AllocateClassroom classRoom = null;

            while (reader.Read())
            {
                classRoom = new AllocateClassroom();
                classRoom.AllocateClassroomId = (int)reader["Al_ID"];
                classRoom.DepartmentId        = (int)reader["Id"];
                classRoom.CourseName          = reader["CourseName"].ToString();
                classRoom.RoomNo = reader["RoomName"].ToString();
                classRoom.Day    = reader["Day"].ToString();
                classRoom.From   = (TimeSpan)reader["Forms"];
                classRoom.To     = (TimeSpan)reader["Tows"];
            }
            reader.Close();
            connection.Close();
            return(classRoom);
        }
Exemplo n.º 14
0
        public List <AllocateClassroom> GetAllAllocationList(AllocateClassroom allocateClassroom)
        {
            Command.CommandText = "SELECT * FROM AllocateClassroom where ClassroomId='" + allocateClassroom.ClassroomId + "' AND DayId='" + allocateClassroom.DayId + "'";
            Connection.Open();
            SqlDataReader            reader             = Command.ExecuteReader();
            List <AllocateClassroom> allocateClassrooms = new List <AllocateClassroom>();

            while (reader.Read())
            {
                AllocateClassroom ac = new AllocateClassroom();
                ac.Id           = (int)reader["Id"];
                ac.DepartmentId = (int)reader["DepartmentId"];
                ac.CourseId     = (int)reader["CourseId"];
                ac.ClassroomId  = (int)reader["ClassroomId"];
                ac.DayId        = (int)reader["DayId"];
                ac.ClassroomId  = (int)reader["ClassroomId"];
                ac.FromTime     = (int)reader["FromTime"];
                ac.ToTime       = (int)reader["ToTime"];

                allocateClassrooms.Add(ac);
            }

            reader.Close();
            Connection.Close();
            return(allocateClassrooms);
        }
Exemplo n.º 15
0
        public ActionResult Allocate(AllocateClassroom allocate)
        {
            DepartmentManager aDepartmentManager = new DepartmentManager();
            RoomManager       aRoomManager       = new RoomManager();
            sevendaysManager  aSevendaysManager  = new sevendaysManager();

            ViewBag.aldepartments = aDepartmentManager.GetAllDepartmentInfo();
            ViewBag.allrooms      = aRoomManager.GetAllRooms();
            ViewBag.sevendays     = aSevendaysManager.GetAllDays();
            AllocateClassRoomManager allocateClassRoomManager = new AllocateClassRoomManager();
            bool allocateRoom = allocateClassRoomManager.GetRoomCheck(allocate);

            if (allocate.From > allocate.To)
            {
                ViewBag.message = "Your Time Formate isn't Right";
            }

            else if (allocateRoom)
            {
                ViewBag.message = "Room Is Not Free";
            }
            else
            {
                if (allocateClassRoomManager.SaveAllocateClassRoom(allocate) > 0)
                {
                    ViewBag.message = "Room Is Allocated";
                }
                else
                {
                    ViewBag.message = "Failed To Allocated";
                }
            }

            return(View());
        }
Exemplo n.º 16
0
        public List <AllocateClassroom> IsScheduleExists(AllocateClassroom allocateClassroom)
        {
            Query   = "SELECT * FROM AllocateClassroom WHERE RoomId = @roomId AND Day = @day AND Allocate =@allocate ";
            Command = new SqlCommand(Query, Connection);

            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("roomId", SqlDbType.Int);
            Command.Parameters["roomId"].Value = allocateClassroom.RoomId;

            Command.Parameters.Add("day", SqlDbType.VarChar);
            Command.Parameters["day"].Value = allocateClassroom.Day;

            Command.Parameters.Add("allocate", SqlDbType.Bit);
            Command.Parameters["allocate"].Value = 1;
            Reader = Command.ExecuteReader();
            List <AllocateClassroom> allocateClassrooms = new List <AllocateClassroom>();

            if (Reader.Read())
            {
                AllocateClassroom classroom = new AllocateClassroom()
                {
                    FromTime = Reader["FromTime"].ToString(),
                    ToTime   = Reader["ToTime"].ToString(),
                    Allocate = Reader["Allocate"].ToString()
                };
                allocateClassrooms.Add(classroom);
            }
            Reader.Close();
            Connection.Close();
            return(allocateClassrooms);
        }
Exemplo n.º 17
0
        public List <Course> GetAllCourses(AllocateClassroom allocateClassroom)
        {
            Query   = "SELECT * FROM Course Where DepartmentId = @id";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = allocateClassroom.DepartmentId;
            Reader = Command.ExecuteReader();
            List <Course> courses = new List <Course>();

            while (Reader.Read())
            {
                Course course = new Course()
                {
                    Id   = (int)Reader["Id"],
                    Name = Reader["Name"].ToString()
                };

                courses.Add(course);
            }
            Reader.Close();
            Connection.Close();
            return(courses);
        }
        public ActionResult Save(AllocateClassroom allocateClassroom)
        {
            try
            {
                int rowsAffected = allocateClassroomManager.Save(allocateClassroom);
                if (rowsAffected > 0)
                {
                    ViewBag.Message = "Saved";
                }
                else
                {
                    ViewBag.Message = "Save failed";
                }
            }
            catch (Exception exception)
            {
                ViewBag.Message = exception.Message;
            }

            ViewBag.Department = GetAllDepartments();
            ViewBag.Course     = GetAllCourses();
            ViewBag.Day        = GetAllDay();
            ViewBag.Room       = GetAllRoom();
            return(View());
        }
Exemplo n.º 19
0
 public string Allocate(AllocateClassroom _allocateClassroom)
 {
     if (_allocateClassRoomGateway.Check(_allocateClassroom))
     {
         return("Room is already allocated");
     }
     return(_allocateClassRoomGateway.Allocate(_allocateClassroom));
 }
Exemplo n.º 20
0
 public int Save(AllocateClassroom allocateClassroom)
 {
     if (IsScheduleExist(allocateClassroom.TimeFrom, allocateClassroom.TimeTo))
     {
         throw new Exception("The Time Schedule already exists or partially overlapping!");
     }
     return(allocateClassroomGateway.Save(allocateClassroom));
 }
Exemplo n.º 21
0
 public ActionResult Save(AllocateClassroom allocateClassroom)
 {
     ViewBag.Departments        = departmentManager.GetAll();
     ViewBag.Rooms              = manager.GetAllRoom();
     allocateClassroom.Allocate = "Yes";
     ViewBag.msg = manager.Save(allocateClassroom);
     return(View());
 }
        public ActionResult DeleteConfirmed(int id)
        {
            AllocateClassroom allocateClassroom = db.AllocateClassrooms.Find(id);

            db.AllocateClassrooms.Remove(allocateClassroom);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void SaveAllocatedClassRoom(AllocateClassroom classroom)
 {
     using (_projectDbContext = new ProjectDbContext())
     {
         _projectDbContext.AllocateClassrooms.Add(classroom);
         _projectDbContext.SaveChanges();
     }
 }
Exemplo n.º 24
0
        public List <AllocateClassroom> GetAllAllocateClassroomList()
        {
            List <AllocateClassroom> listOfAllocateClassroom = new List <AllocateClassroom>();
            DBPlayer db = new DBPlayer();

            try
            {
                db.cmdText = "SELECT * FROM AllocateClassroomListView ORDER BY RoomNo";

                db.Open();
                SqlDataReader reader = db.command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        AllocateClassroom allocateClassroom = new AllocateClassroom();
                        allocateClassroom.Id             = int.Parse(reader["Id"].ToString());
                        allocateClassroom.RoomNo         = reader["RoomNo"].ToString();
                        allocateClassroom.Day            = reader["Day"].ToString();
                        allocateClassroom.FromTime       = Convert.ToDateTime(reader["FromTime"].ToString());
                        allocateClassroom.ToTime         = Convert.ToDateTime(reader["ToTime"].ToString());
                        allocateClassroom.Time           = allocateClassroom.FromTime.ToShortTimeString() + " - " + allocateClassroom.ToTime.ToShortTimeString();
                        allocateClassroom.TimeDuration   = reader["Duration"].ToString();
                        allocateClassroom.AllocationDate = Convert.ToDateTime(reader["AllocationDate"].ToString());
                        allocateClassroom.CourseId       = int.Parse(reader["CourseId"].ToString());
                        allocateClassroom.CourseCode     = reader["CourseCode"].ToString();
                        allocateClassroom.CourseName     = reader["CourseName"].ToString();
                        allocateClassroom.DepartmentId   = int.Parse(reader["DepartmentId"].ToString());
                        allocateClassroom.DepartmentName = reader["DepartmentName"].ToString();
                        allocateClassroom.StatusFlag     = Convert.ToBoolean(reader["Status"]);

                        if (Convert.ToBoolean(reader["Status"]))
                        {
                            allocateClassroom.Status = "Allocated";
                        }
                        else
                        {
                            allocateClassroom.Status = "Unallocated";
                        }

                        listOfAllocateClassroom.Add(allocateClassroom);
                    }
                }

                reader.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Close();
            }

            return(listOfAllocateClassroom);
        }
Exemplo n.º 25
0
        public int SaveAllocateRoomInfo(AllocateClassroom allocateClassroom)
        {
            if (IsRoomAvailable(allocateClassroom.Day, allocateClassroom.FromTime, allocateClassroom.ToTime, int.Parse(allocateClassroom.RoomNo)))
            {
                return(_allocateClassroomGateway.SaveAllocateRoomInfo(allocateClassroom));
            }

            throw new Exception("Room Is Not Available With This Time!!");
        }
 public ActionResult Index(AllocateClassroom _allocateClassroom)
 {
     ViewBag.Message     = _allocateClassRoomManager.Allocate(_allocateClassroom);
     ViewBag.StartTime   = _startTimeManager.GetAllTimes();
     ViewBag.EndTime     = _endTimeManager.GetAllTimes();
     ViewBag.Rooms       = _roomManager.GetAllRooms();
     ViewBag.Days        = _daysManager.GetAllDays();
     ViewBag.Departments = _departmentManager.GetAllDepartment();
     return(View());
 }
        public ActionResult AllocateClassrooms(AllocateClassroom allocateClassroom)
        {
            ViewBag.departments = aDepartmentManager.ViewAllDepartments();
            ViewBag.rooms       = aRoomManager.GetAllRooms();
            ViewBag.days        = aRoomManager.GetDays();
            //string fromTime = allocateClassroom.FromTime.ToShortTimeString();



            //string toTime = allocateClassroom.ToTime.ToShortTimeString();
            //DateTime t = DateTime.Parse(toTime);
            //allocateClassroom.Ttime = toTime;
            //allocateClassroom.Ftime = fromTime;

            //DateTime time = DateTime.Parse("6/22/2009 09:30AM");
            //DateTime compare = DateTime.Parse(time.ToShortDateString() + " 2:00PM");
            //bool greater = (time < compare);


            //TimeSpan t1 = allocateClassroom.FromTime.TimeOfDay;
            //TimeSpan t2 = time.TimeOfDay;

            //int com = TimeSpan.Compare(t1, t2);


            //DateTime time1 = DateTime.Parse("6/21/2009 10:00AM");
            //DateTime compare1 = DateTime.Parse("5/23/2009 10:00PM");
            //bool greater1 = (time > compare);

            //DateTime time2 = DateTime.Parse("5/21/2009 10:00AM");
            //DateTime compare2 = DateTime.Parse("5/21/2009 10:00AM");
            //bool greater2 = (time == compare);

            //dt.ToString("HH:mm"); // 07:00 // 24 hour clock // hour is always 2 digits



            //if (allocateClassroom.FromTime>allocateClassroom.ToTime)
            //{
            //    Response.Write("totime");
            //    //Console.WriteLine("tym_one is before tym_two");
            //}
            //else if (allocateClassroom.FromTime < allocateClassroom.ToTime)
            //{
            //    Response.Write("fromtime");
            //    //Console.WriteLine("tym_one is after tym_two");
            //}
            //else
            //{
            //    Response.Write("same");
            //    //Console.WriteLine("tym_one is the same as tym_two");
            //}
            ViewBag.message = aRoomManager.AllocateRoom(allocateClassroom);
            return(View());
        }
        public ActionResult Index(int departmentId, AllocateClassroom allocateClassroom)
        {
            ViewBag.Departments = _departmentManager.GetAllDepartmentsManager();

            ViewBag.Rooms = _roomManager.GetAllRoomsManager();
            ViewBag.Days  = _dayManager.GetAllDaysManager();

            ViewBag.message = _allocateClassroomManager.AllocateClassroominfoSave(allocateClassroom);

            return(View());
        }
Exemplo n.º 29
0
        public bool UpdateAllocateClassroom(AllocateClassroom allocateClassroom)
        {
            bool     flag = false;
            DBPlayer db   = new DBPlayer();

            try
            {
                string fromTime = allocateClassroom.FromTime.ToString("hh:mm tt");
                string toTime   = allocateClassroom.ToTime.ToString("hh:mm tt");

                TimeSpan start = TimeSpan.Parse(allocateClassroom.FromTime.ToString("HH:mm"));
                TimeSpan end   = TimeSpan.Parse(allocateClassroom.ToTime.ToString("HH:mm"));
                //TimeSpan duration = allocateClassroom.ToTime - allocateClassroom.FromTime;
                TimeSpan duration = new TimeSpan(0, 0, 0, (int)allocateClassroom.ToTime.Subtract(allocateClassroom.FromTime).TotalSeconds);

                db.cmdText = "UPDATE AllocateClassrooms SET RoomNo = @RoomNo, Day = @Day, FromTime = @FromTime, ToTime = @ToTime, StartTime = @StartTime, EndTime = @EndTime, Duration = @Duration, AllocationDate = @AllocationDate, Status = @Status WHERE Id = @Id AND DepartmentId = @DepartmentId AND CourseId = @CourseId";

                db.command.Parameters.AddWithValue("@RoomNo", allocateClassroom.RoomNo);
                db.command.Parameters.AddWithValue("@Day", allocateClassroom.Day);
                db.command.Parameters.AddWithValue("@FromTime", fromTime);
                db.command.Parameters.AddWithValue("@ToTime", toTime);
                db.command.Parameters.AddWithValue("@StartTime", start);
                db.command.Parameters.AddWithValue("@EndTime", end);
                db.command.Parameters.AddWithValue("@Duration", duration);
                db.command.Parameters.AddWithValue("@AllocationDate", DateTime.Now);
                db.command.Parameters.AddWithValue("@Status", allocateClassroom.StatusFlag);
                db.command.Parameters.AddWithValue("@Id", allocateClassroom.Id);
                db.command.Parameters.AddWithValue("@DepartmentId", allocateClassroom.DepartmentId);
                db.command.Parameters.AddWithValue("@CourseId", allocateClassroom.CourseId);

                db.Open();
                int rowsAffected = db.command.ExecuteNonQuery();

                if (rowsAffected > 0)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                db.Close();
            }

            return(flag);
        }
        public int SaveAllocation(AllocateClassroom aClassroom)
        {
            Query = "INSERT INTO AllocateClassroom VALUES ('" + aClassroom.DepartmentId + "','" + aClassroom.CourseId +
                    "','" + aClassroom.RoomId + "','" + aClassroom.DayId + "','" + aClassroom.FromTime + "','" +
                    aClassroom.ToTime + "','True')";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            int rowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowAffected);
        }