//删除博客 static void Delete() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); Blog blog = bbl.Query(id); bbl.Delete(blog); }
//删除 static void Delete() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); StudentClass studentClass = bbl.Query(id); bbl.Delete(studentClass); }
//显示全部博客 static void QueryBlog() { BlogBusinessLayer bbl = new BlogBusinessLayer(); var blogs = bbl.Query(); foreach (var item in blogs) { Console.WriteLine(item.BlogId + " " + item.Name); } }
//显示全部博客 static void QueryStudentClass() { BlogBusinessLayer bbl = new BlogBusinessLayer(); var blogs = bbl.Query(); foreach (var item in blogs) { Console.WriteLine(item.StudentClassId + " " + item.StudentClassName); } }
static void Update() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); Blog blog = bbl.Query(id); Console.WriteLine("请输入新名字"); string name = Console.ReadLine(); blog.Name = name; bbl.Update(blog); }
//删除博客 static void Delete() { QueryBlog(); BlogBusinessLayer bbl = new BlogBusinessLayer(); Console.WriteLine("请输入需要删除到博客id"); int id = int.Parse(Console.ReadLine()); Blog blog = bbl.Query(id); bbl.Delete(blog); Console.Clear(); selectBlog(); }
//显示全部博客 static void QueryBlog() { BlogBusinessLayer bbl = new BlogBusinessLayer(); var query = bbl.Query(); Console.WriteLine("所有数据库中的博客"); foreach (var item in query) { Console.Write(item.BlogId + ""); Console.WriteLine(item.Name); } }
//修改 static void Update() { Console.WriteLine("请输入ID"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); StudentClass studentClass = bbl.Query(id); Console.WriteLine("请输入新名字"); string name = Console.ReadLine(); studentClass.StudentClassName = name; bbl.Update(studentClass); }
//更新博客 static void Update() { QueryBlog(); Console.WriteLine("请输入需要修改的博客id"); int id = int.Parse(Console.ReadLine()); BlogBusinessLayer bbl = new BlogBusinessLayer(); Blog blog = bbl.Query(id); Console.WriteLine("请输入博客新名字"); string name = Console.ReadLine(); blog.Name = name; bbl.Update(blog); Console.Clear(); selectBlog(); }
/// <summary> /// 检测博客ID是否存在 /// </summary> /// <returns></returns> static int BlogIdDetection(string idStr, int id) { BlogBusinessLayer bbl = new BlogBusinessLayer(); bool idDetection = true; while (idDetection) { if (bbl.Query(id) == null) { Console.WriteLine("没有该博客ID,请重新输入!"); idStr = PositiveWholeNumberDetection(); id = int.Parse(idStr); } else { idDetection = false; } } return(id); }