コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AMS_PlayListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AMS_PlayList(");
            strSql.Append("Number,PlayList,ReleaseDate,EffectDate,EndDate)");
            strSql.Append(" values (");
            strSql.Append("@Number,@PlayList,@ReleaseDate,@EffectDate,@EndDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",      SqlDbType.NVarChar,  50),
                new SqlParameter("@PlayList",    SqlDbType.Text),
                new SqlParameter("@ReleaseDate", SqlDbType.DateTime),
                new SqlParameter("@EffectDate",  SqlDbType.DateTime),
                new SqlParameter("@EndDate",     SqlDbType.DateTime)
            };
            parameters[0].Value = model.PlayListNo;
            parameters[1].Value = model.ToXml();
            parameters[2].Value = model.ReleaseDate;
            parameters[3].Value = model.EffectDate;
            parameters[4].Value = model.EndDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMS_PlayListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_PlayList set ");
            strSql.Append("Number=@Number,");
            strSql.Append("PlayList=@PlayList,");
            strSql.Append("ReleaseDate=@ReleaseDate,");
            strSql.Append("EffectDate=@EffectDate,");
            strSql.Append("EndDate=@EndDate");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",      SqlDbType.NVarChar,  50),
                new SqlParameter("@PlayList",    SqlDbType.Text),
                new SqlParameter("@ReleaseDate", SqlDbType.DateTime),
                new SqlParameter("@EffectDate",  SqlDbType.DateTime),
                new SqlParameter("@EndDate",     SqlDbType.DateTime),
                new SqlParameter("@Id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.PlayListNo;
            parameters[1].Value = model.ToXml();
            parameters[2].Value = model.ReleaseDate;
            parameters[3].Value = model.EffectDate;
            parameters[4].Value = model.EndDate;
            parameters[5].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }