Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(abc.Model.Model.CourseAccessory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CourseAccessory(");
            strSql.Append("CourseId,LessonId,FileId)");
            strSql.Append(" values (");
            strSql.Append("SQL2012CourseId,SQL2012LessonId,SQL2012FileId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012CourseId", SqlDbType.Int, 4),
                new SqlParameter("SQL2012LessonId", SqlDbType.Int, 4),
                new SqlParameter("SQL2012FileId",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CourseId;
            parameters[1].Value = model.LessonId;
            parameters[2].Value = model.FileId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(abc.Model.Model.CourseAccessory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CourseAccessory set ");
#warning 系统发现缺少更新的字段,请手工确认如此更新是否正确!
            strSql.Append("AccessoryId=SQL2012AccessoryId,");
            strSql.Append("CourseId=SQL2012CourseId,");
            strSql.Append("LessonId=SQL2012LessonId,");
            strSql.Append("FileId=SQL2012FileId");
            strSql.Append(" where AccessoryId=SQL2012AccessoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012AccessoryId", SqlDbType.Int, 4),
                new SqlParameter("SQL2012CourseId",    SqlDbType.Int, 4),
                new SqlParameter("SQL2012LessonId",    SqlDbType.Int, 4),
                new SqlParameter("SQL2012FileId",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AccessoryId;
            parameters[1].Value = model.CourseId;
            parameters[2].Value = model.LessonId;
            parameters[3].Value = model.FileId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public abc.Model.Model.CourseAccessory DataRowToModel(DataRow row)
 {
     abc.Model.Model.CourseAccessory model = new abc.Model.Model.CourseAccessory();
     if (row != null)
     {
         if (row["AccessoryId"] != null && row["AccessoryId"].ToString() != "")
         {
             model.AccessoryId = int.Parse(row["AccessoryId"].ToString());
         }
         if (row["CourseId"] != null && row["CourseId"].ToString() != "")
         {
             model.CourseId = int.Parse(row["CourseId"].ToString());
         }
         if (row["LessonId"] != null && row["LessonId"].ToString() != "")
         {
             model.LessonId = int.Parse(row["LessonId"].ToString());
         }
         if (row["FileId"] != null && row["FileId"].ToString() != "")
         {
             model.FileId = int.Parse(row["FileId"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public abc.Model.Model.CourseAccessory GetModel(int AccessoryId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AccessoryId,CourseId,LessonId,FileId from CourseAccessory ");
            strSql.Append(" where AccessoryId=SQL2012AccessoryId");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012AccessoryId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AccessoryId;

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

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