Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <E_tb_RoleAction> DataTableToList(DataTable dt)
        {
            List <E_tb_RoleAction> modelList = new List <E_tb_RoleAction>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                E_tb_RoleAction model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new E_tb_RoleAction();
                    if (dt.Rows[n]["RoleActionID"].ToString() != "")
                    {
                        model.RoleActionID = int.Parse(dt.Rows[n]["RoleActionID"].ToString());
                    }
                    if (dt.Rows[n]["RoleID"].ToString() != "")
                    {
                        model.RoleID = int.Parse(dt.Rows[n]["RoleID"].ToString());
                    }
                    if (dt.Rows[n]["ActionID"].ToString() != "")
                    {
                        model.ActionID = int.Parse(dt.Rows[n]["ActionID"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(E_tb_RoleAction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_RoleAction set ");
            strSql.Append("RoleID=@RoleID,");
            strSql.Append("ActionID=@ActionID");
            strSql.Append(" where RoleActionID=@RoleActionID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleID",       SqlDbType.Int, 4),
                new SqlParameter("@ActionID",     SqlDbType.Int, 4),
                new SqlParameter("@RoleActionID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleID;
            parameters[1].Value = model.ActionID;
            parameters[2].Value = model.RoleActionID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(E_tb_RoleAction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_RoleAction(");
            strSql.Append("RoleID,ActionID)");
            strSql.Append(" values (");
            strSql.Append("@RoleID,@ActionID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleID",   SqlDbType.Int, 4),
                new SqlParameter("@ActionID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleID;
            parameters[1].Value = model.ActionID;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 设置权限
 /// </summary>
 /// <param name="ActionIDS"></param>
 /// <returns></returns>
 public ActionResult SaveRolePurview(E_tb_Role eRole, string ActionIDS)
 {
     tRoleAction.DeleteByWhere("RoleID=" + eRole.RoleID);
     if (ActionIDS.Length > 0)
     {
         ActionIDS = ActionIDS.TrimEnd(',');
         string[] IDS = ActionIDS.Split(',');
         for (int i = 0; i < IDS.Count(); i++)
         {
             E_tb_RoleAction eRoleAction = new E_tb_RoleAction();
             eRoleAction.RoleID   = eRole.RoleID;
             eRoleAction.ActionID = int.Parse(IDS[i]);
             tRoleAction.Add(eRoleAction);
         }
     }
     return(Content("OK"));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public E_tb_RoleAction GetModel(int RoleActionID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RoleActionID,RoleID,ActionID from tb_RoleAction ");
            strSql.Append(" where RoleActionID=@RoleActionID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleActionID", SqlDbType.Int, 4)
            };
            parameters[0].Value = RoleActionID;

            E_tb_RoleAction model = new E_tb_RoleAction();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["RoleActionID"].ToString() != "")
                {
                    model.RoleActionID = int.Parse(ds.Tables[0].Rows[0]["RoleActionID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["RoleID"].ToString() != "")
                {
                    model.RoleID = int.Parse(ds.Tables[0].Rows[0]["RoleID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ActionID"].ToString() != "")
                {
                    model.ActionID = int.Parse(ds.Tables[0].Rows[0]["ActionID"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(E_tb_RoleAction model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(E_tb_RoleAction model)
 {
     return(dal.Add(model));
 }