Пример #1
0
        /// <summary>
        /// 根据学号删除学生信息
        /// </summary>
        public void Delete_one()
        {
            Console.WriteLine("请输入要修改的学生学号:");
            string Student_Id = Console.ReadLine();

            Console.WriteLine("确定要删除此学生信息?(yes/no)");
            string judge = Console.ReadLine();
            string sql   = string.Format("Delete from Student Where StudentNo='{0}'", Student_Id);

            try
            {
                var delete = DBOperation.ExecuteNonQuery(sql);
                if (judge == "yes")
                {
                    if (delete > 0)
                    {
                        Console.WriteLine("删除成功!");
                    }
                    else
                    {
                        Console.WriteLine("删除失败!请查看输入的学生学号是否有误!");
                    }
                }
                else
                {
                    Console.WriteLine("您取消了修改!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("出现异常:{0}", ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// 根据学生学号修改学生出生日期
        /// </summary>
        public void Modify_one()
        {
            Console.WriteLine("请输入要修改的学生学号:");
            string Student_Id = Console.ReadLine();

            Console.WriteLine("请输入修改日期(使用‘-’隔开):");
            string Data_Birth = Console.ReadLine();
            string sql        = string.Format("Update Student set BornDate='{0}' Where StudentNo='{1}'", Data_Birth, Student_Id);

            try
            {
                var modify = DBOperation.ExecuteNonQuery(sql);
                if (modify > 0)
                {
                    Console.WriteLine("修改成功!");
                }
                else
                {
                    Console.WriteLine("修改失败!请查看输入的学生学号或修改日期是否有误!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("出现异常:{0}", ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// 新增年级
        /// </summary>
        public void New_one()
        {
            Console.WriteLine("请输入待插入的年级名称:");
            string Grade_Name = Console.ReadLine();
            string sql        = string.Format("Insert Grade Values('{0}')", Grade_Name);

            try
            {
                var New = DBOperation.ExecuteNonQuery(sql);
                if (New > 0)
                {
                    Console.WriteLine("插入成功!");
                }
                else
                {
                    Console.WriteLine("插入失败!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("出现异常:{0}", ex.Message);
            }
        }