SQL数据库图书管理系统(完整代码)

合集下载

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

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

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

图书馆一个数据库设计SQL

图书馆一个数据库设计SQL

综合设计性实验
为图书馆设计一个数据库,此数据库对每个借阅者保存读者记录,包括:借书证号、姓名、性别、单位、可借数量。

对每本书记录:书号、书名、作者、出版社。

对每本被借出的书有:读者号、借出日期、应还日期。

可以随时查阅书库中的书籍信息,所有的书籍均由书号唯一标识;可以随时查阅书籍借还情况,系统约定任何人可以借多本图书,任何一种图书可以为多人所借,借书证号具有唯一性。

要求:
1.基于《数据库概论》中所学的知识分析该数据库的基本结构,
2.用Transact-sql命令完成如下要求:
(1)创建数据库和数据表,定义每个表的主键和外键,为每个属性选择合适的数据类型,定义每个属性是否允许空值,是否有默认值等;
(2)结合具体情况为数据库表设置合理的约束或规则;
(3)如果需要,为数据表设计合理的触发器;
(4)使用SQL语句,在你设计的每个表中插入至少3条数据,要求记录满足数据约束要求,且尽量真实可信;
(5)自行设计查询要求,给出经常需要用到的查询语句。

3.写出完整的实验报告。

附:实验报告模板
网络工程系综合性实验
实验报告
课程名称数据库技术与应用
学号
姓名张欢
任课老师高宁
2012年11 月。

图书馆管理系统源代码

图书馆管理系统源代码

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

(完整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。

图书管理系统C#源代码

图书管理系统C#源代码

using System;using System。

Collections。

Generic;using ponentModel;using System。

Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1{public partial class Form_BuyAndSale : Form{public Form_BuyAndSale(){InitializeComponent();}SQL sql;string lastSQL = ””;public void show(){listBox1。

Items。

Clear();listBox2.Items.Clear();listBox3。

Items。

Clear();if (sql。

rows。

GetLength(0) != 0){for (int i = 0; i 〈 sql。

rows。

GetLength(0); i++){listBox1.Items。

Add(sql。

rows[i, 0].ToString());listBox2.Items.Add(sql.rows[i, 1].ToString());listBox3.Items。

Add(sql。

rows[i, 2].ToString());}}else{listBox1.Text = ”";listBox2。

Text = ””;listBox3。

Text = "”;MessageBox。

Show("无符合查询条件的结果!”, "提示”);}}private void Form_BuyAndSale_Load(object sender, EventArgs e){//将窗体的任务栏隐藏this。

FormBorderStyle = System.Windows。

vb图书管理系统源代码

vb图书管理系统源代码

Borbook:Public sqltxt As StringPublic rno As String '保存读者借书证号Public bno As String '保存读者图书编号Public xm As String '保存读者姓名Public dw As String '保存读者单位Public rs As ADODB.RecordsetPrivate Sub Comm1_Click()rno = Trim(Text1(0).Text)If rno = "" ThenMsgBox "借书证号不能为空,请输入", vbOKOnly, "信息提示"Comm2.Enabled = FalseElsesqltxt = "select * from reader where 借书证号='" + rno + "'"Set rs = exesql(sqltxt)If rs.RecordCount = 0 ThenMsgBox "该读者未登记,不能借书", vbOKOnly, "信息提示"Comm2.Enabled = FalseElseText2(0).Text = rs.Fields("姓名")Text2(1).Text = str(rs.Fields("借书总数"))Text2(2).Text = str(rs.Fields("借书总数") - rs.Fields("已借书数"))If Val(Trim(Text2(2).Text)) > 0 Thenxm = rs.Fields("姓名")dw = rs.Fields("单位")Comm2.Enabled = TrueElseMsgBox "该读者已借满图书,不能再借!", vbOKOnly, "信息提示"Comm2.Enabled = FalseEnd IfEnd IfEnd IfEnd SubPrivate Sub Comm2_Click()If Val(Trim(Text2(2).Text)) = 0 ThenMsgBox "该读者已借满图书,不能再借!", vbOKOnly, "信息提示"Comm2.Enabled = FalseExit SubEnd Ifbno = Trim(Text1(1).Text)If bno = "" ThenMsgBox "图书编号不能为空,请输入", vbOKOnly, "信息提示"Comm2.Enabled = FalseElsesqltxt = "select * from book where 图书编号='" + bno + "'"Set bs = exesql(sqltxt)If bs.RecordCount = 0 ThenMsgBox "图书编号不对旳,请重新输入", vbOKOnly, "信息提示"ElseIf bs.Fields("借否") = "借" ThenMsgBox "该图书编号相应旳图书已借出,不能再借!", vbOKOnly, "信息提示"Elsesqltxt = "select * from borrow"Set brs = exesql(sqltxt)brs.AddNewbrs.Fields("图书编号") = bnobrs.Fields("书名") = bs.Fields("书名")brs.Fields("作者") = bs.Fields("作者")brs.Fields("出版社") = bs.Fields("出版社")brs.Fields("借书证号") = rnobrs.Fields("姓名") = xmbrs.Fields("单位") = dwbrs.Fields("借书日期") = Datebrs.Updatebs.Fields("借否") = "借"bs.Updaters.Fields("已借书数") = rs.Fields("已借书数") + 1rs.UpdateText2(2).Text = str(rs.Fields("借书总数") - rs.Fields("已借书数"))End IfEnd IfEnd IfEnd SubPrivate Sub retCom_Click()Unload MeEnd SubPrivate Sub Form_Load()Comm2.Enabled = FalseEnd SubPrivate Sub DataGrid1_Click()End SubPrivate Sub Form_Load()'阐明:为什么使用recs,而不直接使用adodc1.recordset.recordcount?在调用edbook1窗体添加一种记录(拟定)后,再'返回到本表单,若不在Form_Activate()事件过程中调用adodc1.refresh进行刷新,adodc1.recordset.recordcount值'仍未增1,这样调用encomm过程时出错;若在Form_Activate()事件过程中调用adodc1.refresh进行刷新,'adodc1.recordset.recordcount值增1了,调用encomm过程时也对旳,但返回本窗体时,目前行总是第一行,显然也不行,'由于顾客在添加或修改后但愿在datagrid1中显示目前操作旳那条记录.recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate()DataGrid1.SetFocusCall encommEnd SubPrivate Sub Comm1_Click()flag = 1edbook1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edbook1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("书名")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Unload MePrivate Sub selcmd1_Click() '拟定Dim str As Stringstr = "" '条件体现式If Trim(Text1(0).Text) <> "" ThenIf str = "" Thenstr = "图书编号='" + Trim(Text1(0).Text) + "'"Elsestr = str + " and 图书编号='" + Trim(Text1(0).Text) + "'"End IfEnd IfIf Trim(Text1(1).Text) <> "" ThenIf str = "" Thenstr = "书名='" + Trim(Text1(1).Text) + "'"Elsestr = str + " and 书名='" + Trim(Text1(1).Text) + "'"End IfEnd IfIf Trim(Text1(2).Text) <> "" ThenIf str = "" Thenstr = "作者='" + Trim(Text1(2).Text) + "'"Elsestr = str + " and 作者='" + Trim(Text1(2).Text) + "'"End IfEnd IfIf Trim(Text1(3).Text) <> "" ThenIf str = "" Thenstr = "出版社='" + Trim(Text1(3).Text) + "'"Elsestr = str + " and 出版社='" + Trim(Text1(3).Text) + "'"End IfEnd IfIf Trim(Text1(4).Text) <> "" ThenIf str = "" Thenstr = "借否='" + Trim(Text1(4).Text) + "'"Elsestr = str + " and 借否='" + Trim(Text1(4).Text) + "'"End IfEnd IfIf str <> "" ThenAdodc1.RecordSource = "select * from book where " + strAdodc1.RefreshElseAdodc1.RecordSource = "select * from book"Adodc1.RefreshEnd Ifrecs = Adodc1.Recordset.RecordCountIf recs = 0 ThenMsgBox "没有任何满足条件旳记录", vbOKOnly, "信息提示" End IfCall encommEnd SubPrivate Sub selcmd2_Click() '重置Text1(0).Text = ""Text1(1).Text = ""Text1(2).Text = ""Text1(3).Text = ""Text1(4).Text = ""End SubPrivate Sub encomm() '自定义子过程:判断Adodc1中与否存在记录If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) Call endata(KeyAscii)End SubEdbook1:Dim rs As ADODB.RecordsetPrivate Sub Form_Load()If flag = 2 Then '修改操作Text1(0).Text = edbook.Adodc1.Recordset.Fields("图书编号") & ""Text1(1).Text = edbook.Adodc1.Recordset.Fields("分类号") & ""Text1(2).Text = edbook.Adodc1.Recordset.Fields("书名") & ""Text1(3).Text = edbook.Adodc1.Recordset.Fields("作者") & ""DataCombo1.Text = edbook.Adodc1.Recordset.Fields("出版社") & ""Text1(4).Text = edbook.Adodc1.Recordset.Fields("定价") & ""Text1(5).Text = edbook.Adodc1.Recordset.Fields("入库日期") & ""Text1(0).Enabled = FalseElse '添加操作Text1(5).Text = DateEnd IfEnd SubPrivate Sub Form_Activate()Adodc1.Refresh '数据源刷新End SubPrivate Sub Comm1_Click()If Trim(Text1(0).Text) = "" Or Trim(Text1(2).Text) = "" Or Trim(Text1(3).Text) = "" Or Trim(Text1(5).Text) = "" ThenMsgBox "加*数据项不能为空,请重新设立", vbOKOnly, "信息提示"Exit SubEnd IfIf flag = 1 Then '添加操作sqltxt = "select * from book where 图书编号='" + Trim(Text1(0).Text) + "'" '对book中记录进行判断Set rs = exesql(sqltxt)If rs.RecordCount <> 0 ThenMsgBox "存在相似旳图书编号", vbOKOnly, "信息提示"Text1(0).SetFocusrs.CloseExit SubElsers.CloseEnd Ifedbook.Adodc1.Recordset.AddNewedbook.Adodc1.Recordset.Fields("图书编号") = Trim(Text1(0).Text)edbook.Adodc1.Recordset.Fields("分类号") = Trim(Text1(1).Text)edbook.Adodc1.Recordset.Fields("书名") = Trim(Text1(2).Text)edbook.Adodc1.Recordset.Fields("作者") = Trim(Text1(3).Text)edbook.Adodc1.Recordset.Fields("出版社") = Trim(DataCombo1.Text)edbook.Adodc1.Recordset.Fields("定价") = Val(Trim(Text1(4).Text))edbook.Adodc1.Recordset.Fields("入库日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edbook.Adodc1.Recordset.Fields("借否") = "否"edbook.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作edbook.Adodc1.Recordset.Fields("图书编号") = Trim(Text1(0).Text)edbook.Adodc1.Recordset.Fields("分类号") = Trim(Text1(1).Text)edbook.Adodc1.Recordset.Fields("书名") = Trim(Text1(2).Text)edbook.Adodc1.Recordset.Fields("作者") = Trim(Text1(3).Text)edbook.Adodc1.Recordset.Fields("出版社") = Trim(DataCombo1.Text)edbook.Adodc1.Recordset.Fields("定价") = Val(Trim(Text1(4).Text))edbook.Adodc1.Recordset.Fields("入库日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edbook.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubPrivate Sub selcom_Click()tna = "press"cap = "出版社"edrec.Show vbModalEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)If Index = 1 ThenIf KeyAscii = 13 Thensqltxt = "select * from book where 分类号='" + Trim(Text1(1).Text) + "'" '对book中记录进行判断Set rs = exesql(sqltxt)If rs.RecordCount > 0 ThenText1(2).Text = rs.Fields("书名")Text1(3).Text = rs.Fields("作者")Text1(4).Text = rs.Fields("定价")DataCombo1.Text = rs.Fields("出版社")rs.CloseText1(5).SetFocusElseCall endata(KeyAscii)End IfEnd IfElseCall endata(KeyAscii)End IfEnd SubPrivate Sub DataCombo1_KeyPress(KeyAscii As Integer) Call endata(KeyAscii)End SubDim msg As StringPrivate Sub Form_Load()recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate()Call encommEnd SubPrivate Sub Comm1_Click()flag = 1edlev1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edlev1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("级别")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Unload MeEnd SubPrivate Sub encomm()If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubDim cond As StringPrivate Sub Form_Load()If flag = 2 ThenText1(0).Text = edlev.Adodc1.Recordset.Fields("级别")Text1(1).Text = edlev.Adodc1.Recordset.Fields("过期罚款")Text1(2).Text = edlev.Adodc1.Recordset.Fields("借书总数")Text1(3).Text = edlev.Adodc1.Recordset.Fields("借书天数")End IfEnd SubPrivate Sub Comm1_Click()If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Text1(2).Text) = "" Or _ Trim(Text1(3).Text) = "" ThenMsgBox "数据项不全,请重新设立", vbOKOnly, "信息提示"Text1(0).SetFocusExit SubEnd IfIf flag = 1 Then '添加操作If edlev.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0cond = "级别='" + Trim(Text1(0).Text) + "'"edlev.Adodc1.Recordset.MoveFirst '每次从头开始查找edlev.Adodc1.Recordset.Find (cond)If Not edlev.Adodc1.Recordset.EOF() ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"Text1(0).SetFocusExit SubEnd IfEnd Ifedlev.Adodc1.Recordset.AddNewedlev.Adodc1.Recordset.Fields("级别") = Trim(Text1(0).Text)edlev.Adodc1.Recordset.Fields("过期罚款") = Val(Trim(Text1(1).Text))edlev.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(2).Text))edlev.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(3).Text))edlev.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作n = edlev.Adodc1.Recordset.AbsolutePositioncond = "级别='" + Trim(Text1(0).Text) + "'"edlev.Adodc1.Recordset.MoveFirst '每次从头开始查找edlev.Adodc1.Recordset.Find (cond)If Not edlev.Adodc1.Recordset.EOF() And edlev.Adodc1.Recordset.AbsolutePosition <> n ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"edlev.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edlev.Adodc1.Recordset.Move (n - 1)Text1(0).SetFocusExit SubEnd Ifedlev.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edlev.Adodc1.Recordset.Move (n - 1)edlev.Adodc1.Recordset.Fields("级别") = Trim(Text1(0).Text)edlev.Adodc1.Recordset.Fields("过期罚款") = Val(Trim(Text1(1).Text))edlev.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(2).Text))edlev.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(3).Text))edlev.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubEdreader:Private Sub DataGrid1_Click()End SubPrivate Sub Form_Load()recs = Adodc1.Recordset.RecordCountEnd SubPrivate Sub Form_Activate()DataGrid1.SetFocusCall encommEnd SubPrivate Sub Comm1_Click()flag = 1edreader1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edreader1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("姓名")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Unload MeEnd SubPrivate Sub selcmd1_Click() '设立条件拟定Dim str As Stringstr = "" '条件体现式If Trim(Text1(0).Text) <> "" ThenIf str = "" Thenstr = "借书证号='" + Trim(Text1(0).Text) + "'"Elsestr = str + " and 借书证号='" + Trim(Text1(0).Text) + "'"End IfEnd IfIf Trim(Text1(1).Text) <> "" ThenIf str = "" Thenstr = "姓名='" + Trim(Text1(1).Text) + "'"Elsestr = str + " and 姓名='" + Trim(Text1(1).Text) + "'"End IfEnd IfIf Trim(Text1(2).Text) <> "" ThenIf str = "" Thenstr = "单位='" + Trim(Text1(2).Text) + "'"Elsestr = str + " and 单位='" + Trim(Text1(2).Text) + "'"End IfEnd IfIf Trim(Text1(3).Text) <> "" ThenIf str = "" Thenstr = "级别='" + Trim(Text1(3).Text) + "'"Elsestr = str + " and 级别='" + Trim(Text1(3).Text) + "'"End IfEnd IfIf Trim(Text1(4).Text) <> "" ThenIf str = "" Thenstr = "性别='" + Trim(Text1(4).Text) + "'"Elsestr = str + " and 性别='" + Trim(Text1(4).Text) + "'"End IfEnd IfIf str <> "" ThenAdodc1.RecordSource = "select * from reader where " + strAdodc1.RefreshElseAdodc1.RecordSource = "select * from reader"Adodc1.RefreshEnd Ifrecs = Adodc1.Recordset.RecordCountIf recs = 0 ThenMsgBox "没有任何满足条件旳记录", vbOKOnly, "信息提示" End IfCall encommEnd SubPrivate Sub selcmd2_Click() '设立条件重置Text1(0).Text = ""Text1(1).Text = ""Text1(2).Text = ""Text1(3).Text = ""Text1(4).Text = ""End SubPrivate Sub encomm() '自定义子过程:判断Adodc1中与否存在记录If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) Call endata(KeyAscii)End SubEdreader1:Dim rs As ADODB.RecordsetPrivate Sub Form_Load()If flag = 2 Then '修改操作Text1(0).Text = edreader.Adodc1.Recordset.Fields("借书证号") & ""Text1(1).Text = edreader.Adodc1.Recordset.Fields("姓名") & ""If edreader.Adodc1.Recordset.Fields("性别") = "男" Thenopt1.Value = TrueElseopt2.Value = TrueEnd IfDataCombo2.Text = edreader.Adodc1.Recordset.Fields("单位") & ""DataCombo1.Text = edreader.Adodc1.Recordset.Fields("级别") & ""Text1(2).Text = edreader.Adodc1.Recordset.Fields("过期罚款") & ""Text1(3).Text = edreader.Adodc1.Recordset.Fields("借书总数") & ""Text1(4).Text = edreader.Adodc1.Recordset.Fields("借书天数") & ""Text1(5).Text = edreader.Adodc1.Recordset.Fields("登记日期") & ""Text1(0).Enabled = FalseElse '添加操作Text1(5).Text = DateEnd IfEnd SubPrivate Sub Form_Activate()Adodc1.Refresh '数据源刷新Adodc2.Refresh '数据源刷新DataCombo1.RefreshDataCombo2.RefreshEnd SubPrivate Sub Comm1_Click()If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Text1(5).Text) = "" Or Trim(DataCombo1.Text) = "" ThenMsgBox "加*数据项不能为空,请重新设立", vbOKOnly, "信息提示"Exit SubEnd IfIf flag = 1 Then '添加操作sqltxt = "select * from reader where 借书证号='" + Trim(Text1(0).Text) + "'" '对reader中记录进行判断Set rs = exesql(sqltxt)If rs.RecordCount <> 0 ThenMsgBox "存在相似旳借书证号", vbOKOnly, "信息提示"Text1(0).SetFocusrs.CloseExit SubElsers.CloseEnd Ifedreader.Adodc1.Recordset.AddNewedreader.Adodc1.Recordset.Fields("借书证号") = Trim(Text1(0).Text)edreader.Adodc1.Recordset.Fields("姓名") = Trim(Text1(1).Text)If opt1.Value = True Thenedreader.Adodc1.Recordset.Fields("性别") = "男"Elseedreader.Adodc1.Recordset.Fields("性别") = "女"End Ifedreader.Adodc1.Recordset.Fields("单位") = Trim(DataCombo2.Text)edreader.Adodc1.Recordset.Fields("级别") = Trim(DataCombo1.Text)edreader.Adodc1.Recordset.Fields("过期罚款") = Trim(Text1(2).Text)edreader.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(3).Text))edreader.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(4).Text))edreader.Adodc1.Recordset.Fields("已借书数") = 0edreader.Adodc1.Recordset.Fields("登记日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edreader.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作edreader.Adodc1.Recordset.Fields("借书证号") = Trim(Text1(0).Text)edreader.Adodc1.Recordset.Fields("姓名") = Trim(Text1(1).Text)If opt1.Value = True Thenedreader.Adodc1.Recordset.Fields("性别") = "男"Elseedreader.Adodc1.Recordset.Fields("性别") = "女"End Ifedreader.Adodc1.Recordset.Fields("单位") = Trim(DataCombo2.Text)edreader.Adodc1.Recordset.Fields("级别") = Trim(DataCombo1.Text)edreader.Adodc1.Recordset.Fields("过期罚款") = Trim(Text1(2).Text)edreader.Adodc1.Recordset.Fields("借书总数") = Val(Trim(Text1(3).Text))edreader.Adodc1.Recordset.Fields("借书天数") = Val(Trim(Text1(4).Text))edreader.Adodc1.Recordset.Fields("登记日期") = Format(Trim(Text1(5).Text), "yyyy-mm-dd")edreader.Adodc1.Recordset.Updateedreader.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubPrivate Sub selcom1_Click()edlev.Show vbModalEnd SubPrivate Sub selcom2_Click()tna = "depart"cap = "单位"edrec.Show vbModalEnd SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)Call endata(KeyAscii)End SubPrivate Sub DataCombo1_LostFocus()If Adodc1.Recordset.RecordCount > 0 ThenIf Trim(DataCombo1.Text) <> "" ThenAdodc1.Recordset.MoveFirstAdodc1.Recordset.Find ("级别='" & Trim(DataCombo1.Text) & "'")Text1(2).Text = Adodc1.Recordset.Fields("过期罚款")Text1(3).Text = Adodc1.Recordset.Fields("借书总数")Text1(4).Text = Adodc1.Recordset.Fields("借书天数")End IfElseMsgBox "没有任何级别项可选,请设立", vbOKOnly, "信息提示" End IfEnd SubPrivate Sub DataCombo1_KeyPress(KeyAscii As Integer)Call endata(KeyAscii)End SubPrivate Sub DataCombo2_KeyPress(KeyAscii As Integer)endata (KeyAscii)End SubDim msg As StringPrivate Sub Form_Load()Adodc1.RecordSource = "select * from " + tnaAdodc1.Refreshrecs = Adodc1.Recordset.RecordCountDataGrid1.Columns(0).Caption = capDataGrid1.Columns(0).DataField = "fn"End SubPrivate Sub Form_Activate()Call encommEnd SubPrivate Sub Comm1_Click()flag = 1edrec1.Show vbModalEnd SubPrivate Sub Comm2_Click()flag = 2edrec1.Show vbModalEnd SubPrivate Sub Comm3_Click()If MsgBox("真旳要删除[" + Trim(Adodc1.Recordset.Fields("fn")) + "]吗?", vbYesNo, "信息提示") = vbYes ThenAdodc1.Recordset.Deleterecs = recs - 1Call encommEnd IfEnd SubPrivate Sub Comm4_Click()Adodc1.Recordset.UpdateBatchAdodc1.Recordset.CloseUnload MeEnd SubPrivate Sub encomm()If recs = 0 ThenComm2.Enabled = FalseComm3.Enabled = FalseElseComm2.Enabled = TrueComm3.Enabled = TrueEnd IfEnd SubDim cond As StringPrivate Sub Form_Load()Label1.Caption = capIf flag = 1 ThenText1.Text = ""ElseText1.Text = edrec.Adodc1.Recordset.Fields("fn")End IfEnd SubPrivate Sub Comm1_Click()If Trim(Text1.Text) = "" ThenMsgBox "数据项不能为空,请重新设立", vbOKOnly, "信息提示"Text1.SetFocusExit SubEnd IfIf flag = 1 Then '添加操作If edrec.Adodc1.Recordset.RecordCount > 0 Then '原记录个数大于0cond = "fn='" + Trim(Text1.Text) + "'"edrec.Adodc1.Recordset.MoveFirst '每次从头开始查找edrec.Adodc1.Recordset.Find (cond)If Not edrec.Adodc1.Recordset.EOF() ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"Text1.SetFocusExit SubEnd IfEnd Ifedrec.Adodc1.Recordset.AddNewedrec.Adodc1.Recordset.Fields("fn") = Trim(Text1.Text)edrec.Adodc1.Recordset.Updaterecs = recs + 1Else '修改操作n = edrec.Adodc1.Recordset.AbsolutePositioncond = "fn='" + Trim(Text1.Text) + "'"edrec.Adodc1.Recordset.MoveFirst '每次从头开始查找edrec.Adodc1.Recordset.Find (cond)If Not edrec.Adodc1.Recordset.EOF() And edrec.Adodc1.Recordset.AbsolutePosition <> n ThenMsgBox "存在完全相似旳记录", vbOKOnly, "信息提示"edrec.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edrec.Adodc1.Recordset.Move (n - 1)Text1.SetFocusExit SubEnd Ifedrec.Adodc1.Recordset.MoveFirst '这两个语句恢复原记录位置edrec.Adodc1.Recordset.Move (n - 1)edrec.Adodc1.Recordset.Fields("fn") = Trim(Text1.Text)edrec.Adodc1.Recordset.UpdateEnd IfUnload MeEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubMenu:Private Sub MDIForm_Load()If Not userlevel = "系统管理员" Thenmenu21.Enabled = Falsemenu31.Enabled = Falsemenu41.Enabled = Falsemenu42.Enabled = FalseEnd IfEnd SubPrivate Sub menu11_Click()borbook.Show vbModalEnd SubPrivate Sub menu12_Click()retbook.Show vbModalEnd SubPrivate Sub menu13_Click()EndEnd SubPrivate Sub menu21_Click()edbook.Show vbModalEnd SubPrivate Sub menu22_Click()qubook.Show vbModalEnd SubPrivate Sub menu31_Click()edreader.Show vbModalEnd SubPrivate Sub menu32_Click()qureader.Show vbModalEnd SubPrivate Sub menu41_Click()setuser.Show vbModalEnd SubPrivate Sub menu42_Click()If MsgBox("本功能要清除系统中所有数据,真旳初始化吗?", vbYesNo, "确认初始化操作")= vbYes ThenCall deldata("book")Call deldata("reader")Call deldata("borrow")Call deldata("rlevel")Call deldata("depart")Call deldata("press")Call deldata("oper")MsgBox "系统初始化完毕,下次只能以1234/1234(顾客名/口令)进入本系统", vbOKOnly, "信息提示"End IfEnd SubPass:Public n As IntegerPrivate Sub Command1_Click()Dim mrc As ADODB.Recordsettxtsql = "select * from oper where 顾客名='" & _Trim$(Text1(0).Text) & "'" & " And 口令= '" & Trim$(Text1(1).Text) + "'"Set mrc = exesql(txtsql)If mrc.RecordCount = 0 Then '未找到顾客记录n = n + 1If n < 3 ThenMsgBox "没有这个顾客,继续登录", vbOKOnly + vbExclamation, "信息提示"Text1(0).Text = ""Text1(1).Text = ""Text1(0).SetFocusElseMsgBox "已登录失败三次,退出系统", vbOKOnly + vbExclamation, "信息提示"mrc.CloseUnload MeEnd IfElse '找到合法顾客记录userlevel = Trim(mrc.Fields("级别"))mrc.CloseUnload Memenu.Show '调用menu窗体End IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()n = 0 'n保存登录旳次数End SubPrivate Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)Call endata(KeyAscii)End SubQubook:Private Sub Comm1_Click()Dim sqltxt As StringIf Adodc1.Recordset.Fields("借否") = "借" Thenno = Trim(Adodc1.Recordset.Fields("图书编号"))sqltxt = "select * from borrow where 图书编号='" + no + "'"Set rs = exesql(sqltxt)If rs.RecordCount = 0 ThenMsgBox "该图书没有借书记录", vbOKOnly, "信息提示"ElseMsgBox "图书编号:" + no + Chr(10) + Chr(13) + _"书名:" + Trim(rs.Fields("书名")) + Chr(10) + Chr(13) + _"借书人:" + Trim(rs.Fields("姓名")) + Chr(10) + Chr(13) + _"单位:" + Trim(rs.Fields("单位")) + Chr(10) + Chr(13) + _"借书日期:" + Format(rs.Fields("借书日期"), "yyyy.mm.dd"), vbOKOnly, "查找成果"End Ifrs.CloseElseMsgBox "该书没有外借,不能显示借书人", vbOKOnly, "信息提示"End IfEnd SubPrivate Sub Comm2_Click()Unload MeEnd SubPrivate Sub Form_Activate()Adodc1.RefreshDataGrid1.RefreshDataGrid1.SetFocusCall encommEnd SubPrivate Sub selcmd1_Click() '设立条件拟定Dim str As Stringstr = "" '条件体现式If Trim(Text1(0).Text) <> "" ThenIf str = "" Thenstr = "图书编号='" + Trim(Text1(0).Text) + "'"Elsestr = str + " and 图书编号='" + Trim(Text1(0).Text) + "'"End IfEnd IfIf Trim(Text1(1).Text) <> "" ThenIf str = "" Thenstr = "书名='" + Trim(Text1(1).Text) + "'"Elsestr = str + " and 书名='" + Trim(Text1(1).Text) + "'"End IfEnd IfIf Trim(Text1(2).Text) <> "" ThenIf str = "" Thenstr = "作者='" + Trim(Text1(2).Text) + "'"Elsestr = str + " and 作者='" + Trim(Text1(2).Text) + "'"End IfEnd IfIf Trim(Text1(3).Text) <> "" ThenIf str = "" Thenstr = "出版社='" + Trim(Text1(3).Text) + "'"Elsestr = str + " and 出版社='" + Trim(Text1(3).Text) + "'"End IfEnd IfIf Trim(Text1(4).Text) <> "" ThenIf str = "" Thenstr = "借否='" + Trim(Text1(4).Text) + "'"Elsestr = str + " and 借否='" + Trim(Text1(4).Text) + "'"End IfEnd IfIf Trim(Text1(5).Text) <> "" ThenIf str = "" Thenstr = "定价=" + Trim(Text1(5).Text)Elsestr = str + " and 定价=" + Trim(Text1(5).Text)End IfEnd IfIf str <> "" ThenAdodc1.RecordSource = "select * from book where " + strAdodc1.RefreshElseAdodc1.RecordSource = "select * from book"Adodc1.RefreshEnd IfIf Adodc1.Recordset.RecordCount = 0 ThenMsgBox "没有任何满足条件旳记录", vbOKOnly, "信息提示"。

图书管理系统数据库设计

图书管理系统数据库设计

图书管理系统数据库设计1. 引言图书管理系统是一个用于管理图书馆馆藏图书的软件系统。

它提供了图书的借阅、归还、查询等功能,方便读者进行图书借阅和图书馆管理员进行图书管理。

本文档将介绍图书管理系统的数据库设计。

通过组织图书、读者、借阅记录等相关数据,实现图书管理系统的各项功能。

2. 数据库设计2.1 数据库结构图书管理系统的数据库主要包含以下几个表:•图书表(books):存储图书的基本信息,如图书编号、名称、作者、出版社等。

•读者表(readers):存储读者的基本信息,如读者编号、姓名、性别、年龄等。

•借阅记录表(borrow_records):存储图书的借阅记录,包括借阅编号、借阅日期、归还日期、读者编号等。

2.2 数据库字段2.2.1 图书表(books)•book_id:图书编号,主键•book_name:图书名称•author:作者•publisher:出版社•publication_date:出版日期•price:价格2.2.2 读者表(readers)•reader_id:读者编号,主键•reader_name:读者姓名•gender:性别•age:年龄•phone:联系电话2.2.3 借阅记录表(borrow_records)•record_id:借阅记录编号,主键•book_id:借阅图书编号,外键•reader_id:借阅读者编号,外键•borrow_date:借阅日期•return_date:归还日期2.3 数据库关系•图书表与读者表之间是多对多的关系,通过借阅记录表进行关联。

•图书表与借阅记录表是一对多的关系,一个图书可以对应多条借阅记录。

•读者表与借阅记录表也是一对多的关系,一个读者可以借阅多本图书。

2.4 数据库约束•图书编号(book_id)在图书表中是唯一的,不能重复。

•读者编号(reader_id)在读者表中是唯一的,不能重复。

•借阅记录编号(record_id)在借阅记录表中是唯一的,不能重复。

高校图书馆管理系统(SQL数据库)

高校图书馆管理系统(SQL数据库)

高校图书馆管理系统(SQL数据库)高校图书馆管理系统(SQL数据库)随着信息技术的发展,高校图书馆管理系统在图书馆运营中的重要性日益凸显。

为了更好地管理馆藏资源和提供优质的服务,许多高校选择使用SQL数据库作为图书馆管理系统的基础。

本文将探讨高校图书馆管理系统中SQL数据库的应用及其优势。

一、图书馆管理系统简介图书馆管理系统是高校图书馆中的核心业务系统,它涵盖了图书馆的各个环节,包括图书采购、编目、借阅、归还、查询等功能。

通过图书馆管理系统,读者可以方便地查找、借阅和归还图书,图书馆工作人员也可以高效地管理馆藏资源。

二、SQL数据库在图书馆管理系统中的应用1. 数据库设计在图书馆管理系统中,SQL数据库的设计是至关重要的一环。

通过合理的数据库设计,可以提高系统的查询效率和安全性。

例如,可以将图书馆中的书籍信息、读者信息、借阅记录等存储在不同的数据库表中,并通过外键关联它们,实现数据的联合查询。

2. 图书馆资源管理SQL数据库提供了强大的查询和管理功能,可以方便地进行图书馆资源管理。

通过SQL语句,图书馆管理员可以实现对图书馆馆藏资源进行分类、检索和统计。

同时,SQL数据库还支持数据的备份和恢复,保障了图书馆数据的安全性。

3. 借阅管理借阅管理是图书馆管理系统中的核心功能之一。

SQL数据库可以存储读者的借阅记录,包括借阅时间、归还时间、借阅状态等信息。

通过SQL查询语句,管理员可以实时监控图书的借阅情况,及时催还逾期图书。

4. 读者管理通过SQL数据库,图书馆管理员可以方便地管理读者信息。

包括读者的个人信息、借阅历史记录、借阅限制等。

管理员可以针对不同的读者类型设置不同的借阅权限,确保图书馆资源的合理利用。

5. 统计和报表SQL数据库提供了强大的统计和报表功能,方便图书馆管理员进行图书馆运营效果的评估。

通过SQL查询语句,可以得到图书馆的借阅量、图书馆藏资源的流通情况等各项指标,为图书馆决策提供有力支持。

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

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

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

图书馆管理系统SQL数据库

图书馆管理系统SQL数据库

图书馆管理系统S Q L数据库Document number【AA80KGB-AA98YT-AAT8CB-2A6UT-A18GG】摘要在计算机日益普及的今天,对个人而言若采用一套行之有效的图书管理系统来管理自己的书籍,会方便许多。

对图书管理部门而言,以前单一的手工检索已不能满足人们的要求,往往是投入了大量的人力和财力却得不到高效的管理效率。

为了便于图书资料的管理需要有效的图书管理软件,减轻工作人员的工作量,方便工作人员对它的操作,提高管理的质量和水平,做到高效、智能化管理,达到提高图书借阅信息管理效率的目的。

采用数据库技术生成的图书馆借阅管理系统将会极大地方便借阅者并简化图书馆管理人员和工作人员的劳动,使工作人员从繁忙、复杂的工作进入到一个简单、高效的工作中关键字:图书借阅;人员管理;图书维护。

目录1.引言随着社会信息量的与日俱增,职场竞争的日趋激烈,越来越多的人更关注知识的积累、能力的培养。

作为信息存储的主要媒体之一图书,数量、规模比以往任何时候都大的多,不论个人还是图书管理部门都需要使用方便而有效的方式来管理自己的书籍。

在计算机日益普及的今天,对个人而言若采用一套行之有效的图书管理系统来管理自己的书籍,会方便许多。

对图书管理部门而言,以前单一的手工检索已不能满足人们的要求,为了便于图书资料的管理需要有效的图书管理软件。

对于日益扩大的图书馆,查找特定的书目总是借阅者或工作人员劳神费力,有时还没有结果。

因此往往是投入了大量的人力和财力却得不到高效的管理效率。

为了缩短借阅者的等待时间,减轻工作人员的工作量,方便工作人员对它的操作,提高管理的质量和水平,做到高效、智能化管理,从而达到提高图书借阅信息管理效率的目的,采用数据库技术生成的图书馆借阅管理系统将会极大地方便借阅者并简化图书馆管理人员和工作人员的劳动,使工作人员从繁忙、复杂的工作进入到一个简单、高效的工作中。

本文以高校图书馆管理系统管理系统开发过程为背景,全文分为目录、需求分析、概要设计、逻辑设计、物理设计,以及系统的实现等全过程。

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

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

图书借阅管理系统代码图书管理系统源代码#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;}。

数据库图书信息管理数据库SQL语句

数据库图书信息管理数据库SQL语句

实验 SQL语言一、实验目的1、理解数据库以及数据表的设计;2、熟悉SQL Server2005中的数据类型;3、熟悉使用SQL语句创建和删除模式和索引;4、掌握使用SQL语句创建、修改和删除数据表;5、掌握使用SQL语句查询表中的数据;6、掌握使用SQL语句插入、修改和删除数据表中的数据;7、掌握使用SQL语句创建、删除、查询和更新视图。

二、实验内容(一)创建数据库和模式1、通过SQL语句创建图书信息管理数据库,命名为“db_Library”,数据文件和日志文件放在D盘下以自己学号和姓名命名的文件夹中,数据文件的逻辑名为db_Library_data,数据文件的操作系统名为db_Library_data.mdf,文件初始大小为10MB,最大可增加至300MB,增幅为10%;日志文件的逻辑名为db_Library_log,日志文件的操作系统名为db_Library_data.ldf,文件初始大小为5MB,最大可增加至200MB,增幅为2MB。

2、通过SQL语句在该数据库中创建模式L-C。

(二)创建和管理数据表要求为各数据表的字段选择合适的数据类型及名称;为各数据表设置相应的完整性约束条件。

1、通过SQL语句将以下数据表创建在L-C模式下:课程信息表(tb_course)——课程编号Course number 、课程名Course name 、先修课The first course 、学分credit2、通过SQL语句将以下数据表创建在该数据库的默认模式dbo下:图书类别信息表(tb_booktype)——类别编号Type number 、类别名称Category name图书信息表(tb_book)——图书编号ISBN 、类别编号Type number、书名title 、作者author、出版社BookPublic、定价BookPrice、库存数Inventory number读者信息表(tb_reader)——读者编号Reader ID 、姓名、性别、学号Student ID 、班级、系部pastern借阅信息表(tb_borrow)——图书编号、读者编号、借阅日期Borrowing date 、归还日期Return date3、通过SQL语句对读者信息表进行修改:删除系部字段、添加所在系字段。

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

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

毕业设计_图书管理系统一、数据库设计数据库设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{。

java+swing+mysql图书管理系统(附完整源代码)

java+swing+mysql图书管理系统(附完整源代码)

课程设计精品图书If理系统书生系统说明:本系统釆用eclipse开发,IDEA, eclipse, myedipse均可运行界面采用swing实现数据库:mysql.附sql代码,其余数据库可复制sql代码运行数据库连接文件mysql-connector-java-8.0.16.jar本系统的背景图片可根据自己的需求替换项目分为管理员和普通用户两种角色管理员有图书査询、图书借还、账户管理(修改密码、账户信息、借书记录)、图书管理(増加、修改、删除)的权限普通用户有图书査询、图书借还、账户管理(修改密码、借书记录)的权限项目结朴-温图书系饨>,JRE 基绽库(JavaSE-12]IS src y .[« Dao>dZl AdminDao.java>® BookDao.java><2)BorrowDao.java>I/) DB.java>El LandDao.javav SB Test>JZ) LandTest.java击View>ABorrowBookFace.java 通AccountMsgFacejava>i£\ AddBookFace.java>(2 AdminFace.java>Lfi BookAdminFace.java>® BookReturnFace.java>Si BookSearc h Fac e.java>DeleteBookFace.java>JZ) LogonFace.java>Si MainFace.java>JZl UBorrowBookFace.java><2)UpdateBookFace.java>UpdatePswFace.java>E) UserFace.java> i引用的阵y 4 datebase圍tsglsys.sql〜〜img。

Java+MySQL实现图书管理系统(完整代码)

Java+MySQL实现图书管理系统(完整代码)

Java+MySQL实现图书管理系统(完整代码)(完整代码+实训报告):觉着有⽤就点个赞哦~⼀,功能1. 管理员登录2. 图书借阅信息管理3. 图书信息管理4. 管理员更改密码5. 退出系统⼆,⼯具Eclipse Version: 2018-09 (4.9.0)MySQL Workbench 8.0 CEmysql-connector-java-8.0.13.jar三、效果图:登录界⾯:主界⾯:借阅书籍管理:个⼈书库管理:更改密码:四、数据库设计1)图书表2)⽤户表两个数据表间没有关联:五、JAVA层次分析(1)逻辑图(2)包结构,采⽤MVC三层架构组织各个模块六、主要Java代码分析Dao类(以BookDao为例)package pers.cyz.dao;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;import java.util.List;import pers.cyz.model.Book;import pers.cyz.util.DBUtil;/*** 数据库图书表信息数据访问对象类,包含增加图书信息、删除图书信息* 、更新图书信息、查询图书信息、查询借阅信息和归还图书** @author 1651200111 陈彦志*/public class BookDao {/*** 增加图书信息*/public void addBook(Book book) throws Exception{// ⾸先拿到数据库的连接Connection con = DBUtil.getConnection();String sql="insert into tb_books"// ISBN、书名、图书价格、图书作者、出版社+ "(ISBN, book_name, book_price, book_author, published_house,"// 分类号、借书⼈姓名、借书⼈电话、借书⽇期,已借天数+ "book_category, borrower_name, borrower_phone) "+ "values("/** 参数⽤?表⽰,相当于占位符,然后在对参数进⾏赋值。

SQL数据库图书管理系统(完整代码)

SQL数据库图书管理系统(完整代码)

广西交通职业技术学院信息工程系作品设计报告书题目:《图书管理系统》班级网络2012-1班学号 20120404026姓名唐张森课程名称数据库应用技术指导教师乐文行二O一三年六月目录数据库课程设计报告书一、设计目标1.掌握计算机管理信息系统设计的一般方法,主要包括系统分析、系统设计的组织和实施。

2.关系型数据库管理系统的编程技术,并能独立完成一般小系统的程序设计、调试运行等工作。

3.培养把所学知识运用到具体对象,并能求出解决方案的能力。

二、数据库存储设计指导思想在数据库存储设计的无数选择中,简单是系统架构师和 DBA 的秘密武器。

简单,有时候就来自于对一个特定的表或表空间没有选择最优 I/O 特性,总有这么一种可能,一个富有经验的 DBA 拥有高超的存储技能并可以没有时间限制的去为一个非常重要的表或者索引配置一个存储。

然而这样做的问题是,就算能达到设计的最佳性能,为了维护原始对象,这也经常造成对一个系统的管理变得更加复杂。

好的数据库存储设计的要点是,在一个动态系统上,实现所有目标应该是最初的系统设计的一部分,并应该在数据库运行过程中长期进行。

这篇文档简单的最佳实践描述达到了这些目标并且几乎没有性能损失。

三、任务角色:读者、图书馆馆员、系统管理员;基础数据:读者信息、图书信息、操作员信息;业务数据:借还书记录登记、罚款登记;统计数据:书籍借阅情况统计或读者借阅情况统计。

基本要求:利用数据库技术,完成基础数据和业务数据的储存和操作,数据库设计合理1.设计报告:含E-R图、数据字典、关系模式、关系实例、查询描述、关系代数、SQL 实现的查询语言及查询结果。

2.上机实现。

1.问题描述1.1背景随着图书馆规模的不断扩大,图书数量也相应的增加,有关图书的各种信息量也成倍增加,面对着庞大的信息量,传统的人工方式管理会导致图书馆管理上的混乱,人力与物力过多浪费,图书馆管理费用的增加,从而使图书馆的负担过重,影响整个图书馆的运作和控制管理,因此,必须制定一套合理、有效,规范和实用的图书管理系统,对图书资料进行集中统一的管理。

小型数据库应用系统开发

小型数据库应用系统开发

小型数据库应用系统开发1.建立数据库“图书管理系统”,向数据库中添加操作员表、借书还书表、图书表以及相应数据2.设计图书馆管理系统的登录窗口w_xitongdenglu:“登录”按钮cb_1的代码如下:// Profile 图书管理系统SQLCA.DBMS = "ODBC"SQLCA.AutoCommit = FalseSQLCA.DBParm = "Connectstring='DSN=图书管理系统'"//连接数据库connect;//检索用户名和密码记录string username, passwordselect 操作员表.用户名,操作员表.密码into :username,:passwordfrom 操作员表where 操作员表.用户名= :sle_1.text ;//判断用户输入的用户名是否正确,正确就打开w_main主窗口if username=sle_1.text and password=sle_2.text thenopen(w_main)//打开图书管理系统主界面close(parent)end if3.设计系统主窗口w_main ,窗口与主菜单mainmenu相连,通过其可进行图书管理4.设计主菜单并添加代码使菜单与相关窗口相联系5.修改密码窗口w_xiugaimima :“确定”按钮cb_1的代码:string username, passwordselect "操作员表"."用户名","操作员表"."密码"into :username,:passwordfrom "操作员表"where "操作员表"."用户名" = :sle_1.text ;//判断输入的用户名是否正确//更改密码if username=sle_1.text and password=sle_2.text thenupdate "操作员表"set "密码" = :sle_3.textwhere "操作员表"."用户名" = :sle_1.text ;if sle_3.text<>sle_4.text thenmessagebox("错误!","新密码两次输入不相同!",exclamation!,ok!,2)elsemessagebox("成功!","密码已被更改,请记住改后密码!",exclamation!,ok!,2) end ifend if6.借还书窗口w_jiehuanshu :“借书”按钮cb_1的代码://显示特定会员和图书的借阅记录dw_1.settransobject(SQLCA)dw_1.setfilter("会员编号='"+trim(sle_1.text)+"' and 图书编号='"+trim(sle_2.text)+"'") //trim修剪,删减dw_1.retrieve()dw_2.settransobject(SQLCA)dw_2.setfilter("图书编号='"+trim(sle_2.text)+"'") //trim修剪,删减dw_2.retrieve()//得到记录的总行书int m,n//得到借书记录总行数和图书当前行号if dw_2.retrieve()=1 thenm=dw_1.rowcount()n=dw_2.getrow()if dw_2.object.库存[n]>0 then//插入借书记录dw_1.insertrow(m+1)dw_1.scrolltorow(m+1)dw_1.object.会员编号[m+1]=sle_1.textdw_1.object.图书编号[m+1]=sle_2.textdw_1.object.借书日期[m+1]= string(today())dw_1.object.备注[m+1]= "未归还"//库存减1dw_2.object.库存[n]=dw_2.object.库存[n]-1//更新数据库if dw_1.update()=1 and dw_1.update()=1 thencommit;messagebox("成功!","更新数据库成功!")elserollback;messagebox("失败!","更新数据库失败!")end ifelse//提示用户不能借书的原因messagebox("错误!","库存不足或您的卡号被锁定,会员或图书不存在,无法借阅!",exclamation!,ok!,2)end ifend if“还书”按钮cb_2的代码://显示特定会员和图书的借阅记录dw_1.settransobject(sqlca)dw_1.setfilter("会员编号='"+trim(sle_1.text)+"' and 图书编号='"+trim(sle_2.text)+"' and 备注='未归还'")dw_1.retrieve()dw_2.settransobject(sqlca)dw_2.setfilter("图书编号='"+trim(sle_2.text)+"'" )dw_2.retrieve()//判断哪一行为还书记录int nn=dw_1.rowcount() //记录数if dw_1.retrieve()=1 or n>1 then//找到还书记录后修改记录dw_1.object.还书日期[n]= string(today())dw_1.object.备注[n]= "已归还"//end if//将会员还的书库存加1int mm=dw_2.getrow()dw_2.object.库存[m]=dw_2.object.库存[m]+1//更新数据库if dw_1.update()=1 and dw_2.update()=1 thencommit;messagebox("成功!","更新数据库成功!")elserollback;messagebox("失败!","更新数据库失败!")end ifelsemessagebox("错误!","没有借书记录!",exclamation!,ok!,2) end if7.查询窗口w_chaxun :“检索信息”按钮的代码:dw_1.dataobject="d_tushu"dw_1.settransobject(sqlca)// 取消所有过滤条件dw_1.setfilter("")if rb_1.checked=true then //若选rb_1精确查询//精确查询模式程序choose case ddlb_1.textcase "图书编号"dw_1.setfilter("图书编号='"+sle_1.text+"'")case "书名"dw_1.setfilter("书名='"+sle_1.text+"'")case "作者"dw_1.setfilter("作者='"+sle_1.text+"'")case "出版社"dw_1.setfilter("出版社='"+sle_1.text+"'")end chooseelse//模糊查询模式程序choose case ddlb_1.textcase "图书编号"dw_1.setfilter("图书编号like"+"'%"+sle_1.text+"%'")case "书名"dw_1.setfilter("书名like"+"'%"+sle_1.text+"%'")case "作者"dw_1.setfilter("作者like"+"'%"+sle_1.text+"%'")case "出版社"dw_1.setfilter("出版社like'"+"'%"+sle_1.text+"%'")end chooseend ifdw_1.retrieve() //检索数据8. 建立数据d_tushu , d_jiehuanshu与w_jiehuanshu窗口中的两个数据窗口相联系三.运行结果:(1)根据数据库中“操作员表”中的表项选择其中一操作员的用户名和密码填入登录窗口(2)进入图书管理系统主窗口(3)进入主窗口后可进行修改密码、重新登录以及图书借阅查询的各种操作:。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

广西交通职业技术学院信息工程系作品设计报告书题目:《图书管理系统》班级网络2012-1班学号026姓名唐张森课程名称数据库应用技术指导教师乐文行二O一三年六月目录数据库课程设计报告书一、设计目标1.掌握计算机管理信息系统设计的一般方法,主要包括系统分析、系统设计的组织和实施。

2.关系型数据库管理系统的编程技术,并能独立完成一般小系统的程序设计、调试运行等工作。

3.培养把所学知识运用到具体对象,并能求出解决方案的能力。

二、数据库存储设计指导思想在数据库存储设计的无数选择中,简单是系统架构师和DBA 的秘密武器。

简单,有时候就来自于对一个特定的表或表空间没有选择最优I/O 特性,总有这么一种可能,一个富有经验的DBA 拥有高超的存储技能并可以没有时间限制的去为一个非常重要的表或者索引配置一个存储。

然而这样做的问题是,就算能达到设计的最佳性能,为了维护原始对象,这也经常造成对一个系统的管理变得更加复杂。

好的数据库存储设计的要点是,在一个动态系统上,实现所有目标应该是最初的系统设计的一部分,并应该在数据库运行过程中长期进行。

这篇文档简单的最佳实践描述达到了这些目标并且几乎没有性能损失。

三、任务角色:读者、图书馆馆员、系统管理员;基础数据:读者信息、图书信息、操作员信息;业务数据:借还书记录登记、罚款登记;统计数据:书籍借阅情况统计或读者借阅情况统计。

基本要求:利用数据库技术,完成基础数据和业务数据的储存和操作,数据库设计合理1.设计报告:含E-R图、数据字典、关系模式、关系实例、查询描述、关系代数、SQL 实现的查询语言及查询结果。

2.上机实现。

1.问题描述背景随着图书馆规模的不断扩大,图书数量也相应的增加,有关图书的各种信息量也成倍增加,面对着庞大的信息量,传统的人工方式管理会导致图书馆管理上的混乱,人力与物力过多浪费,图书馆管理费用的增加,从而使图书馆的负担过重,影响整个图书馆的运作和控制管理,因此,必须制定一套合理、有效,规范和实用的图书管理系统,对图书资料进行集中统一的管理。

另一方面,IT产业和Internet获得了飞速发展,计算机应用已渗透到了各个领域,引起信息管理的革命,实现了信息的自动化处理,提高了处理的及时性和正确性。

提高图书管理工作效率,作到信息的规范管理,科学统计和快速查询,让图书馆更好的为学校,社会服务。

数据需求图书馆管理信息系统需要完成功能主要有:1. 读者基本信息的输入,包括借书证编号、读者姓名、读者性别。

2.读者基本信息的查询、修改,包括读者借书证编号、读者姓名、读者性别等。

3.书籍类别标准的制定、类别信息的输入,包括类别编号、类别名称。

4.书籍类别信息的查询、修改,包括类别编号、类别名称。

5.书籍库存信息的输入,包括书籍编号、书籍名称、书籍类别、作者姓名、出版社名称、出版日期、登记日期。

6.书籍库存信息的查询,修改,包括书籍编号、书籍名称、书籍类别、作者姓名、出版社名称、出版日期登记日期等。

7.借书信息的输入,包括读者借书证编号、书籍编号、借书日期。

8.借书信息的查询、修改,包括借书证编号、读者编号、读者姓名、书籍编号、书籍名称、借书日期等。

9.还书信息的输入,包括借书证编号、书籍编号、还书日期。

10.还书信息的查询和修改,包括还书读者借书证编号、读者姓名、书籍编号、书籍名称、借书日期、还书日期等。

11.超期还书罚款输入,还书超出期限包括超出期限还书的读者借书证号,书籍编号,罚款金额。

12.超期还书罚款查询,删除,包括读者借书证编号、读者姓名、书籍编号、书籍名称,罚款金额等关系模式(一)书籍类别(种类编号,种类名称)(二)读者(借书证编号,读者姓名,读者性别,读者种类,登记时期)(三)书籍(书籍编号,书籍名称,书籍类别,书记作者,出版社名称,出版日期,登记日期)(四)借阅(借书证编号,书籍编号,读者借书时间)(五)还书(借书证编号,书籍编号,读者还书时间)(六)罚款(借书证编号,读者姓名,借书证编号,书籍编号,读者借书时间)以上通过关系代数方法的进行运算得到所需要的结果,在实验结果中可以看到。

2.方案图表设计E-R图根据1)所要实现的功能设计,可能建立它们之间的关系,进而实现逻辑结构功能。

图书管理信息系统可以划分的实体有:书籍类别信息实体、读者信息实体、书籍信息实体、借阅记录信息实体,归还记录信息实体。

用E-R图一一描述这些实体。

类别实体E-R图:图2-1类别实体E-R图读者信息实体E-R图:图2-2 读者信息实体E-R图信息实体E-R图:信息实体E-R图:图2-4 记录信息实体E-R图记录信息实体E-R图:图2-5记录信息实体E-R图罚款信息实体E-R图:图2-6罚款信息实体E-R图总的信息实体E-R图:图2-7总的信息实体E-R图数据流程图图2-7系统的数据流程图数据字典表2-1book_sytle 书籍类别信息表表2-2system_readers读者信息表格表2-4borrow_record 借阅记录信息表关系图:图2-8数据库存表关系图3.数据库源代码数据库建立创建数据库USE mastergoCREATE DATABASE tangzhangsentsgON(NAME= librarysystem,FILENAME='c:\',SIZE= 10,MAXSIZE= 50,FILEGROWTH= 5)LOG ON(NAME='library',FILENAME='c:\',SIZE= 5MB,MAXSIZE= 25MB,FILEGROWTH= 5MB)go书本类别表建立create table book_style(bookstyleno varchar(30) primary key, bookstyle varchar(30))创建书库表create table system_books(bookid varchar(20) primary key,bookname varchar(30) Not null,bookstyleno varchar(30) Not null,bookauthor varchar(30),bookpub varchar(30) ,bookpubdate datetime,bookindate datetime ,isborrowed varchar (2) ,foreign key (bookstyleno) references book_style (bookstyleno), )借书证表建立create table system_readers( readerid varchar(9)primary key,readername varchar(9)not null ,readersex varchar(2) not null,readertype varchar(10),regdate datetime)借书记录表建立create table borrow_record( bookid varchar(20) primary key,readerid varchar(9),borrowdate datetime,foreign key (bookid) references system_books(bookid), foreign key (readerid) references system_readers(readerid), )还书记录表建立create table return_record( bookid varchar(20) primary key,readerid varchar(9),returndate datetime,foreign key (bookid) references system_books(bookid), foreign key (readerid) references system_readers(readerid) )罚款单表建立*/create table reader_fee( readerid varchar(9)not null,readername varchar(9)not null ,bookid varchar(20) primary key,bookname varchar(30) Not null,bookfee varchar(30) ,borrowdate datetime,foreign key (bookid) references system_books(bookid),foreign key (readerid) references system_readers(readerid))数据初始化将书籍类别加入表book_style中insert into book_style(bookstyleno,bookstyle)values('1','修真小说')insert into book_style(bookstyleno,bookstyle)values('2','穿越小说')insert into book_style(bookstyleno,bookstyle)values('3','恐怖小说')insert into book_style(bookstyleno,bookstyle)values('4','都市小说')insert into book_style(bookstyleno,bookstyle)values('5','科幻小说')insert into book_style(bookstyleno,bookstyle)values('6','仙侠小说')insert into book_style(bookstyleno,bookstyle)values('7','言情小说')将已有的图书加入system_books表中insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub,bookpubdate, bookindate, isborrowed )values('901','飘渺之旅','1','萧潜','鲜网','2005-09-01','2013-05-25','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub,bookpubdate, bookindate, isborrowed )values('902','唐朝好男人','2','多一半','新星出版社','2008-05-09','2013-05-26','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('903','鬼吹灯','3','天下霸唱','安徽文艺出版社','2007-09-18','2013-05-27','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub,bookpubdate, bookindate, isborrowed )values('904','和空姐同居的日子','4','三十','中国海关出版社','2009-04-08','2013-05-28','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('905','卡徒','5','方想','广西人民出版社','2009-10-11','2013-05-29','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('906','蜀山剑侠传','6','还珠楼主','山西人民出版社','1998-08-17','2013-05-30','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('907','何以笙箫默','7','顾漫','朝华出版社','2007-04-09','2013-05-31','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('908','步步惊心','2','桐华','民族出版社','2006-06-20','2013-05-30','1');将已有图书证的读者加入system_readers表中*/insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q','李雷','男','学生','2013-01-18 12:20')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q','唐张森','男','学生','2013-01-19 13:15')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q','韩梅梅','女','学生','2013-01-20 13:33')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q','露西','女','学生','2013-01-21 12:01')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q','王强','男','学生','2013-01-22 15:23')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('201005','毛正标','男','教师','2013-01-23 18:50')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('201006','陆海鹏','男','教师','2013-01-24 18:25')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('GL001','李燕玲','女','管理','2013-01-01 16:20')添加已借书读者的记录,同时将在已借出的借阅标记置0*/insert into borrow_record(bookid,readerid,borrowdate)values('901','Q','2013-01-18 12:20')update system_booksset isborrowed=0where bookid='901'insert into borrow_record(bookid,readerid,borrowdate)values('902','Q','2013-01-19 13:15')update system_booksset isborrowed=0where bookid='902' and isborrowed='1'insert into borrow_record(bookid,readerid,borrowdate)values('903','Q','2013-01-20 13:33')update system_booksset isborrowed=0where bookid='903' and isborrowed='1'insert into borrow_record(bookid,readerid,borrowdate)values('904','Q','2013-01-21 12:01')update system_booksset isborrowed=0where bookid='904' and isborrowed='1'insert into borrow_record(bookid,readerid,borrowdate) values('905','Q','2013-01-22 15:23')update system_booksset isborrowed=0where bookid='905' and isborrowed='1'insert into borrow_record(bookid,readerid,borrowdate) values('907','201005','2013-01-23 18:50')update system_booksset isborrowed=0where bookid='907' and isborrowed='1'insert into borrow_record(bookid,readerid,borrowdate) values('908','201006','2013-01-24 18:25')update system_booksset isborrowed=0where bookid='908' and isborrowed='1'4.结果数据处理单表查询表book_style中查询演示:查询语句:select*from book_style图4-1 表book_style中内容表system_books中查询演示:查询语句:select*from system_books将已有图书证的读者加入system_readers表中结果查询:查询语句:select*from system_readers图4-3 表system_readers中内容借书纪录表borrow_record结果查询:查询语句:select*from borrow_record超期处理现在对已有借书证的读者进行查询借书是否超期查询语句:(这里归定30天):select读者借书证编号,readername 读者姓名,书籍编号,bookname 书名,borrowdate 借书时间,datediff(day,convert(smalldatetime,borrowdate),getdate())-30 超过天数from borrow_record ,system_readers,system_bookswhere=and=and datediff(day,convert(smalldatetime,borrowdate),getdate())>=30说明:当前的getdate()以当前的时间和日期计算图4-4 选出借出超过30天的读者同时也可以用语句超过天数的读者进行罚款,加入到罚款单里面,一天以元扣除计算:语句insert into reader_fee(readerid,readername,bookid,bookname,bookfee,borrowdate) select读者借书证编号,readername 读者姓名,书籍编号,bookname 书名,*(Datediff(day,convert(smalldatetime,borrowdate),getdate())-30)超过时间天数, borrowdate 借书时间from borrow_record ,system_readers ,system_bookswhere=and=and Datediff(day,convert(smalldatetime,borrowdate),getdate())>=30goselect readerid 书读者借书证编号,readername 读者姓名,bookid 书籍编号,bookfee 超期罚款from reader_fee图4-5查看罚款单还书操作现在对某一读者进行还书操作:1.首先还书要在还书纪录中添加一条还书纪录insert into return_record(bookid,readerid,returndate)select bookid,readerid,getdate()from borrow_recordwhere bookid='901'(1 行受影响)查询语句:select bookid 书籍编号,readerid 读者借书证号,returndate 归还时间from return_record图4-6 增加了901纪录2.其次删除相应书本的借阅纪录deletefrom borrow_recordwhere bookid='901'(1 行受影响)查询语句:select bookid 书籍编号,readerid 读者借书证号,borrowdate 归还时间from borrow_record图4-7 901这本书在借书纪录里没有了3.最后在书库中标记该本书为1,表示归还了未借,可供其他读者借阅update system_booksset isborrowed=1where bookid='901'(1 行受影响)查询语句:select bookid 书籍编号,bookname 书籍名称,isborrowed 是否借出from system_bookswhere bookid='901'图4-8 标记设为了‘1’说明:这本书重新回到未被借出标记为1其结果为还书成功,相应的各表都有变化,对于罚款单通过借阅记录表borrow_record中更新。

相关文档
最新文档