Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SmartTeaching.Entity.Base_UserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Base_UserRole set ");
            strSql.Append(" UserId = @UserId , ");
            strSql.Append(" RoleId = @RoleId , ");
            strSql.Append(" NewsTypeId = @NewsTypeId  ");
            strSql.Append(" where UserRoleId=@UserRoleId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",     SqlDbType.Int, 4),
                new SqlParameter("@RoleId",     SqlDbType.Int, 4),
                new SqlParameter("@NewsTypeId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.UserId;
            parameters[1].Value = model.RoleId;
            parameters[2].Value = model.NewsTypeId;
            int rows = SqlServerHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SmartTeaching.Entity.Base_UserRole GetModel(int UserRoleId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select UserRoleId, UserId, RoleId, NewsTypeId  ");
            strSql.Append("  from Base_UserRole ");
            strSql.Append(" where UserRoleId=@UserRoleId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserRoleId", SqlDbType.Int, 4)
            };
            parameters[0].Value = UserRoleId;


            SmartTeaching.Entity.Base_UserRole model = new SmartTeaching.Entity.Base_UserRole();
            DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["UserRoleId"].ToString() != "")
                {
                    model.UserRoleId = int.Parse(ds.Tables[0].Rows[0]["UserRoleId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].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]["NewsTypeId"].ToString() != "")
                {
                    model.NewsTypeId = int.Parse(ds.Tables[0].Rows[0]["NewsTypeId"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(SmartTeaching.Entity.Base_UserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Base_UserRole(");
            strSql.Append("UserId,RoleId,NewsTypeId");
            strSql.Append(") values (");
            strSql.Append("@UserId,@RoleId,@NewsTypeId");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId",     SqlDbType.Int, 4),
                new SqlParameter("@RoleId",     SqlDbType.Int, 4),
                new SqlParameter("@NewsTypeId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.UserId;
            parameters[1].Value = model.RoleId;
            parameters[2].Value = model.NewsTypeId;
            SqlServerHelper.ExecuteSql(strSql.ToString(), parameters);
        }