Ejemplo n.º 1
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Maticsoft.Model.Tao.OffLineCourse> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Tao.OffLineCourse> modelList = new List<Maticsoft.Model.Tao.OffLineCourse>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Maticsoft.Model.Tao.OffLineCourse model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Maticsoft.Model.Tao.OffLineCourse();
             if (dt.Rows[n]["CourseID"] != null && dt.Rows[n]["CourseID"].ToString() != "")
             {
                 model.CourseID = int.Parse(dt.Rows[n]["CourseID"].ToString());
             }
             if (dt.Rows[n]["CourseName"] != null && dt.Rows[n]["CourseName"].ToString() != "")
             {
                 model.CourseName = dt.Rows[n]["CourseName"].ToString();
             }
             if (dt.Rows[n]["Description"] != null && dt.Rows[n]["Description"].ToString() != "")
             {
                 model.Description = dt.Rows[n]["Description"].ToString();
             }
             if (dt.Rows[n]["CategoryId"] != null && dt.Rows[n]["CategoryId"].ToString() != "")
             {
                 model.CategoryId = int.Parse(dt.Rows[n]["CategoryId"].ToString());
             }
             if (dt.Rows[n]["StartTime"] != null && dt.Rows[n]["StartTime"].ToString() != "")
             {
                 model.StartTime = DateTime.Parse(dt.Rows[n]["StartTime"].ToString());
             }
             if (dt.Rows[n]["EndTime"] != null && dt.Rows[n]["EndTime"].ToString() != "")
             {
                 model.EndTime = DateTime.Parse(dt.Rows[n]["EndTime"].ToString());
             }
             if (dt.Rows[n]["TimeSpan"] != null && dt.Rows[n]["TimeSpan"].ToString() != "")
             {
                 model.TimeSpan = dt.Rows[n]["TimeSpan"].ToString();
             }
             if (dt.Rows[n]["RegionID"] != null && dt.Rows[n]["RegionID"].ToString() != "")
             {
                 model.RegionID = int.Parse(dt.Rows[n]["RegionID"].ToString());
             }
             if (dt.Rows[n]["CoursePrice"] != null && dt.Rows[n]["CoursePrice"].ToString() != "")
             {
                 model.CoursePrice = decimal.Parse(dt.Rows[n]["CoursePrice"].ToString());
             }
             if (dt.Rows[n]["Tags"] != null && dt.Rows[n]["Tags"].ToString() != "")
             {
                 model.Tags = dt.Rows[n]["Tags"].ToString();
             }
             if (dt.Rows[n]["ImageURL"] != null && dt.Rows[n]["ImageURL"].ToString() != "")
             {
                 model.ImageURL = dt.Rows[n]["ImageURL"].ToString();
             }
             if (dt.Rows[n]["LimitCount"] != null && dt.Rows[n]["LimitCount"].ToString() != "")
             {
                 model.LimitCount = int.Parse(dt.Rows[n]["LimitCount"].ToString());
             }
             if (dt.Rows[n]["Recommended"] != null && dt.Rows[n]["Recommended"].ToString() != "")
             {
                 if ((dt.Rows[n]["Recommended"].ToString() == "1") || (dt.Rows[n]["Recommended"].ToString().ToLower() == "true"))
                 {
                     model.Recommended = true;
                 }
                 else
                 {
                     model.Recommended = false;
                 }
             }
             if (dt.Rows[n]["Latest"] != null && dt.Rows[n]["Latest"].ToString() != "")
             {
                 if ((dt.Rows[n]["Latest"].ToString() == "1") || (dt.Rows[n]["Latest"].ToString().ToLower() == "true"))
                 {
                     model.Latest = true;
                 }
                 else
                 {
                     model.Latest = false;
                 }
             }
             if (dt.Rows[n]["Hotsale"] != null && dt.Rows[n]["Hotsale"].ToString() != "")
             {
                 if ((dt.Rows[n]["Hotsale"].ToString() == "1") || (dt.Rows[n]["Hotsale"].ToString().ToLower() == "true"))
                 {
                     model.Hotsale = true;
                 }
                 else
                 {
                     model.Hotsale = false;
                 }
             }
             if (dt.Rows[n]["PV"] != null && dt.Rows[n]["PV"].ToString() != "")
             {
                 model.PV = int.Parse(dt.Rows[n]["PV"].ToString());
             }
             if (dt.Rows[n]["AttentionCount"] != null && dt.Rows[n]["AttentionCount"].ToString() != "")
             {
                 model.AttentionCount = int.Parse(dt.Rows[n]["AttentionCount"].ToString());
             }
             if (dt.Rows[n]["BookCount"] != null && dt.Rows[n]["BookCount"].ToString() != "")
             {
                 model.BookCount = int.Parse(dt.Rows[n]["BookCount"].ToString());
             }
             if (dt.Rows[n]["CreatedUserID"] != null && dt.Rows[n]["CreatedUserID"].ToString() != "")
             {
                 model.CreatedUserID = int.Parse(dt.Rows[n]["CreatedUserID"].ToString());
             }
             if (dt.Rows[n]["CreatedDate"] != null && dt.Rows[n]["CreatedDate"].ToString() != "")
             {
                 model.CreatedDate = DateTime.Parse(dt.Rows[n]["CreatedDate"].ToString());
             }
             if (dt.Rows[n]["UpdatedDate"] != null && dt.Rows[n]["UpdatedDate"].ToString() != "")
             {
                 model.UpdatedDate = DateTime.Parse(dt.Rows[n]["UpdatedDate"].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;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Tao.OffLineCourse GetModel(int CourseID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT  TOP 1 CourseID,CourseName,Description,CategoryId,StartTime,EndTime,TimeSpan,RegionID,Address,CoursePrice,Tags,ImageURL,LimitCount,Recommended,Latest,Hotsale,PV,AttentionCount,BookCount,CreatedUserID,CreatedDate,UpdatedDate,Status FROM Tao_OffLineCourse ");
            strSql.Append(" WHERE CourseID=@CourseID");
            SqlParameter[] parameters = {
                    new SqlParameter("@CourseID", SqlDbType.Int,4)
            };
            parameters[0].Value = CourseID;

            Maticsoft.Model.Tao.OffLineCourse model = new Maticsoft.Model.Tao.OffLineCourse();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                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]["CourseName"] != null && ds.Tables[0].Rows[0]["CourseName"].ToString() != "")
                {
                    model.CourseName = ds.Tables[0].Rows[0]["CourseName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"] != null && ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CategoryId"] != null && ds.Tables[0].Rows[0]["CategoryId"].ToString() != "")
                {
                    model.CategoryId = int.Parse(ds.Tables[0].Rows[0]["CategoryId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StartTime"] != null && ds.Tables[0].Rows[0]["StartTime"].ToString() != "")
                {
                    model.StartTime = DateTime.Parse(ds.Tables[0].Rows[0]["StartTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EndTime"] != null && ds.Tables[0].Rows[0]["EndTime"].ToString() != "")
                {
                    model.EndTime = DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TimeSpan"] != null && ds.Tables[0].Rows[0]["TimeSpan"].ToString() != "")
                {
                    model.TimeSpan = ds.Tables[0].Rows[0]["TimeSpan"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RegionID"] != null && ds.Tables[0].Rows[0]["RegionID"].ToString() != "")
                {
                    model.RegionID = int.Parse(ds.Tables[0].Rows[0]["RegionID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "")
                {
                    model.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CoursePrice"] != null && ds.Tables[0].Rows[0]["CoursePrice"].ToString() != "")
                {
                    model.CoursePrice = decimal.Parse(ds.Tables[0].Rows[0]["CoursePrice"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Tags"] != null && ds.Tables[0].Rows[0]["Tags"].ToString() != "")
                {
                    model.Tags = ds.Tables[0].Rows[0]["Tags"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImageURL"] != null && ds.Tables[0].Rows[0]["ImageURL"].ToString() != "")
                {
                    model.ImageURL = ds.Tables[0].Rows[0]["ImageURL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LimitCount"] != null && ds.Tables[0].Rows[0]["LimitCount"].ToString() != "")
                {
                    model.LimitCount = int.Parse(ds.Tables[0].Rows[0]["LimitCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Recommended"] != null && ds.Tables[0].Rows[0]["Recommended"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Recommended"].ToString() == "1") || (ds.Tables[0].Rows[0]["Recommended"].ToString().ToLower() == "true"))
                    {
                        model.Recommended = true;
                    }
                    else
                    {
                        model.Recommended = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Latest"] != null && ds.Tables[0].Rows[0]["Latest"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Latest"].ToString() == "1") || (ds.Tables[0].Rows[0]["Latest"].ToString().ToLower() == "true"))
                    {
                        model.Latest = true;
                    }
                    else
                    {
                        model.Latest = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Hotsale"] != null && ds.Tables[0].Rows[0]["Hotsale"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Hotsale"].ToString() == "1") || (ds.Tables[0].Rows[0]["Hotsale"].ToString().ToLower() == "true"))
                    {
                        model.Hotsale = true;
                    }
                    else
                    {
                        model.Hotsale = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["PV"] != null && ds.Tables[0].Rows[0]["PV"].ToString() != "")
                {
                    model.PV = int.Parse(ds.Tables[0].Rows[0]["PV"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AttentionCount"] != null && ds.Tables[0].Rows[0]["AttentionCount"].ToString() != "")
                {
                    model.AttentionCount = int.Parse(ds.Tables[0].Rows[0]["AttentionCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BookCount"] != null && ds.Tables[0].Rows[0]["BookCount"].ToString() != "")
                {
                    model.BookCount = int.Parse(ds.Tables[0].Rows[0]["BookCount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreatedUserID"] != null && ds.Tables[0].Rows[0]["CreatedUserID"].ToString() != "")
                {
                    model.CreatedUserID = int.Parse(ds.Tables[0].Rows[0]["CreatedUserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreatedDate"] != null && ds.Tables[0].Rows[0]["CreatedDate"].ToString() != "")
                {
                    model.CreatedDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UpdatedDate"] != null && ds.Tables[0].Rows[0]["UpdatedDate"].ToString() != "")
                {
                    model.UpdatedDate = DateTime.Parse(ds.Tables[0].Rows[0]["UpdatedDate"].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;
            }
        }