示例#1
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Maticsoft.Model.Tao.CourseMaterial> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Tao.CourseMaterial> modelList = new List<Maticsoft.Model.Tao.CourseMaterial>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Maticsoft.Model.Tao.CourseMaterial model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Maticsoft.Model.Tao.CourseMaterial();
             if (dt.Rows[n]["MaterialID"] != null && dt.Rows[n]["MaterialID"].ToString() != "")
             {
                 model.MaterialID = int.Parse(dt.Rows[n]["MaterialID"].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]["MaterialURL"] != null && dt.Rows[n]["MaterialURL"].ToString() != "")
             {
                 model.MaterialURL = dt.Rows[n]["MaterialURL"].ToString();
             }
             if (dt.Rows[n]["Status"] != null && dt.Rows[n]["Status"].ToString() != "")
             {
                 model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Tao.CourseMaterial GetModel(int MaterialID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 MaterialID,MaterialName,CourseID,ModuleID,MaterialURL,Status from Tao_CourseMaterial ");
            strSql.Append(" where MaterialID=@MaterialID");
            SqlParameter[] parameters = {
                    new SqlParameter("@MaterialID", SqlDbType.Int,4)
            };
            parameters[0].Value = MaterialID;

            Maticsoft.Model.Tao.CourseMaterial model = new Maticsoft.Model.Tao.CourseMaterial();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MaterialID"] != null && ds.Tables[0].Rows[0]["MaterialID"].ToString() != "")
                {
                    model.MaterialID = int.Parse(ds.Tables[0].Rows[0]["MaterialID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MaterialName"] != null && ds.Tables[0].Rows[0]["MaterialName"].ToString() != "")
                {
                    model.Materialname = ds.Tables[0].Rows[0]["MaterialName"].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]["MaterialURL"] != null && ds.Tables[0].Rows[0]["MaterialURL"].ToString() != "")
                {
                    model.MaterialURL = ds.Tables[0].Rows[0]["MaterialURL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Status"] != null && ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }