Пример #1
0
        //删除博客
        static void Delete()
        {
            Console.WriteLine("请输入ID");
            int id = int.Parse(Console.ReadLine());
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            Blog blog             = bbl.Query(id);

            bbl.Delete(blog);
        }
Пример #2
0
        //删除
        static void Delete()
        {
            Console.WriteLine("请输入ID");
            int id = int.Parse(Console.ReadLine());
            BlogBusinessLayer bbl          = new BlogBusinessLayer();
            StudentClass      studentClass = bbl.Query(id);

            bbl.Delete(studentClass);
        }
Пример #3
0
        //显示全部博客
        static void QueryBlog()
        {
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            var blogs             = bbl.Query();

            foreach (var item in blogs)
            {
                Console.WriteLine(item.BlogId + " " + item.Name);
            }
        }
Пример #4
0
        //显示全部博客
        static void QueryStudentClass()
        {
            BlogBusinessLayer bbl = new BlogBusinessLayer();
            var blogs             = bbl.Query();

            foreach (var item in blogs)
            {
                Console.WriteLine(item.StudentClassId + " " + item.StudentClassName);
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        //删除博客
        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();
        }
Пример #7
0
        //显示全部博客
        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);
            }
        }
Пример #8
0
        //修改
        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);
        }
Пример #9
0
        //更新博客
        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();
        }
Пример #10
0
        /// <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);
        }