예제 #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Light.Model.newsinfo> DataTableToList(DataTable dt)
        {
            List <Light.Model.newsinfo> modelList = new List <Light.Model.newsinfo>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Light.Model.newsinfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Light.Model.newsinfo();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.title    = dt.Rows[n]["title"].ToString();
                    model.subtitle = dt.Rows[n]["subtitle"].ToString();
                    if (dt.Rows[n]["isread"].ToString() != "")
                    {
                        if ((dt.Rows[n]["isread"].ToString() == "1") || (dt.Rows[n]["isread"].ToString().ToLower() == "true"))
                        {
                            model.isread = true;
                        }
                        else
                        {
                            model.isread = false;
                        }
                    }
                    if (dt.Rows[n]["ishot"].ToString() != "")
                    {
                        if ((dt.Rows[n]["ishot"].ToString() == "1") || (dt.Rows[n]["ishot"].ToString().ToLower() == "true"))
                        {
                            model.ishot = true;
                        }
                        else
                        {
                            model.ishot = false;
                        }
                    }
                    if (dt.Rows[n]["createman"].ToString() != "")
                    {
                        model.createman = int.Parse(dt.Rows[n]["createman"].ToString());
                    }
                    if (dt.Rows[n]["createtime"].ToString() != "")
                    {
                        model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
예제 #2
0
파일: newsinfo.cs 프로젝트: seven7610/light
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Light.Model.newsinfo> DataTableToList(DataTable dt)
        {
            List<Light.Model.newsinfo> modelList = new List<Light.Model.newsinfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Light.Model.newsinfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Light.Model.newsinfo();
                                                    if(dt.Rows[n]["id"].ToString()!="")
                {
                    model.id=int.Parse(dt.Rows[n]["id"].ToString());
                }
                                                                                                                                                model.title= dt.Rows[n]["title"].ToString();
                                                                                                                                                                                                                                model.subtitle= dt.Rows[n]["subtitle"].ToString();
                                                                                                                                                                                if(dt.Rows[n]["isread"].ToString()!="")
                {
                    if((dt.Rows[n]["isread"].ToString()=="1")||(dt.Rows[n]["isread"].ToString().ToLower()=="true"))
                    {
                    model.isread= true;
                    }
                    else
                    {
                    model.isread= false;
                    }
                }
                                                                                                                                if(dt.Rows[n]["ishot"].ToString()!="")
                {
                    if((dt.Rows[n]["ishot"].ToString()=="1")||(dt.Rows[n]["ishot"].ToString().ToLower()=="true"))
                    {
                    model.ishot= true;
                    }
                    else
                    {
                    model.ishot= false;
                    }
                }
                                                                if(dt.Rows[n]["createman"].ToString()!="")
                {
                    model.createman=int.Parse(dt.Rows[n]["createman"].ToString());
                }
                                                                                                                                if(dt.Rows[n]["createtime"].ToString()!="")
                {
                    model.createtime=DateTime.Parse(dt.Rows[n]["createtime"].ToString());
                }

                    modelList.Add(model);
                }
            }
            return modelList;
        }
예제 #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Light.Model.newsinfo model)
 {
     return(dal.Update(model));
 }
예제 #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void  Add(Light.Model.newsinfo model)
 {
     dal.Add(model);
 }