图书借阅管理系统代码图书管理系统源代码

合集下载

图书管理系统数据库源代码

图书管理系统数据库源代码

图书管理系统数据库源代码//创建工程及设计主界面public class Main extends JFrame{private static final JDesktopPane{DESKTOP_PANE=new JDesktopPane(); //桌面窗体}public static void main(String[] args) //入口方法{try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //设置系统界面外观new BookLogin(); //登录窗口}catch(Exception ex){ex.printStackTrace();}}public static void addIFame(JInternalFrame iframe) //添加子窗体的方法{DESKTOP_PANE.add(iframe); //新增子窗体}public Main(){super(); //设置“关闭”按钮处理事件setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); //创建工具栏Toolkit tool=Toolkit,getDefaultToolkit(); //获得屏幕大小Dimension screenSize=tool.getScreenSize();setSize(800,600); //设置窗体大小setLocation((screenSize.width-getWidth())/2,(screenSize.height-getHeight())/2; //设置窗体位置setTitle("图书管理系统");//设置窗体标题JMenuBar menuBar=createMenu(); //创建菜单栏setJMenuBar(menuBar); //设置菜单栏JToolBar toolBar=createToolBar(); //创建工具栏的方法getContentPane(),add(toolBar,BorderLayout.NORTH); //设置工具栏final JLable lable=new JLable(); //创建一个标签,用来显示图片lable.setBounds(0,0,0,0); //设置窗体的大小和位置lable.setIcon(null); //窗体背景DESKTOP_PANE.addComponentListener(new ComponentAdapter()){public void componentResized(final ComponentEvent e){Dimension size=e.getComponent().getSize(); //获得组建大小lable.setSize(e.getComponent().getSize()); //设置标签大小lable.setText("<html><imgwidth="+size.width+"height="+size.height+"src='"+this.getClass().getResource("/bac kImg.jpg")+"'></html>");//设置标签文本,设置窗口背景}} //将标签添加到桌面窗体DESKTOP_PANE.add(lable,new Integer(Integer.MIN_V ALUE));getContentPane().add(DESKTOP_PANE); //将桌面窗体添加到主窗体中}}private JToolBar createToolBar() //创建工具栏的方法{JToolBar toolBar=new JToolBar(); //初始化工具栏toolBar.setFloatable(false); //设置是否可以移动工具栏toolBar.setBorder(new BevelBorder(BevelBorder.RAIZED)); //设置边框//图书信息添加按钮JButton bookAddButton=new JButton(MenuActions.BOOK_ADD);ImageIcon icon=new ImageIcon(Main.class.getResource("/bookAddtb.jpg")); //添加菜单栏图标bookAddButton.setIcon(icon); //设置按钮图标bookAddButton.setHideActionText(true); //显示提示文本toolBar.add(bookAddButton); //添加到工具栏中JButton bookModiAndDelButton=new JButton(MenuActions.BOOK_MODIFY); //图书信息修改按钮ImageIcon bookmodiicon=Icon.add("bookModiAndDeltb.jpg"); //创建图表方法bookModiAndDelButton.setIcon(bookmodiicon); //设置按钮图标bookModiAndDelButton.setHideActionText(true); //显示提示文本toolBar.add(bookModiAndDelButton); //添加到工具栏JButton bookTypeAddButton=new JButton(MenuActions.BOOKTYPE_ADD); //图书类别添加按钮ImageIcon bookTypeAddicon=Icon.add("bookTypeAddtb.jpg"); //创建图标方法bookTypeAddButton.setIcon(bookTypeAddicon); //设置按钮图标bookTypeAddButton.setHideActionText(true); //显示提示文本toolBar.add(bookTypeAddButton); //添加到工具栏JButton bookBorrowButton=new JButton(MenuActions.BORROW); //图书借阅按钮ImageIcon bookBorrowicon=Icon.add("bookBorrowtb.jpg"); //创建图标方法bookBorrowButton.setIcon(bookBorrowicon); //设置按钮图标bookBorrowButton.setHideActionText(true); //显示提示文本toolBar.add(bookBorrowButton); //添加到工具栏JButton bookOrderButton=new JButton(MenuActions.NEWBOOK_ORDER); //新书订购按钮ImageIcon bookOrdericon=Icon.add("bookOrdertb.jpg"); //创建图标方法bookOrderButton.setIcon(bookOrdericon); //设置按钮图标bookOrderButton.setHideActionText(true); //显示提示文本toolBar.add(bookOrderButton); //添加到工具栏JButton bookCheckButton=new JButton(MenuActions.NEWBOOK_CHECK); //验收新书按钮ImageIcon bookCheckicon=Icon.add("newbookChecktb.jpg"); //创建图标方法bookCheckButton.setIcon(bookCheckicon); //设置按钮图标bookCheckButton.setHideActionText(true); //显示提示文本toolBar.add(bookCheckButton); //添加到工具栏JButton readerAddButton=new JButton(MenuActions.READER_ADD); //读者信息添加按钮ImageIcon readerAddicon=Icon.add("readerAddtb.jpg"); //创建图标方法readerAddButton.setIcon(readerAddicon); //设置按钮图标readerAddButton.setHideActionText(true); //显示提示文本toolBar.add(readerAddButton); //添加到工具栏JButton readerModiAndDelButton=new JButton(MenuActions.READER_MODIFY); //读者信息修改按钮ImageIcon readerModiAndDelicon=Icon.add("readerModiAndDeltb.jpg"); //创建图标方法readerModiAndDelButton.setIcon(readerModiAndDelicon); //设置按钮图标readerModiAndDelButton.setHideActionText(true); //显示提示文本toolBar.add(readerModiAndDelButton); //添加到工具栏JButton ExitButton=new JButton(MenuActions.EXIT); //退出系统按钮ImageIcon Exiticon=Icon.add("exittb.jpg"); //创建图标方法ExitButton.setIcon(Exiticon); //设置按钮图标ExitButton.setHideActionText(true); //显示提示文本toolBar.add(ExitButton); //添加到工具栏return toolBar;}public class Business{protected static String dbClassName="com.mysql.jdbc.Driver"; //数据库驱动类protected static String dbUr1="jdbc:mysql://localhost/ts"; //连接URLprotected static String dbUser="root"; //数据库用户名protected static String dbpwd="root"; //数据库密码private static Connection conn=null; //数据库连接对象,初值为null public Business(){try{if(coon==null) //连接对象为空{Class.forName(dbClassName); //加载驱动类信息conn=DriverManager.getConnection(dbUr1,dbUser,dbPwd); //建立连接对象}}catch(Exception ee){ee.printStackTrace();}}public static ResultSet executeQuery(String sql) //执行查询方法{try{//如果连接对象为空,则重新调用构造方法if (conn==null){new Business();returnconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_ UPDATABLE).executeQuery(sql);//执行查询}}catch(SQLException e){e.printStackTrace();return null; //返回null值}finally{}}public static int executeUpdata(String sql) //更新方法{try{if(conn==null){new Business(); //如果连接对象为空,则重新调用构造方法return conn.createStatement().executeUpdate(sql); //执行更新}}catch(SQLException e){e.printStackTrace();return -1;}finally{}}public static void close() //关闭方法try{conn.close(); //关闭连接对象}catch(SQLException e){e.printStackTrace();}finally{conn=null; //设置连接对象为null值}}}//为数据库添加对应的类public class BookInfo{private String Book_id; //图书编号private String typeid; //类别编号private String writer; //作者private String translator; //译者private String publisher; //出版社private Date date; //出版日期private Double price; //图书单价private String getBookname; //图书名称public String getBookname(){return bookname;}public void setBookname(String bookname){this.bookname=bookname;}public Date getDate(){return date;}public void setDate(Date date){this.date=date;}public string getBook_id()return Book_id;}public void setBook_id(String Book_id) {this.Book_id=Book_id;}public Double getPrice(){return price;}public void setprice(Double price){this.price=price;}public String getPublisher(){return Publisher;}public void setPublisher(String publisher) {this.Publisher=Publisher;}public String getTranslator(){return translator;}public void setTranslator(String translator) {this.translator=translator;}public String getTypeid(){return typeid;}public void setTypeid(String typeid){this.typeid=typeid;}public String getWriter(){return writer;}public void setWriter(String writer)this.writer=writer;}}public class BookType //图书列表信息类{private String id; //图书类别编号private String typeName; //图书类别名称private String days; //可解天数private String fk; //每罚款金额public String getFk(){return fk;}public void setFk(String fk){this.fk=fk;}public String getDays(){return days;}public void setDays(String days){this.days=days;}public string getId(){return id;}public void setId(String id){this.Bid=id;}public String getTypeName(){return typeName;}public void setTypeName(String typeName){this.typeName=typeName;}}public class Order //图书订单信息类{private String Book_id; //图书编号private Date date; //下单时间private String number; //图书数量private String operator; //操作员private String checkAndAccept; //是否收到货private String zk; //图书折扣public String getcheckAndAccept(){return checkAndAccept;}public void setcheckAndAccept(String checkAndAccept) {this.checkAndAccept=checkAndAccept;}public Date getDate(){return date;}public void setDate(Date date){this.date=date;}public string getBook_id(){return book_id;}public void setBook_id(String book_id){this.book_id=book_id;}public String getNumber(){return number;}public void setNumber(String number){this.number=number;}public String getOperator(){return operator;}public void setOperator(String operator){this.operatorr=operator;}public String getZk(){return zk;}public void setZk(String Zk){this.zk=zk;}}public class Operater{private String id; //操作员编号private String name; //操作员用户名private String grade; //操作员等级private String password; //操作员密码private String type; //出版社public String getType(){return type;}public void setType(String type){this.type=type;}public string getGrade(){return grade;}public void setGrade(String grade){this.grade=grade;}public String getId(){return id;}public void setId(String id){this.id=id;}public String getName()return name;}public void setName(String name){=name;}public String getPassword(){return password;}public void setPassword(String password){this.password=password;}}public class Borrow //书籍借阅信息类{private int id; //借阅编号private String book_id; //图书编号private String reader_id; //读者编号private String num; //借书数量private String borrowDate; //借书日期private String backDate; //应还日期private String Bookname; //图书名称public String getBookname(){return bookname;}public void setBookname(String bookname){this.bookname=bookname;}public string getBackDate(){return backDate;}public void setBackDate(String backDate){this.backDate=backDate;}public string getBorrowDate(){return borrowDate;public void setBorrowDate(String borrowDate){this.borrowDate=borrowDate;}public String getNum(){return num;}public void setNum(String num){this.num=num;}public String getBook_id(){return book_id;}public void setBook_id(String book_id){this.book_id=book_id;}public String getReader_id(){return reader_id;}public void setReader_id(String reader_id){this.reader_id=reader_id;}public int getId(){return id;}public void setId(Int id){this.id=id;}}public class Back //图书归还信息类{private String book_id; //图书编号private String bookname; //图书名称private String operatorId; //操作员编号private String borrowDate; //图书借阅时间private String backDate; //图书归还时间private String readerName; //读者姓名private String reader_id; //读者编号private int typeId;private int id;public int getId(){return id;}public void setId(int id){this.id=id;}public int getTypeId(){return typeid;}public void setTypeId(int typeid){this.typeId=typeId;}public string getBackDate(){return backDate;}public void setBackDate(String backDate) {this.backDate=backDate;}public String getBookname(){return bookname;}public void setBookname(String bookname) {this.bookname=bookname;}public string getBorrowDate(){return borrowDate;}public void setBorrowDate(String borrowDate) {this.borrowDate=borrowDate;}public String getOperatorId(){return operatorId;}public void setOperatorId(String operatorId){this.operatorId=operatorId;}public String getBook_id(){return book_id;}public void setBook_id(String book_id){this.book_id=book_id;}public String getReader_id(){return reader_id;}public void setReader_id(String reader_id){this.reader_id=reader_id;}public String getReaderName(){return readerName;}public void setReaderName(String readerName){this.readerName=readerName;}}//系统登录模块设计public class BookLogin extends JFrame{private static final Operater Type=null; //人员类型private static Operater user; //用户名private JPasswordField password;private JTextField username;private JButton login;private JButton reset;public BookLogin(){super();final BorderLayout borderLayout=new BorderLayout(); //创建布局管理器setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置“关闭”按钮处理事件borderLayout.setVgap(10); //设置组件间的垂直关系getContentPane().setLayout(borderLayout); //使用布局管理器setTitle("图书管理系统登录") //设置窗体标题Toolkit tool=Toolkit.getDefaultToolkit(); //获得默认的工具箱Dimension screenSize=tool.getScreenSize(); //获得屏幕的大小setSize(285,194);setLocation((screenSize.width-getWidth())/2,(screenSize.height-getHeight())/2); //设置窗体位置final JPanel mainPanel=new JPanel(); //创建主面板mainPanel.setLayout(new BorderLayout()); //设置边框布局mainPanel.setBorder(new EmptyBorder(0,0,0,0)) //设置边框为0getContentPane().add(mainPanel); //在窗体中加入主面板final JLabel imageLabel=new JLabel; //创建一个标签,用来显示图片ImageIcon loginIcon=Icon.add("login.jpg"); //创建一个图像图标imagelabel.setIcon(loginIcon); //设置图片imageLabel.setOpaque(true); //设置绘制其边界内的所有像素imageLabel.setBackground(Color.GREEN); //设置背景颜色imageLabel.setpreferredSize(new Dimension(260,60)); //设置标签大小mainPanel.add(imageLabel,BorderLayout.NORTH); //添加标签到主面板final JPanel centerPanel=new JPanel(); //添加一个中心面板final GridLayout gridLayout=new GridLayout(2,2); //创建网络布局管理器gridLayout.setHgap(5); //设置组件之间平行的距离gridLayout.setVgap(20); //设置组件之间垂直的距离centerPanel.setLayout(gridLayout); //使用布局管理器mainPanel.add(centerPanel); //添加到主桌面final JLabel userNamelabel=new JLabel(); //创建一个标签userNameLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置对齐方式userNameLabel.setPreferredSize(new Dimension(0,0)); //设置组件大小userNameLabel.setMinimumSize(new Dimension(0,0)); //设置组件最小的大小centerPanel.add(userNameLabel); //添加到中心面板userNameLabel.setText("用户名:"); //设置标签文本username=new JTextField(20); //创建文本框username.setPreferredSize(new Dimension(0,0)); //设置组件大小centerPanel.add(username); //添加到中心面板final JLabel passwordLabel=new JLabel(); //创建一个标签passwordLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置对齐方式centerPanel.add(passwordLabel); //添加到中心面板passwordLabel.setText("密码:"); //设置标签文本password=new JPasswordField(20); //创建密码框password.setDocument(new Document(6)); //设置密码长度为6password.addKeyListener(new KeyAdapter() //监听密码框{public void keyPressed(final keyEvent e) //监听键盘案件事件{if(e.getKeyCode()==10) //如果按了回车键{login.doClick(); //进行登录}}})centerPanel.add(password); //添加到中心面板final JPanel southPanel=new JPanel; //新增一个底部面板mainPanel.add(southPanel,BorderLayout.SOUTH); //添加到主面板中login=new JButton(); //创建按钮组件login.addActionListener(new BookLoginAtion()); //添加监听器login.setText("登录"); //设置按钮文本southPanel.add(login); //把按钮添加到底部面板reset=new JButton(); //创建按钮组件reset.addActionListener(new BookResetAction()); //添加监听器reset.setText("重置");//设置按钮文本southPanel.add(reset); //把按钮添加到底部面板setVisible(true); //设置创建可见setResizable(false); //设置窗体不可改变大小}public static Operater getUser(){return user;}public static Operater getType(){return Type;}public static void setUser(Operater user){er=user;}}private class BookResetAction implements ActionListener{public void actionPerformed(final ActionEvent e){username.setText(""); //设置用户名输入框为空password.setText(""); //设置密码输入框为空}}private class BookLoginAction implements ActionListener{public void actionPerformed(final ActionEvent e){user=Business.check(username.getText(),newString(password.getPassword())); //调用business方法if(user.getName()!=null) //判断用户名是否为null{try{Main frame=new Main(); //创建一个主窗体frame.setVisible(true); //设置其可见BookLogin.this.setVisible(false); //设置登录窗体为不显示}catch(Exception ex){ex.printStackTrace();}}else{JOptionPane.showMessageDialog(null,"请输入正确的用户名和密码!"); //弹出提示框username.setText(""); //设置用户名输入框为空password.setText(""); //设置密码输入框为空}}}//基本信息管理模块public class ReaderAdd extends JInternalFrame //添加读者信息{public ReaderAdd(){super();setTitle("读者相关信息添加");setIconifiable(true); //设置窗体可最小化setClosable(true); //设置窗体可关闭setBounds(100,100,500,350);final JLabel logoLabel=new JLabel();ImageIcon readerAddIcon=Icon.add("readerAdd.jpg");logoLabel.setIcon(readerAddIcon);logoLabel.setOpaque(true);logoLabel.setBackground(Color.CYAN);logoLabel.setPreferredSize(new Dimension(400,60));getContentPane().add(logoLabel,BorderLayout.NORTH);final JPanel panel=new JPanel();panel.setLayout(new FlowLayout());getContentPane().add(panel);final JPanel panel_1=new JPanel();final GridLayout gridLayout=new GridLayout(0,4);gridLayout.setVgap(15);gridLayout.setHgap(15);panel_1.setLayout(gridLayout);panel_1.setPreferredSize(new Dimension(450,200));panel.add(panel_1);final JLabel label_2=new JLabel();label_2.setText("姓名:");panel_1.add(label_2);readername=new JTextField();readername.setDocument(new Document(10));panel_1.add(readername);final JLabel label_3=new JLabel();public void actionPerformed(final ActionEvent e){Check validator=new Check(); //校验类String zj=String.valueof(comboBox.getSelectedIndex());String id=read_id.getText().trim();Vector v1=new Vector();v1.clear();v1.add("reader"); //读取配置文件中相应的查询语句v1.add(id);if(l==validator.Validate(V1)) //检查是否存在该读者{JOptionPane.showMessageDialog(null,"添加失败,该读者编号已存在!");}else{Inti=Business.InsertReader(readername.getText().trim(),sex.trim(),age.getText().trim(),zj number.getText().trim(),Date.valueOf(date.getText().trim()),maxnumber.getText().trim().tel.getText().trim (),Double.valueof(keepmoney.getText().trim()),zj,zy.getText().trim(),Date.valueOf(bztime.getText().trim()),read_id.getText().tri m());if(i==1){JOptionPane.showMessageDialog(null,"添加成功!");doDefaultCloseAction();}}}}class TelListener extends KeyAdapter{public void keyTyped(KeyEvent e){String numStr="0123456789-"+(char)8; //类型转换if(numStr.indexOf(e.getKeyChar())<0){e.consume();}}}//添加“关闭”按钮的事件监听器class CloseActionListener implements ActionListener{public void actionPerformed(final ActionEvent e){doDefaultCloseAction();}}private String[] columnNames("名称","性别","年龄","证件号码","借书证有效日期","借书量","电话","押金","证件","职业","读者编号","办证时间");private String[] array=new String[]{"身份证","军人证","学生证"};String id;private Object[][] getFileStates(List list){Object[][]results=new Object[list.size()][columnNames.length];for(int i=0;i<list.size();i++){Reader reader=(Reader)list.get(i);result[i][0]=reader.getName(); //定义二维数组String sex;if(reader.getSex().equals("1")){sex="男";}else{sex="女";}results[i][1]=sex; //读取读者歌属性值results[i][2]=reader.getAge();results[i][3]=reader.getIdentityCard();results[i][4]=reader.getDate();results[i][5]=reader.getMaxNum();results[i][6]=reader.getTel();results[i][7]=reader.getKeepMoney();results[i][8]=array[reader.getZj()];results[i][9]=reader.getZy();results[i][10]=reader.getBook_id();results[i][11]=reader.getBZtime();}return results;}//图书类别管理//添加图书信息utton.addActionListener(new ActionListener(){public void actionPerformed(final ActionEvent e){if(bookTypeName.getText().length()==0){JOptionPane.showMMessageDialog(null,"图书类别文本框不可为空");return;}if(days.getText().length()==0){JOptionPane.showMessageDialog(null,"可借天数文本框不可为空");return;}if(!check.isNumeric(days.getText().trim())){JOptionPane.showMessageDialog(null,"可借天数必须为数字");return;}if(fakuan.getText().length()==0){JOptionPane.showMessageDialog(null,"罚款文本框不可为空");return;}if(!check.isNumeric(fakuan.getText().trim())){JOptionPane.showMessageDialog(null,"罚款必须为数字");return;}inti=Business.InsertBookType(bookTypeName.getText().trim(),days.getText().trim(),Do uble.valueof(fakuan.getText.trim())/10);if(i==1){JOptionPane.showMessageDialog(null,"添加成功!");doDefaultCloseAction();}}});panel_6.add(button);final JButton buttonDel=new JButton();buttonDel.setText("关闭");buttonDel.addActionListener(new ActionListener(){public void actionPerformed(final ActionEvent e){doDefaultCloseAction();}});panel_6.add(buttonDel);setVisibel(true);}//修改图书类class ButtonAddListener implements ActionListener{public void actionPerformed(ActionEvent e){Object selectedItem=bookTypeModel.getSelectedItem();inti=Business.UpdatebookType(BookTypeId.getText().trim(),selectedItem.toString(),day s.getText().trim(),fk.getText().trim());if(i==1){JOptionPane.showMessageDialog(null,"修改成功");object[][] results=getFileStates(Business.selectBookCategory());model.setDataVector(results.columnNames);table.setModel(model);}}}。

图书馆管理系统源代码

图书馆管理系统源代码

以我给的标题写原创文档,最低1200字,要求以Markdown文本格式输出,不要带图片和AI、人工智能、Markdown、GPT等关键词,标题为:图书馆管理系统源代码# 图书馆管理系统源代码## 一、引言图书馆作为一个重要的知识资源和学术场所,对于学生和研究人员具有重要意义。

为了更好地管理图书馆资源和提供服务,图书馆管理系统应运而生。

本文将介绍图书馆管理系统的源代码设计和实现。

## 二、系统功能需求### 1. 登录功能- 提供管理员和用户登录功能- 管理员可进行图书管理、借阅管理等操作- 用户可查询图书信息、借阅情况等### 2. 图书管理- 添加新书籍信息- 修改或删除现有书籍信息- 查询图书信息,包括书名、作者、出版社等### 3. 借阅管理- 用户借阅图书- 用户归还图书- 管理员监管借阅情况### 4. 查询功能- 用户可以根据条件查询图书信息- 管理员可以查询借阅情况、用户信息等## 三、系统设计### 1. 数据库设计- 数据库包括图书信息表、用户信息表、借阅记录表等- 表之间建立关联,保证数据一致性和完整性### 2. 源代码结构```- books- README.md- book.js- bookRouter.js- users- README.md- user.js- userRouter.js- borrows- README.md- borrow.js- borrowRouter.js- index.js```### 3. 源代码逻辑- 使用Node.js构建后端服务- 使用Express框架处理路由和请求- 使用MongoDB作为数据库存储## 四、系统实现### 1. 登录功能```javascript// 用户登录router.post('/login', (req, res) => {// 处理登录逻辑});// 管理员登录router.post('/admin/login', (req, res) => { // 处理管理员登录逻辑});```### 2. 图书管理```javascript// 添加新书籍router.post('/addBook', (req, res) => {// 处理添加书籍逻辑});// 修改书籍信息router.put('/updateBook/:id', (req, res) => {// 处理修改书籍信息逻辑});// 删除书籍router.delete('/deleteBook/:id', (req, res) => {// 处理删除书籍逻辑});```### 3. 借阅管理```javascript// 用户借阅图书router.post('/borrowBook', (req, res) => {// 处理借阅图书逻辑});// 用户归还图书router.put('/returnBook/:id', (req, res) => {// 处理归还图书逻辑});```## 五、总结通过本文介绍,读者可以了解图书馆管理系统源代码的设计和实现逻辑。

C语言课程设计图书馆管理系统程序代码

C语言课程设计图书馆管理系统程序代码

#include〈stdio.h〉#include<windows.h〉#include〈string。

h〉#include<conio。

h>#define M 100struct books{char tsmc[12];inttsbh;float dj;char zz[12];char czzt[12];char xm[12];char xb[12];intxh; }s[M];int N;bool flag;intmain (){intsele;flag=0;sele=1;void sr();void cx();void sc();void js();void hs();void tc();void jsh();//system ("tsgl”);printf("\n\n");printf(" ************************\n"); printf(" 1:输入2:查询3:删除\n");printf(”4:借书5:还书0:退出\n");printf(” ************************\n"); while(1){printf(”\n\n请输入功能序号:");scanf (”%d",&sele);if(sele>=0 && sele<=5){switch(sele){case 1:sr();break;case 2:cx();break;case 3:sc();break;case 4:js();break;case 5:hs();break;case 0:jsh();break;}if(flag)break;printf(”\n\n");printf(” ************************\n”); printf(" 1:输入2:查询3:删除\n");printf(”4:借书5:还书0:退出\n”);printf(” ************************\n”);}else{printf(”输入错误请再次输入|\n\n");printf("\n\n");printf(” ************************\n”);printf(" 1:输入2:查询3:删除\n”);printf(”4:借书5:还书0:退出\n");printf(" ************************\n");}printf("\n\n让任意键继续\n”);} //wr_file();}/******主函数***//*********输入*********/void sr(){intn,i;N=0;printf("可输入的书本数:");scanf("%d",&n);N=n+N;printf("请输入相关信息:\n");for(i=1;i<=n;i++){printf(”图书名称:”);scanf(”%s",s[N-n-1+i]。

图书管理系统程序代码

图书管理系统程序代码

#include <stdio.h>#include <string.h>#include <stdlib.h>#define SIZE (struct booklist *)malloc(sizeof(struct booklist))//建立已借阅图书信息结构体struct borrow{char borbook_num[10];char borbook_name[22];char return_time[15];char stu_num[15];char stu_name[15];struct borrow *next;};//建立预借图书信息结构体struct prebor_stu{char prebook_num[10];char prestu_num[15];struct prebor_stu *next;};//建立图书结构体struct booklist{char num[10];char name[22];char zuozhe[15];char leibie[10];char pub_time[10];char price[10];char condition[10];struct booklist *next;};struct booklist *create(void); /*创建图书信息链表*/struct borrow *borrow_creat(struct booklist *head); //创建已借阅图书信息链表int pre_creat(struct booklist *head); //学生登录系统预借图书并将信息存入文件prebor_stulist.txtstruct prebor_stu *prebor_creat(void); //创建预借阅图书信息链表void printf1_(struct booklist *); //输出单个基本图书的数据void store(struct booklist *head); /*保存链表中的图书信息到文件booklist.txt*/void printfb1_(struct borrow *); //输出单个借出图书的部分数据void printfb_(struct borrow *p); //输出单个借出图书的数据void printfp1_(struct prebor_stu *); //输出单个被预借出图书的部分数据void printfp_(struct prebor_stu *); //输出单个被预借出图书的数据void printf_(struct booklist *,struct borrow *,struct prebor_stu *); /*2---输出链表中的图书信息*/struct booklist *load(void); //5---从文件读入图书信息struct booklist *num_paixu(struct booklist *); //4---按编号排序struct booklist *price_paixu(struct booklist *); //3---按价格顺序排序int kcnum(struct booklist *head); //6---统计库存数void chaxun1_(struct booklist *,struct borrow *,struct prebor_stu *); //7---查询图书的编号图书的信息,并输出void chaxun2_(struct booklist *,struct prebor_stu *,struct borrow *);//7---按作者查询信息并输出void chaxun3_(struct booklist *,struct prebor_stu *,struct borrow *); //7---查询某类别图书信息并自动输出void chaxun4_(struct borrow *,prebor_stu *,struct booklist *); //7---按学号查询借阅信息struct booklist *shanchu(struct booklist *,struct borrow *,struct prebor_stu *); //9---删除数据struct borrow *shanchu2_(struct borrow *,struct borrow *); //删除一个 struct borrow 结构体的数据struct prebor_stu *shanchu3_(struct prebor_stu *,struct prebor_stu *); //删除一个 struct prebor_stu 结构体的数据void xiugai(struct booklist *,struct borrow *,struct prebor_stu *); //10---修改数据void borstore(struct borrow *borrow_head); //保存已借阅图书信息到文件borrowlist.txt//重新保存修改后的预借阅信息到文件 prebor_stulist.txt (全部覆盖)void prestore(struct prebor_stu *pre_head);struct borrow *borload(void); //从文件提取信息创建已借阅图书源信息链表struct booklist *charu(struct booklist *head,struct borrow *borrow_head); //8---将图书的数据到顺序排放的链表中.且插入后也是顺序排放的struct booklist *scanf1_(void); // 输入单个图书源数据void exchange(struct booklist *,struct booklist *) ;//交换两个结构体内的内容struct borrow *tianjia1_(struct borrow *borrow_head,struct booklist *p); //添加一个 struct borrow 结构体的数据int main(void){int n, n1, x , k = 0, flag, flag1, x1;char ch;struct booklist *head = NULL; //图书信息链表头指针struct borrow *borrow_head = NULL ; //已借阅图书信息链表头指针struct prebor_stu *pre_head = NULL ; //预借图书信息链表头指针flag1 = 0; x = x1 = 1;while(x){system("cls");printf("***************************************************************************\n");printf("* >>>>>>>>>>>>>欢迎使用君宁图书管理系统<<<<<<<<<<<<<<< *\n");printf("* 0---退出系统 5---从文件录入数据 *\n");printf("* 1---录入数据 6---统计库存数 *\n");printf("* 2---输出信息 10---修改数据 7---查询功能 *\n");printf("* 3---按价格排序 8---增加数据 *\n");printf("* 4---按编号排序 9---删除数据 *\n");printf("***************************************************************************\n");printf("请选择功能:");scanf("%d", &n);getchar();switch(n){case 0: //0---退出系统{x = 0;printf("*******谢谢使用君宁图书管理系统!******\n");printf("****** 欢迎下次使用! ******\n");break;}case 1: //1---录入数据{while(x1){system("cls");printf("*******欢迎使用君宁图书信息录入系统*******\n");printf("*** 0---放弃录入 ****\n");printf("** 1---录入图书源信息 **\n");printf("* 2---录入借出图书信息 *\n");printf("** 3---录入预借图书信息 **\n");printf("******** 祝您使用愉快 ********\n");printf("请选择功能:");scanf("%d", &n1);getchar();switch(n1){case 0:{x1 = 0;break;}case 1:{head = create( ); /*创建图书信息链表*/printf("是否将源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}case 2:{if(head == NULL ){printf("请先录入图书源信息!\n");getchar();break;}else{borrow_head = borrow_creat(head); //创建已借阅图书信息链表printf("是否将源图书信息保存到文件borrowlist.txt!...(Y/N) :" );ch = getchar();if(ch == 'y' || ch == 'Y')borstore(borrow_head);getchar();break;}}case 3:{if(head == NULL ){printf("请先录入图书源信息!\n");getchar();break;}else{flag = pre_creat(head);if(flag == 1)printf("没有录入预借图书信息!\n\n");if(flag == 2)pre_head = prebor_creat(); //创建预借阅图书信息链表getchar();break;}}default :{printf("输入错误指示!\n\n");break;}}}}case 2: //2---输出信息{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{printf_(head,borrow_head,pre_head);break;}}case 3: //3---按价格排序{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = price_paixu(head);printf("是否将排序后的源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}}case 4: //4---按编号排序{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = num_paixu(head);printf("是否将排序后的源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}}case 5: //11---从文件读取数据{head = load();if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{borrow_head = borload(); //从文件提取信息创建已借阅图书源信息链表pre_head = prebor_creat(); //创建预借阅图书信息链表getchar();break;}}case 6: //6---统计库存数{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{k = kcnum(head);printf("总共有%3d本图书!\n\n", k);getchar();break;}}case 7: //7---查询信息{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{while(x1){system("cls");printf("*******欢迎使用君宁图书信息查询系统*******\n");printf("****** 0---退出查询******\n");printf("***** 1---按编号*****\n");printf("**** 2---按作者****\n");printf("***** 3---按类别*****\n");printf("****** 4---按学号******\n");printf("******** 祝您使用愉快********\n");printf("******************\n");printf("********************\n");printf("请选择功能:");scanf("%d", &n1);getchar();switch(n1){case 0:{x1 = 0;break;}case 1:{chaxun1_(head,borrow_head,pre_head);getchar();break;}case 2:{chaxun2_(head,pre_head,borrow_head);getchar();break;}case 3:{chaxun3_(head,pre_head,borrow_head);getchar();break;}case 4:{chaxun4_(borrow_head,pre_head,head);getchar();break;}default :{printf("输入指示有误!\n\n");break;}}}}x1 = 1;break;}case 8:{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = charu(head,borrow_head);printf("是否将源图书信息保存到文件booklist.txt!...(Y/N) :");ch = getchar();if(ch == 'y' || ch == 'Y')store(head);getchar();break;}}case 9: //9---删除数据{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{head = shanchu(head,borrow_head,pre_head);borrow_head = borload();pre_head = prebor_creat();break;}}case 10: //10---修改数据{if(head == NULL ){printf("请先录入图书信息!\n");getchar();break;}else{xiugai(head,borrow_head,pre_head);borrow_head = borload();getchar();break;}}default :{printf("输入错误指示.请重新输入!");getchar();break;}}}return 0;}/*创建图书源信息信息链表*/struct booklist *create(void){struct booklist *head, *tail, *p;char num[10],name[22], zuozhe[15], leibie[10], pub_time[10], price[10],condition[10];head = tail = p = NULL;printf("当输入图书编号为0时结束信息输入\n");printf("请输入图书编号:");gets(num);while(strcmp(num,"0") != 0){p = SIZE;printf("请输入书名:");gets(name);printf("请输入作者:");gets(zuozhe);printf("请输入类别:");gets(leibie);printf("请输入出版时间:");gets(pub_time);printf("请输入价格:");gets(price);printf("请输入借阅情况:");gets(condition);printf("\n");strcpy(p -> num, num);strcpy(p -> name, name);strcpy(p -> zuozhe, zuozhe);strcpy(p -> leibie, leibie);strcpy(p -> pub_time, pub_time);strcpy(p -> price, price);strcpy(p -> condition, condition);p -> next = NULL;if(head == NULL)head = p;elsetail -> next = p;tail = p;printf("请输入图书编号:");gets(num);}printf("图书源信息已建立链条!\n");return head;}//创建已借阅图书源信息链表struct borrow *borrow_creat(struct booklist *head) {struct booklist *p;struct borrow *borrow_head , *p1, *tail;borrow_head = p1 = tail = NULL;for(p = head; p != NULL; p = p -> next){p1 = (struct borrow *)malloc(sizeof(struct borrow));if(strcmp(p -> condition,"借出") == 0){printf("创建借出信息:\n");strcpy(p1 -> borbook_num ,p -> num);strcpy(p1 -> borbook_name ,p -> name);getchar();printf("借阅编号为%s的图书的借阅信息:\n",p -> num);printf("请输入应归还时间:");gets(p1 -> return_time);printf("请输入学生学号:");gets(p1 -> stu_num);printf("请输入学生姓名:");gets(p1 -> stu_name);printf("\n");p1 -> next = NULL;if(borrow_head == NULL)borrow_head = p1;elsetail -> next = p1;tail = p1;}}printf("成功创建已借出信息链表!\n\n");getchar();return borrow_head;}//保存已借阅图书信息到文件 borrowlist.txtvoid borstore(struct borrow *borrow_head){FILE *fp;struct borrow *p;if((fp = fopen("borrowlist.txt","w")) == NULL){printf("File open error! \n");exit(0);}p = borrow_head;while(p != NULL){fprintf(fp,"%16s%26s%16s%16s%16s\n",p -> borbook_num, p -> borbook_name, p -> return_time,p -> stu_num, p -> stu_name);p = p -> next;}fclose(fp);printf("文件成功保存到 borrowlist.txt 中!\n");getchar();}//从文件提取信息创建已借阅图书源信息链表struct borrow *borload(void){struct borrow *p, *tail, *head;FILE *fp;head = p = tail = NULL;if((fp = fopen("borrowlist.txt","r")) == NULL){printf("文件 borrowlist.txt 打开失败!\n");getchar();exit(0);}while(!feof(fp)){p = (struct borrow *)malloc(sizeof(struct borrow));fscanf(fp,"%16s%26s%16s%16s%16s\n",p -> borbook_num, p -> borbook_name, p -> return_time,p -> stu_num, p -> stu_name);if(head == NULL)head = p;elsetail -> next = p;tail = p;}tail -> next = NULL;fclose(fp);printf("已成功从文件 borrowlist.txt 提取信息创建已借阅图书源信息!\n");return head;}//录入预借图书信息并将信息存入文件 prebor_stulist.txtint pre_creat(struct booklist *head){struct booklist *b;struct prebor_stu *p;char a[10], c[15];int n, x = 1, flag = 1;FILE *fp;b = head;p = (struct prebor_stu *)malloc(sizeof(struct prebor_stu));printf("进入预借图书!(按回车键继续、、、)\n");getchar();while(x){printf("请输入要预借阅的图书编号:");gets(a);while((strcmp(b -> num ,a) != 0) && b -> next != NULL){b = b -> next;}if(strcmp(b -> num ,a) != 0){printf("没有找到编号为%s的图书!\n", a);printf("输入--0 结束录入!(输入其他数字继续录入...)\n\n");printf("请选择功能:");scanf("%d", &n);getchar();if(n == 0){x = 0;}getchar();}else{printf("请输入学号:");gets(c);strcpy(p -> prebook_num, a);strcpy(p -> prestu_num, c);if((fp = fopen("prebor_stulist.txt","a+")) == NULL){printf("File open error! \n");exit(0);}fprintf(fp,"%16s%16s\n",p -> prebook_num, p -> prestu_num);fclose(fp);flag = 2;printf("输入--0 结束录入!(输入其他数字继续录入...)\n\n");printf("请选择功能:");scanf("%d", &n);getchar();if(n == 0){x = 0;getchar();}}}return flag;}//重新保存修改后的预借阅信息到文件 prebor_stulist.txt (全部覆盖)void prestore(struct prebor_stu *pre_head){struct prebor_stu *p;FILE *fp;p = pre_head;if((fp = fopen("prebor_stulist.txt","w")) == NULL){printf("File open error! \n");exit(0);}while(p != NULL){fprintf(fp,"%16s%16s\n",p -> prebook_num, p -> prestu_num); p = p -> next;}fclose(fp);printf("文件成功保存到 prebor_stulist.txt 中!\n");getchar();}//从文件 prebor_stulist.txt创建预借阅图书信息链表struct prebor_stu *prebor_creat(void){struct prebor_stu *p, *tail, *head;FILE *fp;head = p = tail = NULL;if((fp = fopen("prebor_stulist.txt","r")) == NULL){printf("文件 prebor_stulist.txt 打开失败!\n");getchar();}while(!feof(fp)){p = (struct prebor_stu *)malloc(sizeof(struct prebor_stu));fscanf(fp,"%16s%16s\n",p -> prebook_num, p -> prestu_num);if(head == NULL)head = p;elsetail -> next = p;tail = p;}tail -> next = NULL;fclose(fp);printf("已从文件 prebor_stulist.txt 成功读取并建立预借阅图书信息!\n");getchar();return head;}/*2---保存链表中的图书信息到文件booklist.txt*/void store(struct booklist *head){FILE *fp;struct booklist *p;if((fp = fopen("booklist.txt","w")) == NULL){printf("File open error! \n");exit(0);}p = head;while(p != NULL){fprintf(fp,"%16s%26s%16s%16s%16s%16s%16s\n",p -> num, p -> name, p -> zuozhe, p -> leibie,p -> pub_time, p -> price, p -> condition);p = p -> next;}fclose(fp);printf("文件成功保存到 booklist.txt 中!\n");getchar();}// 输入单个图书源数据struct booklist *scanf1_(void) {struct booklist *p;p = SIZE;printf("请输入图书编号:");gets(p -> num);printf("请输入书名:");gets(p -> name);printf("请输入作者:");gets(p -> zuozhe);printf("请输入类别:");gets(p -> leibie);printf("请输入出版时间:");gets(p -> pub_time);printf("请输入价格:");gets(p -> price);printf("请输入借阅情况:");gets(p -> condition);return p;}//输出单个图书的数据void printf1_(struct booklist *p) {printf("编号:");puts(p -> num);printf("书名:");puts(p -> name);printf("作者:");puts(p -> zuozhe);printf("类别:");puts(p -> leibie);printf("出版时间:");puts(p -> pub_time);printf("价格:");puts(p -> price);printf("借阅情况:");}//输出单个借出图书的部分数据void printfb1_(struct borrow *p) {printf("应归还时间:");puts(p -> return_time);printf("借阅学生学号:");puts(p -> stu_num);printf("借阅学生姓名:");puts(p -> stu_name);}//输出单个借出图书的数据void printfb_(struct borrow *p) {printf("图书编号:");puts(p -> borbook_num);printf("书名:");puts(p -> borbook_name);printf("应归还时间:");puts(p -> return_time);printf("借阅学生学号:");puts(p -> stu_num);printf("借阅学生姓名:");puts(p -> stu_name);}//输出单个被预借出图书的部分数据void printfp1_(struct prebor_stu *p) {printf("预借图书的学生学号:"); puts(p -> prestu_num);}//输出单个被预借出图书的数据void printfp_(struct prebor_stu *p) {printf("图书编号:");printf("预借阅图书的学生学号:");puts(p -> prestu_num);}/*3---输出链表中的图书信息*/void printf_(struct booklist *head, struct borrow *borrow_head,struct prebor_stu *pre_head){struct booklist *p;struct borrow *b;struct prebor_stu *pre;int x = 1, n;p = head; b = borrow_head; pre = pre_head;while(x == 1){system("cls");printf("*******欢迎使用君宁图书信息输出系统*******\n");printf("* 0---退出 *\n");printf("* 1---输出图书源信息 *\n");printf("* 2---输出借出图书信息 *\n");printf("* 3---输出预借借图书信息 *\n");printf("******** 祝您使用愉快 ********\n");printf("请选择功能:");scanf("%d", &n);getchar();switch(n){case 0:{x = 0;break;}case 1:{if(head != NULL){printf("图书源信息如下:\n");do{printf1_(p);printf("\n\n");p = p -> next;}while(p != NULL);}getchar();break;}case 2:{if(borrow_head == NULL){printf("没有借出图书信息(按回车键继续、、、)!\n");getchar();break;}else{printf("借出图书信息如下:\n");do{printfb_(b);printf("\n\n");b = b -> next;}while(b != NULL);}printf("按回车键继续、、\n");getchar();break;}case 3:{if(pre_head == NULL){printf("没有预借图书信息(按回车键继续、、、)!\n");getchar();getchar();break;}else{printf("预借借图书信息如下:\n");do{printfp_(pre);printf("\n\n");pre = pre -> next;}while(pre != NULL);}printf("按回车键继续、、\n");getchar();break;}default :{printf("输入错误(按回车键继续、、、)!\n");getchar();break;}}}}//11---从文件读入图书信息struct booklist *load(void){struct booklist *p, *tail, *head;FILE *fp;head = p = tail = NULL;if((fp = fopen("booklist.txt","r")) == NULL){printf("文件 booklist.txt 打开失败!\n");getchar();exit(0);}while(!feof(fp)){p = SIZE;fscanf(fp,"%16s%26s%16s%16s%16s%16s%16s\n",p -> num, p -> name, p -> zuozhe, p -> leibie,p -> pub_time, p -> price,p -> condition);if(head == NULL)head = p;elsetail -> next = p;tail = p;}tail -> next = NULL;fclose(fp);printf("已成功读取文件 booklist.txt ,建立源图书信息链表!\n");return head;}//4---按编号排序并输出struct booklist *num_paixu(struct booklist *head){struct booklist *p, *p1, *tail;p1 = NULL;tail = SIZE;for(p = head;p -> next != NULL; p = p -> next){for(p1 = p ->next; p1 != NULL; p1 = p1 ->next){if(strcmp(p -> num,p1 -> num) > 0){exchange(tail,p1);exchange(p1,p);exchange(p,tail);}}}printf("图书已按编号排序成功,具体信息如下:\n");for(p = head; p != NULL; p = p -> next){printf1_(p);printf("\n");}return head;}//3---按价格排序struct booklist *price_paixu(struct booklist *head) {struct booklist *p, *p1, *tail;p1 = NULL;tail = SIZE;for(p = head;p -> next != NULL; p = p -> next){for(p1 = p ->next; p1 != NULL; p1 = p1 ->next){if(strcmp(p -> price,p1 -> price) > 0){exchange(tail,p1);exchange(p1,p);exchange(p,tail);}}}printf("图书已按价格排序成功,具体信息如下:\n");for(p = head; p != NULL; p = p -> next){printf1_(p);printf("\n");}return head;}//6---统计库存数int kcnum(struct booklist *head){int i = 0;struct booklist *p;for(p = head;p != NULL; p = p -> next)i++;return i;}//7---按编号查询信息并输出void chaxun1_(struct booklist *head,struct borrow *borrow_head,struct prebor_stu *pre_head){char a[10];struct booklist *p;struct borrow *b;struct prebor_stu *p1;int x1, x2;p = head; x1 = x2 = 0;printf("请输入要查询的图书编号:");gets(a);while((strcmp(p -> num ,a) != 0) && p -> next != NULL){p = p -> next;}if(strcmp(p -> num ,a) != 0)printf("没有找到编号为%s的图书!\n", a);else{for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> borbook_num ,a) == 0){x1 = 1;printf("您要查询的书已借出,其具体信息如下:\n");printfb1_(b); //输出单个借出图书的数据printf1_(p);}}for(p1 = pre_head;p1 != NULL; p1 = p1 -> next){if(strcmp(p1 -> prebook_num ,a) == 0){ x2 = 1;printf("您要查询的书已预借,其具体信息如下:\n");printfp1_(p1); //输出单个被预借出图书的数据printf1_(p);}}if(x1 == 0 && x2 == 0){printf("此书未被预借!\n\n");printf("您要查询的图书信息如下:\n");printf1_(p);}}}//7---按作者查询信息void chaxun2_(struct booklist *head,struct prebor_stu *pre_head,struct borrow *borrow_head){char a[10];struct booklist *p;struct borrow *b;struct prebor_stu *pre;int flag = 1, x1 ;printf("请输入要查询的图书的作者:");gets(a);for(p = head;p != NULL; p = p -> next){if(strcmp(p -> zuozhe,a) == 0){if(flag == 1){printf("您查询的%s的所有图书信息如下:\n\n",a);flag = -1;}printf1_(p);for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> borbook_num ,p -> num) == 0){printfb1_(b);}}x1 = 0;for(pre = pre_head; pre != NULL; pre = pre -> next){if(strcmp(pre -> prebook_num, p -> num) == 0){printf("此书已被%s学号的学生预借!\n",pre -> prestu_num );x1 = 1;}}if(x1 == 0){printf("此书未被预借!\n");x1 = 1;}printf("\n\n");}}if(flag == 1)printf("没有找到您要查询的的图书信息!\n\n");}//7---查询某类别图书信息并自动输出void chaxun3_(struct booklist *head,struct prebor_stu *pre_head,struct borrow *borrow_head){char a[10];struct booklist *p;struct prebor_stu *pre;struct borrow *b;int flag = 1 , x1;printf("请输入要查询的图书的类别:");gets(a);for(p = head;p != NULL; p = p -> next){if(strcmp(p -> leibie,a) == 0){if(flag == 1){printf("您查询的%s的所有图书信息如下:\n\n",a);flag = -1;}printf1_(p);for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> borbook_num ,p -> num) == 0){printfb1_(b);}}x1 = 0;for(pre = pre_head; pre != NULL; pre = pre -> next){if(strcmp(pre -> prebook_num, p -> num) == 0){printf("此书已被%s学号的学生预借!\n",pre -> prestu_num );x1 = 1;}}if(x1 == 0){printf("此书未被预借!\n");x1 = 1;}printf("\n\n");}}if(flag == 1)printf("没有找到您要查询的的图书信息!\n\n");}//7---按学号查询图书借阅信息并自动输出void chaxun4_(struct borrow *borrow_head,struct prebor_stu *pre_head,struct booklist *head){//建立图书编号结构体struct book_num{char booknum[10];struct book_num *next;};struct prebor_stu *p ;struct borrow *b;struct booklist *p2;char a[15];int i, j;i = j = 0;struct book_num *bnumhead1, *bnumhead2, *tail, *p1;bnumhead1 = bnumhead2 = tail = p1 = NULL;printf("请输入学生学号:");gets(a);for(p = pre_head; p != NULL; p = p -> next){if(strcmp(p -> prestu_num,a) ==0){i++;p1 = (struct book_num *)malloc(sizeof(struct book_num)); strcpy( p1 -> booknum, p ->prebook_num);if(bnumhead1 == NULL)bnumhead1 = p1;elsetail -> next = p1;tail = p1;p1 -> next = NULL;}}for(b = borrow_head;b != NULL; b = b -> next){if(strcmp(b -> stu_num,a) ==0){j++;p1 = (struct book_num *)malloc(sizeof(struct book_num)); strcpy( p1 -> booknum, b ->borbook_num);if(bnumhead2 == NULL)bnumhead2 = p1;elsetail -> next = p1;tail = p1;p1 -> next = NULL;}}if(i == 0 && j == 0)printf("没有您要查询学生的借阅信息!");else{if( j != 0){printf("该生一共借了%d本书,其借阅书的信息如下:\n", j);for( p1 = bnumhead2; p1 != NULL; p1 = p1 -> next){for(p2 = head; p2 != NULL; p2 = p2 -> next){if(strcmp(p1 -> booknum, p2 -> num) == 0){printf1_(p2);if(strcmp(p2 -> condition,"借出") ==0){for(b = borrow_head;b != NULL; b = b -> next)if(strcmp(b -> borbook_num,p2 -> num) ==0)printfb1_(b);}printf("\n");}}}}if( i != 0){printf("该生一共预借借了%d本书,其借阅书的信息如下:\n", i);for( p1 = bnumhead1; p1 != NULL; p1 = p1 -> next){for(p2 = head; p2 != NULL; p2 = p2 -> next){if(strcmp(p1 -> booknum, p2 -> num) == 0){printf1_(p2);if(strcmp(p2 -> condition,"借出") ==0){for(b = borrow_head;b != NULL; b = b -> next)if(strcmp(b -> borbook_num,p2 -> num) ==0)printfb1_(b);}printf("\n");}}}}}}//9---删除数据struct booklist *shanchu(struct booklist *head,struct borrow *borrow_head,struct prebor_stu *pre_head){struct booklist *p1 , *p2;struct borrow *b;struct prebor_stu *p;char a[10];p1 = p2 = head;printf("请输入要删除的图书编号:");gets(a);while((strcmp(p1 -> num ,a) != 0) && p1 -> next != NULL) {p2 = p1;p1 = p1 -> next;}if(strcmp(p1 -> num ,a) != 0)printf("没有找到要删除的图书信息!\n");else if(p1 == head){head = p1 -> next;printf("删除成功!\n");store(head);for(b = borrow_head; b != NULL; b = b -> next){if(strcmp(b -> borbook_num,a) == 0)borrow_head = shanchu2_(borrow_head,b);}for(p = pre_head; p != NULL; p = p -> next){if(strcmp(p -> prebook_num,a) == 0)pre_head = shanchu3_(pre_head,p);}}else{p2 -> next = p1 -> next;printf("删除成功!\n");store(head);for(b = borrow_head; b != NULL; b = b -> next){if(strcmp(b -> borbook_num,a) == 0)borrow_head = shanchu2_(borrow_head,b);}for(p = pre_head; p != NULL; p = p -> next){if(strcmp(p -> prebook_num,a) == 0)pre_head = shanchu3_(pre_head,p);}}return head;}//删除一个 struct borrow 结构体的数据struct borrow *shanchu2_(struct borrow *borrow_head,struct borrow *p) {struct borrow *p1 , *p2;p1 = p2 = borrow_head;while(strcmp(p1 -> borbook_num ,p -> borbook_num) != 0) {p2 = p1;p1 = p1 -> next;}if(p1 == borrow_head){borrow_head = p1 -> next;borstore(borrow_head);}else{p2 -> next = p1 -> next;borstore(borrow_head);}getchar();return borrow_head;}//添加一个 struct borrow 结构体的数据。

图书馆管理系统源代码

图书馆管理系统源代码

源程序清单1、文件名 login(login.frm)功能说明:整个系统的登陆界面,需要输入用户名和登陆密码才能进入到系统中,进行借阅等操作。

源代码:Option ExplicitDim cnt As IntegerPrivate Sub Command1_Click()Dim sql As StringDim rs_login As New ADODB.RecordsetIf Trim(Combo1.Text) = "" ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""Combo1.SetFocusElsesql = "select * from 系统管理 where 用户名='" & Combo1.Text & "'" rs_login.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_login.EOF = True ThenMsgBox "没有这个用户", vbOKOnly + vbExclamation, ""Combo1.SetFocusElseIf Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) ThenuserID = Combo1.Textrs_login.CloseUnload Meform1.ShowElseMsgBox "密码不正确", vbOKOnly + vbExclamation, ""txtpwd.SetFocusEnd IfEnd Ifcnt = cnt + 1If cnt = 3 ThenUnload MeEnd IfExit SubEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim connectionstring As Stringconnectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _"data source=book.mdb"conn.Open connectionstringcnt = 0End SubPrivate Sub txtuser_Change()End Sub2、文件名 form1(form1.frm)功能说明:整个系统的主界面,其中包括图书管理、读者管理、图书借阅管理、系统管理、关于,以及在这下面的子菜单。

图书借阅管理系统代码图书管理系统源代码

图书借阅管理系统代码图书管理系统源代码

#include<stdio。

h>#include 〈stdlib。

h>#include <string.h>#define num 7 //全局定义void showmain() //显示菜单{printf("\n\n 欢迎使用图书借阅管理系统\n\n");printf(" 1、查询所有图书\n\n");printf(" 2、归还现有图书\n\n");printf(" 3、租借现有图书\n\n”);printf(”0、退出借书系统\n\n");printf(”请输入您所需的服务编号:”);}void viewbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num]){int i;int j;for(i=1;i〈7;i++)//设置编号score[i]=i;yajin[1]=26.00;//将原图书的各项值保存yajin[2]=28.50;yajin[3]=98。

00;yajin[4]=79.80;yajin[5]=49。

00;yajin[6]=15.00;for(i=1;i<7;i++)//将原图书的各项值保存{free[i]=30;jiage[i]=0.5;}flag[1]=0; //flag为0代表已借出,为1代表未借出flag[2]=1;flag[3]=1;flag[4]=0;flag[5]=1;flag[6]=1;printf("编号\t|书名\t |作者\t|押金\t|免费天数\t|收费价格\t|出租状态\n"); //制表同时输出printf(”—--——-—---——-------—--——-————-——-———-—-—————--—————-—--——-——————-—-—---——-—\n”);for(i=1;i<7;i++){printf(”%d\t|%s\t|%s\t|%。

图书管理系统实验报告+源代码

图书管理系统实验报告+源代码

图书信息管理系统课程设计:图书信息管理系统设计人员:林俊柱开发环境: eclipse数据库: sql server 2005说明:数据库里面的用户名为”sa”, 密码为:”1111”登录程序所用的用户名为: ljz ,密码为: 0000,当然,也可以使用注册功能,注册完成后使用自己的用户名和密码登录设计思路:该图书信息管理系统主要便于图书管理员管理教师的书籍借阅情况。

该程序实现的功能总共有五个板块:1、教师信息管理:包含了增加、删除、修改、查询教师信息等功能;2、图书信息管理:包含了增加、删除、修改、查询图书信息等功能;3、借书登记:登记教师借阅图书的相关信息;4、还书登记:登记教师归还图书的相关信息;5、催还:查询出并列出教师借阅图书超过期限的相关信息,以便催促教师还书.数据库的设计思路为:Teacher(读者号,姓名,性别,年龄,部门,联系方式)Book(ISBN,书名,作者,出版社,价格,类型)Borrow(读者号,ISBN,借阅日期,归还日期,办理人,归还办理人)(横线为主键,蓝色字体为外键)管理员信息表:Administrator(管理员编号,管理员密码,管理员姓名,性别,年龄,联系电话)数据库的连接:public class Dataclass {private static Connection conn = null;String driverName= "com.microsoft.sqlserver.jdbc.SQLServerDriver";String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=Java 课程设计数据库 ";String userName="sa"; //默认用户名String userPwd="1111"; //密码//构造函数public Dataclass(){ //用于连接数库try {if (conn == null) {Class.forName(driverName);conn= DriverManager.getConnection(dbURL, userName, userPwd);}elsereturn;}catch (Exception e) { //捕获数据库连接不成功异常e.printStackTrace();}}public static ResultSet executeQuery(String sql) { //传送返回结果集的SQL语句try {if(conn==null)new Dataclass(); //调用构造函数连接数据库returnconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR _UPDATABLE).executeQuery(sql); //返回可滚动的并发事件}catch (SQLException e) { //捕获访问数据库失败异常e.printStackTrace();return null;}}public static boolean executeUpdate(String sql) { //发送不返回结果集的SQL语句try {if(conn==null)new Dataclass(); //调用构造函数连接数据库int i = conn.createStatement().executeUpdate(sql);if(i != 0)return true;}catch (SQLException e) { //捕获访问数据库失败异常System.out.println(e.getMessage());return false; //不成功返回-1}return false;}public static void close() { //断开数据库连接方法try {conn.close();}catch (SQLException e) {e.printStackTrace();}finally{conn = null; //设置数据库连接对象为空}}}登录界面的实现:代码为:public class KCSJDL extends JFrame{JTextField textField1;JPasswordField textField2;public KCSJDL(){t ry{// 设置Windows观感UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.Windows LookAndFeel");}catch(Exception e){System.out.println("Look and Feel Exception");System.exit(0);}setTitle("图书管理系统登录界面");setBounds(400, 200, 376, 300);setResizable(false);Container con=getContentPane();JLabel lblNewLabel = new JLabel();lblNewLabel.setIcon(new ImageIcon("images/head.jpg"));JPanel Jpanel1 = new JPanel();Jpanel1.setLayout(new GridLayout(2, 1, 0, 0));JPanel Jpanel1_1 = new JPanel();Jpanel1_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 30));Jpanel1.add(Jpanel1_1);JLabel lblNewLabel2 = new JLabel(" 管理员编号:");Jpanel1_1.add(lblNewLabel2);textField1 = new JTextField();Jpanel1_1.add(textField1);textField1.setColumns(25);JPanel Jpanel1_2 = new JPanel();Jpanel1_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));Jpanel1.add(Jpanel1_2);JLabel label_1 = new JLabel(" 管理员密码:");Jpanel1_2.add(label_1);textField2 = new JPasswordField();Jpanel1_2.add(textField2);textField2.setColumns(25);JPanel Jpanel2 = new JPanel();JLabel label = new JLabel(" ");JButton button1 = new JButton(" 登录 ");JButton button2 = new JButton(" 注册 ");Jpanel2.add(label);Jpanel2.add(button1);Jpanel2.add(button2);con.add(lblNewLabel,"North");con.add(Jpanel1,"Center");con.add(Jpanel2,"South");textField1.addActionListener(new KCSJDLEvent(this));textField2.addActionListener(new KCSJDLEvent(this));button1.addActionListener(new KCSJDLEvent(this));button2.addActionListener(new KCSJDLEvent(this));}public static void main(String []args){K CSJDL test = new KCSJDL();t est.setVisible(true);t est.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}注册界面的实现:代码为:public class KCSJZC extends JFrame{private ButtonGroup buttonGroup = new ButtonGroup();JTextField textField1_1;JTextField textField2_1;JTextField textField3_1;JTextField textField4_1;JTextField textField4_2;JRadioButton radioButton1;JRadioButton radioButton2;public KCSJZC(){try{// 设置Windows观感UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.Windows LookAndFeel");}catch(Exception e){System.out.println("Look and Feel Exception");System.exit(0);}setTitle("注册");setBounds(400, 200,500,550);setResizable(false);Container con=getContentPane();JLabel lblNewLabel = new JLabel();lblNewLabel.setIcon(new ImageIcon("images/ZC.png"));con.add(lblNewLabel,"North");JPanel Jpanel = new JPanel();Jpanel.setBorder(new TitledBorder(null, "管理员注册", TitledBorder.CENTER, TitledBorder.TOP, null, null));Jpanel.setLayout(new GridLayout(5, 1, 0, 0));con.add(Jpanel,"Center");JPanel J1 = new JPanel();J1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));Jpanel.add(J1);JLabel lb1_1 = new JLabel("管理员编号:");textField1_1 = new JTextField();textField1_1.setColumns(20);JLabel lb1_2 = new JLabel(" ");J1.add(lb1_1);J1.add(textField1_1);J1.add(lb1_2);JPanel J2 = new JPanel();J2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));Jpanel.add(J2);JLabel lb2_1 = new JLabel("管理员密码:");textField2_1 = new JTextField();textField2_1.setColumns(20);JLabel lb2_2 = new JLabel(" 确认密码:");JTextField textField2_2 = new JTextField();textField2_2.setColumns(20);J2.add(lb2_1);J2.add(textField2_1);J2.add(lb2_2);J2.add(textField2_2);JPanel J3 = new JPanel();J3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20)); Jpanel.add(J3);JLabel lb3_1 = new JLabel("管理员姓名:");textField3_1 = new JTextField();textField3_1.setColumns(20);JLabel lb3_2 = new JLabel(" 性别:");radioButton1 = new JRadioButton(" 男");//" " buttonGroup.add(radioButton1);JLabel lb3_3 = new JLabel(" ");radioButton2 = new JRadioButton(" 女");buttonGroup.add(radioButton2);J3.add(lb3_1);J3.add(textField3_1);J3.add(lb3_2);J3.add(radioButton1);J3.add(lb3_3);J3.add(radioButton2);JPanel J4 = new JPanel();J4.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20)); Jpanel.add(J4);JLabel lb4_1 = new JLabel("年龄:");textField4_1 = new JTextField();textField4_1.setColumns(20);JLabel lb4_2 = new JLabel(" 联系电话:");textField4_2 = new JTextField();textField4_2.setColumns(20);J4.add(lb4_1);J4.add(textField4_1);J4.add(lb4_2);J4.add(textField4_2);JPanel J5 = new JPanel();J5.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20)); Jpanel.add(J5);JButton Jb1 = new JButton(" 注册 ");Jb1.setIcon(new ImageIcon("images/JY.png"));Jb1.addActionListener(new enrollEvent(this));JButton Jb2 = new JButton("返回登录界面");Jb2.setIcon(new ImageIcon("images/GH.png"));Jb2.addActionListener(new enrollEvent(this));J5.add(Jb1);J5.add(Jb2);}}首页界面的实现:代码为:class KCSJMain extends JFrame {JButton Jbutton[] = new JButton[6];JPanel Jpanel;JPanel Jpanel1;JPanel Jpanel2;JPanel Jpanel3;JPanel Jpanel4;JPanel Jpanel5;JTextField textField_1;JTextField textField_2;JTextField textField_3;JTextField textField_4;JTextField textField_5;public KCSJMain(){t ry{// 设置Windows观感UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.Windows LookAndFeel");}catch(Exception e){System.out.println("Look and Feel Exception");System.exit(0);}s etTitle("图书管理系统");s etBounds(150, 150, 950, 620);s etResizable(false);C ontainer con=getContentPane();S tring str[] = {" 首页 ","教师信息管理","图书信息管理"," 借书登记"," 还书登记 "," 催还 "};String Pfilename[] ={"images/c6.png","images/p1.png","images/p2.png","images/p3.png","ima ges/p4.png","images/p5.png"};for(int i = 0;i < str.length;i++){Jbutton[i] = new JButton(str[i]);Jbutton[i].setIcon(new ImageIcon(Pfilename[i]));Jbutton[i].setHorizontalTextPosition(JButton.CENTER);Jbutton[i].setVerticalTextPosition(JButton.BOTTOM);}JPanel panel = new JPanel();panel.setBorder(new LineBorder(Color.LIGHT_GRAY));for(int i = 0;i < str.length;i++){panel.add(Jbutton[i]);}//左边JPanel jpanel = new JPanel();jpanel.setBorder(new LineBorder(Color.LIGHT_GRAY));jpanel.setLayout(new BoxLayout(jpanel, BoxLayout.Y_AXIS));JPanel panel_1 = new JPanel();panel_1.setBorder(newTitledBorder(UIManager.getBorder("TitledBorder.border"), "欢迎使用图书管理系统", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 0, 0)));jpanel.add(panel_1);JTextArea textArea = new JTextArea();textArea.setColumns(30);textArea.setRows(5);textArea.setText("【功能简要介绍】:\n 该系统可以对教师读者以及图 \n 书进行管理,包括增删改查等功能\n ,方便于管理,是管理员的小小\n 助手!");textArea.setBackground(SystemColor.control);textArea.setEditable(false);panel_1.add(textArea);JPanel panel_2 = new JPanel();panel_2.setBorder(new TitledBorder(null, "您好,欢迎登录图书管理系统", TitledBorder.CENTER, TitledBorder.TOP, null, null));jpanel.add(panel_2);JPanel jp = new JPanel();jp.setLayout(new GridLayout(5, 1, 0, 0));panel_2.add(jp);String str1[] = {"管理员编号:","管理员姓名:"," 性别: "," 年龄:"," 联系电话: "};JPanel JP[] = new JPanel[str1.length];JLabel label[] = new JLabel[str1.length];for(int i = 0;i < str1.length;i++){JP[i] = new JPanel();label[i]= new JLabel(str1[i]);JP[i].add(label[i]);jp.add(JP[i]);}textField_1 = new JTextField();textField_1.setColumns(20);JP[0].add(textField_1);textField_2 = new JTextField();textField_2.setColumns(20);JP[1].add(textField_2);textField_3 = new JTextField();textField_3.setColumns(20);JP[2].add(textField_3);textField_4 = new JTextField();textField_4.setColumns(20);JP[3].add(textField_4);textField_5 = new JTextField();textField_5.setColumns(20);JP[4].add(textField_5);//面板Jpanel = new JPanel();Jpanel.setBorder(new LineBorder(Color.LIGHT_GRAY));JLabel lblNewLabel = new JLabel("");lblNewLabel.setIcon(new ImageIcon("images/picture.png"));Jpanel.add(lblNewLabel);Jpanel1 = new JPanelclass1();Jpanel2 = new JPanelclass2();Jpanel3 = new JPanelclass3();Jpanel4 = new JPanelclass4();Jpanel5 = new JPanelclass5();con.add(panel,"North");con.add(jpanel,"West");con.add(Jpanel,"Center");//注册事件侦听器Jbutton[0].addActionListener(new ButtonEvent(this,Jpanel));Jbutton[1].addActionListener(new ButtonEvent(this,Jpanel1));Jbutton[2].addActionListener(new ButtonEvent(this,Jpanel2));Jbutton[3].addActionListener(new ButtonEvent(this,Jpanel3));Jbutton[4].addActionListener(new ButtonEvent(this,Jpanel4));Jbutton[5].addActionListener(new ButtonEvent(this,Jpanel5));//确认退出系统this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE) ;this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {int confirm=JOptionPane.showConfirmDialog(null,"是否要退出图书馆管理系统?","确认框",JOptionPane.YES_NO_OPTION);if (confirm==JOptionPane.YES_OPTION)System.exit(0);}});}}//当点击功能板块的图标时,图标会发生变化class ButtonEvent implements ActionListener {private KCSJMain frame;private JPanel jpanel;public ButtonEvent(KCSJMain frame,JPanel jpanel){this.frame = frame;this.jpanel = jpanel;}public void actionPerformed(ActionEvent e){String btnLabel = e.getActionCommand();if(btnLabel.equals("教师信息管理")){frame.Jbutton[0].setIcon(new ImageIcon("images/p6.png"));frame.Jbutton[1].setIcon(new ImageIcon("images/c1.png"));frame.Jbutton[2].setIcon(new ImageIcon("images/p2.png"));frame.Jbutton[3].setIcon(new ImageIcon("images/p3.png"));frame.Jbutton[4].setIcon(new ImageIcon("images/p4.png"));frame.Jbutton[5].setIcon(new ImageIcon("images/p5.png"));}else if(btnLabel.equals("图书信息管理")){frame.Jbutton[0].setIcon(new ImageIcon("images/p6.png"));frame.Jbutton[1].setIcon(new ImageIcon("images/p1.png"));frame.Jbutton[2].setIcon(new ImageIcon("images/c2.png"));frame.Jbutton[3].setIcon(new ImageIcon("images/p3.png"));frame.Jbutton[4].setIcon(new ImageIcon("images/p4.png"));frame.Jbutton[5].setIcon(new ImageIcon("images/p5.png"));}else if(btnLabel.equals(" 借书登记 ")){frame.Jbutton[0].setIcon(new ImageIcon("images/p6.png"));frame.Jbutton[1].setIcon(new ImageIcon("images/p1.png"));frame.Jbutton[2].setIcon(new ImageIcon("images/p2.png"));frame.Jbutton[3].setIcon(new ImageIcon("images/c3.png"));frame.Jbutton[4].setIcon(new ImageIcon("images/p4.png"));frame.Jbutton[5].setIcon(new ImageIcon("images/p5.png"));}else if(btnLabel.equals(" 还书登记 ")){frame.Jbutton[0].setIcon(new ImageIcon("images/p6.png"));frame.Jbutton[1].setIcon(new ImageIcon("images/p1.png"));frame.Jbutton[2].setIcon(new ImageIcon("images/p2.png"));frame.Jbutton[3].setIcon(new ImageIcon("images/p3.png"));frame.Jbutton[4].setIcon(new ImageIcon("images/c4.png"));frame.Jbutton[5].setIcon(new ImageIcon("images/p5.png"));}else if(btnLabel.equals(" 催还 ")){frame.Jbutton[0].setIcon(new ImageIcon("images/p6.png"));frame.Jbutton[1].setIcon(new ImageIcon("images/p1.png"));frame.Jbutton[2].setIcon(new ImageIcon("images/p2.png"));frame.Jbutton[3].setIcon(new ImageIcon("images/p3.png"));frame.Jbutton[4].setIcon(new ImageIcon("images/p4.png"));frame.Jbutton[5].setIcon(new ImageIcon("images/c5.png"));}else{frame.Jbutton[0].setIcon(new ImageIcon("images/c6.png"));frame.Jbutton[1].setIcon(new ImageIcon("images/p1.png"));frame.Jbutton[2].setIcon(new ImageIcon("images/p2.png"));frame.Jbutton[3].setIcon(new ImageIcon("images/p3.png"));frame.Jbutton[4].setIcon(new ImageIcon("images/p4.png"));frame.Jbutton[5].setIcon(new ImageIcon("images/p5.png")); }frame.Jpanel.setVisible(false);frame.Jpanel1.setVisible(false);frame.Jpanel2.setVisible(false);frame.Jpanel3.setVisible(false);frame.Jpanel4.setVisible(false);frame.Jpanel5.setVisible(false);frame.add(jpanel,"Center");jpanel.setVisible(true);}}教师信息管理的实现(面板中还有四个功能):代码为:class JPanelclass1 extends JPanel {//选项卡1private ButtonGroup buttonGroup1 = new ButtonGroup();JTextField ZJtextField11;JTextField ZJtextField12;JRadioButton radioButton11;JRadioButton radioButton12;JTextField ZJtextField22;JTextField ZJtextField31;JTextField ZJtextField32;//选项卡2JTextField SCtextField2_11;JPanel SCJp2_2;//选项卡3private ButtonGroup buttonGroup2 = new ButtonGroup();JTextField XGtextField3_11;JTextField XGtextField3_21;JRadioButton radioButton21;JRadioButton radioButton22;JTextField XGtextField3_221;JTextField XGtextField3_222;JTextField XGtextField3_231;//选项卡4JTextField CXtextField4_1;JPanel CXJp4_2;public JPanelclass1(){setLayout(new BorderLayout(0, 0));setBorder(new LineBorder(Color.LIGHT_GRAY));//选择面板JTabbedPane JT1 = new JTabbedPane(JTabbedPane.TOP);add(JT1);//选项卡1JPanel panel_1 = new JPanel();panel_1.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("增加教师信息", null, panel_1, null);JPanel J1 = new JPanel();J1.setBorder(new TitledBorder(null, "增加教师信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J1.setLayout(new GridLayout(4, 1, 0, 0));panel_1.add(J1);JPanel Jp_1 = new JPanel();Jp_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));J1.add(Jp_1);JLabel Jl11 = new JLabel("读者号:");ZJtextField11 = new JTextField();ZJtextField11.setColumns(20);JLabel Jl12 = new JLabel("*必填");JLabel Jl13 = new JLabel(" 姓名:");ZJtextField12 = new JTextField();ZJtextField12.setColumns(20);JLabel Jl14 = new JLabel("*必填");Jp_1.add(Jl11);Jp_1.add(ZJtextField11);Jp_1.add(Jl12);Jp_1.add(Jl13);Jp_1.add(ZJtextField12);Jp_1.add(Jl14);JPanel Jp_2 = new JPanel();J1.add(Jp_2);JLabel Jl21 = new JLabel("性别: "); radioButton11 = new JRadioButton(" 男");//" " buttonGroup1.add(radioButton11);JLabel Jl23 = new JLabel(" ");radioButton12 = new JRadioButton(" 女"); buttonGroup1.add(radioButton12);JLabel Jl22 = new JLabel(" 年龄:"); ZJtextField22 = new JTextField();ZJtextField22.setColumns(20);JLabel Jl24 = new JLabel(" ");Jp_2.add(Jl21);Jp_2.add(radioButton11);Jp_2.add(radioButton12);Jp_2.add(Jl23);Jp_2.add(Jl22);Jp_2.add(ZJtextField22);Jp_2.add(Jl24);JPanel Jp_3 = new JPanel();J1.add(Jp_3);JLabel Jl31 = new JLabel("部门:"); ZJtextField31 = new JTextField();ZJtextField31.setColumns(20);JLabel Jl32 = new JLabel(" 联系方式:"); ZJtextField32 = new JTextField();ZJtextField32.setColumns(20);JLabel Jl33 = new JLabel("*必填");Jp_3.add(Jl31);Jp_3.add(ZJtextField31);Jp_3.add(Jl32);Jp_3.add(ZJtextField32);Jp_3.add(Jl33);JPanel Jp_4 = new JPanel();J1.add(Jp_4);JButton Jb1 = new JButton(" 增加 ");Jb1.setIcon(new ImageIcon("images/ZJ.png")); Jp_4.add(Jb1);//注册侦听器Jb1.addActionListener(new JPanelclass1_1Event(this));//选项卡2JPanel panel_2 = new JPanel();panel_2.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("删除教师信息", null, panel_2, null);JPanel J2 = new JPanel();J2.setBorder(new TitledBorder(null, "删除教师信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J2.setLayout(new GridLayout(3, 1, 0, 0));panel_2.add(J2);JPanel Jp2_1 = new JPanel();Jp2_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 25));J2.add(Jp2_1);JLabel Jl2_11 = new JLabel("请输入读者号:");SCtextField2_11 = new JTextField();SCtextField2_11.setColumns(20);JButton Jb2_1 = new JButton(" 查询 ");Jb2_1.setIcon(new ImageIcon("images/b.png"));Jp2_1.add(Jl2_11);Jp2_1.add(SCtextField2_11);Jp2_1.add(Jb2_1);SCJp2_2 = new JPanel();SCJp2_2.setLayout(new BorderLayout());SCJp2_2.setBorder(new TitledBorder(null, "该教师的信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));J2.add(SCJp2_2);JPanel Jp2_3 = new JPanel();Jp2_3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 25));J2.add(Jp2_3);JButton Jb2_2 = new JButton(" 删除 ");Jb2_2.setIcon(new ImageIcon("images/SC.png"));Jp2_3.add(Jb2_2);//注册侦听器Jb2_1.addActionListener(new JPanelclass1_2Event(this));Jb2_2.addActionListener(new JPanelclass1_2Event(this));//选项卡3JPanel panel_3 = new JPanel();panel_3.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("修改教师信息", null, panel_3, null);JPanel J3 = new JPanel();J3.setBorder(new TitledBorder(null, "修改教师信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J3.setLayout(new GridLayout(2, 1, 0, 0));panel_3.add(J3);JPanel Jp3_1 = new JPanel();Jp3_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));J3.add(Jp3_1);JLabel Jl3_11 = new JLabel("请输入读者号:");XGtextField3_11 = new JTextField();XGtextField3_11.setColumns(20);JButton Jb3_1 = new JButton(" 查询该教师 ");Jb3_1.setIcon(new ImageIcon("images/b.png"));Jp3_1.add(Jl3_11);Jp3_1.add(XGtextField3_11);Jp3_1.add(Jb3_1);JPanel Jp3_2 = new JPanel();Jp3_2.setBorder(new TitledBorder(null, "修改教师信息", TitledBorder.LEADING, TitledBorder.TOP, null, null));Jp3_2.setLayout(new GridLayout(4, 1, 0, 0));J3.add(Jp3_2);JPanel Jp3_21 = new JPanel();Jp3_2.add(Jp3_21);JLabel Jl3_21 = new JLabel("教师姓名:");XGtextField3_21 = new JTextField();XGtextField3_21.setColumns(20);JLabel Jl3_22 = new JLabel(" 教师性别:");radioButton21 = new JRadioButton("男");//" "buttonGroup2.add(radioButton21);JLabel Jl3_23 = new JLabel(" ");radioButton22 = new JRadioButton("女");buttonGroup2.add(radioButton22);JLabel Jl3_24 = new JLabel(" ");Jp3_21.add(Jl3_21 );Jp3_21.add(XGtextField3_21);Jp3_21.add(Jl3_22);Jp3_21.add(radioButton21);Jp3_21.add(radioButton22);Jp3_21.add(Jl3_23);Jp3_21.add(Jl3_24);JPanel Jp3_22 = new JPanel();Jp3_2.add(Jp3_22);JLabel Jl3_221 = new JLabel("年龄:");XGtextField3_221 = new JTextField();XGtextField3_221.setColumns(20);JLabel Jl3_222 = new JLabel(" 部门:");XGtextField3_222 = new JTextField();XGtextField3_222.setColumns(20);Jp3_22.add(Jl3_221);Jp3_22.add(XGtextField3_221);Jp3_22.add(Jl3_222);Jp3_22.add(XGtextField3_222);JPanel Jp3_23 = new JPanel();Jp3_2.add(Jp3_23);JLabel Jl3_231 = new JLabel("联系方式:");XGtextField3_231 = new JTextField();XGtextField3_231.setColumns(20);JLabel Jl3_232 = new JLabel(" "); Jp3_23.add(Jl3_231);Jp3_23.add(XGtextField3_231);Jp3_23.add(Jl3_232);JPanel Jp3_24 = new JPanel();Jp3_2.add(Jp3_24);JButton Jb3_24 = new JButton(" 修改 ");Jb3_24.setIcon(new ImageIcon("images/XG.png"));Jp3_24.add(Jb3_24);//注册侦听器Jb3_1.addActionListener(new JPanelclass1_3Event(this));Jb3_24.addActionListener(new JPanelclass1_3Event(this));//选项卡4JPanel panel_4 = new JPanel();panel_4.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("查询教师信息", null, panel_4, null);JPanel J4 = new JPanel();J4.setBorder(new TitledBorder(null, "查询教师信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J4.setLayout(new GridLayout(2, 1, 0, 0));panel_4.add(J4);JPanel Jp4_1 = new JPanel();Jp4_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));J4.add(Jp4_1);JLabel Jl4_1 = new JLabel("请输入读者号:");CXtextField4_1 = new JTextField();CXtextField4_1.setColumns(20);JButton Jb4_1 = new JButton(" 查询该教师 ");Jb4_1.setIcon(new ImageIcon("images/b.png"));Jp4_1.add(Jl4_1);Jp4_1.add(CXtextField4_1);Jp4_1.add(Jb4_1);CXJp4_2 = new JPanel();CXJp4_2.setLayout(new BorderLayout());CXJp4_2.setBorder(new TitledBorder(null, "查询结果", TitledBorder.LEADING, TitledBorder.TOP, null, null));J4.add(CXJp4_2);//注册侦听器Jb4_1.addActionListener(new JPanelclass1_4Event(this));}}图书信息管理的实现:class JPanelclass2 extends JPanel{//选项卡1JTextField ZJtextField1_1;JTextField ZJtextField1_12;JTextField ZJtextField1_2;JTextField ZJtextField1_22;JTextField ZJtextField1_3;JTextField ZJtextField1_32;//选项卡2JTextField SCtextField2_1;JPanel SCJp2_2;//选项卡3JTextField XGtextField3_1;JTextField XGtextField3_21;JTextField XGtextField3_22;JTextField XGtextField3_221;JTextField XGtextField3_222;JTextField XGtextField3_23;//选项卡4JTextField CXtextField14;JPanel CXJp4_2;public JPanelclass2(){setLayout(new BorderLayout(0, 0));setBorder(new LineBorder(Color.LIGHT_GRAY));//选择面板JTabbedPane JT1 = new JTabbedPane(JTabbedPane.TOP);add(JT1);//选项卡1JPanel panel_1 = new JPanel();panel_1.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("增加图书信息", null, panel_1, null);JPanel J1 = new JPanel();J1.setBorder(new TitledBorder(null, "增加图书信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J1.setLayout(new GridLayout(4, 1, 0, 0));panel_1.add(J1);JPanel Jp1_1 = new JPanel();Jp1_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));J1.add(Jp1_1);JLabel Jl1_1 = new JLabel(" ISBN:");ZJtextField1_1 = new JTextField();ZJtextField1_1.setColumns(20);JLabel Jl1_12 = new JLabel("*必填书名:");ZJtextField1_12 = new JTextField();ZJtextField1_12.setColumns(20);JLabel Jl1_13 = new JLabel("*必填");Jp1_1.add(Jl1_1);Jp1_1.add(ZJtextField1_1);Jp1_1.add(Jl1_12);Jp1_1.add(ZJtextField1_12);Jp1_1.add(Jl1_13);JPanel Jp1_2 = new JPanel();J1.add(Jp1_2);JLabel Jl1_2 = new JLabel("作者:");ZJtextField1_2 = new JTextField();ZJtextField1_2.setColumns(20);JLabel Jl1_22 = new JLabel("*必填价格:");ZJtextField1_22 = new JTextField();ZJtextField1_22.setColumns(20);JLabel Jl1_23 = new JLabel("*必填");Jp1_2.add(Jl1_2);Jp1_2.add(ZJtextField1_2);Jp1_2.add(Jl1_22);Jp1_2.add(ZJtextField1_22);Jp1_2.add(Jl1_23);JPanel Jp1_3 = new JPanel();J1.add(Jp1_3);JLabel Jl1_3 = new JLabel("出版社:");ZJtextField1_3 = new JTextField();ZJtextField1_3.setColumns(20);JLabel Jl1_32 = new JLabel("*必填类型:");ZJtextField1_32 = new JTextField();ZJtextField1_32.setColumns(20);JLabel Jl1_33 = new JLabel(" ");Jp1_3.add(Jl1_3);Jp1_3.add(ZJtextField1_3);Jp1_3.add(Jl1_32);Jp1_3.add(ZJtextField1_32);Jp1_3.add(Jl1_33);JPanel Jp1_4 = new JPanel();J1.add(Jp1_4);JButton Jb1_4 = new JButton(" 增加 ");Jb1_4.setIcon(new ImageIcon("images/ZJ.png"));Jp1_4.add(Jb1_4);//注册侦听器Jb1_4.addActionListener(new JPanelclass2_1Event(this));//选项卡2JPanel panel_2 = new JPanel();panel_2.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("删除图书信息", null, panel_2, null);JPanel J2 = new JPanel();J2.setBorder(new TitledBorder(null, "删除图书信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J2.setLayout(new GridLayout(3, 1, 0, 0));panel_2.add(J2);JPanel Jp2_1 = new JPanel();Jp2_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 25));J2.add(Jp2_1);JLabel Jl2_1 = new JLabel("请输入ISBN:");SCtextField2_1 = new JTextField();SCtextField2_1.setColumns(20);JButton Jb2_1 = new JButton("查询");Jb2_1.setIcon(new ImageIcon("images/b.png"));Jp2_1.add(Jl2_1);Jp2_1.add(SCtextField2_1);Jp2_1.add(Jb2_1);SCJp2_2 = new JPanel();SCJp2_2.setLayout(new BorderLayout());SCJp2_2.setBorder(new TitledBorder(null, "查询结果", TitledBorder.LEADING, TitledBorder.TOP, null, null));J2.add(SCJp2_2);JPanel Jp2_3 = new JPanel();Jp2_3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 25));J2.add(Jp2_3);JButton Jb2_2 = new JButton(" 删除 ");Jb2_2.setIcon(new ImageIcon("images/SC.png"));Jp2_3.add(Jb2_2);//注册侦听器Jb2_1.addActionListener(new JPanelclass2_2Event(this));Jb2_2.addActionListener(new JPanelclass2_2Event(this));//选项卡3JPanel panel_3 = new JPanel();panel_3.setLayout(new GridLayout(0, 1, 0, 0));JT1.addTab("修改图书信息", null, panel_3, null);JPanel J3 = new JPanel();J3.setBorder(new TitledBorder(null, "修改图书信息", TitledBorder.CENTER, TitledBorder.TOP, null, null));J3.setLayout(new GridLayout(2, 1, 0, 0));panel_3.add(J3);JPanel Jp3_1 = new JPanel();Jp3_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));J3.add(Jp3_1);。

图书管理系统毕业设计源代码

图书管理系统毕业设计源代码

图书管理系统毕业设计源代码1. 简介图书管理系统是一个用于管理图书馆藏书及借阅情况的软件系统。

本文档将详细介绍图书管理系统的毕业设计源代码。

2. 源代码结构图书管理系统的源代码采用模块化的设计,分为以下几个模块: - 用户管理模块:负责管理员和读者的管理,包括用户注册、登录、修改密码等功能。

- 图书管理模块:负责图书的录入、删除、查找等功能。

- 借阅管理模块:负责借阅记录的管理,包括借书、还书、查看借阅历史等功能。

- 统计分析模块:负责统计图书馆的借阅情况、读者喜好等信息。

- 权限管理模块:负责管理不同角色的权限,例如管理员有更高的权限。

3. 技术选型•后端开发语言:采用Java语言进行开发,利用Java的面向对象和多线程的特性来实现系统的各个功能模块。

•前端开发:采用HTML、CSS和JavaScript进行前端开发,使用Bootstrap框架来实现页面的美化和响应式布局。

•数据库:采用MySQL关系数据库管理系统,存储图书馆的图书信息、用户信息及借阅记录等数据。

4. 代码实现细节4.1 用户管理模块用户管理模块的主要功能包括用户注册、登录、修改密码等。

- 用户注册:用户可以填写注册表单,并将信息提交到服务器进行注册。

服务器会将用户的信息存储到数据库中,并为用户分配一个唯一的ID。

- 用户登录:用户在登录页面输入用户名和密码,服务器会校验用户的登录信息,并根据用户的角色跳转到相应的首页。

- 修改密码:用户可以在个人信息页面修改密码,需要输入原密码和新密码。

4.2 图书管理模块图书管理模块的主要功能包括图书的录入、删除、查找等。

- 图书录入:管理员可以在后台管理页面输入图书的信息,包括书名、作者、出版社、ISBN等,并提交保存到数据库中。

- 图书删除:管理员可以根据图书的ID或其他关键字进行图书的删除操作,同时删除数据库中的对应记录。

- 图书查找:管理员和读者可以根据图书的关键字进行查找,系统会显示匹配的图书列表。

图书管理系统源代码 (3)

图书管理系统源代码 (3)

图书管理系统源代码1. 简介图书管理系统是一种用于管理图书馆或书店中图书信息的软件系统。

它主要提供了图书的添加、编辑、删除、查询等功能,便于管理人员对图书信息进行集中管理,同时也能方便读者进行图书的查询和借阅操作。

本文档将介绍一个基于Python的简单图书管理系统的源代码,以及其使用说明和功能演示。

2. 系统设计2.1 使用的库该图书管理系统使用了以下Python库来实现不同功能:•Tkinter:用于GUI界面的设计和实现。

•SQLite3:用于图书信息的持久化存储。

2.2 数据库设计在该图书管理系统中,我们使用了一个简单的图书信息表来存储图书的相关信息。

该表包含以下字段:•book_id:图书ID,唯一标识一个图书。

•book_title:图书标题,描述图书的名称。

•book_author:图书作者,描述图书的作者信息。

•book_publisher:图书出版商,描述图书的出版商信息。

2.3 功能设计该图书管理系统实现了以下功能:•添加图书:管理员可以添加一本新的图书到系统中。

•编辑图书:管理员可以编辑已存在的图书信息。

•删除图书:管理员可以从系统中删除指定的图书。

•查询图书:管理员和读者都可以根据图书的标题、作者或出版商来查询图书信息。

3. 源代码以下是该图书管理系统的源代码(使用Python编写):```python import tkinter as tk import sqlite3连接到数据库conn = sqlite3.connect(’library.db’) c = conn.cursor()创建图书信息表c.execute(’’’ CREATE TABLE IF NOT EXISTS books ( book_id INTEGER PRIMARY KEY AUTOINCREMENT, book_title TEXT, book_author TEXT, book_publisher TEXT ) ’’’)窗口初始化window = () window.title(。

图书管理系统源代码

图书管理系统源代码

#include<iostream>#include<string>#include<fstream>#include<strstream>#include<sstream>using namespace std;//定义类class Book{ public:char name[80];char auther[80];int num;//定义一个输出函数void out(){ cout<<"书名:"<<name<<" "<<"作者:"<<auther<<" "<<"数量:"<<num<<endl;}};//定义暂时存储数据的数组Book booklist[20];//寻找数组中空位的函数int locate1(){int z=0;while(z<20){if(booklist[z].name[0]=='n'&&booklist[z].name[1]=='u'&&booklist[z].name[2]=='l'&&booklist[z].name[3]=='l'){return z; //如果书名为null表示当前是空位则返回此位置}else{z++;}}}//依据书名和作者寻找书的位置int locate2(char m[80],char n[80]){int a=0;while(a<20){if(strcmp(n, booklist[a].auther)==0&&strcmp(m, booklist[a].name)==0){return a;break; //若书名和作者均符合则返回此位置并跳出}else{a++;}}if(a=20){return 20;}}//依据书名寻找书的位置int locate3(char m[80]){int a=0;while(a<20){if(strcmp(m, booklist[a].name)==0){return a; //书名相同即返回此位置break;}else{a++;}}if(a=20){return 20;}}//借书函数void borrow(){void menu();system("cls"); //刷新屏幕if(booklist[0].name[0]=='n'&&booklist[0].name[1]=='u'&&booklist[0 ].name[2]=='l'&&booklist[0].name[3]=='l'){cout<<"库中无图书,暂不能借书!\n";}else{system("cls");char m[80],n[80];cout<<"请输入要借阅的书名:(空格用下划线代替)"<<endl;cin>>m;cout<<"请输入要借阅的书作者:(空格用下划线代替)"<<endl;cin>>n;int l=locate2(m,n); //依据书名和作者定位if(l==20){cout<<"书库中无此书"<<endl;}else{if(booklist[l].num==0){system("cls");cout<<"抱歉,该书全部借出。

图书管理系统的C#代码完整版

图书管理系统的C#代码完整版

C#代码清单共1个项目,包含5个类。

项目: librarysystem类:主类代码:namespace librarysystem{ PublicationISBN = PublicationISBN;= PublicationName;= PublicationAuthor;= PublicationType;= PublicationStatus;}}}读者类代码:namespace librarysystem{ 询图书");("2.借书服务");("3.还书服务");("4.新出版物入库");("5.录入新读者");("6.查询读者的借阅信息");("7.退出管理系统");("-------------------------------------------------------------------");bool flag;do{flag = false;("请选择:");string key = ();switch (key){case"1":("请输入需要查询图书的书名:");ShowPubInfo();break;case"2":("请输入您的姓名:");();ShowBorrowInfo();("请输入您的姓名:");();ShowReturnInfo();break;case"4":("请按照提示逐步输入需要入库出版物的信息……");ShowAddPublications();break;case"5":("请按照提示逐步输入新注册读者的信息……");ShowAddReaders();break;case"6":("请输入您的姓名: ");();ShowRedPubInfo;break;case"7":flag = false;break;default:("无此业务,是否重新选择(y/n)");string answer = ();if (answer != "y"){flag = false;}else{flag = true;}break;}} while (flag);}/*显示查询到的出版物信息*/public void ShowPubInfo(){if ()){("您要查询的出版物信息:");("-------------------------------------------------------------------"); ("编号: " + ("出版物名字: " + ("出版物作者: " + ("出版物类型: " + if {("出版物状态:在架,可借");else{("出版物状态:未在架,不可借");}("-------------------------------------------------------------------"); ("");("");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();}else{("结束");}}else{("抱歉,未找到该图书!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();();}else{("结束");}}}/*显示借阅操作结果*/public void ShowBorrowInfo(){if{("恭喜,借阅成功!");ShowRedPubInfo;}{("抱歉,借阅失败!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}}/*显示归还操作结果*/public void ShowReturnInfo(){if{("恭喜,归还成功!");ShowRedPubInfo;}else{("抱歉,归还失败!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}}public void ShowRedPubInfo(Readers red){("当前你的借阅信息如下:");("--------------------------------------------------------------------"); ("编号: " + ;("姓名: " + ;("性别: " + ;("主修专业: " + ;("已借图书: ");for (int{if [i] != ""){(" "+[i]);}}("");("--------------------------------------------------------------------"); ("");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();}else{("结束");}}/*显示新出版物入库的信息*/public void ShowAddPublications(){pub = new Publications();("请输入出版物的编号: ");=();("请输入出版物的名称: ");= ();("请输入出版物的编者: ");= ();("请输入出版物的类型: ");= ();= true;(pub);("新出版物入库成功!");("是否办理其他业务(y/n)");string answer = ();if (answer == "y"){ShowMainMenu();();}else{("结束");}}/*显示新读者注册的信息*/public void ShowAddReaders(){red = new Readers();("请输入新注册读者的编号: "); = ();("请输入新注册读者的姓名: "); = ();("请输入新注册读者的性别: "); = ();("请输入新注册读者的院系: "); = ();("请输入新注册读者的专业: "); = ();for(int i=0;i<10;i++){[i]="";}(red);("新读者注册成功!");("是否办理其他业务(y/n) ");string answer = ();if (answer == "y"){ShowMainMenu();();();}else{("结束");}}}}。

书籍管理 php源代码

书籍管理 php源代码

书籍管理 php源代码以下是一个简单的书籍管理 PHP 源代码示例,包含了添加、查看、修改和删除书籍的基本功能:```php<?php// 连接数据库$servername = "localhost";$username = "你的用户名";$password = "你的密码";$dbname = "你的数据库名称";// 创建连接$conn = new mysqli($servername, $username, $password, $dbname);// 检查连接if ($conn->connect_error) {die("连接失败: ". $conn->connect_error);}// 定义操作函数function addBook($title, $author, $isbn) {$sql = "INSERT INTO books (title, author, isbn) VALUES ('".$title."', '".$author."', '".$isbn."')";if ($conn->query($sql) === TRUE) {echo "图书添加成功";} else {echo "图书添加失败: ". $conn->error;}}function viewBooks() {$sql = "SELECT * FROM books";$result = $conn->query($sql);if ($result->num_rows > 0) {while($row = $result->fetch_assoc()) {echo "标题: ". $row["title"]. " ". "作者: ". $row["author"]. " ". "ISBN: ". $row["isbn"]. "<br>";}} else {echo "没有图书记录";}}function updateBook($id, $title, $author, $isbn) {$sql = "UPDATE books SET title = '".$title."', author = '".$author."', isbn = '".$isbn."' WHERE id = ".$id;if ($conn->query($sql) === TRUE) {echo "图书修改成功";} else {echo "图书修改失败: ". $conn->error;}}function deleteBook($id) {$sql = "DELETE FROM books WHERE id = ".$id;if ($conn->query($sql) === TRUE) {echo "图书删除成功";} else {echo "图书删除失败: ". $conn->error;}}// 处理表单操作if ($_SERVER["REQUEST_METHOD"] == "POST") {if (isset($_POST["addBook"])) {addBook($_POST["title"], $_POST["author"], $_POST["isbn"]);} else if (isset($_POST["viewBooks"])) {viewBooks();} else if (isset($_POST["updateBook"])) {updateBook($_POST["id"], $_POST["title"], $_POST["author"], $_POST["isbn"]);} else if (isset($_POST["deleteBook"])) {deleteBook($_POST["id"]);}}// 显示图书管理页面><!DOCTYPE html><html><head><title>图书管理</title></head><body><h1>图书管理</h1><form action="" method="post"><input type="submit" name="addBook" value="添加图书"></form><form action="" method="post"><input type="submit" name="viewBooks" value="查看图书"></form><form action="" method="post"><input type="submit" name="updateBook" value="修改图书"></form><form action="" method="post"><input type="submit" name="deleteBook" value="删除图书"></form></body></html><?php// 关闭数据库连接$conn->close();>```上述代码实现了一个简单的图书管理系统,包含了添加、查看、修改和删除图书的功能。

图书借阅管理系统java代码

图书借阅管理系统java代码

以我给的标题写原创文档,最低1200字,要求以Markdown文本格式输出,不要带图片和AI、人工智能、Markdown、GPT等关键词,标题为:图书借阅管理系统java代码# 图书借阅管理系统Java代码## 一、介绍图书借阅管理系统是一个帮助图书馆管理图书借阅情况的系统。

本系统基于Java开发,采用面向对象的编程方式,实现了对图书信息、借阅记录等数据的管理与处理。

用户可以通过该系统查询图书信息、借阅图书、归还图书,并实现了管理员对系统的管理功能。

## 二、功能模块### 1. 图书管理模块- 实现对图书信息的添加、删除、修改和查询功能。

- 对图书的分类管理,方便用户按照分类查找图书信息。

### 2. 用户管理模块- 用户注册与登录功能,保证用户数据的安全。

- 用户查询借阅情况、借阅历史等个人信息。

### 3. 借阅管理模块- 实现图书的借阅功能,包括借书日期、归还日期等信息的记录。

- 用户借阅超时提醒,确保图书及时归还。

### 4. 管理员模块- 管理员登录后可以对图书信息、用户信息进行管理。

- 实现图书归还、逾期处理等功能。

## 三、系统架构本系统采用MVC(Model-View-Controller)架构,实现了模型层、视图层、控制层之间的分离,提高了系统的灵活性和可维护性。

具体架构如下:1. Model层:负责处理数据的逻辑操作,包括对图书信息、用户信息、借阅记录等数据的管理。

2. View层:负责系统的界面展示,包括用户界面和管理员界面。

3. Controller层:负责处理用户请求,调用Model层的方法,并将结果返回给View层进行展示。

## 四、代码示例以下是借阅图书的Java代码示例:```javapublic class BorrowBook {private Book book;private User user;private Date borrowDate;private Date returnDate;// Constructorpublic BorrowBook(Book book, User user, Date borrowDate, Date returnDate) {this.book = book;er = user;this.borrowDate = borrowDate;this.returnDate = returnDate;}// Getters and setters}```以上代码实现了一个借阅图书的类`BorrowBook`,包含了借阅的图书信息、用户信息,借阅时间和归还时间。

图书管理系统C语言实现代码

图书管理系统C语言实现代码
int number;
char telephone[20];
int NO;
char bookname[20];
int borrowdate;
int returndate;
if((fp=fopen("jieshujilu.txt","r"))==NULL){
scanf("%s",);
fprintf(fp,"%s",);
printf("请输入借书人班级:");
scanf("%s",p.classes);
fprintf(fp," %s",p.classes);
printf("请输入借书人学号:");
scanf("%d",&p.number);
/*随代码必须新建一下文件:jieshujilu.txt shuku.txt tempbook.txt tempshuku.txt */
#include<stdio.h>
#include<stdlib.h>
struct book{
char bookname[20]; //书名
exit(0);
}
printf("请输入此次收到的书本总数:");
scanf("%d",&i);
for(j=0;j<i;j++){
printf("请输入书名:");
scanf("%s",b.bookname);
fprintf(fp,"%s",b.bookname);

图书管理系统的设计(C语言)

图书管理系统的设计(C语言)

图书管理系统设计图书管理信息包括:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等功能描述:1 .新进熟土基本信息的输入2 .图书基本信息的查询3 .对撤销图书信息的删除4 .为借书人办理注册5 .办理借书手续6 .办理换书手续要求:以文件方式存储数据,系统以菜单方式工作。

这是本人大一第二学期初 C 语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天无意中居然在QQ 网络硬盘中找到了当初的teta 版,发布于此,以作记念。

C 源代码如下:#include〈stdio 。

h〉#include<stdlib。

h〉#include〈string 。

h>struct book {char book_name [30];int bianhao;double price;char author[20];char state [20] ;char name[20];char sex [10];int xuehao;struct book *book_next;};struct club {char name [20];char sex[10];int xuehao;char borrow [30];struct club *club_next;};void Print_Book(struct book *head_book);/*浏览所有图书信息*/void Print_Club(struct club *head_club);/*浏览所有会员信息*/struct book *Create_New_Book();/*创建新的图书库, 图书编号输入为0 时结束*/struct book *Search_Book_bianhao(int bianhao,struct book *head_book);struct book *Search_Book_name (char *b_name,struct book *head_book);struct book *Search_Book_price (double price_h,double price_l,struct book *head_book);struct book *Insert_Book (struct book *head_book,struct book *stud_book) ;/*增加图书,逐个添加*/struct book *Delete_Book(struct book *head_book,int bianhao);/*删除图书*/struct club *Create_New_Club() ;struct club *Search_Club_xuehao(int xuehao,struct club *head_club);struct club *Search_Club_name (char *c_name,struct club *head_club);struct club *Insert_Club (struct club *head_club,struct club *stud_club);struct club *Delete_Club (struct club *head_club,int xuehao);struct book *Lent_Book (int bianhao ,int xuehao,struct book *head_book,struct club *head_club);struct book *back (int bianhao,int xuehao,struct book *head_book,struct club *head_club); int main(){struct book *head_book,*p_book;char book_name [30],name [20],author [20],sex [10];int bianhao;double price,price_h,price_l;int size_book=sizeof(struct book);int m=1,n=1,f;char *b_name,*c_name;struct club *head_club,*p_club;int xuehao;int size_club=sizeof (struct club) ;int choice;printf ("\n 欢迎您第一次进入图书管理系统!\n\n");printf("---——>[向导]————-〉[新建图书库] \n\n”) ;printf ("注意:当输入图书编号为0 时,进入下一步.\n\n");head_book=Create_New_Book();system(”cls”) ;printf("\n 欢迎您第一次进入图书管理系统!\n\n") ;printf("----—〉[向导]——---〉[新建会员库]\n\n”);printf(”注意:当输入会员学号为0 时,进入主菜单.\n\n”);head_club=Create_New_Club () ;system (”cls”);do {printf(”\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n”);printf("\n”);printf ("\t\t\t[1] :借书办理\t");printf(" [6]:还书办理\n”);printf (”\n");printf(”\t\t\t[2]:查询图书\t");printf(" [7]:查询会员\n”);printf (” \t\t\t[3]:添加图书\t");printf (" [8]:添加会员\n”);printf ("\t\t\t[4]:删除图书\t");printf (” [9] :删除会员\n") ;printf (” \t\t\t[5]:遍历图书\t");printf (” [10]:遍历会员\n\n”) ;printf ("\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n\n”);printf("\t\t\t0:退出\n\n”) ;printf(”请选择〈0~10〉:”);scanf(”%d",&choice);switch(choice) {case 1:printf ("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf (”输入所借图书编号:\n");scanf (”%d",&bianhao);printf ("输入借书人的学号:\n”);scanf ("%d",&xuehao);head_book=Lent_Book(bianhao,xuehao,head_book,head_club);system (”cls");printf (” \n 借阅成功!\n\n");printf (”相关信息如下:\n\n");head_book=Search_Book_bianhao (bianhao,head_book);break;case 2:system ("cls”) ;printf(”\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n”); printf ("1。

图书管理系统源代码(原创)

图书管理系统源代码(原创)

#include<stdio.h>#include<stdlib.h>#include<string.h>struct book{int num;char bname[50];char wname[20];char press[50];char sort[50];int time;float price;struct book *next;};struct book *creatbook(); //创建链表struct book *addbook(struct book *head); //添加图书int yanzheng(struct book *head,int m); //验证新添加的图书编码是否已存在void deletebook(struct book *head); //删除图书void fprint(struct book *head); //将链表写入文件struct book *load(); //从文件中读取信息并建成链表void print_book(struct book *head); //将链表信息输出void chaxun(struct book *head); //查询图书信息void num_chaxun(struct book *head); //按图书编号查询图书void wname_chaxun(struct book *head); //按作者名查询图书void sort_chaxun(struct book *head); //按类别查询图书void time_chaxun(struct book *head); //按出版时间查询图书void bname_chaxun(struct book *head); //按图书名查询图书void xiugai(struct book *head); //修改图书信息void paixu(struct book *head); //对图书进行排序void num_paixu(struct book *head); //按图书编号排序void time_paixu(struct book *head); //按图书出版时间排序void price_paixu(struct book *head); //按图书价格排序void bname_paixu(struct book *head); //按图书名排序void wname_paixu(struct book *head); //按作者名排序int main(){int choice,n,x,y=1,c,c1=1;char a,d,b[10],b1[10]="1";struct book *head=NULL;while(y){system("cls");printf("\n\n\n\n\n");printf(" ----------------------------------------------------------------------\n");printf(" --- ||-------------||-------图书信息管理系统--------||-----------||---\n");printf(" --- ||-------------||------- 登陆界面--------||-----------||---\n");printf(" ----------------------------------------------------------------------\n");printf("\n");printf(" ============1-进入系统===========\n");printf(" ============0-退出系统===========\n");printf(" ----------------------------------------------------------------------\n");printf(" 请输入选择:");scanf("%d",&n);printf("\n");getchar();switch(n){case 0:y=0;break;case 1:printf(" 请输入您的用户名(输入1即可):");gets(b);printf("\n");printf(" 请输入您的密码(输入1即可):");scanf("%d",&c);printf("\n");if(strcmp(b,b1)!=0||c!=c1){printf(" 验证失败,请重新输入!\n");scanf("%c",&d);getchar();system("cls");}else{printf(" 验证通过!请按Enter键进入!\n");scanf("%c",&d);getchar();x=1;while(x){system("cls");system ("color 1F");printf(" ----------------------------------------------------------------------\n\n");printf(" --- ||-------------||-------图书信息管理系统--------||-----------||---\n\n");printf(" --- ||-------------||-----------操作界面------------||-----------||---\n\n");printf(" ----------------------------------------------------------------------\n\n");printf(" ----------------------------------------------\n");printf(" ----||-----------系统菜单选项-----------||----\n");printf(" ----------------------------------------------\n");printf(" -|| 1-添加图书删除图书-2 ||-\n\n");printf(" -|| 3-图书列表图书排序-4 ||-\n\n");printf(" -|| 5-查询图书修改图书-6 ||-\n\n");printf(" -|| 7-录入数据退出系统-0 ||-\n\n");printf(" ----------------------------------------------\n");printf(" ----------------------------------------------\n\n");printf("请输入所选择的序号:");scanf("%d",&choice);getchar();system("cls");switch(choice){case 0:x=0;break;case 1:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{head=addbook(head);printf("添加成功!\n");printf("是否将新信息保存到文件?(y/n)\n");scanf("%c",&a);getchar();switch(a){case 'n':break;case 'y':fprint(head);printf("保存成功!\n");getchar();break;}break;}case 2:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{deletebook(head);getchar();break;}break;case 3:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{print_book(head);getchar();break;}case 4:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{paixu(head);getchar();}break;case 5:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{chaxun(head);getchar();}break;case 6:head=load();if(head==NULL){printf("文件为空,请先录入数据!\n");getchar();break;}else{xiugai(head);getchar();break;}break;case 7:printf("注意:输入图书编码为0时结束!\n");head=creatbook();printf("是否将输入的信息保存到文件以覆盖文件中已存在的信息?(y/n)\n");getchar();scanf("%c",&a);getchar();switch(a){case '0':break;case 'y':fprint(head);printf("保存成功!\n");getchar();break;}break;default:printf("输入有误,请重新输入!\n");getchar();break;}}}break;default:printf(" 输入有误,请重新输入!\n");getchar();break;}}}//录入数据并形成链表struct book *creatbook(){struct book *head,*tail,*p;int num,time,n;char bname[50],wname[20],press[50],sort[50];float price;int size=sizeof(struct book);head=tail=NULL;printf("请输入图书编号:");scanf("%d",&num);printf("请输入图书名:");scanf("%s",bname);getchar();printf("请输入作者名:");scanf("%s",wname);getchar();printf("请输入出版社:");scanf("%s",press);getchar();printf("请输入类别:");scanf("%s",sort);getchar();printf("请输入出版时间:");scanf("%d",&time);getchar();printf("请输入价格:");scanf("%f",&price);getchar();while(1){p=(struct book *)malloc(size);p->num=num;strcpy(p->bname,bname);strcpy(p->wname,wname);strcpy(p->press,press);strcpy(p->sort,sort);p->time=time;p->price=price;p->next=NULL;if(head==NULL)head=p;elsetail->next=p;tail=p;do{printf("请输入图书编号:");scanf("%d",&num);n=yanzheng(head,num);if(n==0)break;elseprintf("您输入的编号已存在,请重新输入!\n"); }while(1);if(num==0)break;else{printf("请输入图书名:");scanf("%s",bname);getchar();printf("请输入作者名:");scanf("%s",wname);getchar();printf("请输入出版社:");scanf("%s",press);getchar();printf("请输入类别:");scanf("%s",sort);getchar();printf("请输入出版时间:");scanf("%d",&time);getchar();printf("请输入价格:");scanf("%f",&price);getchar();}}return head;}//插入结点,并且插入后仍按一定顺序struct book *addbook(struct book *head){struct book *ptr,*p1,*p2,*p;char bname[50],wname[20],press[50],sort[50];int size=sizeof(struct book);int num,time,n=1;float price;do{printf("请输入图书编号:");scanf("%d",&num);n=yanzheng(head,num);if(n==0)break;elseprintf("您输入的编号已存在,请重新输入!\n");}while(1);printf("请输入图书名:");scanf("%s",bname);getchar();printf("请输入作者名:");scanf("%s",wname);getchar();printf("请输入出版社:");scanf("%s",press);getchar();printf("请输入类别:");scanf("%s",sort);getchar();printf("请输入出版时间:");scanf("%d",&time);getchar();printf("请输入价格:");scanf("%f",&price);getchar();p=(struct book *)malloc(size);p->num=num;strcpy(p->bname,bname);strcpy(p->wname,wname);strcpy(p->press,press);strcpy(p->sort,sort);p->time=time;p->price=price;p2=head;ptr=p;while((ptr->num>p2->num)&&(p2->next!=NULL)){ p1=p2;p2=p2->next;}if(ptr->num<=p2->num){if(head==p2)head=ptr;else{p1->next=ptr;p->next=p2;}}else{p2->next=ptr;p->next=NULL;}return head;}//验证添加的图书编号是否已存在int yanzheng(struct book *head,int m){struct book *p;p=head;while(p!=NULL){if(p->num==m)break;p=p->next;}if(p==NULL)return 0;elsereturn 1;}//将新链表写入文件中void fprint(struct book *head){FILE *fp;char ch='1';struct book *p1;if((fp=fopen("f1.txt","w"))==NULL){printf("File open error!\n");exit(0);}fputc(ch,fp);for(p1=head;p1;p1=p1->next){fprintf(fp,"%d %s %s %s %s %d %f\n",p1->num,p1->bname,p1->wname,p1->press,p1->sort ,p1->time,p1->price);}fclose(fp);}//从文件中读取图书信息struct book *load(){FILE *fp;char ch;struct book *head,*tail,*p1;head=tail=NULL;if((fp=fopen("f1.txt","r"))==NULL){printf("File open error!\n");exit(0);}ch=fgetc(fp);if(ch=='1'){while(!feof(fp)){p1=(struct book *)malloc(sizeof(struct book));fscanf(fp,"%d%s%s%s%s%d%f\n",&p1->num,p1->bname,p1->wname,p1->press,p1->sort,&p1-> time,&p1->price);if(head==NULL)head=p1;elsetail->next=p1;tail=p1;}tail->next=NULL;fclose(fp);return head;}elsereturn NULL;}//将整个链表的信息输出void print_book(struct book *head){struct book *ptr;if(head==NULL){printf("\n没有信息!\n");return;}printf(" 图书信息列表如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(ptr=head;ptr;ptr=ptr->next)printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", ptr->num,ptr->bname,ptr->wname,ptr->press,ptr->sort,ptr->time,ptr->price);printf("====================================================================== ======\n");}//删除图书信息void deletebook(struct book *head){int a;char b,ch='1';struct book *p1,*p2;FILE *fp;printf("请输入要删除的图书编号:");scanf("%d",&a);p1=head;if(p1->num==a&&p1->next==NULL){ //对于文件中只有一组数据printf("是否清空文件!(y/n)\n");getchar();scanf("%c",&b);getchar();switch(b){case 'n':break;case 'y':if((fp=fopen("f1.txt","w"))==NULL){printf("File open error!\n");exit(0);}fclose(fp);printf("文件已清空!\n");}}else{while(p1->num!=a&&p1->next!=NULL){p2=p1;p1=p1->next;}if(p1->next==NULL){if(p1->num==a){p2->next=NULL;printf("是否确定从文件中彻底删除该图书?(y/n)\n");getchar();scanf("%c",&b);switch(b){case 'n':break;case 'y':fprint(head);printf("删除成功!\n");getchar();break;}}else{printf("没有找到要删除的数据!\n");getchar();}}else if(p1==head){head=p1->next;printf("是否确定从文件中彻底删除该图书?(y/n)\n");getchar();scanf("%c",&b);switch(b){case 'n':break;case 'y':fprint(head);printf("删除成功!\n");getchar();break;}}else{p2->next=p1->next;printf("是否确定从文件中彻底删除该图书?(y/n)\n");getchar();scanf("%c",&b);switch(b){case 'n':break;case 'y':fprint(head);printf("删除成功!\n");getchar();break;}}}}//图书查询void chaxun(struct book *head){int a;printf("==========================================================\n");printf(" ** 1-按图书编号查询2-按图书名查询**\n");printf(" ** 3-按图书类别查询4-按作者名查询**\n");printf(" ** 5-按出版时间查询0-退出查询**\n");printf("==========================================================\n");printf("请输入所选择的编号:");scanf("%d",&a);getchar();switch(a){case 0:break;case 1:num_chaxun(head);break;case 2:bname_chaxun(head);break;case 3:sort_chaxun(head);break;case 4:wname_chaxun(head);break;case 5:time_chaxun(head);break;default:printf("您的输入有误!\n");break;}}//按编号查询图书信息void num_chaxun(struct book *head){int a;struct book *p;printf("请选择您要查询的图书编号:");scanf("%d",&a);getchar();p=head;while(p!=NULL){if(p->num==a)break;p=p->next;}if(p==NULL){printf("没有找到该编号的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);printf("====================================================================== ======\n");}}//按图书名查询图书信息void bname_chaxun(struct book *head){char a[50];int flag=0;struct book *p;printf("请选择您要查询的图书名:");gets(a);p=head;while(p!=NULL){if(strcmp(p->bname,a)==0){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(strcmp(p->bname,a)==0){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);}p=p->next;}printf("====================================================================== ======\n");}}//按作者名查询图书信息void wname_chaxun(struct book *head){char a[50];int flag=0;struct book *p;printf("请选择您要查询的图书作者名:");gets(a);p=head;while(p!=NULL){if(strcmp(p->wname,a)==0){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(strcmp(p->wname,a)==0){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}p=p->next;}printf("============================================================================\n");}}//按图书类别查询图书信息void sort_chaxun(struct book *head){char a[50];int flag=0;struct book *p;printf("请选择您要查询的图书类别:");gets(a);p=head;while(p!=NULL){if(strcmp(p->sort,a)==0){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(strcmp(p->sort,a)==0){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}p=p->next;}printf("====================================================================== ======\n");}}//按图书出版时间查询图书信息void time_chaxun(struct book *head){int a,flag=0;struct book *p;printf("请选择您要查询的图书出版时间:");scanf("%d",&a);getchar();p=head;while(p!=NULL){if(p->time==a){flag=1;break;}p=p->next;}if(flag==0){printf("没有找到该图书名的图书!\n");}else{printf(" 你所查询的图书信息如下\n");printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");while(p!=NULL){if(p->time==a){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n", p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}p=p->next;}printf("====================================================================== ======\n");}}//修改图书信息void xiugai(struct book *head){int a,b;char c;struct book *p;printf("请输入要修改的图书编号:");scanf("%d",&a);p=head;while(p!=NULL){if(p->num==a)break;p=p->next;}if(p==NULL){printf("没有找到该编号的图书!\n");getchar();}else{printf("============================================================\n");printf(" ** 1-编号2-图书名3-作者名**\n");printf(" ** 4-出版社5-类别6-出版时间**\n");printf(" ** 7-价格8-修改全部0-放弃修改**\n");printf("============================================================\n");printf("请选择你要修改的信息编号:");scanf("%d",&b);getchar();switch(b){case 1:printf("请输入新编号:");scanf("%d",&p->num);printf("修改成功!\n");getchar();break;case 2:printf("请输入新图书名:");gets(p->bname);printf("修改成功!\n");break;case 3:printf("请输入新作者名:");gets(p->wname);printf("修改成功!\n");break;case 4:printf("请输入新出版社:");gets(p->press);printf("修改成功!\n");break;case 5:printf("请输入新类别:");gets(p->sort);printf("修改成功!\n");break;case 6:printf("请输入新出版时间:");scanf("%d",&p->time);printf("修改成功!\n");getchar();break;case 7:printf("请输入新价格:");scanf("%f",&p->price);printf("修改成功!\n");getchar();break;case 8:printf("请输入新图书编号:");scanf("%d",&p->num);printf("请输入新图书名:");scanf("%s",p->bname);getchar();printf("请输入新作者名:");scanf("%s",p->wname);getchar();printf("请输入新出版社:");scanf("%s",p->press);getchar();printf("请输入新类别:");scanf("%s",p->sort);getchar();printf("请输入新出版时间:");scanf("%d",&p->time);getchar();printf("请输入新价格:");scanf("%f",&p->price);getchar();printf("修改成功!\n");getchar();break;case 0:break;default :printf("您的输入有误!\n");break;}printf("是否将修改后的信息保存到文件中?(y/n)\n");scanf("%c",&c);getchar();switch(c){case 'n':break;case 'y':fprint(head);printf("保存成功!\n");getchar();break;}}}//图书排序void paixu(struct book *head){int a;printf("================================================================\n");printf(" ** 1-按图书编号排序2-按出版时间排序**\n");printf(" ** 3-按图书价格排序4-按图书名排序**\n");printf(" ** 5-按作者名排序0-取消排序操作**\n");printf("================================================================\n");printf("请输入您选择的编号:");scanf("%d",&a);getchar();switch(a){case 0:break;case 1:num_paixu(head);break;case 2:time_paixu(head);break;case 3:price_paixu(head);break;case 4:bname_paixu(head);break;case 5:wname_paixu(head);break;default:printf("您的输入有误!\n");break;}}//按图书编号排序void num_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(a[i]->num<a[index]->num)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按出版时间排序void time_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(a[i]->time<a[index]->time)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按图书价格排序void price_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(a[i]->price<a[index]->price)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按图书名排序void bname_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(strcmp(a[index]->bname,a[i]->bname)>0)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}//按作者名排序void wname_paixu(struct book *head){struct book *a[1000],*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;p;p=p->next)n++;for(i=0;i<n;i++){a[i]=p1;p1=p1->next;}for(k=0;k<n-1;k++){index=k;for(i=k+1;i<n;i++){if(strcmp(a[index]->wname,a[i]->wname)>0)index=i;}temp=a[index];a[index]=a[k];a[k]=temp;}printf("排序成功!\n");printf("是否显示排序结果?(y/n)\n");scanf("%s",&b);getchar();switch(b){case 'n':break;case 'y':printf("====================================================================== ======\n");printf(" 编号图书名作者名出版社类别出版时间价格\n");for(i=0;i<n;i++){printf(" %3d %-12s %-8s %-14s %-2s %-4d %.2f\n",a[i]->n um,a[i]->bname,a[i]->wname,a[i]->press,a[i]->sort,a[i]->time,a[i]->price);}printf("====================================================================== ======\n");break;default:printf("您的输入有误!\n");break;}}。

C语言图书管理系统源代码

C语言图书管理系统源代码

#include<stdio。

h〉#include<stdlib.h〉#include〈string。

h〉struct tushu{ /*图书结构体*/ char num[10]; /*编号*/char name[20];/*书名*/char writer[20];/*作者*/char press[20];/*出版社*/char kind[20];/*类别*/double time; /*时间*/double price;/*价格*/struct tushu *next;};struct stu /*学生结构体*/ {int snum;/*学号*/char mima[10]; /*密码*/struct stu *next;};FILE *fp; /*图书文件*/FILE *fp1; /*管理员信息文件*/ FILE *fp2; /*学生信息文件*/void menu();/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/void xmenu();/*学生主菜单(学生进入可对图书,密码进行操作)*/void gfind(); /*管理员查询(管理员可按一定的方式查询图书)*/void xfind();/*学生查询(学生可按一定的方式查询图书)*/ void secret();/*管理员权限(管理员登陆所用,输入错误次数过多自动退出)*/void sort();/*排序(管理员可按一定的方式对图书进行排序,排序完之后可选择文件进行保存)*/void fprint(struct tushu *head);/*保存(可追加的保存,如添加可用)*/void fprint_(struct tushu *head);/*保存(可覆盖保存如修改,删除,排序后用)*/void hfprint(struct tushu *head); /*还书保存(还书成功后自动保存到文件)*/void jfprint_(struct tushu *head);/*借书保存(借书成功之后自动从图书馆删除)*/struct tushu * Input(); /*图书添加(可进行图书的添加)*/struct tushu *create(); /*从文件创建链表(从文件中读出信息,建立单链表)*/void gBrowse(struct tushu *head);/*管理员浏览(对图书进行遍历)*/void xBrowse(struct tushu *head);/*学生浏览(学生对图书进行遍历)*/void count(struct tushu *head); /*统计数量(管理员可对图书进行统计)*/void Findofname(struct tushu *head); /*按书名查找*/ void Findofwriter(struct tushu *head); /*按作者查找*/void Findofkind(struct tushu *head); /*按类别查找*/void xFindofname(struct tushu *head);/*学生按书名查找*/void xFindofwriter(struct tushu *head);/*学生按作者查找*/ void xFindofkind(struct tushu *head); /*学生按类别查找*/ void Sort_time(struct tushu * head); /*按时间排序(管理员按时间对图书进行排序,排序完之后可选择文件进行保存)*/ void Sort_price(struct tushu *head); /*按价格排序*/void Sort_num(struct tushu * head);/*按编号排序*/ void Delete(struct tushu * head,char m[15]);/*按编号删除(管理员可按编号删除图书)*/void Revise(struct tushu *head);/*修改(管理员可对图书进行修改,并选择是否保存)*/void borrow(struct tushu *head); /*借书*/void huanshu(); /*还书(学生借完书之后进行还书,若没有图书则不能借)*/void gxinxi(); /*管理员信息(有管理员的账号及密码,可进行修改)*/void xmima(struct stu *head1);/*学生密码修改(学生可对自己的密码进行修改)*/struct stu *xcreate();/*从文件创建学生信息(从文件读出学生信息,建立学生链表)*/void xsecret(struct stu *head1);/*学生权限(学生登陆所用)*/void menu() /*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/{int choice,n=0;struct tushu *head;struct stu *head1,*p;char m[15];there:printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf(" ┃┃socat 图书管理系统printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf(" ┃●[0]退出系统┃\n");printf(” ┃┃\n”);prin tf(” ┃●[1]帮助┃\n");printf(” ┃┃\n”);printf(” ┃●[2]浏览图书┃\n");printf(” ┃┃\n");printf(” ┃●[3]统计图书数目┃\n”);printf(" ┃┃\n”);printf(” ┃●[4]查询┃\n”);printf(” ┃printf(” ┃●[5]添加┃\n");printf(” ┃┃\n”);printf(” ┃●[6]排序┃\n");printf(” ┃┃\n");printf(" ┃●[7]修改┃\n”);printf(” ┃┃\n");printf(" ┃●[8]删除┃\n”);printf(" ┃┃\n”);printf(" ┃●[9]修改账号及密码┃\n");printf(” ┃┃\n”);printf(” ┃●[10]学生信息printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");printf(” 请选择:”);fflush(stdin);head=create();scanf("%d”,&choice);if(choice==1){//help();printf(”没有内容!\n”);system("pause”);system(”cls”);menu();}else if(choice==2){system(”cls");if(head==NULL){printf(”没有图书,请先添加图书!\n”);system("pause");system("cls");menu();}gBrowse(head);}else if(choice==3){system(”cls");count(head);}else if(choice==4){system("cls");if(head==NULL){printf(”没有图书,请先添加图书!\n”);system("pause”);system(”cls”);menu();}gfind();}else if(choice==5){Input();}else if(choice==6){system("cls");if(head==NULL){printf(”没有图书,请先添加图书!\n”); system("pause”);system(”cls”);menu();}sort(head);}else if(choice==7){system("cls”);if(head==NULL){printf(”没有图书,请先添加图书!\n”);system("pause");system("cls”);menu();}Revise(head);}else if(choice==8){if(head==NULL){printf("没有图书,请先添加图书!\n");system(”pause");system(”cls");menu();}printf(" 请输入想要删除的图书编号:”);scanf(”%s",m);Delete(head,m);}else if(choice==9){gxinxi();else if(choice==10){system(”cls”);head1=xcreate();if(head1==NULL){printf("没有学生信息,请到xuesheng_list.txt添加!\n”); sys tem(”pause”);system(”cls”);menu();}for(p=head1;p!=NULL;p=p—>next){printf(”学生学号密码\n”);printf("%d %s\n",p->snum,p—>mima);}system(”pause”);system("cls”);menu();}else if(choice==0)system(”cls");printf(”\n\n\n\n”);printf(” ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n”);exit(0);}else{system("cls");printf(”\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ");system("pause”);system(”cls”);n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n”);printf(" ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");system(”pause");exit(0);}goto there;}}void xmenu()/*学生主菜单(学生进入可对图书,密码进行操作)*/{struct tushu *head;struct stu *head1;int choice,n=0;there:printf(”┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");printf(” ┃┃socat 图书借阅系统┃┃\n");printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf(” ┃●[0]退出系统┃\n”);printf(” ┃printf(” ┃●[1]帮助┃\n”);printf(” ┃┃\n”);printf(” ┃●[2]浏览图书┃\n");printf(” ┃┃\n”);printf(" ┃●[3]查询┃\n”);printf(” ┃┃\n”);printf(” ┃●[4]借书┃\n");printf(” ┃┃\n”);printf(" ┃●[5]还书┃\n");printf(" ┃┃\n”);printf(” ┃●[6]修改密码printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n”); printf(" 请选择:");fflush(stdin);head=create();scanf("%d”,&choice);if(choice==1){//xhelp();printf(”没有内容!\n");system(”pa use");system(”cls”);xmenu();}else if(choice==2){system("cls");if(head==NULL){printf(”没有图书!\n");system("pause”);xmenu();}xBrowse(head);}else if(choice==3){if(head==NULL){printf(”没有图书!\n”);system(”pause”);system(”cls”);xmenu();}xfind();}else if(choice==4){if(head==NULL){printf(”没有图书!\n");system(”pause”);xmenu();}borrow(head);}else if(choice==5){huanshu(head);}else if(choice==6){system("cls”);head1=xcreate();if(head1==NULL){printf(”学生信息被清空!!\n”);system("pause");system("cls”);xmenu();}xmima(head1); ;}else if(choice==0){system("cls");printf(”\n\n\n\n”);printf(” ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n");exit(0);}else{system("cls”);printf("\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system(”pause”);system(”cls”);n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n”);printf(” ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n”);system("pause”);exit(0);}goto there;}}void gfind()/*管理员查询(管理员可按一定的方式查询图书)*/{int choice,n=0;struct tushu *head;there:system(”cls”);printf(” ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n”);printf(” ┃┃socat 图书借阅系统┃┃\n”);printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");printf(" ┃●[0]返回┃\n");printf(" ┃┃\n”);printf(" ┃●[1]按书名查找┃\n”);printf(" ┃┃\n”);printf(" ┃●[2]按作者查找┃\n”);printf(” ┃┃\n”);printf(" ┃●[3]按类别查找┃\n”);printf(" ┃┃\n”);printf(" ┃● ┃\n”);printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n”);printf(" 请选择:”);fflush(stdin);head=create();scanf(”%d”,&choice);if(choice==1){system(”cls");Findofname(head); }else if(choice==2){system(”cls”); Findofwriter(head); }else if(choice==3){system(”cls");Findofkind(head); }else if(choice==0){system(”cls”);menu();}else{system(”cls”);printf(”\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system("pause");system(”cls");n++;if(n==3){printf(" \n\n\n ━━━━━━━━你错误次数太多,自动退出! ━━━━━━━━\n\n\n”);printf(" ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n”);system(”pause”);exit(0);}goto there;}}void xfind()/*学生查询(学生可按一定的方式查询图书)*/ {struct tushu *head;int choice,n=0;there:system("cls”);printf(” ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n”);printf(” ┃┃socat 图书借阅系统┃┃\n”);printf(” ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");printf(” ┃●[0]返回┃\n”);printf(” ┃┃\n");printf(" ┃●[1]按书名查找┃\n”);printf(” ┃┃\n”);printf(" ┃●[2]按作者查找┃\n”);printf(" ┃┃\n");printf(” ┃●[3]按类别查找┃\n");printf(” ┃┃\n”);printf(" ┃● ┃\n");printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf(” 请选择:");fflush(stdin);head=create();scanf(”%d",&choice);if(choice==1){system(”cls”);xFindofname(head);}else if(choice==2){system(”cls”);xFindofwriter(head);}else if(choice==3){system("cls");xFindofkind(head);}else if(choice==0){system(”cls");xmenu();}else{system("cls");printf("\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system(”pause”);system(”cls");n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n”);printf(” ━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n”);system("pause”);exit(0);}goto there;}}void sort(){struct tushu *head;int choice,n=0;there:system("cls”);printf(” ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");printf(” ┃┃socat 图书借阅系统┃┃\n");printf(" ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n”);printf(" ┃●[0]返回┃\n”);printf(” ┃┃\n");printf(” ┃●[1]按时间排序┃\n”);printf(” ┃┃\n”);printf(” ┃●[2]按价格排序┃\n");printf(" ┃┃\n”);printf(” ┃●[3]按编号排序┃\n”);printf(" ┃┃\n”);printf(” ┃●┃\n”);printf(”┗━━━━━━━━━━━━━━━━━━━━━━━┛\n”);printf(" 请选择:”);fflush(stdin);head=create();scanf("%d",&choice);if(choice==1){system("cls”); Sort_time(head);}else if(choice==2){sys tem(”cls");Sort_price(head);}else if(choice==3){system(”cls”);Sort_num(head); }else if(choice==0){system("cls”); menu();}else{system(”cls");printf("\n\n\n\n ━━━━输入错误,请重新输入!━━━━\n\n\n ”);system(”pause”);system(”cls”);n++;if(n==3){printf(” \n\n\n ━━━━━━━━你错误次数太多,自动退出! ━━━━━━━━\n\n\n”);printf(” ━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n”);system("pause”);exit(0);}goto there;}}struct tushu *Input(){struct tushu *p1,*p2,*head,*ptr;char num;int x,i=0;system("cls”);p1=(struct tushu *)malloc(sizeof(struct tushu));head=p1;p1-〉price=—1;while(i!=1){printf(”请输入编号,以’#’结束\n”);scanf("%s",p1—>num);if(strcmp(p1-〉num,”#")==0)i=1;while(i!=1){printf(”请依次输入书名作者出版社类别出版时间价格\n”); scanf(”%s%s%s%s%lf%lf”,p1—>name,p1—>writer,p1—〉press,p1-〉kind,&p1-〉time,&p1—〉price);p2=p1;p1=(struct tushu *)malloc(sizeof(struct tushu));p2—〉next=p1;break;}}if(p1-〉price!=-1)p2—〉next=NULL;elsehead=NULL;system("cls”);printf("\n\n\n\t\t\t图书信息输入结束!\n\n\n”);system(”pause”);system(”cls”);printf(”\n\n\n\t\t\t是否保存图书信息?(1。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
printf("\n操作成功...\n");
printf("%s %s %.2lf %d %.2lf ",name[i],writter[i],yajin[i],free[i],jiage[i]);
flag[i]=1;
panding=1; //操作成功的提示
printf("已归还\n");
}
}
}
if(panding==0)
for(i=1;i<7;i++) //将原图书的各项值保存
{
free[i]=30;
jiage[i]=0.5;
}
flag[1]=0; //flag为0代表已借出,为1代表未借出
flag[2]=1;
flag[3]=1;
flag[4]=0;
flag[5]=1;
flag[6]=1;
printf("编号\t|书名\t |作者\t|押金\t|免费天数\t|收费价格\t|出租状态\n"); //制表同时输出
if(flag[i]==0)
{
printf("已借出\n"); //通过设置flag来判定是否被借出
}
else
{
printf("未借出\n");
}
}
}
void returnbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num])
returnbooks(score,name,writter,yajin,free,jiage,flag);
break;
case 3: //租借现有图书
jiebooks(score,name,writter,yajin,free,jiage,flag);
break;
case 0: //退出系统
printf("\n感谢您的使用!\n");exit(0);
{
int bianhao;
int panding=0; //设置一个值来判断该操作是否会成功
int i;
printf("\n请输入要归还图书的编号:");
scanf("%d",&bianhao);
for(i=1;i<7;i++)
{
if(score[i]==bianhao)
{
if(flag[i]==0) //库中存在该书且已经被借出
break;
default: printf("\n感谢您的使用!\n"); exit(0);
break;
}
}
return 0;
}
while(1) //每次选择后返回主菜单
{
showmain();
scanf("%d",&choose);
switch(choose)
{
case 1: //查询所有图书
viewbooks(score,name,writter,yajin,free,jiage,flag);
break;
case 2: //归还现有图书
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#define num 7 //全局定义
void showmain() //显示菜单
{
printf("\n\n欢迎使用图书借阅管理系统\n\n");
printf(" 1、查询所有图书\n\n");
{
int bianhao;
int panding=0; //设置一个值来判断该操作是否会成功
int i;
printf("\n请输入要租借图书的编号:");
scanf("%d",&bianhao);
for(i=1;i<7;i++)
{
if(score[i]==bianhao)
{
if(flag[i]==1) //库中存在该书且仍未被借出
printf("---------------------------------------------------------------------------\n");
for(i=1;i<7;i++)
{
printf("%d\t|%s\t|%s\t|%.2lf\t|%d\t|%.2lf\t|",score[i],name[i],writter[i],yajin[i],free[i],jiage[i]);
printf("\n操作失败!!!\n\n该图书已借出!\n");
}
int main()
{
int choose; //用户的选择
int score[7];
char name[7][100]={"0","C语言设计","Java程序设计","C#入门经典","Visual Basic","Linux标准教程","会计基础"}; //二维数组的初始化
printf(" 2、归还现有图书\n\n");
printf(" 3、租借现有图书\n\n");
printf(" 0、退出借书系统\n\n");
printf("请输入您所需的服务编号:");
}
void viewbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num])
{
int i;
int j;
for(i=1;i<7;i++) //设置编号
score[i]=i;
yajin[1]=26.00; //将原图书的各项值保存
yajin[2]=28.50;
yajin[3]=98.00;
yajin[4]=79.80;
yajin[5]=49.00;
yajin[6]=15.00;
char writter[7][100]={"0","谭浩强","王志文","karli Watson","Bryan Newsome","IT同路人","中国会计学会"}; //二维数组的初始化
double yajin[7];
int free[7];
double jiage[7];
int flag[7];
{
printf("\n操作成功...\n");
printf("%s %s %.2lf %d %.2lf ",name[i],writter[i],yajin[i],free[i],jiage[i]);
flag[i]=0;
panding=1; //操作成功的提示
printf("已借出\n");
}
}
}
if(panding==0)
printf("\n操作失败!!!\n\n该图书未借出!\nt score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num])
相关文档
最新文档