using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 图书馆管理系统
{
class Program
{

    public static void Main(string[] args){ //登陆读入图书数据Book book = new Book();List<Book> books = new List<Book>();book.ReadBook(books);//登陆Console.WriteLine("---------欢迎使用图书管理系统---------");Console.WriteLine("您的身份是?");Console.WriteLine("如果您的身份是学生请输入“1”");Console.WriteLine("如果您的身份是教师请输入“2”");bool A = false;string identity = Convert.ToString(Console.ReadLine());switch (identity){case "1"://学生登陆Console.WriteLine("您的身份是学生,请登录");StudentWhetherUser();Student s1 = new Student();s1.StudentLogin();         break;case "2"://教师登陆Console.WriteLine("您的身份是教师,请登录");TeacherWhetherUser();A = true;break;}if (A==true){//进入系统读取数据List<Student> array = new List<Student>();Start(array);bool a = true;do {Console.WriteLine("---------欢迎使用图书管理系统---------");Console.WriteLine("输入1,添加学生信息");Console.WriteLine("输入2,删除学生信息");Console.WriteLine("输入3,修改学生信息");Console.WriteLine("输入4,查看全部学生信息");Console.WriteLine("输入5,添加图书信息");Console.WriteLine("输入6,查看图书信息");Console.WriteLine("输入7,退出系统");Console.WriteLine("请输入您的选择");string sc = Convert.ToString(Console.ReadLine());switch (sc){case "1"://Console.WriteLine("添加学生信息");addStudent(array);Console.WriteLine();break;case "2":// Console.WriteLine("删除学生信息");deleteStudent(array);break;case "3"://Console.WriteLine("修改学生信息");updateStudent(array);break;case "4":// Console.WriteLine("查看全部学生信息");findallStudent(array);break;case "5"://添加图书信息book.AddBook(books);break;case "6"://查看图书信息Student student = new Student();student.ScreachBook(books);break;case "7"://退出系统Leave(array);Console.WriteLine("期待您的再次使用");a = false;break;}} while (a);}//添加学生信息void addStudent(List<Student> array){Student sc = new Student();Console.WriteLine("请输入学生姓名");string name = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生年龄");string age = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生学号");string studentId = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生班级");string classId = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生联系地址");string address = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生联系电话");string phoneNumber = Convert.ToString(Console.ReadLine());Student s = new Student();s.Name = name;s.Age = age;s.StudentId = studentId;s.ClassId = classId;s.Address = address;s.PhoneNumber = phoneNumber;array.Add(s);Console.WriteLine("添加学生信息成功");}//删除学生信息void deleteStudent(List<Student> array){bool S = false;Console.WriteLine("请输入您要删除的学生的学号");string s = Convert.ToString(Console.ReadLine());for (int i = 0; i < array.Count; i++){Student student = array[i];if (student.StudentId.Equals(s)){array.Remove(array[i]);S = true;}}if (S==true){Console.WriteLine("删除学生信息成功");}else{Console.WriteLine("输入学号有误");}}//修改学生信息void updateStudent(List<Student> array){bool c = true;Student s = new Student();Console.WriteLine("请输入要修改的学生的学生学号");String studentId = Convert.ToString(Console.ReadLine());for (int i = 0; i < array.Count; i++){Student student = array[i];if (student.StudentId.Equals(studentId)){break;}else{Console.WriteLine("输入学号有误");c = false;}}if (c==true){Console.WriteLine("请输入学生的新姓名");string name = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生的新年龄");string  age = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生的新班级");string classId = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生的新联系地址");string address = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入学生的新联系电话");string phoneNumber = Convert.ToString(Console.ReadLine());s.Name = name;s.Age = age;s.StudentId = studentId;s.ClassId = classId;s.Address = address;s.PhoneNumber = phoneNumber;for (int i = 0; i < array.Count; i++){Student student = array[i];if (student.StudentId.Equals(studentId)){array[i] = s;break;}}}}//查看所有学生信息void findallStudent(List<Student> array){Console.WriteLine("姓名\t年龄\t\t学号\t\t\t\t班级\t\t联系地址\t\t\t联系电话");for (int i = 0; i < array.Count; i++){Student s = array[i];Console.WriteLine(s.Name +"\t"+ s.Age + "岁\t\t" + s.StudentId + "\t\t\t" + s.ClassId + "\t\t" + s.Address + "\t\t\t\t" + s.PhoneNumber+"\t");}}//退出系统,保存数据void Leave(List<Student> array){using (StreamWriter stream = new StreamWriter(@"D:\C#\图书馆管理系统\图书馆管理系统\StudentInfoemation.txt",false, Encoding.UTF8)){for (int i = 0; i < array.Count-1; i++){Student s = array[i];stream.WriteLine(s.Name);stream.WriteLine(s.Age);stream.WriteLine(s.StudentId);stream.WriteLine(s.ClassId);stream.WriteLine(s.Address);stream.WriteLine(s.PhoneNumber);stream.WriteLine();}for (int i = array.Count - 1; i < array.Count; i++){Student s = array[i];stream.WriteLine(s.Name);stream.WriteLine(s.Age);stream.WriteLine(s.StudentId);stream.WriteLine(s.ClassId);stream.WriteLine(s.Address);stream.WriteLine(s.PhoneNumber);}}}//读入学生信息void  Start(List<Student> array){using (StreamReader stream = new StreamReader(@"D:\C#\图书馆管理系统\图书馆管理系统\StudentInfoemation.txt")){do{Student s = new Student();s.Name = stream.ReadLine();s.Age = stream.ReadLine();s.StudentId = stream.ReadLine();s.ClassId = stream.ReadLine();s.Address = stream.ReadLine();s.PhoneNumber = stream.ReadLine();array.Add(s);} while (stream.ReadLine() != null);}}}//判断是否拥有账号public static void StudentWhetherUser(){Console.WriteLine("未拥有账号?注册请输入“1”,若已拥有账号输入任意键登陆");string a = Convert.ToString(Console.ReadLine());if (a == "1"){Student s1 = new Student();s1.StudentRegister();}} public static void TeacherWhetherUser(){Console.WriteLine("未拥有账号?教师注册需输入身份验证码,若已有账号请输入“1”");//1574212if (Convert.ToString(Console.ReadLine())=="1"){Manager m1 = new Manager();m1.ManagerLogin();}else{string A = "1574212";Console.WriteLine("请输入:");string a = Convert.ToString(Console.ReadLine());if (a == A){Manager m1 = new Manager();m1.ManagerRegister();}else { return; }}}}

}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace 图书馆管理系统
{ [Serializable]
class Spersonal
{
private string suser;
private string spassword;

    public string Suser { get => suser; set => suser = value; }public string Spassword { get => spassword; set => spassword = value; }
}
class Student
{private string name;private string  age;private string studentId;private string classId;private string address;private string phoneNumber;public Student() { }public Student(string name, string age, string studentId, string classId, string address, string PhoneNumber){this.name = name;this.age = age;this.studentId = studentId;this.classId = classId;this.address = address;this.phoneNumber = PhoneNumber;}public string Name { get; set; }public string Age { get; set; }public string StudentId { get; set; }public string ClassId { get; set; }public string Address { get; set; }public string PhoneNumber { get; set; }//学生注册登录public void StudentRegister(){Console.WriteLine("请输入用户名");string SUser1 = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入密码");string Spassworld = Convert.ToString(Console.ReadLine());using (StreamWriter writer = new StreamWriter(@"D:\C#\图书馆管理系统\图书馆管理系统\Spersonal.txt", true)){writer.WriteLine(SUser1);writer.WriteLine(Spassworld);}Console.WriteLine("注册成功");}public void StudentLogin(){Console.WriteLine("请输入用户名");string a1 = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入密码");string a2 = Convert.ToString(Console.ReadLine());using (StreamReader reader = new StreamReader(@"D:\C#\图书馆管理系统\图书馆管理系统\Spersonal.txt")){bool A = false;bool B = true;do{if (a1 == reader.ReadLine()){A = true;}} while (reader.ReadLine() != null);do{if (a2 == reader.ReadLine()){B = true;}} while (reader.ReadLine() != null);if (A == true && B == true){Console.WriteLine("登陆成功");Operate();}else{Console.WriteLine("用户名或者密码错误");Console.ReadKey();return;}}}//学生登陆成功后可进行操作public void Operate() {List<Book> books = new List<Book>();Book book = new Book();book.ReadBook(books);bool l = true;do{ Console.WriteLine("========欢迎使用图书管理系统学生端========");Console.WriteLine("输入“1”,查询书籍");Console.WriteLine("输入“2”,借阅书籍");Console.WriteLine("输入“3”,退出系统");string f = Convert.ToString(Console.ReadLine());switch (f){case "1":ScreachBook(books);break;case "2":BorrowingBooks(books);break;case "3":Console.WriteLine("感谢使用");l = false;break;} } while (l);}//查询书籍public void ScreachBook(List<Book> books){if (books.Count == 0){Console.WriteLine("无信息,请先添加信息再查询");return;}Console.WriteLine("书名\t\t\t作者\t\t是否被借阅\t借阅时间\t预计归还时间");for (int i = 0; i < books.Count; i++){Book B= books[i];Console.WriteLine(B.Name + "\t\t" + B.Author + "\t\t" + B.Condition  + "\t\t" + B.LendingTime + "\t\t" + B.Returntime );}}//借阅书籍public void BorrowingBooks(List<Book>books) {Console.WriteLine("请输入您要借阅的书籍");string s = Convert.ToString(Console.ReadLine());for (int i = 0; i < books.Count; i++){Book B = books[i];if (B.Name.Equals(s)){B.Condition = "已借阅";Console.WriteLine("请输入借书时间");B.LendingTime = Convert.ToString(Console.ReadLine());Console.WriteLine("您的预计归还时间为:");B.Returntime = Convert.ToString(Console.ReadLine());using (StreamWriter writer = new StreamWriter(@"D:\C#\图书馆管理系统\图书馆管理系统\Book.txt", false, Encoding.UTF8)){ for (int j = 0; j< books.Count; j++){writer.WriteLine(B.Name);writer.WriteLine(B.Author);writer.WriteLine(B.Condition);writer.WriteLine(B.LendingTime);writer.WriteLine(B.Returntime);} }}}}
}

}using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace 图书馆管理系统
{
[Serializable]
class Mpersonal
{
private string muser;
private string mpassword;

    public string Muser { get => muser; set => muser = value; }public string Mpassword { get => mpassword; set => mpassword = value; }
}
class Manager
{  //管理员注册登录public void ManagerRegister() {Console.WriteLine("请输入用户名");string MUser1 = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入密码");string Mpassworld = Convert.ToString(Console.ReadLine());using (StreamWriter writer=new StreamWriter(@"D:\C#\图书馆管理系统\图书馆管理系统\Tpersonal.txt",true)) {writer.WriteLine(MUser1);writer.WriteLine(Mpassworld);}Console.WriteLine("注册成功");}//管理员登陆验证public void ManagerLogin(){Console.WriteLine("请输入用户名");string a1 = Convert.ToString(Console.ReadLine()) ;Console.WriteLine("请输入密码");string a2 = Convert.ToString(Console.ReadLine());using (StreamReader reader = new StreamReader(@"D:\C#\图书馆管理系统\图书馆管理系统\Tpersonal.txt")){bool A = false;bool B = true;do{if (a1 == reader.ReadLine()){A = true;}} while (reader.ReadLine()!=null);do{if (a2 == reader.ReadLine()){B= true;}} while (reader.ReadLine()!=null);if (A==true&&B==true){Console.WriteLine("登陆成功");}else{Console.WriteLine("用户名或者密码错误");ManagerLogin();}}}}

}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace 图书馆管理系统
{
[Serializable]
class Mpersonal
{
private string muser;
private string mpassword;

    public string Muser { get => muser; set => muser = value; }public string Mpassword { get => mpassword; set => mpassword = value; }
}
class Manager
{  //管理员注册登录public void ManagerRegister() {Console.WriteLine("请输入用户名");string MUser1 = Convert.ToString(Console.ReadLine());Console.WriteLine("请输入密码");string Mpassworld = Convert.ToString(Console.ReadLine());using (StreamWriter writer=new StreamWriter(@"D:\C#\图书馆管理系统\图书馆管理系统\Tpersonal.txt",true)) {writer.WriteLine(MUser1);writer.WriteLine(Mpassworld);}Console.WriteLine("注册成功");}//管理员登陆验证public void ManagerLogin(){Console.WriteLine("请输入用户名");string a1 = Convert.ToString(Console.ReadLine()) ;Console.WriteLine("请输入密码");string a2 = Convert.ToString(Console.ReadLine());using (StreamReader reader = new StreamReader(@"D:\C#\图书馆管理系统\图书馆管理系统\Tpersonal.txt")){bool A = false;bool B = true;do{if (a1 == reader.ReadLine()){A = true;}} while (reader.ReadLine()!=null);do{if (a2 == reader.ReadLine()){B= true;}} while (reader.ReadLine()!=null);if (A==true&&B==true){Console.WriteLine("登陆成功");}else{Console.WriteLine("用户名或者密码错误");ManagerLogin();}}}}

}

大一上学期闭组考核(借阅功能有逻辑错误)相关推荐

  1. 大一上学期C++课程设计——学生成绩管理系统(QT项目)

    这里是一个大一的萌新!仅做学习分享 工程文件在评论区置顶!! 近期整理了一下大一上学期的课程设计报告作为学习总结,使用的软件是Qt Creator,主界面效果如下图 ----------以下为课程设计 ...

  2. 大一上学期C语言不熟知识点学习总结

    大一上学期C语言不熟知识点学习总结通过前几章对顺序结构程序设计程序.if选择结构.switch语句.循环结构.数组.函数的学习,这一次我将主要针对几种不熟悉的知识点及题型进行分析. 一. 增1和减1运 ...

  3. 大一上学期Python学习心得体会

    Python学习心得体会 经过了大一上学期的Python学习,我已经逐渐摸索到了Python的一些学习方法,学习Python,就像学习其他编程语言或者是学习一门外语一样 ,我们应该从Python的基础 ...

  4. 大一上学期学习生活情况总结

    大一上学期学习生活情况总结 在本学期各科都已结课的某个夜里,我开始写我的这份总结.说实话,我真的很喜欢夜的这种安静--静能生慧. 我是高二下学期开始与计算机结缘,好吧,接触的比较晚啦.但这并不妨碍我对 ...

  5. 关于对大一上学期的学习总结及大一下学期的规划。

    1. 对大一上学期的学习总结 大学一学期很快就过去了,关于对大一上学期的学习总结,总的就二个方面:学习上,能够赶上老师的步伐,遇到不懂的问题也能虚心的向同学请教,这使我从一个技术小白很快的适应到自己的 ...

  6. 大一上学期大作业贪吃蛇

    ************准备借此记录下自己的成长历 大一上学期就要结束 了 最后一个的c++大作业是 贪吃蛇 看了好多博主 百度了好多东西 又结合自己写出了这个代码 以下是自己写的代码 #includ ...

  7. 大一上学期C语言学习总结

    大一上学期C语言学习总结 一.知识点总结 第二章:C语言处理的数据有常量和变量两种形式,C语言的基本数据类型有整型.实型.字符型和枚举类型等,变量必须先定义,后使用,=是赋值运算符,将=右边的表达式的 ...

  8. 计算机网络大一上学期期末考试试题及答案,大一第一学期期末计算机考试题及答案)...

    大一第一学期期末计算机考试题及答案 学计算机基础试题 一.单项选择 1.完整的计算机系统由(C)组成. A.运算器.控制器.存储器.输入设备和输出设备 B.主机和外部设备 C.硬件系统和软件系统 D. ...

  9. 大一上学期C语言大作业—森林冰火人

    C语言大作业-森林冰火人 大作业简介 第三方库 界面图片切换 冰火娃动作图片切换 冰娃火娃的跑动 地面,墙壁,冰水,火水与毒液等的判断 代码实现 头文件 变量简介 结构体及数据初始化 冰火娃图片切换 ...

  10. 大一上学期总结和下学期的计划

    上学期总结 这学期没学到什么东西,还是一只小菜鸟. 这学期就学了C和C++,对指针和类的应用很少,还学习了HTML5和一部分java,在社团里学习了opencv,还有刷一些cf上的水题. 寒假计划: ...

最新文章

  1. qt 搜索隐藏文件_MacOS如何搜索隐藏文件?MacOS搜索隐藏文件的方法
  2. 内核同步机制——自旋锁
  3. `pydot` failed to call GraphViz.Please install GraphViz
  4. php接收get数组数据,来自HTTP的PHP注入GET数据用作PHP数组键值
  5. 值得关注!2021音视频人才成长路线图发布了
  6. 语音情感识别--RNN
  7. 一线互联网公司Java高级面试题总结
  8. learning opencv3: 一:overview 打开自己的视频文件加上暂停快进按钮
  9. c# ThreadPoold使用心得
  10. 西门子Step7的AT指令示例
  11. 内网渗透(一)——本机信息收集
  12. 分布式系统的阿喀琉斯之踵:数据一致性!
  13. linux 组建raid0教程,用两块硬盘组建RAID0磁盘阵列简单教程(图文详解)
  14. 老猿学5G专栏完结说明
  15. OSChina 周日乱弹 —— 进入读图时代
  16. 无粉丝无流量怎么加入快手小黄车?怎么开通小黄车?
  17. 真无线蓝牙耳机哪家的音质最好?四款音质好蓝牙耳机
  18. JavaScript实现贷款利息计算器
  19. 【数据分析与挖掘(一)】笔试题汇总(附答案)
  20. https信任证书的三种方式

热门文章

  1. win7 php7.1,win7下php7.1运行getenv('REMOTE_ADDR')fastcgi停止运行-Go语言中文社区
  2. pip 安装小白教程
  3. 当不知轴承型号时如何寻找轴承故障频率_轴承故障了?检测,处理,简单实用...
  4. 内容创作费时费力?这款AI写作神器超给力!
  5. html手机表白弹窗,抖音弹窗表白代码怎么玩 弹窗表白制作方法与教程一览
  6. t检验的p值对照表_R语言系列第四期:①R语言单样本双样本差异性检验
  7. 基于opencv库把图像灰度化,二值化
  8. 基于matlab的模糊PID控制仿真
  9. 合作开发过程产生的专利_合作开发合同和技术联营合同的区别及
  10. 奥的斯自动人行道服务器密码,奥的斯服务器中文说明21页