예제 #1
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Maticsoft.Model.Tao.CourseNotes> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Tao.CourseNotes> modelList = new List<Maticsoft.Model.Tao.CourseNotes>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Maticsoft.Model.Tao.CourseNotes model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Maticsoft.Model.Tao.CourseNotes();
             if (dt.Rows[n]["NoteID"] != null && dt.Rows[n]["NoteID"].ToString() != "")
             {
                 model.NoteID = int.Parse(dt.Rows[n]["NoteID"].ToString());
             }
             if (dt.Rows[n]["UserID"] != null && dt.Rows[n]["UserID"].ToString() != "")
             {
                 model.UserID = int.Parse(dt.Rows[n]["UserID"].ToString());
             }
             if (dt.Rows[n]["CourseID"] != null && dt.Rows[n]["CourseID"].ToString() != "")
             {
                 model.CourseID = int.Parse(dt.Rows[n]["CourseID"].ToString());
             }
             if (dt.Rows[n]["ModuleID"] != null && dt.Rows[n]["ModuleID"].ToString() != "")
             {
                 model.ModuleID = int.Parse(dt.Rows[n]["ModuleID"].ToString());
             }
             if (dt.Rows[n]["Updatetime"] != null && dt.Rows[n]["Updatetime"].ToString() != "")
             {
                 model.Updatetime = DateTime.Parse(dt.Rows[n]["Updatetime"].ToString());
             }
             if (dt.Rows[n]["Contents"] != null && dt.Rows[n]["Contents"].ToString() != "")
             {
                 model.Contents = dt.Rows[n]["Contents"].ToString();
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Tao.CourseNotes GetModel(int NoteID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 NoteID,UserID,CourseID,ModuleID,Updatetime,Contents from Tao_CourseNotes ");
            strSql.Append(" where NoteID=@NoteID");
            SqlParameter[] parameters = {
                    new SqlParameter("@NoteID", SqlDbType.Int,4)
            };
            parameters[0].Value = NoteID;

            Maticsoft.Model.Tao.CourseNotes model = new Maticsoft.Model.Tao.CourseNotes();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["NoteID"] != null && ds.Tables[0].Rows[0]["NoteID"].ToString() != "")
                {
                    model.NoteID = int.Parse(ds.Tables[0].Rows[0]["NoteID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserID"] != null && ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CourseID"] != null && ds.Tables[0].Rows[0]["CourseID"].ToString() != "")
                {
                    model.CourseID = int.Parse(ds.Tables[0].Rows[0]["CourseID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ModuleID"] != null && ds.Tables[0].Rows[0]["ModuleID"].ToString() != "")
                {
                    model.ModuleID = int.Parse(ds.Tables[0].Rows[0]["ModuleID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Updatetime"] != null && ds.Tables[0].Rows[0]["Updatetime"].ToString() != "")
                {
                    model.Updatetime = DateTime.Parse(ds.Tables[0].Rows[0]["Updatetime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Contents"] != null && ds.Tables[0].Rows[0]["Contents"].ToString() != "")
                {
                    model.Contents = ds.Tables[0].Rows[0]["Contents"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }