图书管理系统模板(附代码)

合集下载

图书馆管理系统源代码

图书馆管理系统源代码

源程序清单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)功能说明:整个系统的主界面,其中包括图书管理、读者管理、图书借阅管理、系统管理、关于,以及在这下面的子菜单。

图书馆管理系统完整代码

图书馆管理系统完整代码
out.println("<h3>"+warning3+"</h3>"); String login=request.getParameter("login"); if(login!=null)
out.println("<h3>"+login+"</h3>"); %> </div></body> </html>
logon.jsp <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 "/TR/html4/loose.dtd"> <html> <script language="JavaScript">
{ alert("请输入有效电话!"); return false;
} } var em,index; em=myform.email.value; index=myform.email.value.indexOf('@'); if(index<=0||index>=em.length-1) {
alert("请输入合法的电子邮件地址!"); return false; } } </script> <head> <title>用户注册</title> </head> <body><div align="center"><h2> 用户注册 </h2> <%!String sex=null; %> <form action="dealLogon.jsp" method="post" onSubmit="return check()" name="myform"> <table height="100%" border="1" align="center" width="90%"> <tbody><tr> <td align="right">用户名:<br></td> <td align="left"><input type="text" name="username"></td></tr> <tr> <td align="right">真实姓名:<br></td> <td align="left"><input type="text" name="truename"></td></tr> <tr> <td align="right">密码:</td> <td align="left"><input type="password" name="password"></td></tr> <tr> <td align="right">确认密码:</td> <td align="left"><input type="password" name="confirmPassword"></td></tr> <tr> <td align="right">年龄: </td> <td align="left"><input type="text" name="age"></td></tr> <tr> <td align="right">性别:</td> <td align="left"><input type="radio" name="sex" value="男" <%if(sex.equals("男")) out.println("checked");%>> <img src="Images/boy.gif" width="24" height="24">男

(完整word版)图书管理系统源代码

(完整word版)图书管理系统源代码

图书管理系统源代码(一)程序代码1。

主窗口界面import java.awt。

*;import java.awt。

event.*;import javax。

swing.*;import javax.swing.border.TitledBorder;import java.awt。

Font;import javax.swing。

JMenu;public class MainWindow extends JFrame implements ActionListener { private static final long serialVersionUID = 1L;static String loginName;static String loginNo;JLabel mlabel;JPanel jp=new JPanel();//建立菜单栏JMenu a=new JMenu();JMenu b=new JMenu();JMenu c=new JMenu();//建立系统管理菜单组JMenuItem aa=new JMenuItem();JMenuItem ab=new JMenuItem();JMenuItem ac=new JMenuItem();//建立读者管理菜单组JMenuItem bb=new JMenuItem();//建立书籍管理菜单组JMenuItem ca=new JMenuItem();JMenuItem cb=new JMenuItem();JMenuItem cc=new JMenuItem();JMenuItem cd=new JMenuItem();public MainWindow(){super(”图书管理系统");addWindowListener(new WindowAdapter(){System.exit(0);}});Container d=getContentPane();this。

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

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

图书信息管理系统课程设计:图书信息管理系统设计人员:林俊柱开发环境: 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);。

图书信息管理系统设计源代码

图书信息管理系统设计源代码

头函数名:#include<stdio.h>#include<stdlib.h>#include<string.h>/*********图书信息结构体*********//***包括登录号,书名,作者名,分类号,出版单位,出版时间,价格等***/ struct bookinf{ int num; ******************************************************登录号char bname[20];***************************************书名char wname[10];***************************************作者名char clanum[14];***************************************分类号char pubcom[10];***************************************出版单位char pubtime[10];***************************************出版时间float price;*********************************************价格};一管理员登录系统模块:(1)来到图书信息管理系统页面void index(){char input; 注释:运行时printf("\n\n\t\t\t*****************************\n"); 直接进入printf("\t\t\t 图书信息管理系统\n"); 这个页面printf("\t\t\t*****************************\n\n\n");printf(" ------------------------------------------------------------------------------\n");printf("\t<按任意键进入>\n\t");input=getchar();}(2)管理员登陆进入功能菜单页面FILE *fp;struct manage pswd;if ((fp=fopen("password.txt","r"))==NULL) {printf("\n\n\n\tCannot open file!\n\t");}else{do{printf("\n\n\t请输入管理员帐号:");scanf("%s",name);printf("\n\n\t请输入管理员密码:");scanf("%s",password);fp=fopen("password.txt","r");fread(&pswd,sizeof(struct manage),1,fp);fclose(fp);w=strcmp(pswd.manage_name,name);k=strcmp(pswd.password,password);adm_servelist();}while (w!=0||k!=0);adm_servelist();}}(3)来到功能菜单页面{void book_add();void book_view();void change();void del();void book_search();void login();void pwchange();int in; 注释:菜单列出的服务种类char input; 从1,2,3,4,5,6 do 所对应的功能进行选择{printf("\n\n\n\t--欢迎使用信息管理系统--");printf("\n\n\t1.图书信息录入\n");printf("\t2.图书信息浏览\n");printf("\t3.图书信息查询\n");printf("\t4.图书信息删除\n");printf("\t5.图书信息修改\n");printf("\t6.退出管理模式\n");printf("\n\t请选择服务种类:");scanf("%d",&in);if (in!=1&&in!=2&&in!=3&&in!=4&&in!=5&&in!=6){printf("\n\t没有这项服务~\n");printf("\t按任意键重新选择");input=getchar();}}while (in!=1&&in!=2&&in!=3&&in!=4&&in!=5&&in!=6);switch (in){case 1: book_add(); break; 注释:选择自己所需要case 2: book_view(); break; 后摁下数字键则case 3: book_search(); break; 则进入此功能页面case 4: del(); break;case 5: change();break;case 6: login(); break;}}(3)图书信息录入功能模块void book_add(){void book_add();int i=0,j;FILE *fp;char input; 注释:输入的图书信息struct bookinf books; 是通过文件进行struct bookinf book_taxis[30]; 保存的printf("\n\n\n\t---请输入图书信息---\n\n");printf("\t登录号:");scanf("%d",&books.num);printf("\n\t书名:");scanf("%s",books.bname);printf("\n\t作者名:");scanf("%s",books.wname);printf("\n\t分类号:");scanf("%s",books.clanum);printf("\n\t出版单位:");scanf("%s",books.pubcom);printf("\n\t出版时间:");scanf("%s",books.pubtime);printf("\n\t价格:");scanf("%f",&books.price);if ((fp=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp);i=i+1;}while(!feof(fp));fclose(fp);for (j=0;j<=i;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("\t按任意键返回管理菜单~");input=getchar();adm_servelist();break;}}if ((fp=fopen("book.txt","r"))==NULL){fp=fopen("book.txt","w");}else{fclose(fp);fp=fopen("book.txt","a");}fwrite(&books,sizeof(struct bookinf),1,fp);fclose(fp);printf("\n\n\n\t信息输入完毕~按任意键继续\n");input=getchar();adm_servelist();}(4)图书信息浏览功能模块void book_view(){void adm_servelist();void book_view();int inp,i=0,n=0;FILE *fp;char input;struct bookinf bookview[20];if ((fp=fopen("book.txt","r"))==NULL){printf("\n\n\n\t数据尚未初始化~~\n\n\t请在管理菜单中增加图书信息~~~\n"); printf("\n\t<按任意键返回管理菜单>\n\t");input=getchar();adm_servelist();}else{do{fread(&bookview[i],sizeof(struct bookinf),1,fp);i=i+1;}while (!feof(fp));fclose(fp);do{printf("\n\t--------共有%d条记录--------",i-1);printf("\n\n\t登录号: %d\n",bookview[n].num);printf("\n\t书名: %s\n",bookview[n].bname);printf("\n\t作者名: %s\n",bookview[n].wname);printf("\n\t分类号: %s\n",bookview[n].clanum);printf("\n\t出版单位: %s\n",bookview[n].pubcom);printf("\n\t出版时间: %s\n",bookview[n].pubtime);printf("\n\t价格: %f\n",bookview[n].price);printf("\n\n\t1.上一页\t2.下一页\t3.回目录\n");printf("\n\t请选择:");scanf("%d",&inp);switch (inp){case 1:{if (n==0){printf("\n\t已到达首页\n\t按任意键重新选择");input=getchar();}else n=n-1; break;}case 2:{if (n==i-2){printf("\n\t已到达最末页\n\t按任意键重新选择");input=getchar();}else n=n+1; break;}case 3:{adm_servelist();break;}default:{printf("\n\t没有这项服务\n\t按任意键重新选择");input=getchar();}}}while (inp!=3);}}(5)图书信息修改与删除功能模块修改:void change(int x){int inp,i=0,j;void book_search();FILE *fp,*fp1;char input;struct bookinf books,book_taxis[20];do{printf("\n\n\n\t注意:您确定要修改该记录吗?\n"); printf("\n\t1.是\t2.否\n");printf("\n\t请输入:");scanf("%d",&inp);if (inp!=1&&inp!=2){printf("\n\t对不起~没有这项服务~\n");printf("\t按任意键重新选择\n\t");input=getchar();}}while (inp!=1&&inp!=2);if (inp==2)book_search();if (inp==1){printf("\n\n\n\t---请输入图书信息---\n\n");printf("\t登录号:");scanf("%d",&books.num);printf("\n\t书名:");scanf("%s",books.bname);printf("\n\t作者名:");scanf("%s",books.wname);printf("\n\t分类号:");scanf("%s",books.clanum);printf("\n\t出版单位:");scanf("%s",books.pubcom);printf("\n\t出版时间:");scanf("%s",books.pubtime);printf("\n\t价格:");scanf("%f",&books.price);if ((fp1=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp1);i=i+1;}while(!feof(fp1));fclose(fp1);for (j=0;j<x;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("\t按任意键返回管理菜单~");printf("0");input=getchar();book_search();break;}for (j=x+1;j<i-2;j++)if (books.num==book_taxis[j].num){printf("\n\n\n\t对不起,这个编号已经使用过了~\n");printf("1");printf("\t按任意键返回管理菜单~");input=getchar();book_search();break;}}book_taxis[x]=books;fp=fopen("book.txt","w");for (j=0;j<i-1;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);printf("\n\n\t信息修改完成!按任意键返回");input=getchar();book_search();}}S删除:void del(int y){char input;FILE *fp;int inp,i=0,j;struct bookinf book_taxis[20];void book_search();void adm_servelist();do{printf("\n\n\n\t注意:您确定要删除该记录吗?\n"); printf("\n\t1.是\t2.否\n");printf("\n\t请输入:");scanf("%d",&inp);if (inp!=1&&inp!=2){printf("\n\t对不起~没有这项服务~\n");printf("\t按任意键重新选择\n\t");input=getchar();}}while (inp!=1&&inp!=2);if (inp==2)book_search();if (inp==1){if ((fp=fopen("book.txt","r"))!=NULL){do{fread(&book_taxis[i],sizeof(struct bookinf),1,fp);i=i+1;}while(!feof(fp));fclose(fp);}if (i>2){fp=fopen("book.txt","w");for (j=0;j<y;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);fp=fopen("book.txt","a");for (j=y+1;j<i-1;j++)fwrite(&book_taxis[j],sizeof(struct bookinf),1,fp);fclose(fp);}else{remove("book.txt");}printf("\n\n\t记录已删除!\n\n\t按任意键返回\n\t");input=getchar();adm_servelist();}}(6)图书信息查询功能模块void book_search(){void adm_servelist();void id_search();void wr_search();void bn_search();char input;FILE *fp;int inp;if ((fp=fopen("book.txt","r"))==NULL){printf("\n\n\n\t数据尚未初始化~~\n\n\t请在管理菜单中增加图书信息~~~\n"); printf("\n\t<按任意键返回管理菜单>\n\t");input=getchar();adm_servelist();}else{do{printf("\n\n\n\t1.按图书登录号查询\n");printf("\n\t2.按图书作者查询\n");printf("\n\t3.按图书名查询\n");printf("\n\t4.回到主菜单\n");printf("\n\n\t请选择查询类别:");scanf("%d",&inp);if (inp!=1&&inp!=2&&inp!=3&&inp!=4){printf("\n\n\t没有这项服务~\n\t按任意键重新选择~");input=getchar();}}while (inp!=1&&inp!=2&&inp!=3&&inp!=4);fclose(fp);switch (inp){case 1: id_search(); break;case 2: wr_search(); break;case 3: bn_search(); break;case 4: adm_servelist(); break;}}}。

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

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

图书借阅管理系统代码图书管理系统源代码#include#include#include#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|%.2lf\t|%d\t|%.2lf\t|",score[i],name[i], writter[i],yajin[i],free[i],jiage[i]);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])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) //库中存在该书且已经被借出{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)printf("\n 操作失败\n\n 该图书未借出!\n");}void jiebooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num]){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 操作成功...\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 该图书已借出!\n");}int main(){int choose; //用户的选择int score[7];char name[7][100]={"0","C语言设计","Java程序设计","C#入门经典","Visual Basic","Linux 标准教程","会计基础"}; //二维数组的初始化char writter[7][100]={"0","谭浩强","王志文","karli Watson","Bryan Newsome","IT 同路人","中国会计学会"}; //二维数组的初始化double yajin[7];int free[7];double jiage[7];int flag[7];while(1) //每次选择后返回主菜单{showmain();scanf("%d",&choose);switch(choose){case 1: //查询所有图书viewbooks(score,name,writter,yajin,free,jiage,flag);break;case 2: //归还现有图书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);break;default: printf("\n 感谢您的使用!\n"); exit(0);break;}}return 0;}。

图书馆管理系统代码

图书馆管理系统代码

图书馆管理系统代码。

txt男人偷腥时的智商仅次于爱因斯坦。

美丽让男人停下,智慧让男人留下.任何东西都不能以健康做交换.#include<stdio.h〉#include<math。

h〉#include<string。

h>#include<stdlib.h>struct books_list{char author[20]; /*作者名*/char bookname[20]; /*书名*/char publisher[20]; /*出版单位*/char pbtime[15]; /*出版时间*/char loginnum[10]; /*登陆号*/float price; /*价格*/char classfy[10]; /*分类号*/struct books_list * next; /*链表的指针域*/};struct books_list * Create_Books_Doc(); /*新建链表*/void InsertDoc(struct books_list * head); /*插入*/void DeleteDoc(struct books_list * head , int num);/*删除*/void Print_Book_Doc(struct books_list * head);/*浏览*/void search_book(struct books_list * head); /*查询*/void info_change(struct books_list * head);/*修改*/void save(struct books_list * head);/*保存数据至文件*//*新建链表头节点*/struct books_list * Create_Books_Doc(){struct books_list * head;head=(struct books_list *)malloc(sizeof(struct books_list)); /*分配头节点空间*/head—>next=NULL; /*头节点指针域初始化,定为空*/return head;}/*保存数据至文件*/void save(struct books_list * head){struct books_list *p;FILE *fp;p=head;fp=fopen("data.txt","w+"); /*以写方式新建并打开 data。

图书管理系统程序代码

图书管理系统程序代码

#include<fstream〉#include<iostream〉#include<stdlib.h〉#include〈ctime〉#include<cmath>#include〈termios.h〉#include <sstream〉#include<string。

h〉#include<assert.h〉//改变字体颜色#define NONE "\033[m"#define RED "\033[0;32;31m”#define GREEN ”\033[0;32;32m”#define BLUE "\033[0;32;34m”#define YELLOW ”\033[1;33m”#define LIGHT_RED ”\033[1;31m”#define LIGHT_GREEN "\033[1;32m"#define LIGHT_BLUE "\033[1;34m”/*程序导读:1。

程序中对书的操作,可通过书名,编号来进行,flag=0按书名来操作,flag=1按书编号来操作2.程序中对用户的操作,也可通过姓名,用户ID号或编号两种方式来进行,flag=0按姓名来操作,flag=1按用户ID号或编号来操作3。

本程序分5个部分,具体已标识如(1)图书管理。

.*/using namespace std;class Book{public:string book_name;string book_num;//编号string book_pre;//出版社string book_aut;//作者int book_con;//这样的书还有几本int book_mux;//这样的书总共有几本public:Book(){book_con=0;book_mux=0;}void show_book();};/****************************************(1)图书管理*******************************************/void Book::show_book(){cout<〈"书名:”<〈book_name<〈endl;cout〈〈”出版社:"〈<book_pre〈〈endl;cout<<”此书的作者:"〈<book_aut〈<endl;cout〈<”ISBN编号:”<〈book_num<〈endl;cout<<"此书共有"〈<book_mux<<”本”〈〈endl;cout<<”还有"<<book_con〈〈”本书未借出!"〈<endl;}class BookNode{public:Book book;BookNode *next;};BookNode *headbook=NULL;class BookManage{public:int totolbook;public:BookManage(){totolbook=0;}void addbook();void delbook(string s,int num,int flag);void findbook(string s,int flag);//查询图书};void BookManage::addbook(){string h;cout〈〈"添加输入0,退出输入—1"<〈endl;cin>>h;if(h==”-1”)return;else if(h=="0”)while(1){if(h==”-1”)break;else if(h==”0”){string na,nu,p1,aut;int con;BookNode *p=new BookNode;cout<<”请输入书名:"〈〈endl;cin〉>na;p—〉book.book_name=na;cout<〈"请输入ISBN编号:”<<endl;cin>〉nu;p->book。

图书馆管理系统设计附带源代码

图书馆管理系统设计附带源代码

毕业设计_图书管理系统一、数据库设计数据库设CREATE DATABASE TSGLGOUSE TSGLGOCREATE TABLE Bmanage(bId varchar(10) PRIMARY KEY,bName varchar(50), --添加图书--图书编号--书名bNumber varchar(10), --书数目)GObSore varchar(50) --分类CREATE TABLE Madmin(mName varchar(10)PRIMARY KEY,mPwd varchar(25),mAge varchar(8),mSex varchar(4),mNumber varchar(15),mrole varchar(8))GO--图书员管理--图书管理员姓名--图书管理员密码--图书管理员年龄--图书管理员性别--图书管理员电话--图书管理员角色CREATE TABLE Reader (rSno varchar (10) PRIMARY KEY , rName varchar (10), rPwd varchar (25), rAge varchar (8), rSex varchar (4), rState varchar (8), rNumber varchar (15), rEmail varchar (25),--读者信息表reader--读者号 --姓名 --密码 --年龄 --性别--状态 --电话号码--电子邮件 rAdressvarChar (50),--地址) GOrGrade varChar (15),rClass varchar (15),rRole varchar (8)--年级 --班级 --角色CREATE TABLE Rrecord (rSno varchar (10) PRIMARY KEY , rName varChar (10), bId varchar (10), bName varChar (50), bTime varchar (10), bBackTime varchar (10) ) GOCREATE TABLE SysSet (rRole varchar (8)PRIMARY KEY , rState varchar (8), Fine float (25), rDay varchar (8)--读者编号学号 --读者姓名 --图书编号--图书名称 --借书时间 --还书时间--读者角色 --读者可借书数 --过期罚款设置 --可借书天数)二、界面截图及说明1) 登录窗口(实现管理员和馆长的登陆)2) 管理员窗口3) 馆长窗口4) 关于窗口5) 新增图书窗口6) 新增管理员、查找及修改窗口7) 新增读者、查找及修改窗口8) 图书的查找及修改窗口9) 借阅窗口10)系统设置窗口三、主要代码主要代1) 登录窗口(实现管理员和馆长的登陆)登陆检查:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.ClassLib.Logic{class clsLoginCheck{public static DataTable CheckLogin(string UserId, string PWD){{string SQLstmt = "select mName,mPwd,mRole from Madmin where mName= '" + UserId + "'and mPwd= '" + PWD + "'";DataTable dt = clsGlobalVar.GetDataTable(SQLstmt);return dt;}}}}登陆:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.Logic;namespace prjTSGL.TSGL_UI{public partial class frmLogin : Form{public frmLogin(){InitializeComponent();}private void btnLogin_Click(object sender, EventArgs e){string strUserID = loginid.Text.Trim();string strPWD = loginpwd.Text.Trim();string type = "";try{DataTable dt = clsLoginCheck.CheckLogin(strUserID, strPWD);if (dt.Rows.Count == 0){MessageBox.Show("登陆失败,请重新输入!");loginpwd.Focus();return;}else{type = dt.Rows[0]["mRole"].ToString().Trim();if (cboLT.Text.Trim()=="馆长" ){if (type == "馆长"){this.Hide();frmManager objManager = new frmManager();objManager.Show();}else{MessageBox.Show("您没有权限!");loginpwd.Focus();return;}}else{if (type =="管理员"){this.Hide();frmAdmin objAdmin = new frmAdmin();objAdmin.Show();}else{MessageBox.Show("您没有权限!");loginpwd.Focus();return;}}}}catch (Exception ex){throw ex;}}private void btnExit_Click(object sender, EventArgs e){this.Close();}}}2) 管理员窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace prjTSGL.TSGL_UI{public partial class frmAdmin : Form{public frmAdmin(){InitializeComponent();}private void ShowForm(Form frmToShow){this.Cursor = Cursors.WaitCursor;foreach (Form frmChild in this.MdiChildren){if (frmChild.GetType() == frmToShow.GetType()){frmToShow.Dispose();frmChild.Activate();this.Cursor = Cursors.Default;return;}}frmToShow.MdiParent = this;frmToShow.Show();this.Cursor = Cursors.Default;}private void读者信息修改ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmUpdateReader());}private void新增图书ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAddNewBook());}private void图书的查找和修改ToolStripMenuItem_Click(object sender, EventArgs e) {ShowForm(new f rmUpdateBook());}private void流通管理ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmBorrow());}private void帮助ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAbout());}private void退出ToolStripMenuItem_Click(object sender, EventArgs e){Application.Exit();}}}3) 馆长窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace prjTSGL.TSGL_UI{public partial class frmManager : Form{public frmManager(){InitializeComponent();}private void ShowForm(Form frmToShow){this.Cursor = Cursors.WaitCursor;foreach (Form frmChild in this.MdiChildren){if (frmChild.GetType() == frmToShow.GetType()){frmToShow.Dispose();frmChild.Activate();this.Cursor = Cursors.Default;return;}}frmToShow.MdiParent = this;frmToShow.Show();this.Cursor = Cursors.Default;}private void frmManager_FormClosed(object sender, FormClosedEventArgs e){Application.Exit();}private void管理员信息管理ToolStripMenuItem_Click_1(object sender, EventArgs e) {ShowForm(new f rmSelectAdmin());}private void系统设置ToolStripMenuItem_Click_1(object sender, EventArgs e){ShowForm(new f rmSys());}private void关于ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAbout());}private void退出ToolStripMenuItem_Click_1(object sender, EventArgs e){Application.Exit();}}}4) 关于窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace prjTSGL.TSGL_UI{public partial class frmAbout : Form{public frmAbout(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){this.Close();}}}5) 新增图书窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{public partial class frmAddNewBook : Form{public frmAddNewBook(){InitializeComponent();}private bool ValidatInput(){if (textBox1.Text == ""){MessageBox.Show("请输入图书编号!", "输入提示", MessageBoxButtons.OK, rmation);textBox1.Focus();return false;}if (textBox2.Text == ""){MessageBox.Show("请输入图书名称!", "输入提示", MessageBoxButtons.OK, rmation);textBox2.Focus();return false;}if (textBox3.Text == ""){MessageBox.Show("请输入图书数目!", "输入提示", MessageBoxButtons.OK,rmation);textBox3.Focus();return false;}if (comboBox1.Text == ""){MessageBox.Show("请选择图书类别!", "输入提示", MessageBoxButtons.OK, rmation);textBox3.Focus();return false;}return true;}private void btnOK_Click_1(object sender, EventArgs e){if (ValidatInput()){//string id = textBox1.Text;//string name = textBox2.Text;//string Number = textBox3.Text;//string sore = comboBox1.Text;string sql = "SELECT *FROM Bmanage WHERE bId='" + textBox1.Text.Trim() + " '";DataTable dt = clsGlobalVar.GetDataTable(sql);if (dt.Rows.Count == 0){string SQL = "insert into Bmanage(bId,bName,bNumber,bSore)values('" + textBox1.Text.Trim() + " ','" + textBox2.Text.Trim() + " ','" + textBox3.Text.Trim() + " ','"+ comboBox1.Text.Trim() + " ')";try{bool result = clsGlobalVar.ExecSQL(SQL);if (result){MessageBox.Show("添加成功!", "操作提示", MessageBoxButtons.OK, rmation);textBox1.Text = "";textBox2.Text = "";textBox3.Text = "";comboBox1.Text = "";textBox1.Focus();}else{MessageBox.Show("添加失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch (Exception ex){MessageBox.Show("操作数据库出错!", "操作演示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}else{MessageBox.Show("图书编号已存在!", "操作提示", MessageBoxButtons.OK, rmation);textBox1.Focus();}}}private void btnCancel_Click(object sender, EventArgs e){this.Close();}}}6) 新增管理员、查找及修改窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{public partial class frmSelectAdmin : Form{public frmSelectAdmin(){InitializeComponent();}string name = "";string SQL = "";string PWD = "";string Age = "";string Sex = "";string Tel = "";string Role = "";private void SelectAdmin(){string strfilter = "";string SQL = "select mName AS 用户名,mPwd AS 密码,mAge AS 年龄,mSex AS 性别,mNumber AS 电话,mRole AS 角色from Madmin ";if (txtName.Text == "")strfilter = "";elsestrfilter = "where mName='" + txtName.Text.Trim() + "'";try{DataTable dt = clsGlobalVar.GetDataTable(SQL + strfilter);int intIndex = 0;if (dt.Rows.Count == 0){MessageBox.Show("抱歉,没有您要找的用户!", "结果提示", MessageBoxButtons.OK, rmation);txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";}else{{LV.Columns.Clear();LV.Items.Clear();LV.Columns.Add("序号", 100, HorizontalAlignment.Center);for (int intJ = 0; intJ < dt.Columns.Count; intJ++){LV.Columns.Add(dt.Columns[intJ].ColumnName, 200, HorizontalAlignment.Center);}for (int intI = 0; intI < dt.Rows.Count; intI++){intIndex = intI + 1;LV.Items.Add(intIndex.ToString());LV.Items[intI].SubItems.Add(dt.Rows[intI]["用户名"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["密码"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["年龄"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["性别"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["电话"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["角色"].ToString().Trim());}}}}//连接数据库,将数据读取出放入MadminDatacatch (Exception ex){MessageBox.Show("查询数据库出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}private void btnSearch_Click(object sender, EventArgs e){SelectAdmin();//调用函数}//实现修改功能private void btnUpdata_Click(object sender, EventArgs e){if (txtName.Text == "" || cboRole.Text==""){MessageBox.Show("请选择要修改的用户!");}else{SQL = "UPDATE Madmin SET mName='" + txtName.Text.Trim() + "',mPwd='" + txtPWD.Text.Trim() + "',mAge='" + txtAge.Text.Trim() + "',mSex='" + cboSex.Text.Trim() +"',mNumber='" + txtTel.Text.Trim() + "',mRole='" + cboRole.Text.Trim() + "' where mName='" + name+ "'AND mPwd='" + PWD + "'AND mAge='" + Age + "'AND mSex='" + Sex + "'AND mNumber='" + Tel + "'AND mRole='" + Role + "'";try{bool result = clsGlobalVar.ExecSQL(SQL);if (result){//txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";MessageBox.Show("修改已成功");SelectAdmin();}else{MessageBox.Show("更新失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch (Exception ex){MessageBox.Show("操作数据库出错!", "操作演示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}}private void btnExit_Click(object sender, EventArgs e){this.Close();}private void LV_SelectedIndexChanged_1(object sender, EventArgs e){txtName.Text = LV.FocusedItem.SubItems[1].Text.Trim();txtPWD.Text = LV.FocusedItem.SubItems[2].Text.Trim();txtAge.Text = LV.FocusedItem.SubItems[3].Text.Trim();cboSex.Text = LV.FocusedItem.SubItems[4].Text.Trim();txtTel.Text = LV.FocusedItem.SubItems[5].Text.Trim();cboRole.Text = LV.FocusedItem.SubItems[6].Text.Trim();name = LV.FocusedItem.SubItems[1].Text.Trim();PWD = LV.FocusedItem.SubItems[2].Text.Trim();Age = LV.FocusedItem.SubItems[3].Text.Trim();Sex = LV.FocusedItem.SubItems[4].Text.Trim();Tel = LV.FocusedItem.SubItems[5].Text.Trim();Role = LV.FocusedItem.SubItems[6].Text.Trim();}private void frmSelectAdmin_Load(object sender, EventArgs e){this.btnSearch_Click(sender, e);}private void btnAdd_Click(object sender, EventArgs e){if (txtName.Text == "" || txtPWD.Text == "" || txtAge.Text == "" ||cboSex.Text =="" || txtTel.Text=="" ||cboRole.Text == ""){MessageBox.Show("请至少输入用户名,密码和角色!");}else{SQL = "SELECT mName,mPwd,mAge ,mSex,mNumber,mRole from Madmin WHERE mName='" + txtName.Text.Trim() + "' ";DataTable dt = clsGlobalVar.GetDataTable(SQL);if (dt.Rows.Count == 0){SQL = "INSERT INTO Madmin VALUES ('" + txtName.Text.Trim() + "','" +txtPWD.Text.Trim() + "','" + txtAge.Text.Trim() + "','" + cboSex.Text.Trim() + "','" +txtTel.Text.Trim() + "','" + cboRole.Text.Trim() + "')";if (clsGlobalVar.ExecSQL(SQL) == true){//txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";MessageBox.Show("成功添加新管理员!");SelectAdmin();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}else{MessageBox.Show("用户名已存在,请选择其他用户名!", "结果提示", MessageBoxButtons.OK, rmation);txtName.Text = "";}}}private void btnDelete_Click(object sender, EventArgs e){if (txtName.Text == "" || cboRole.Text == ""){MessageBox.Show("请选择要删除的管理员用户!");}else{DialogResult dr = MessageBox.Show("此操作不可撤销,确定要删除此用户信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);if (dr == DialogResult.Yes){SQL = "DELETE FROM Madmin WHERE mName='" + name + "'AND mPwd='" + PWD + "'ANDmAge='" + Age + "'AND mSex='" + Sex + "'AND mNumber='" + Tel + "'AND mRole='" + Role + "'";if (clsGlobalVar.ExecSQL(SQL) == true){MessageBox.Show("成功删除此管理信息!");SelectAdmin();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}}}private void btnReset_Click(object sender, EventArgs e){txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";}}}7) 新增读者、查找及修改窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{public partial class frmUpdateReader : Form{public frmUpdateReader(){InitializeComponent();}string Sno = "";string Pwd = "";string Age = "";string name = "";string Sex = "";string State = "";string Adress = "";string Number = "";string Email = "";string Grade = "";string Class = "";string Role = "";//查找学生读者private void SelectStudent(){string strfilter = "";string SQL = "select rSno AS 读者编号,rName AS 读者姓名,rPwd AS 密码,rAge AS 年龄,rSex AS 性别,rState AS 借书状态,rAdress AS 地址,rNumber AS 电话,rEmail AS 邮箱,rGrade AS 年级,rClass AS 班级,rRole AS 角色from Reader ";if (txtReaderName.Text == "")strfilter = "";elsestrfilter = "where rName='" + txtReaderName.Text.Trim() + "'";try{DataTable dt = clsGlobalVar.GetDataTable(SQL + strfilter);int intIndex = 0;if (dt.Rows.Count==0){MessageBox.Show("抱歉,没有您要找的读者信息!", "结果提示", MessageBoxButtons.OK, rmation);}else{LV.Columns.Clear();LV.Items.Clear();LV.Columns.Add("序号", 100, HorizontalAlignment.Center);for (int intJ = 0; intJ < dt.Columns.Count; intJ++){LV.Columns.Add(dt.Columns[intJ].ColumnName, 200, HorizontalAlignment.Center);}for (int intI = 0; intI < dt.Rows.Count; intI++){intIndex = intI + 1;LV.Items.Add(intIndex.ToString());for (int j=1; j < dt.Columns.Count; j++){LV.Items[intI].SubItems.Add(dt.Rows[intI][j].ToString());}//LV.Items[intI].SubItems.Add(dt.Rows[intI]["读者编号"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["读者姓名"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["密码"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["年龄"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["性别"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["借书状态"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["地址"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["电话"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["邮箱"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["年级"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["班级"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["角色"].ToString());}}}catch (Exception ex){MessageBox.Show("查询数据库出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}//实现查找功能private void btnSearch_Click(object sender, EventArgs e){SelectStudent();}//实现修改功能private void btnUpdata_Click(object sender, EventArgs e){if (textBox2.Text == ""){MessageBox.Show("请选择要修改的用户!");}else//string sql = "SELECT * from Reader WHERE rSno='" + textBox2.Text.Trim() + "' ";//DataTable dt = clsGlobalVar.GetDataTable(sql);//if (dt.Rows.Count == 0)//{{string SQL = "UPDATE Reader SET rSno='" + textBox2.Text.Trim() + "',rPwd='" + textBox3.Text.Trim() + "',rAge='" + textBox1.Text.Trim() + "',rName='" +txtReaderName.Text.Trim() + "',rSex='" + cboSex.Text.Trim() + "',rState='" + textBox4.Text.Trim()+ "',rAdress='" + textBox5.Text.Trim() + "',rNumber='" + textBox6.Text.Trim() + "',rEmail='" + textBox7.Text.Trim() + "',rGrade='" + textBox8.Text.Trim() + "',rClass='" + textBox9.Text.Trim()+ "' ,rRole='" + cboRole.Text.Trim() + "'";string strfilter = "where rSno='" + Sno + "'";try{bool result = clsGlobalVar.ExecSQL(SQL + strfilter);if (result){textBox2.Text = "";textBox3.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";MessageBox.Show("修改已成功");SelectStudent();}else{MessageBox.Show("读者信息不存在!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch (Exception ex){MessageBox.Show("操作数据库出错!", "操作演示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}//}//else//{// MessageBox.Show("用户名已存在,请选择其他用户名!", "结果提示", MessageBoxButtons.OK, rmation);// textBox2.Text = "";//}}private void btnExit_Click(object sender, EventArgs e){this.Close();}private void LV_SelectedIndexChanged(object sender, EventArgs e) {textBox2.Text = LV.FocusedItem.SubItems[1].Text.Trim();txtReaderName.Text = LV.FocusedItem.SubItems[2].Text.Trim();textBox3.Text = LV.FocusedItem.SubItems[3].Text.Trim();textBox1.Text = LV.FocusedItem.SubItems[4].Text.Trim();cboSex.Text = LV.FocusedItem.SubItems[5].Text.Trim();textBox4.Text = LV.FocusedItem.SubItems[6].Text.Trim();textBox5.Text = LV.FocusedItem.SubItems[7].Text.Trim();textBox6.Text = LV.FocusedItem.SubItems[8].Text.Trim();textBox7.Text = LV.FocusedItem.SubItems[9].Text.Trim();textBox8.Text = LV.FocusedItem.SubItems[10].Text.Trim();textBox9.Text = LV.FocusedItem.SubItems[11].Text.Trim();cboRole.Text = LV.FocusedItem.SubItems[12].Text.Trim();Sno = LV.FocusedItem.SubItems[1].Text.Trim();name = LV.FocusedItem.SubItems[2].Text.Trim();Pwd = LV.FocusedItem.SubItems[3].Text.Trim();Age = LV.FocusedItem.SubItems[4].Text.Trim();Sex = LV.FocusedItem.SubItems[5].Text.Trim();State = LV.FocusedItem.SubItems[6].Text.Trim();Adress = LV.FocusedItem.SubItems[7].Text.Trim();Number = LV.FocusedItem.SubItems[8].Text.Trim();Email = LV.FocusedItem.SubItems[9].Text.Trim();Grade = LV.FocusedItem.SubItems[10].Text.Trim();Class= LV.FocusedItem.SubItems[11].Text.Trim();Role = LV.FocusedItem.SubItems[12].Text.Trim();}private void btnReset_Click(object sender, EventArgs e){textBox2.Text = "";textBox3.Text = "";txtReaderName.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";}private void btnAdd_Click(object sender, EventArgs e){string SQL="";if (textBox2.Text == "" || textBox3.Text == "" || txtReaderName.Text == "" ||textBox4.Text == "" || textBox5.Text == ""){MessageBox.Show("请至少输入读者姓名,用户名,密码,借书状态和角色!");}else{string sql = "SELECT * from Reader WHERE rSno='" + textBox2.Text.Trim() + "' ";DataTable dt = clsGlobalVar.GetDataTable(sql);if (dt.Rows.Count == 0){if(cboRole.Text.Trim()=="教师")SQL = "INSERT INTO Reader(rSno,rPwd,rName,rAge,rSex,rState,rAdress,rNumber,rEmail,rGrade,rClass,rRole)VALUES ('" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + txtReaderName.Text.Trim() + "','"+ textBox1.Text.Trim() + "','" + cboSex.Text.Trim() + "','" + textBox4.Text.Trim() + "','" +textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + "NULL"+ "','" + "NULL" + "','" + cboRole.Text.Trim() + "')";elseSQL = "INSERT INTO Reader(rSno,rPwd,rName,rAge,rSex,rState,rAdress,rNumber,rEmail,rGrade,rClass,rRole)VALUES ('" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + txtReaderName.Text.Trim() + "','"+ textBox1.Text.Trim() + "','" + cboSex.Text.Trim() + "','" + textBox4.Text.Trim() + "','" +textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" +textBox8.Text.Trim() + "','" + textBox9.Text.Trim() + "','" + cboRole.Text.Trim() + "')";if (clsGlobalVar.ExecSQL(SQL) == true){textBox2.Text = "";textBox3.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";MessageBox.Show("成功添加此用户!");SelectStudent();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}else{MessageBox.Show("用户名已存在,请选择其他用户名!", "结果提示", MessageBoxButtons.OK, rmation);textBox2.Text = "";}}}private void btnDel_Click(object sender, EventArgs e){if (textBox2.Text == ""){MessageBox.Show("请选择要删除的用户!");}else{DialogResult dt= MessageBox.Show("此操作不可撤销,确定要删除此用户信息吗?", " 提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);if (dt == DialogResult.Yes){string SQL = "DELETE FROM Reader where rSno='" + Sno + "'";if (clsGlobalVar.ExecSQL(SQL) == true){textBox2.Text = "";textBox3.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";MessageBox.Show("删除此用户成功!");SelectStudent();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}}}private void frmUpdateReader_Load(object sender, EventArgs e){SelectStudent();}}}8) 图书的查找及修改窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{。

书籍管理 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`,包含了借阅的图书信息、用户信息,借阅时间和归还时间。

图书管理系统(源代码)

图书管理系统(源代码)

#include"stdio.h"#include"stdlib.h"#include"string.h"#define MENU_ADMIN_COUNT 2#define MENU_SEARCH_BOOK_COUNT 6 #define MENU_USER_COUNT 7#define BOOK_FILE "books.dat"#define USER_FILE "user.dat"#define MAX_BOOK_NAME 20#define MAX_PUBLISHER 20#define MAX_DATE 10#define MAX_AUTHOR 20#define MAX_ISBN 20typedef struct _book_info{ char book_name[MAX_BOOK_NAME]; char author[MAX_AUTHOR];char publisher[MAX_PUBLISHER];char pub_date[MAX_DA TE];char ISBN[MAX_ISBN];int pages;}book_info;typedef struct _book{ book_info bi;struct _book* next;}book;#define MAX_USERNAME 10#define MAX_PASSWORD 10typedef enum _USER_TYPE{ADMIN=0,USER}USER_TYPE;typedef struct _user_info{char username[MAX_USERNAME];char password[MAX_PASSWORD]; USER_TYPE user_type;}user_info;typedef struct _user{ user_info ui;struct _user* next;}user;void init_user();void load_users();USER_TYPE login();void add_user();void search_user();void save_users();void clear_users();void save_users_to_file();user* get_last_user();user* get_previous_user(user* p);user* find_user(char* name);void show_user(user_info* info);void input_user(user_info* info);void delete_user(user* p);void update_user(user* p);void init_book();void load_books();void add_book();void view_book();void delete_book();void save_books();void clear_books();void search_book_by_name();void search_book_by_author();void search_book_by_publisher();void search_book_by_pubdate();void search_book_by_isbn();int findstr(char *source,char *str);void save_books_to_file();book* get_last_book();book* get_previous_book(book* p);void input_book(book_info* info);void show_book(book_info* info);void show_admin_menu();void show_search_book_menu();void show_user_menu();void admin_exit();void user_exit();book *first_book=NULL;user* first_user=NULL;char menu_title[]="=========================================\n" "| 图书管理系统|\n""+---------------------------------------+\n";char menu_admin[]="| |\n" "| (1)图书管理|\n" "| (2)用户管理|\n" "| (3)退出系统|\n" "+---------------------------------------+\n";char admin_menu1[]="-----------------------------------------\n""| 图书管理|\n" "----------------------------------------|\n""| <1>新增图书|\n" "| <2>浏览图书|\n" "| <3>查找图书|\n" "| <4>删除图书|\n" "| <5>保存图书|\n" "| <0>返回主菜单|\n" "-----------------------------------------\n";char admin_menu2[]="----------------------------------------\n"" 用户管理|\n" "----------------------------------------|\n""| <1>新增用户|\n" "| <2>查找用户|\n" "| <3>保存用户|\n" "| <0>返回主菜单|\n" "|---------------------------------------|\n";void(*menu1_fun[])()={add_book,view_book,show_search_book_menu,delete_book,save_books,};void(*menu2_func[])()={add_user,search_user,save_users,};char menu_admin_search_book[]="| 查找图书:|\n" "| <1>按书名查找|\n" "| <2>按作者查找|\n" "| <3>按出版社查找|\n" "| <4>按出版日期查找|\n" "| <5>按国际标准书号(ISBN)查找|\n" "| <0>返回主菜单|\n" "+--------------------------------------+\n";void (*admin_search_book_func[])()={search_book_by_name,search_book_by_author,search_book_by_publisher,search_book_by_pubdate,search_book_by_isbn,};char menu_user[]="| <1>浏览图书|\n" "| <2>按书名查找图书|\n" "| <3>按作者查找图书|\n" "| <4>按出版社查找图书|\n" "| <5>按出版日期查找图书|\n" "| <6>按国际标准书号(ISBN)查找图书|\n" "| <0>退出系统|\n" "+--------------------------------------+\n";void (*user_func[])()={view_book,search_book_by_name,search_book_by_author,search_book_by_publisher,search_book_by_pubdate,search_book_by_isbn,user_exit};void add_book(){ char try_again='Y';book *p=NULL;book *new_book=NULL;while(try_again=='Y' || try_again=='y'){ new_book=(book*)malloc(sizeof(book));memset(new_book,0,sizeof(book));new_book->next=NULL;printf(">新增图书...\n");input_book(&(new_book->bi));p=get_last_book();if(p==NULL){ first_book=new_book;}else{ p->next=new_book;}printf(">继续添加图书吗?(y or n):");getchar();try_again=getchar();}}void view_book(){ book *p=NULL;char input='Y';int count=0;while(input=='y' || input=='Y'){ count=0;p=first_book;printf("+---------------------------------------+\n");printf("| 书名| 作者|\n");printf("+---------------------------------------+\n");while(p!=NULL){ printf("|%20s|%20s|\n",p->bi.book_name,p->bi.author);printf("+-------------------------------------+\n");count++;if(count==5){ count=0;printf(">显示下一页吗?(y or n):");getchar();input=getchar();if(input!='y' && input!='Y'){ break;}}p=p->next;}printf(">再次浏览图书吗?(y or n):");getchar();input=getchar();}}void search_book_by_name(){ book *p=NULL;char s[MAX_BOOK_NAME]={0};char input='Y';int count=0;int i=0;printf(">查找图书...\n");while(input=='Y' || input=='y'){ count=0;p=first_book;memset(s,0,MAX_BOOK_NAME);printf(">请输入书名(最大长度为%d):",MAX_BOOK_NAME);scanf("%s",s);while(p!=NULL){ if(findstr(p->bi.book_name,s)!=-1){ show_book(&(p->bi));count++;}p=p->next;}if(count==0){ printf(">没有找到图书%s。

图书管理系统的设计(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;}}。

图书管理系统代码

图书管理系统代码

图书管理系统代码//***********************//图书馆管理系统//***********************#include<stdio.h>#include<string.h>#include<malloc.h>#define null 0#define max 65536static int n;//*********************// 图书结构体//*********************typedef struct{char num[10]; //书号char name[9]; //书名char addr[31]; //作者int Nowcounter; //现存量int Allcounter; //总库存量}datatype;datatype *x[max]; //定义两个指针数组datatype *p;//*****************************//图书功能函数列表//*****************************void redo(); //主递归函数void creatlist(datatype *x[]); //图书建立函数int menu_select(); //功能菜单函数void find(datatype *x[],int n); //查找函数void delnode(datatype *x[]); //插入函数void printlist(datatype *x[]); //显示函数void jieyue(datatype *x[],int n); //借阅函数void guihuan(datatype *x[],int n); //归还函数//*****************************//主递归函数程序//*****************************void redo(){int i=0,j,n1,k=0,flage;for( ; ;){switch( menu_select()){case 1: //选项1的实现printf("***********************\n");printf("* 图书的建立*\n");printf("***********************\n");creatlist(x);break;case 2: //选项2的实现printf("***********************\n");printf("* 新图书信息的添加*\n");printf("***********************\n");printf(" 插入的个数:");scanf("%d",&n1); //输入插入新图书的个数for(i=0;i<n1;i++){flage=0;p=(datatype *)malloc(sizeof(datatype)); //分配一个节点空间printf(" 书名: ");scanf("%s",p->name); //输入插入书的书名if(flage==0){for(j=0;j<n;j++){if(strcmp(x[j]->name,p->name) == 0 )//调用比较函数查看书名是否已知{x[j]->Allcounter++;x[j]->Nowcounter++;flage=1;}}if(flage==0){n++;printf(" 第%d 个图书数据:\n",n); //插入新的图书p=(datatype *)malloc(sizeof(datatype));x[n-1]=p;printf(" 书名:");scanf("%s",x[n-1]->name); //输入书名printf(" 编号:");scanf(" %s",x[n-1]->num); //输入书号printf(" 作者:");scanf(" %s",x[n-1]->addr); // 输入作者名printf(" 总库存量:");scanf("%d",&x[n-1]->Allcounter); //输入总库存量x[n-1]->Nowcounter=x[n-1]->Allcounter;}}}break;case 3:printf("***********************\n");printf("* 图书信息的查询*\n");printf("***********************\n");find(x,n);break;case 4:printf("************************\n");printf("* 图书信息的删除*\n");printf("************************\n");delnode(x);break;case 5:printf("************************\n");printf("* 图书信息的显示*\n");printf("************************\n");printlist(x);break;case 6:printf("************************\n");printf(" 图书的借阅\n");printf("************************\n");jieyue(x,n);break;case 7:printf("************************\n");printf(" 图书的归还\n");printf("************************\n");guihuan(x,n);break;case 0:printf("\t 谢谢使用,再见! \n");return;}}//*************************//主函数程序//*************************void main (){redo(); //调用主递归函数}//*************************//功能菜单函数//*************************int menu_select(){int i;printf(" 欢迎进入图书管理系统!\n");printf("===========================\n");printf(" 1. 图书信息的采集\n");printf(" 2. 新图书的插入\n");printf(" 3. 图书信息的查询\n");printf(" 4. 图书的删除\n");printf(" 5. 图书的显示\n");printf(" 6. 图书的借阅\n");printf(" 7. 图书的归还\n");printf(" 0. 退出管理系统\n");printf("===========================\n");printf(" 请选择0-7: ");scanf("%d",&i);while(i<0||i>7){printf("\n\t输入出错,重选0-7: ");scanf("%d",&i);}return i;}//********************************// 建立链表图书建造函数//********************************void creatlist(datatype *x[]){int i;printf(" 请输入要建立图书的个数:");scanf("%d",&n);for(i=0;i<n;i++)printf(" 第%d 个图书数据:\n",i+1);p=(datatype *)malloc(sizeof(datatype)); //分配一个节点空间x[i]=p;printf(" 书名:"); //输入图书各项内容scanf("%s",x[i]->name);printf(" 编号:");scanf(" %s",x[i]->num);printf(" 作者:");scanf(" %s",x[i]->addr);printf(" 总库存量:");scanf("%d",&x[i]->Allcounter);x[i]->Nowcounter=x[i]->Allcounter;}}//**********************************// 查找函数程序//*********************************void find(datatype *x[],int n){char num[10];char name[9];int t,i;printf("=================\n"); //输出查找方式printf(" 1.按编号查询\n");printf(" 2.按书名查询\n");printf("=================\n");printf(" 请选择: ");scanf("%d",&t); //输入选择信息if(t==1){printf(" 请输入要查找者的编号: ");scanf("%s",num); //输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num)==0) //调用strcmp函数{printf(" 编号书名作者现库存量总库存量\n");//输出要查询书的信息printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);elsecontinue;}}else{printf(" 请输入要查询的书名: ");scanf("%s",name); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name)==0){printf("编号书名作者现库存量总库存量\n"); //输出要查询书的信息printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i ]->Nowcounter,x[i]->Allcounter);}elsecontinue;}}}//******************************//删除函数程序//******************************void delnode(datatype *x[]){char num1[10],name1[10]; //定义两个字符数组int i,j,m=1,p;printf(" 1.按编号删除\n"); //输出选择方式printf(" 2.按书名删除\n");printf(" 3.返回\n");printf(" 请选择:\n");scanf("%d",&p); //输入选择信息if(p>3||p<1){printf(" 您的输入有误,请重新输入!\n");scanf("%d",&p); //重新输入选择信息}switch(p) //实现删除程序{case 1:printf(" 输入要删除书的编号:\n");scanf(" %s",num1);for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0) //调用strcmp函数{m=0;n--;for(j=i;j<n;j++)x[j]=x[j+1]; //将该书信息删除printf(" 该书已删除!\n");}}if(m==1)printf(" 没有这样的的图书\n");break;case 2:printf(" 输入要删除书的名字:\n");scanf("%s",&name1);for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0) //调用strcmp函数{m=0;n--;for(j=i;j<n;j++) //将该书信息删除x[j]=x[j+1];printf(" 该书已删除!\n");}}if(m==1)printf(" 没有这样的的图书\n");break;case 3:break;}}//////////////////////////////借阅函数程序/////////////////////////void jieyue(datatype *x[],int n){int i,m=1,p;char name1[10],num1[10]; //定义两个字符数组printf(" 1.按名字借阅\n"); //输出选择方式printf(" 2.按编号借阅\n");printf(" 3.返回\n");printf(" 请选择\n");scanf("%d",&p); //输入选择信息if(p>3||p<1){printf(" 您的输入有误!\n");scanf("%d",&p); //重新输入选择信息}switch(p) //实现查询程序{case 1:printf(" 请输入你要的书的名字!\n");scanf("%s",&name1); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0) //调用strcmp函数{m=0;if(x[i]->Nowcounter!=0)x[i]->Nowcounter--;printf(" 借书成功!\n");if(x[i]->Nowcounter==0)printf(" 这本书已经没有了\n");}}if(m==1)printf(" 您要的书不存在!\n");break;case 2:printf(" 请输入你要的书的编号!\n");scanf("%s",&num1); // 输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0) //调用strcmp函数{m=0;if(x[i]->Nowcounter!=0)x[i]->Nowcounter--; //现存书数量减1printf(" 借书成功!\n");if(x[i]->Nowcounter==0)printf(" 这本书已经没有了\n");}}if(m==1)printf(" 您要的书不存在!\n");break;case 3:break;}}////////////////////////////归还程序//////////////////////void guihuan(datatype *x[],int n){int i,q,m=1;char name1[10],num1[10]; //定义两个字符数组printf(" 1.按书名归还\n"); //输出可选择方式printf(" 2.按书号归还\n");printf(" 3.返回\n");printf(" 请选择\n");scanf("%d",&q); //输入选择信息if(q>3||q<1){printf(" 您的输入有误!\n");scanf("%d",&q); //重新输入选择信息}switch(q) //实现归还程序{case 1:printf(" 输入归还书的书名: ");scanf("%s",&name1); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0){m=0;x[i]->Nowcounter++;printf("此书归还成功!\n");printf("此书的存储情况\n");printf("编号书名作者现存量总存量\n"); printf("===============================================\n");printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);printf("===============================================\n");}if(strcmp(x[i]->name,name1)==0)continue;}if(m==1)printf("此书不是图书馆的!\n");break;case 2:printf("输入归还书的书号\n");scanf("%s",&num1); // 输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0){m=0;x[i]->Nowcounter++; //显存书增加1printf("此书归还成功!\n");printf("此书的存储情况\n");printf("编号书名作者现存量总存量\n"); printf("==============================================\n");printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);printf("==============================================\n");}if(strcmp(x[i]->num,num1)==0) //调用strcmp 函数continue;}if(m==1)printf("此书不是图书馆的!\n");break;case 3:break;}}//**************************************// 输出程序//**************************************void printlist(datatype *x[]){int i;printf("编号书名作者现存量总存量\n");//输出图书各项信息for(i=0;i<n;i++){printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i ]->Nowcounter,x[i]->Allcounter);}printf("===============================================\n");}。

图书书籍管理系统模板

图书书籍管理系统模板

序号 图书索引编号
类别 类别 代码
T A M
A B A
001 T-1-A-001 002 A-2-B-002
1
01. 工具书 新华词典 籍 圣经
TKW ABC
TKW简介 ABC简介 梅毅简介
TKW工作 室 圣经协会 小小
2010 2010/1/1 2003 2010/1/1 2001 2010/3/1
ቤተ መጻሕፍቲ ባይዱ书籍目录
说明:白色单元格为可录入区域,有颜色区域为有公式,勿输入数编辑造成错误
书籍查询
还书期限设 定天数
点击新增编辑→书目编类
作者简介 译者/ 出版社 链接 主编 出版 年份
30
当前日期:
作者 书架 标签 号
2019年1月2日
星期三
书名 副书名 作者 购买时间 备注说明 借书人 借书时间 应还日期 还书时间
第 1 页,共 6 页
第 2 页,共 6 页
第 3 页,共 6 页
是否超期
未超期 超期2天 超期97 天
第 4 页,共 6 页
第 5 页,共 6 页
第 6 页,共 6 页
小李 小谭 小小
2010/1/1 2010/1/2 2010/5/6
2010/1/31 2010/2/1 2010/6/5
2010/1/31 2010/2/3 2010/9/10
2 02. 圣经
001 M-10C-A-001 10C
10C. 历史传 太平天国 梅毅 记(儿童少 极乐诱惑 的兴亡 年)

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)。

课程设计报告 图书管理系统的 设计与实现系 名:电子通信与软件工程系 专 业:计算机科学与技术指导教师:二○一三 年 十二 月装订线 中山大学南方学院目录第1章可行性分析 (1)1.1经济可行性 (1)1.2技术可行性 (1)第2章需求分析 (2)2.1 图书管理系统开发的目的 (2)2.2 图书管理系统开发的背景 (2)2.3 图书管理系统开发任务概述 (2)2.4 系统(或用户)的特点 (2)2.5 假定和约束 (3)2.6 软件功能说明 (3)2.7 对功能的一般性规定 (5)2.8 运行环境规定 (6)2.9支撑软件 (6)2.10 接口 (6)第3章总体设计 (7)3.1系统设计 (7)3.2结构设计 (11)3.2.1模块描述 (11)3.2.2系统角色设计 (13)3.3接口设计 (14)3.3.1用户界面设计规则 (14)3.3.2内部接口设计 (14)3.3.3外部接口设计 (14)3.3.4出错处理设计 (14)3.3.5系统维护设计 (14)第4章详细设计 (15)4.1 数据库设计 (15)4.1.1数据库概念结构设计 (15)4.1.2数据库逻辑结构设计 (15)4.2.1程序界面 (15)4.3 服务器模块 (19)4.3.1程序界面 (19)4.3.2功能说明 (19)4.4改进计划 (19)4.5支持软件 (20)4.6使用说明 (20)4.7出错和恢复 (20)4.8版权说明 (22)4.8.1开发团队 (22)4.8.2版权信息 (22)4.8.3版权信息 (22)第5章编码与测试 (23)5.1 编码阶段 (23)5.1.1 连接数据库代码 (23)5.1.2 登录代码 (23)5.1.3 注册代码 (25)5.1.4 违规处理代码 (26)5.2 软件测试报告 (26)5.2.1 引言 (26)5.2.2 测试步骤 (26)5.2.3 测试结果 (27)参考文献 (28)开发心得体会 (29)第1章可行性分析1.1经济可行性自21世纪开始,随着信息技术的飞速发展,越来越多的信息进入人们的生活,普通的人工技术记录已经难以满足人们的正常需求,这便出现了计算机记录管理信息。

我们所做的图书馆管理系统,只需一个管理者便可以操作大量的数据信息,省下大量的人力物力。

相比之下经济可行性很好。

技术可行性目前,我们绝大多数的图书馆都已经普及了图书管理系统。

由此证明,技术上是十分可行的。

1.2 法律可行性目前,在国内外是允许的,并没有触碰法律。

知识产权受法律保护。

第2章需求分析2.1图书馆管理系统开发的目的图书馆提供的物质资源越来越丰富,如何高效准确地对馆藏资料进行整理、借还、盘点成为困扰图书馆管理人员的问题。

2.2图书馆管理系统开发的背景图书管理系统可以降低了管理人员的劳动强度、大幅提高了图书盘点及错架图书整理效率、使错架图书的查找变得更为快捷便利、安全门摆放距离更加宽阔,使读者进出更加自如,有效简化了读者借还书手续,提高了图书借阅率,避免了读者与管理人员之间发生不必要争执,融洽了读者与管理人员之间的关系开发软件系统的名称:图书馆管理系统软件开发者:麦泽明刘志锋廖坤城面向对象(用户):中山大学南方学院全体师生及外来参观人员2.3图书馆管理系统开发任务概述软件开发的意图:使中山大学南方学院的全体师生方便借阅、归还图书。

管理人员方便管理。

应用目标:中山大学南方学院的全体师生及外来参观人员;作用范围:中山大学南方学院校内。

2.4 系统(或用户)的特点1,界面更加简约。

2,功能更加全面。

图2-1 层次方框图2.5 假定和约束目标在17周内完成,经费尚无2.6 软件功能说明图2-2 系统实体-联系图图2-3 系统的状态图2.7 对功能的一般性规定本处仅列出对开发产品的所有功能(或一部分)的共同要求,如要求界面格式统一,统一的错误声音提示,要求有在线帮助等。

1 精度的要求:账号、密码信息输入一定要正确才能登陆。

2 灵活性:当输入发生某些变化时,该系统对这些变化的适应能力。

3输入输出要求:输入账号,密码一定要正确④故障处理要求:软件卡死不会影响数据库信息。

2.8 运行环境规定该软件所需要的硬件设备要求:1,CPU Inter Pentium 1.600MHz 以上2,内存1024MB以上3,磁盘空间20GB以上2.9支撑软件数据库管理系统软件:SQL Myeclipse运行平台:Windows XP win7软件开发语言:JAVA、SQL语言2.10 接口外部接口1。

用户接口:采用窗口化,菜单式进行设计,在操作时响应热键。

2。

硬件接口:扫描仪器等内部接口通过面向对象语言设计类、第3章总体设计3.1系统设计顶层数据流图:第0层图:第1层图:登录子系统管理子系统:查询子系统:第二层图:(1)入库管理:(2)处理学生借书:(3)处理学生还书:(4)处理学生信息查询:(5)处理注销信息查询:(6)处理图书信息查询:图3-1软件结构图3.2结构设计3.2.1总体模块模块1:主界面模块2:登陆系统模块3:查询系统模块8:数据备份3.2.3系统角色设计1.系统管理员图3-3系统管理员用例图2.操作用户图 3-3用户用例图3.3接口设计3.3.1用户界面设计规则符合用户需求的、美观大方的用户界面。

3.3.2内部接口设计由于SQL Server 数据库的独特性,其数据库内部不需要特别设计接口,各模块根据文档内部控制域值提取其所需的数据。

3.3.3外部接口设计与硬件之间的接口:无与软件之间的接口:数据库接口,资源库接口 3.3.4出错处理设计出错处理:在错误发生时,给出出错的原因。

3.3.5系统维护设计采用模块化的设计,方便维护。

第4章详细设计4.1 数据库设计4.1.1数据库概念结构设计图1-3系统E-R图4.1.2数据库逻辑结构设计(1)书签表数据项:收藏ID、图书ID、图书名称、索书号(2)图书表数据项:id、图书id、图书书名、图书作者、图书馆isbn码、图书页码、图书价格、图书出版日期、图书出版社、图书分类、图书索书号(3)图书类别表数据项:图书分类号、图书分类名4.2 客户端模块4.2.1程序界面系统主界面菜单预览图书查询图书删除预览图书4.3 服务器模块4.3.1程序界面4.3.2功能说明主界面提供访问者操作:1查询图书2借阅图书3归还图书4修改个人信息4.4改进计划当前版本由于时间关系未作程序界面上的修饰,存在的界面不美观,上手难,不具亲和力等问题,这对于一款用于商业软件来说是一个非常严重的问题。

幸好,目前当前版本是为了向大家演示本程序功能,对界面方面的要求也就相对较低。

在后续版本中,会采用多窗口轮换显示,降低操作的复杂性 ;每个窗口,底层采用图画,在其上层添加透明的命令控件,来达到程序控制的目的。

后续版本中也将采用类似的方式以增强美观性。

4.5支持软件服务器Windows2000或Windows 2000 Advanced server ,Microsoft. SQL Server.客户端Windows XP ,IE 6.04.6使用说明1.安装、配置服务器端软件(1)在服务器上安装好 Windows2003后,配置 TCP/IP协议中 IP为192.168.0.1,工作组为 WORKGROUP,计算机名为 Server,设置打印机与文件共享。

(2)安装图书管理系统,将图书管理系统快捷方式加入启动项。

(3)安装 SQL Server 2005,将用户名、密码设为: 123、456。

导入位于数据库备份文件。

使用图书管理系统添加一条信息以供测试。

(4)安装、配置 Windowsxp,安装客户机应用软件,安装、调试网络共享,(5)全面测试2.安装客户机应用软件同样安装好系统后,配置TCP/IP协议中IP为192.168.0.2~192.168.0.255,设置工作组为 WORKGROUP,计算机名为房间号。

安装图书管理系统客户端,将图书管理系统快捷方式加入启动项。

3.安装调试运行服务器端图书管理系统,运行客户机端图书管理系统看是否能正常运行,检查设置以及网络共享是否良好。

4.7出错和恢复一般情况下,如遇客户端出错,重启客户机即可,不影响服务器及其它客户机的工作。

如遇服务器出错,重启电脑,如不能解决,重装服务器端程序即可,如遇其它网络问题需自行解决。

如遇数据库出现问题,将数据库备份文件重新导入,注意,数据库需经常备份。

4.8版权说明4.8.1开发团队第19小组:麦泽明、刘志锋、廖坤城、张俊城、郑志远4.8.2版权信息版权所有 . 第19小组保留所有权力。

图书管理系统由麦泽明、刘志锋、廖坤城、张俊城、郑志远共同开发 ,全部核心技术归属第19小组。

4.8.3免责条约由于该程序是免费加以许可的 ,因而也就无法保证该程序符合可用性准则。

任何情况下 ,程序的质量风险和性能风险完全由您承担。

第5章编码与测试5.1 编码阶段5.1.1 连接数据库代码try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.println("加载驱动程序失败!");}try{String url = "jdbc:mysql://localhost:3306/book";Connectioncon=DriverManager.getConnection(url,"root","root");Statement sql;5.1.2 登录代码import java.awt.event.*;import javax.swing.*;import java.awt.*;import java.awt.Container;import java.util.*;import java.sql.*;class Login extends JFrame implements ActionListener{ Container cp=null;JFrame f=null;JButton j1,j2;JTextField name;JPasswordField pwd;JLabel jlable1,jlable2;JPanel jp;Login(){jp=new JPanel();f=new JFrame();jp.setLayout(new GridLayout(3,2));addComponents();this.setLayout(new BorderLayout(50,50));this.add(BorderLayout.NORTH,new JLabel(""));this.add(BorderLayout.SOUTH,new JLabel(""));this.add(BorderLayout.EAST,new JLabel(""));this.add(BorderLayout.WEST,new JLabel(""));this.add(jp);this.setTitle("用户登录界面");this.setSize(350,220);this.setVisible(true);}void addComponents(){JLabel jlbu=new JLabel();jlbu.setText("用户名");name=new JTextField();JLabel jlbp=new JLabel();jlbp.setText("密码");pwd=new JPasswordField();//pwd.setEchoChar("*");j1=new JButton("登录");j2=new JButton("取消");j1.addActionListener(this);j2.addActionListener(this);jp.add(jlbu);jp.add(name);jp.add(jlbp);jp.add(pwd);jp.add(j1);jp.add(j2);f.add(jp);}public void confirm(){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.println("加载驱动程序失败!");}try{String url = "jdbc:mysql://localhost:3306/book";Connectioncon=DriverManager.getConnection(url,"root","root");Statement sql=con.createStatement();String uname=name.getText().trim();String Mima=pwd.getText().trim();String queryMima="select * from user whereuser_name='"+uname+"' and password='"+Mima+"'";ResultSet rs=sql.executeQuery(queryMima);if(rs.next()){new Book(uname);f.hide();con.close();}else{JOptionPane.showMessageDialog(null,"该用户不存在","提示!", JOptionPane.YES_NO_OPTION);}name.setText("");pwd.setText("");}catch(SQLException g){System.out.println(g.getErrorCode());System.out.println(g.getMessage()); }}public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("登录")){confirm();}else if(cmd.equals("取消")){f.dispose();}}public static void main(String []arg){Login a=new Login();}}5.1.3 注册代码jbt1.addActionListener(this);//注册监听器jbt2.addActionListener(this);public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){f.hide();}if(cmd.equals("返回"))f.hide();}5.1.4 违规处理代码try{String url = "jdbc:mysql://localhost:3306/book";Connectioncon=DriverManager.getConnection(url,"root","root");Statement sql;String ql=(String)(ar[index][1]);String s="delete * from book where book_no ='"+ql +"'"; sql=con.createStatement();int del=sql.executeUpdate(s);if(del==1){JOptionPane.showMessageDialog(null,"删除成功!","信息", JOptionPane.YES_NO_OPTION);}con.close();f.repaint();}catch(SQLException g){System.out.println(g.getErrorCode());System.out.println(g.getMessage());}5.2 软件测试报告5.2.1 引言5.2.2 测试步骤1打开****系统并选择测试类型及其他参数2 设置URL3浏览器设置4 开始测试5.2.3 测试结果1 测试结果概况2 测试结果视图参考文献[1] 张海藩.软件工程导论.计算机应用技术,2018开发心得体会姓名麦泽明:我认为,这门课实在获益良多,并且有一些心得体会:相信团队合作才可能把项目做好。

相关文档
最新文档