public void GetClassRooms()
        {
            //用于序列化实体类的对象
            JavaScriptSerializer jss = new JavaScriptSerializer();

            //请求中携带的条件
            string order     = HttpContext.Request.Params["order"];
            string sort      = HttpContext.Request.Params["sort"];
            string searchKey = HttpContext.Request.Params["search"];
            int    offset    = Convert.ToInt32(HttpContext.Request.Params["offset"]);
            int    pageSize  = Convert.ToInt32(HttpContext.Request.Params["limit"]);

            int total = 0;
            ClassRoomInfoManager       manager = new ClassRoomInfoManager();
            List <ClassRoomInfoEntity> list    = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total);

            //给分页实体赋值
            PageModels <ClassRoomInfoEntity> model = new PageModels <ClassRoomInfoEntity>();

            model.total = total;
            if (total % pageSize == 0)
            {
                model.page = total / pageSize;
            }
            else
            {
                model.page = (total / pageSize) + 1;
            }

            model.rows = list;

            //将查询结果返回
            HttpContext.Response.Write(jss.Serialize(model));
        }
        public string SaveClassRoom(string jsonString, string action)
        {
            try
            {
                ClassRoomInfoEntity  entity  = JsonConvert.DeserializeObject <ClassRoomInfoEntity>(jsonString);
                ClassRoomInfoManager manager = new ClassRoomInfoManager();
                if (action == "add")
                {
                    manager.Insert(entity);
                }
                else
                {
                    ClassRoomInfoEntity oldEntity = manager.GetClassRoomInfoByCode(entity.Code);
                    oldEntity.Name    = entity.Name;
                    oldEntity.Address = entity.Address;
                    oldEntity.Type    = entity.Type;
                    oldEntity.SeatNum = entity.SeatNum;

                    oldEntity.UpdateBy = SessionHelper.CurrentUser.Code;

                    manager.Update(oldEntity);
                }
                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Beispiel #3
0
        public List <AutoCompleteItem> getSearchResult(string searchKey)
        {
            List <AutoCompleteItem> result = new List <AutoCompleteItem>();

            //HttpDataService service = new HttpDataService();
            //List<RoomItem> roomList = service.GetSearchRoomList(searchKey);

            //if (roomList != null)
            //{
            //    result = roomList.Where(r => r.roomName.Contains(searchKey)).Select(r => new AutoCompleteItem() { Text = r.roomName, Value = r.roomId }).ToList();
            //}

            ClassRoomInfoManager classRoomInfoManager = new ClassRoomInfoManager();

            var roomList = classRoomInfoManager.GetClassRoomInfoByName(searchKey);

            if (roomList != null)
            {
                result = roomList.Select(r => new AutoCompleteItem()
                {
                    Text = r.Name, Value = r.Code
                }).ToList();
            }

            return(result);
        }
Beispiel #4
0
        public List <RoomItem> getSearchResult(string searchKey)
        {
            //HttpDataService service = new HttpDataService();
            //List<RoomItem> roomList = service.GetSearchRoomList(searchKey);

            //if (roomList != null)
            //{
            //    roomList = roomList.Where(r => r.roomName.Contains(searchKey)).ToList();
            //}

            List <RoomItem> result = new List <RoomItem>();

            ClassRoomInfoManager classRoomInfoManager = new ClassRoomInfoManager();

            var roomList = classRoomInfoManager.GetClassRoomInfoByName(searchKey);

            if (roomList != null)
            {
                roomList.ForEach(r => result.Add(new RoomItem()
                {
                    roomId = r.Code, roomName = r.Name
                }));
            }

            return(result);
        }
        public string PutClassRoomInfo(ClassRoomInfoEntity entity)
        {
            try
            {
                if (entity == null)
                {
                    return("error");
                }

                ClassRoomInfoManager manager = new ClassRoomInfoManager();

                entity.CreateTime = DateTime.Now;
                entity.CreateTime = DateTime.Now;

                manager.Update(entity);

                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
        public string DeleteClassRoomInfo(int id)
        {
            try
            {
                ClassRoomInfoManager manager = new ClassRoomInfoManager();

                ClassRoomInfoEntity entity = manager.GetClassRoomInfoByID(id);
                if (entity != null)
                {
                    entity.Valid      = "F";
                    entity.CreateTime = DateTime.Now;
                    entity.CreateTime = DateTime.Now;

                    manager.Update(entity);
                }

                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
        public string GetAll(string order, string sort, string searchKey, int offset, int pageSize)
        {
            int total = 0;
            ClassRoomInfoManager       manager = new ClassRoomInfoManager();
            List <ClassRoomInfoEntity> list    = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total);

            //给分页实体赋值
            PageModels <ClassRoomInfoEntity> model = new PageModels <ClassRoomInfoEntity>();

            model.total = total;
            if (total % pageSize == 0)
            {
                model.page = total / pageSize;
            }
            else
            {
                model.page = (total / pageSize) + 1;
            }

            model.rows = list;

            //将查询结果返回
            return(new JavaScriptSerializer().Serialize(model));
        }
        public string GetClassRoomInfoByName(string name)
        {
            ClassRoomInfoManager manager = new ClassRoomInfoManager();

            return(new JavaScriptSerializer().Serialize(manager.GetClassRoomInfoByName(name)));
        }
        public string GetClassRoomInfoByID(int id)
        {
            ClassRoomInfoManager manager = new ClassRoomInfoManager();

            return(new JavaScriptSerializer().Serialize(manager.GetClassRoomInfoByID(id)));
        }