Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(FwjSoft.Model.RoleRightModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RoleRight set ");
            strSql.Append("RoleId=@RoleId,");
            strSql.Append("MenuId=@MenuId");
            strSql.Append(" where RoleRightId=@RoleRightId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleId",      SqlDbType.Int, 4),
                new SqlParameter("@MenuId",      SqlDbType.Int, 4),
                new SqlParameter("@RoleRightId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleId;
            parameters[1].Value = model.MenuId;
            parameters[2].Value = model.RoleRightId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(FwjSoft.Model.RoleRightModel model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public FwjSoft.Model.RoleRightModel DataRowToModel(DataRow row)
 {
     FwjSoft.Model.RoleRightModel model = new FwjSoft.Model.RoleRightModel();
     if (row != null)
     {
         if (row["RoleRightId"] != null && row["RoleRightId"].ToString() != "")
         {
             model.RoleRightId = int.Parse(row["RoleRightId"].ToString());
         }
         if (row["RoleId"] != null && row["RoleId"].ToString() != "")
         {
             model.RoleId = int.Parse(row["RoleId"].ToString());
         }
         if (row["MenuId"] != null && row["MenuId"].ToString() != "")
         {
             model.MenuId = int.Parse(row["MenuId"].ToString());
         }
     }
     return(model);
 }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public FwjSoft.Model.RoleRightModel GetModel(int RoleRightId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RoleRightId,RoleId,MenuId from RoleRight ");
            strSql.Append(" where RoleRightId=@RoleRightId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleRightId", SqlDbType.Int, 4)
            };
            parameters[0].Value = RoleRightId;

            FwjSoft.Model.RoleRightModel model = new FwjSoft.Model.RoleRightModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }