コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CdHotelManage.Model.banner model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update banner set ");
            strSql.Append("title=@title,");
            strSql.Append("imgurl=@imgurl,");
            strSql.Append("sortId=@sortId,");
            strSql.Append("pubdate=@pubdate");
            strSql.Append(" where banner_id=@banner_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",     SqlDbType.NVarChar,  100),
                new SqlParameter("@imgurl",    SqlDbType.NVarChar,  200),
                new SqlParameter("@sortId",    SqlDbType.Int,         4),
                new SqlParameter("@pubdate",   SqlDbType.DateTime),
                new SqlParameter("@banner_id", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.imgurl;
            parameters[2].Value = model.sortId;
            parameters[3].Value = model.pubdate;
            parameters[4].Value = model.banner_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CdHotelManage.Model.banner DataRowToModel(DataRow row)
 {
     CdHotelManage.Model.banner model = new CdHotelManage.Model.banner();
     if (row != null)
     {
         if (row["banner_id"] != null)
         {
             model.banner_id = row["banner_id"].ToString();
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["imgurl"] != null)
         {
             model.imgurl = row["imgurl"].ToString();
         }
         if (row["sortId"] != null && row["sortId"].ToString() != "")
         {
             model.sortId = int.Parse(row["sortId"].ToString());
         }
         if (row["pubdate"] != null && row["pubdate"].ToString() != "")
         {
             model.pubdate = DateTime.Parse(row["pubdate"].ToString());
         }
     }
     return(model);
 }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CdHotelManage.Model.banner model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into banner(");
            strSql.Append("banner_id,title,imgurl,sortId,pubdate)");
            strSql.Append(" values (");
            strSql.Append("@banner_id,@title,@imgurl,@sortId,@pubdate)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@banner_id", SqlDbType.NVarChar,  50),
                new SqlParameter("@title",     SqlDbType.NVarChar, 100),
                new SqlParameter("@imgurl",    SqlDbType.NVarChar, 200),
                new SqlParameter("@sortId",    SqlDbType.Int,        4),
                new SqlParameter("@pubdate",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.banner_id;
            parameters[1].Value = model.title;
            parameters[2].Value = model.imgurl;
            parameters[3].Value = model.sortId;
            parameters[4].Value = model.pubdate;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CdHotelManage.Model.banner GetModel(string banner_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 banner_id,title,imgurl,sortId,pubdate from banner ");
            strSql.Append(" where banner_id=@banner_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@banner_id", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = banner_id;

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

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