Example #1
0
 public bool Create(ref ValidationErrors errors, SysStructModel model)
 {
     try
     {
         SysStruct entity = m_Rep.GetById(model.Id);
         if (entity != null)
         {
             errors.Add(Suggestion.PrimaryRepeat);
             return(false);
         }
         entity            = new SysStruct();
         entity.CreateTime = model.CreateTime;
         entity.Enable     = model.Enable;
         entity.Higher     = model.Higher;
         entity.Id         = model.Id;
         entity.Name       = model.Name;
         entity.ParentId   = model.ParentId;
         entity.Remark     = model.Remark;
         entity.Sort       = model.Sort;
         if (m_Rep.Create(entity) == 1)
         {
             return(true);
         }
         errors.Add(Suggestion.InsertFail);
         return(false);
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHandler.WriteException(ex);
         return(false);
     }
 }
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.Sys.SysStructModel model, params string[] updateProperties)
        {
            SysStruct entity = m_Rep.GetById(model.Id);

            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.Id         = model.Id;
                entity.Name       = model.Name;
                entity.ParentId   = model.ParentId;
                entity.Sort       = model.Sort;
                entity.Higher     = model.Higher;
                entity.Enable     = model.Enable;
                entity.Remark     = model.Remark;
                entity.CreateTime = model.CreateTime;
            }
            else
            {
                Type type  = typeof(Apps.Models.Sys.SysStructModel);
                Type typeE = typeof(Apps.Models.SysStruct);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
Example #3
0
        /// <summary>
        /// 获取全部人员
        /// </summary>
        /// <param name="id"></param>
        /// <param name="text"></param>
        /// <param name="value"></param>
        /// <param name="checkState"></param>
        /// <returns></returns>
        public JsonResult GetTreeByEasyui(string id)
        {
            OnlineUserRecorder recorder = HttpContext.Cache[OnlineHttpModule.g_onlineUserRecorderCacheKey] as OnlineUserRecorder;
            List <SysStruct>   list     = structBLL.m_Rep.FindList(a => a.ParentId == id).ToList();
            List <SysUser>     userList = sysUserBLL.m_Rep.FindList(a => a.DepId == id).ToList();

            if (userList.Count > 0)
            {
                foreach (var user in userList)
                {
                    SysStruct addUserToStruct = new SysStruct();
                    addUserToStruct.Id   = user.Id;
                    addUserToStruct.Name = user.TrueName;
                    addUserToStruct.Type = "member";
                    list.Insert(0, addUserToStruct);//把人员加进组
                }
            }
            var json = from m in list
                       select new SysStructUser()
            {
                id         = m.Id.ToString(),
                text       = "<input id=\"" + m.Id + "\" class=\"" + (m.Type == "group" ? "CBGroup" : "CBMember") + "\" type=\"checkbox\" ref=\"" + id + "\" value=\"" + m.Id + "\" />" + m.Name,          //text
                attributes = m.Name,
                iconCls    = m.Type == "group" ? "fa fa-users color-green" : SetOnlineIcon(m.Id.ToString(), recorder),
                state      = m.Type == "group" ? "closed" : "open"
            };

            return(Json(json));
        }
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <SysStructModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        SysStruct entity = new SysStruct();
                        entity.Id         = ResultHelper.NewId;
                        entity.Name       = model.Name;
                        entity.ParentId   = model.ParentId;
                        entity.Sort       = model.Sort;
                        entity.Higher     = model.Higher;
                        entity.Enable     = model.Enable;
                        entity.Remark     = model.Remark;
                        entity.CreateTime = ResultHelper.NowTime;

                        db.SysStruct.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #5
0
 public int Create(SysStruct entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.SysStruct.Add(entity);
         return(db.SaveChanges());
     }
 }
 public int Create(SysStruct entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.SysStruct.Add(entity);
         return(db.SaveChanges());
     }
 }
 public int Edit(SysStruct entity)
 {
     using (DBContainer db = new DBContainer())
     {
         db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         return(db.SaveChanges());
     }
 }
Example #8
0
 public int Edit(SysStruct entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.SysStruct.Attach(entity);
         //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
         db.Entry <SysStruct>(entity).State = EntityState.Modified;
         return(db.SaveChanges());
     }
 }
Example #9
0
        //////[SupportFilter]
        public ActionResult Create(string id)
        {
            SysStruct entity = new SysStruct()
            {
                ParentId = id,
                Enable   = "true"
            };

            return(View(entity));
        }
Example #10
0
 public bool IsExist(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         SysStruct entity = GetById(id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
Example #11
0
 public int Delete(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         SysStruct entity = db.SysStruct.SingleOrDefault(a => a.Id == id);
         if (entity != null)
         {
             db.SysStruct.Remove(entity);
         }
         return(db.SaveChanges());
     }
 }
 public int Delete(string id)
 {
     using (DBContainer db = new DBContainer())
     {
         SysStruct entity = db.SysStruct.SingleOrDefault(o => o.Id == id);
         if (entity != null)
         {
             db.SysStruct.Remove(entity);
         }
         return(db.SaveChanges());
     }
 }
Example #13
0
 public virtual SysStructModel GetById(string id)
 {
     if (IsExists(id))
     {
         SysStruct      entity = m_Rep.GetById(id);
         SysStructModel model  = new SysStructModel();
         model.Id         = entity.Id;
         model.Name       = entity.Name;
         model.ParentId   = entity.ParentId;
         model.Sort       = entity.Sort;
         model.Higher     = entity.Higher;
         model.Enable     = entity.Enable;
         model.Remark     = entity.Remark;
         model.CreateTime = entity.CreateTime;
         return(model);
     }
     return(null);
 }
Example #14
0
        public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(SysStructModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                SysStruct entity = await m_Rep.GetByIdAsync(model.Id);

                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity            = new SysStruct();
                entity.Id         = model.Id;
                entity.Name       = model.Name;
                entity.ParentId   = model.ParentId;
                entity.Sort       = model.Sort;
                entity.Higher     = model.Higher;
                entity.Enable     = model.Enable;
                entity.Remark     = model.Remark;
                entity.CreateTime = model.CreateTime;


                if (await m_Rep.CreateAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
        public virtual void Create(ref ValidationErrors errors, Apps.Models.Sys.SysStructModel model)
        {
            SysStruct entity = m_Rep.GetById(model.Id);

            if (entity != null)
            {
                errors.Add(Resource.PrimaryRepeat);
                return;
            }
            entity            = new SysStruct();
            entity.Id         = model.Id;
            entity.Name       = model.Name;
            entity.ParentId   = model.ParentId;
            entity.Sort       = model.Sort;
            entity.Higher     = model.Higher;
            entity.Enable     = model.Enable;
            entity.Remark     = model.Remark;
            entity.CreateTime = model.CreateTime;

            m_Rep.Create(entity);
        }
Example #16
0
 //////[SupportFilter]
 public JsonResult Edit(SysStruct model)
 {
     if (model != null)
     {
         if (m_BLL.m_Rep.Update(model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "修改", "SysStruct");
             return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "修改", "SysStruct");
             return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ":" + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
     }
 }
Example #17
0
 //////[SupportFilter]
 public JsonResult Create(SysStruct model)
 {
     model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd");
     if (model != null)
     {
         if (m_BLL.m_Rep.Create(model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "创建", "SysStruct");
             return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "SysStruct");
             return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail)));
     }
 }
        public virtual bool Edit(ref ValidationErrors errors, SysStructModel model)
        {
            try
            {
                SysStruct entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id         = model.Id;
                entity.Name       = model.Name;
                entity.ParentId   = model.ParentId;
                entity.Sort       = model.Sort;
                entity.Higher     = model.Higher;
                entity.Enable     = model.Enable;
                entity.Remark     = model.Remark;
                entity.CreateTime = model.CreateTime;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Example #19
0
        public virtual async Task <SysStructModel> GetByIdAsync(object id)
        {
            if (IsExists(id))
            {
                SysStruct entity = await m_Rep.GetByIdAsync(id);

                SysStructModel model = new SysStructModel();
                model.Id         = entity.Id;
                model.Name       = entity.Name;
                model.ParentId   = entity.ParentId;
                model.Sort       = entity.Sort;
                model.Higher     = entity.Higher;
                model.Enable     = entity.Enable;
                model.Remark     = entity.Remark;
                model.CreateTime = entity.CreateTime;

                return(model);
            }
            else
            {
                return(null);
            }
        }
        public virtual Apps.Models.Sys.SysStructModel GetById(string id)
        {
            SysStruct entity = m_Rep.GetById(id);

            if (entity != null)
            {
                //SysStruct entity = m_Rep.GetById(id);
                Apps.Models.Sys.SysStructModel model = new Apps.Models.Sys.SysStructModel();
                model.Id         = entity.Id;
                model.Name       = entity.Name;
                model.ParentId   = entity.ParentId;
                model.Sort       = entity.Sort;
                model.Higher     = entity.Higher;
                model.Enable     = entity.Enable;
                model.Remark     = entity.Remark;
                model.CreateTime = entity.CreateTime;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #21
0
        //////[SupportFilter]
        public ActionResult Edit(string id)
        {
            SysStruct entity = m_BLL.m_Rep.Find(Convert.ToInt32(id));

            return(View(entity));
        }