예제 #1
0
        public string Add()
        {
            string roomNo = Request["RoomNo"];
            string volume = Request["Volume"];
            string roomType = Request["RoomName"];
            string floorNo = Request["FloorNo"];
            string remark = Request["Remark"];

            var model = new ClassRoom();
            var classroom = unitOfWork.ClassRoomBLL.GetEntitys(m => m.RoomNo == roomNo && m.IsValid);
            if (classroom.Any())
            {
                return "房间号已存在!如要修改,请点击编辑按钮!";
            }
            else
            {
                model.Id = Guid.NewGuid();
                model.RoomNo = roomNo;
                model.RoomName = roomType;
                model.FloorNo = floorNo;
                model.Volume = volume;
                model.Remark = remark;
                model.CreateId = CurrentUser.UserId;
                model.CreateName = CurrentUser.UserName;
                model.CreateTime = System.DateTime.Now;
                model.IsValid = true;
                try
                {
                    unitOfWork.ClassRoomBLL.InsertEntity(model);
                    unitOfWork.Save();
                    return "";
                }
                catch (Exception ex)
                {
                    Log.Error("保存教室信息异常:"+ex.Message,ex);
                    return "系统异常,请联系管理员!";
                }
            }
        }
예제 #2
0
        private string ClassRoomImport(DataTable dt,   string filename)
        {
            if (dt != null)
            {
                foreach (DataRow row in dt.Rows)
                {
                    // 		楼层	房间号	房间名称	容量	备注
                    ClassRoom model;
                    var roomNo = row["房间号"].ToString();
                    var modeles = unitOfWork.ClassRoomBLL.GetEntitys(m => m.RoomNo == roomNo && m.IsValid);
                    if (modeles.Any())
                    {
                        model = modeles.ToArray()[0];
                        model.FloorNo = row["楼层"].ToString();
                        model.RoomNo = row["房间号"].ToString();
                        model.RoomName = row["房间名称"].ToString();
                        model.Volume = row["容量"].ToString();
                        model.Remark = row["备注"].ToString();
                        model.LastModifyTime = System.DateTime.Now;
                        model.LastModifyId = CurrentUser.UserId;
                        model.LastModifyName = CurrentUser.UserName;
                        model.IsValid = true;
                        unitOfWork.ClassRoomBLL.UpdateEntity(model);
                    }
                    else
                    {
                        model=new ClassRoom();
                        model.FloorNo = row["楼层"].ToString();
                        model.RoomNo = row["房间号"].ToString();
                        model.RoomName = row["房间名称"].ToString();
                        model.Volume = row["容量"].ToString();
                        model.Remark = row["备注"].ToString();
                        model.Id = Guid.NewGuid();
                        model.CreateTime = System.DateTime.Now;
                        model.CreateId = CurrentUser.UserId;
                        model.CreateName = CurrentUser.UserName;
                        model.IsValid = true;
                        unitOfWork.ClassRoomBLL.InsertEntity(model);
                    }
                }
                unitOfWork.Save();
            }

            return "";
        }