Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public override bool Update(Cook.Model.HeadRecommend model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update HeadRecommend set ");
            strSql.Append("courseid=@courseid,");
            strSql.Append("describe=@describe,");
            strSql.Append("time=@time");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@courseid", SqlDbType.Int,       4),
                new SqlParameter("@describe", SqlDbType.NVarChar, 10),
                new SqlParameter("@time",     SqlDbType.VarChar, 12)
            };
            parameters[0].Value = model.courseid;
            parameters[1].Value = model.describe;
            parameters[2].Value = model.time;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public override bool Add(Cook.Model.HeadRecommend model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HeadRecommend(");
            strSql.Append("courseid,describe,time)");
            strSql.Append(" values (");
            strSql.Append("@courseid,@describe,@time)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@courseid", SqlDbType.Int,       4),
                new SqlParameter("@describe", SqlDbType.NVarChar, 10),
                new SqlParameter("@time",     SqlDbType.VarChar, 12)
            };
            parameters[0].Value = model.courseid;
            parameters[1].Value = model.describe;
            parameters[2].Value = model.time;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public override Cook.Model.HeadRecommend GetModel(string oid)
 {
     try
     {
         int id;
         Int32.TryParse(oid, out id);
         //该表无主键信息,请自定义主键/条件字段
         StringBuilder strSql = new StringBuilder();
         strSql.Append("select * from HeadRecommend ");
         strSql.Append(" where courseid=@id");
         SqlParameter[] parameters =
         {
             new SqlParameter("@id", SqlDbType.Int, 4)
         };
         parameters[0].Value = id;
         Cook.Model.HeadRecommend model = new Cook.Model.HeadRecommend();
         DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
         if (ds.Tables[0].Rows.Count > 0)
         {
             return(DataRowToModel(ds.Tables[0].Rows[0]));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception) {
         return(null);
     }
 }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public override Cook.Model.HeadRecommend DataRowToModel(DataRow row)
 {
     Cook.Model.HeadRecommend model = new Cook.Model.HeadRecommend();
     if (row != null)
     {
         if (row["courseid"] != null && row["courseid"].ToString() != "")
         {
             model.courseid = int.Parse(row["courseid"].ToString());
         }
         if (row["describe"] != null)
         {
             model.describe = row["describe"].ToString();
         }
         if (row["time"] != null)
         {
             model.time = row["time"].ToString();
         }
     }
     return(model);
 }
Пример #5
0
 public Cook.Model.HeadRecommend home(string id)
 {
     Cook.BLL.HeadRecommend   c   = new Cook.BLL.HeadRecommend();
     Cook.Model.HeadRecommend msg = c.GetModel(id);
     return(msg);
 }