示例#1
0
 public static GetPost GetPostDS(DataSet ds)
 {
     try
     {
         GetPost post = new GetPost();
         post.Id      = (int)ds.Tables[0].Rows[0]["Id"];
         post.Title   = ds.Tables[0].Rows[0]["Title"].ToString();
         post.Content = ds.Tables[0].Rows[0]["Content"].ToString();
         post.Photo   = ds.Tables[0].Rows[0]["Photo"].ToString();
         GetCategory category = new GetCategory();
         category.Id   = (int)ds.Tables[0].Rows[0]["Category"];
         category.Name = ds.Tables[0].Rows[0]["Name"].ToString();
         post.Category = category;
         post.OnDate   = (System.DateTime)ds.Tables[0].Rows[0]["OnDate"];
         GetUser user = new GetUser();
         user.Id        = (int)ds.Tables[0].Rows[0]["ByUser"];
         user.Firstname = ds.Tables[0].Rows[0]["Firstname"].ToString();
         user.Lastname  = ds.Tables[0].Rows[0]["Lastname"].ToString();
         post.ByUser    = user;
         return(post);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
示例#2
0
        public static List <GetCategory> GetAllCategoryDS(DataSet ds)
        {
            List <GetCategory> list = new List <GetCategory>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                GetCategory cate = new GetCategory();
                cate.Id          = (int)ds.Tables[0].Rows[i]["Id"];
                cate.Name        = ds.Tables[0].Rows[i]["Name"].ToString();
                cate.Description = ds.Tables[0].Rows[i]["Description"].ToString();
                cate.OnDate      = (System.DateTime)ds.Tables[0].Rows[i]["OnDate"];
                cate.ByUser      = (int)ds.Tables[0].Rows[i]["ByUser"];
                list.Add(cate);
            }
            return(list);
        }
示例#3
0
 public static GetCategory GetCategoryDS(DataSet ds)
 {
     try
     {
         GetCategory cate = new GetCategory();
         cate.Id          = (int)ds.Tables[0].Rows[0]["Id"];
         cate.Name        = ds.Tables[0].Rows[0]["Name"].ToString();
         cate.Description = ds.Tables[0].Rows[0]["Description"].ToString();
         cate.OnDate      = (System.DateTime)ds.Tables[0].Rows[0]["OnDate"];
         cate.ByUser      = (int)ds.Tables[0].Rows[0]["ByUser"];
         return(cate);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#4
0
        public static List <GetPost> GetAllPostDS(DataSet ds)
        {
            List <GetPost> list = new List <GetPost>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                GetPost post = new GetPost();
                post.Id      = (int)ds.Tables[0].Rows[i]["Id"];
                post.Title   = ds.Tables[0].Rows[i]["Title"].ToString();
                post.Content = ds.Tables[0].Rows[i]["Content"].ToString();
                post.Photo   = ds.Tables[0].Rows[i]["Photo"].ToString();
                GetCategory category = new GetCategory();
                category.Id   = (int)ds.Tables[0].Rows[0]["Category"];
                category.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                post.Category = category;
                post.OnDate   = (System.DateTime)ds.Tables[0].Rows[0]["OnDate"];
                GetUser user = new GetUser();
                user.Id        = (int)ds.Tables[0].Rows[0]["ByUser"];
                user.Firstname = ds.Tables[0].Rows[0]["Firstname"].ToString();
                user.Lastname  = ds.Tables[0].Rows[0]["Lastname"].ToString(); list.Add(post);
            }
            return(list);
        }