Example #1
0
        public ActionResult Create(SystemRoleInfo model)
        {
            bool issuc = false;

            model.CreateDate  = DateTime.Now;
            model.CreateIP    = this.GetIP;
            model.IsCanDelete = true;
            int id = roleMgr.Create(model);

            if (id > 0)
            {
                issuc = true;
            }
            MsgInfo msgInfo = new MsgInfo();

            if (issuc)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "操作成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "操作失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Example #2
0
        public ActionResult Destroy(FormCollection col)
        {
            string         id    = col["Id"];
            SystemRoleInfo model = roleMgr.Get(int.Parse(id));

            if (model != null && !model.IsCanDelete)
            {
                return(Content("false"));
            }
            bool res = roleMgr.Delete(new SystemRoleInfo {
                Id = int.Parse(id)
            });
            MsgInfo msgInfo = new MsgInfo();

            if (res)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "删除成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "删除失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Example #3
0
        public ActionResult Destroys(FormCollection col)
        {
            string Ids = col["Ids"];

            string[]       _Ids  = Ids.Split(',');
            List <string>  ids   = new List <string>();
            SystemRoleInfo model = null;

            foreach (string id in _Ids)
            {
                model = roleMgr.Get(int.Parse(id));
                if (model != null && model.IsCanDelete)
                {
                    ids.Add(model.Id.ToString());
                }
            }

            bool    res     = roleMgr.Deletes(string.Join(",", ids));
            MsgInfo msgInfo = new MsgInfo();

            if (res)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "删除成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "删除失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Example #4
0
        private SystemRoleInfo  FillList(IDataReader dataReader)
        {
            SystemRoleInfo model = new SystemRoleInfo();
            object         ojb;

            ojb = dataReader["Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Id = ( int)(ojb);
            }
            ojb = dataReader["RoleName"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RoleName = ( string)(ojb);
            }
            ojb = dataReader["IsCanDelete"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsCanDelete = ( bool)(ojb);
            }
            ojb = dataReader["CreateIP"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateIP = ( string)(ojb);
            }
            ojb = dataReader["CreateDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateDate = ( DateTime)(ojb);
            }

            return(model);
        }
Example #5
0
        public ActionResult Modify(SystemRoleInfo model)
        {
            bool           issuc  = false;
            SystemRoleInfo _model = roleMgr.Get(model.Id);

            if (_model != null)
            {
                _model.RoleName = model.RoleName;

                issuc = roleMgr.Update(_model);
            }
            MsgInfo msgInfo = new MsgInfo();

            if (issuc)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "操作成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "操作失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Example #6
0
        public bool Delete(SystemRoleInfo model)
        {
            Database      db = DBHelper.CreateDataBase();
            StringBuilder sb = new StringBuilder();

            sb.Append("delete from SystemRole");
            sb.Append(" where Id=@Id");
            DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString());

            db.AddInParameter(dbCommand, "@Id", DbType.Int32, model.Id);
            return(db.ExecuteNonQuery(dbCommand) < 1 ? false : true);
        }
Example #7
0
        public bool Update(SystemRoleInfo model)
        {
            Database      db = DBHelper.CreateDataBase();
            StringBuilder sb = new StringBuilder();

            sb.Append("update SystemRole set ");
            sb.Append("RoleName=@RoleName,IsCanDelete=@IsCanDelete,CreateIP=@CreateIP,CreateDate=@CreateDate");
            sb.Append(" where Id=@Id");
            DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString());

            db.AddInParameter(dbCommand, "@Id", DbType.Int32, model.Id);
            db.AddInParameter(dbCommand, "@RoleName", DbType.String, model.RoleName);
            db.AddInParameter(dbCommand, "@IsCanDelete", DbType.Boolean, model.IsCanDelete);
            db.AddInParameter(dbCommand, "@CreateIP", DbType.String, model.CreateIP);
            db.AddInParameter(dbCommand, "@CreateDate", DbType.DateTime, model.CreateDate);
            return(db.ExecuteNonQuery(dbCommand) < 1 ? false : true);
        }
Example #8
0
        public int Create(SystemRoleInfo model)
        {
            Database      db = DBHelper.CreateDataBase();
            StringBuilder sb = new StringBuilder();

            sb.Append("insert into SystemRole(");
            sb.Append("RoleName,IsCanDelete,CreateIP,CreateDate");
            sb.Append(") values(");
            sb.Append("@RoleName,@IsCanDelete,@CreateIP,@CreateDate);SELECT @@IDENTITY;");
            DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString());

            db.AddInParameter(dbCommand, "@RoleName", DbType.String, model.RoleName);
            db.AddInParameter(dbCommand, "@IsCanDelete", DbType.Boolean, model.IsCanDelete);
            db.AddInParameter(dbCommand, "@CreateIP", DbType.String, model.CreateIP);
            db.AddInParameter(dbCommand, "@CreateDate", DbType.DateTime, model.CreateDate);
            int id = Convert.ToInt32(db.ExecuteScalar(dbCommand));

            return(id);
        }
Example #9
0
        public SystemRoleInfo  Get(int Id)
        {
            Database      db = DBHelper.CreateDataBase();
            StringBuilder sb = new StringBuilder();

            sb.Append("select * from SystemRole where Id=@Id");
            DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString());

            db.AddInParameter(dbCommand, "@Id", DbType.Int32, Id);

            SystemRoleInfo model = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = FillList(dataReader);
                }
            }
            return(model);
        }
Example #10
0
 public bool Delete(SystemRoleInfo model)
 {
     return(dal.Delete(model));
 }
Example #11
0
 public bool Update(SystemRoleInfo model)
 {
     return(dal.Update(model));
 }
Example #12
0
        public int Create(SystemRoleInfo model)
        {
            int id = dal.Create(model);

            return(id);
        }