SQL数据库图书管理系统(完整代码)
- 格式:doc
- 大小:723.00 KB
- 文档页数:43
图书管理系统数据库源代码//创建工程及设计主界面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);}}}。
源程序清单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)功能说明:整个系统的主界面,其中包括图书管理、读者管理、图书借阅管理、系统管理、关于,以及在这下面的子菜单。
图书管理系统源代码(一)程序代码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。
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。
图书信息管理系统课程设计:图书信息管理系统设计人员:林俊柱开发环境: 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);。
图书馆管理系统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语言一、实验目的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语句对读者信息表进行修改:删除系部字段、添加所在系字段。
#include<fstream〉#include<iostream〉#include<stdlib.h〉#include〈ctime〉#include<cmath>#include〈termios.h〉#include <sstream〉#include<string。
h〉#include<assert.h〉//改变字体颜色#define NONE "\033[m"#define RED "\033[0;32;31m”#define GREEN ”\033[0;32;32m”#define BLUE "\033[0;32;34m”#define YELLOW ”\033[1;33m”#define LIGHT_RED ”\033[1;31m”#define LIGHT_GREEN "\033[1;32m"#define LIGHT_BLUE "\033[1;34m”/*程序导读:1。
程序中对书的操作,可通过书名,编号来进行,flag=0按书名来操作,flag=1按书编号来操作2.程序中对用户的操作,也可通过姓名,用户ID号或编号两种方式来进行,flag=0按姓名来操作,flag=1按用户ID号或编号来操作3。
本程序分5个部分,具体已标识如(1)图书管理。
.*/using namespace std;class Book{public:string book_name;string book_num;//编号string book_pre;//出版社string book_aut;//作者int book_con;//这样的书还有几本int book_mux;//这样的书总共有几本public:Book(){book_con=0;book_mux=0;}void show_book();};/****************************************(1)图书管理*******************************************/void Book::show_book(){cout<〈"书名:”<〈book_name<〈endl;cout〈〈”出版社:"〈<book_pre〈〈endl;cout<<”此书的作者:"〈<book_aut〈<endl;cout〈<”ISBN编号:”<〈book_num<〈endl;cout<<"此书共有"〈<book_mux<<”本”〈〈endl;cout<<”还有"<<book_con〈〈”本书未借出!"〈<endl;}class BookNode{public:Book book;BookNode *next;};BookNode *headbook=NULL;class BookManage{public:int totolbook;public:BookManage(){totolbook=0;}void addbook();void delbook(string s,int num,int flag);void findbook(string s,int flag);//查询图书};void BookManage::addbook(){string h;cout〈〈"添加输入0,退出输入—1"<〈endl;cin>>h;if(h==”-1”)return;else if(h=="0”)while(1){if(h==”-1”)break;else if(h==”0”){string na,nu,p1,aut;int con;BookNode *p=new BookNode;cout<<”请输入书名:"〈〈endl;cin〉>na;p—〉book.book_name=na;cout<〈"请输入ISBN编号:”<<endl;cin>〉nu;p->book。
毕业设计_图书管理系统一、数据库设计数据库设CREATE DATABASE TSGLGOUSE TSGLGOCREATE TABLE Bmanage(bId varchar(10) PRIMARY KEY,bName varchar(50), --添加图书--图书编号--书名bNumber varchar(10), --书数目)GObSore varchar(50) --分类CREATE TABLE Madmin(mName varchar(10)PRIMARY KEY,mPwd varchar(25),mAge varchar(8),mSex varchar(4),mNumber varchar(15),mrole varchar(8))GO--图书员管理--图书管理员姓名--图书管理员密码--图书管理员年龄--图书管理员性别--图书管理员电话--图书管理员角色CREATE TABLE Reader (rSno varchar (10) PRIMARY KEY , rName varchar (10), rPwd varchar (25), rAge varchar (8), rSex varchar (4), rState varchar (8), rNumber varchar (15), rEmail varchar (25),--读者信息表reader--读者号 --姓名 --密码 --年龄 --性别--状态 --电话号码--电子邮件 rAdressvarChar (50),--地址) GOrGrade varChar (15),rClass varchar (15),rRole varchar (8)--年级 --班级 --角色CREATE TABLE Rrecord (rSno varchar (10) PRIMARY KEY , rName varChar (10), bId varchar (10), bName varChar (50), bTime varchar (10), bBackTime varchar (10) ) GOCREATE TABLE SysSet (rRole varchar (8)PRIMARY KEY , rState varchar (8), Fine float (25), rDay varchar (8)--读者编号学号 --读者姓名 --图书编号--图书名称 --借书时间 --还书时间--读者角色 --读者可借书数 --过期罚款设置 --可借书天数)二、界面截图及说明1) 登录窗口(实现管理员和馆长的登陆)2) 管理员窗口3) 馆长窗口4) 关于窗口5) 新增图书窗口6) 新增管理员、查找及修改窗口7) 新增读者、查找及修改窗口8) 图书的查找及修改窗口9) 借阅窗口10)系统设置窗口三、主要代码主要代1) 登录窗口(实现管理员和馆长的登陆)登陆检查:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.ClassLib.Logic{class clsLoginCheck{public static DataTable CheckLogin(string UserId, string PWD){{string SQLstmt = "select mName,mPwd,mRole from Madmin where mName= '" + UserId + "'and mPwd= '" + PWD + "'";DataTable dt = clsGlobalVar.GetDataTable(SQLstmt);return dt;}}}}登陆:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.Logic;namespace prjTSGL.TSGL_UI{public partial class frmLogin : Form{public frmLogin(){InitializeComponent();}private void btnLogin_Click(object sender, EventArgs e){string strUserID = loginid.Text.Trim();string strPWD = loginpwd.Text.Trim();string type = "";try{DataTable dt = clsLoginCheck.CheckLogin(strUserID, strPWD);if (dt.Rows.Count == 0){MessageBox.Show("登陆失败,请重新输入!");loginpwd.Focus();return;}else{type = dt.Rows[0]["mRole"].ToString().Trim();if (cboLT.Text.Trim()=="馆长" ){if (type == "馆长"){this.Hide();frmManager objManager = new frmManager();objManager.Show();}else{MessageBox.Show("您没有权限!");loginpwd.Focus();return;}}else{if (type =="管理员"){this.Hide();frmAdmin objAdmin = new frmAdmin();objAdmin.Show();}else{MessageBox.Show("您没有权限!");loginpwd.Focus();return;}}}}catch (Exception ex){throw ex;}}private void btnExit_Click(object sender, EventArgs e){this.Close();}}}2) 管理员窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace prjTSGL.TSGL_UI{public partial class frmAdmin : Form{public frmAdmin(){InitializeComponent();}private void ShowForm(Form frmToShow){this.Cursor = Cursors.WaitCursor;foreach (Form frmChild in this.MdiChildren){if (frmChild.GetType() == frmToShow.GetType()){frmToShow.Dispose();frmChild.Activate();this.Cursor = Cursors.Default;return;}}frmToShow.MdiParent = this;frmToShow.Show();this.Cursor = Cursors.Default;}private void读者信息修改ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmUpdateReader());}private void新增图书ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAddNewBook());}private void图书的查找和修改ToolStripMenuItem_Click(object sender, EventArgs e) {ShowForm(new f rmUpdateBook());}private void流通管理ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmBorrow());}private void帮助ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAbout());}private void退出ToolStripMenuItem_Click(object sender, EventArgs e){Application.Exit();}}}3) 馆长窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace prjTSGL.TSGL_UI{public partial class frmManager : Form{public frmManager(){InitializeComponent();}private void ShowForm(Form frmToShow){this.Cursor = Cursors.WaitCursor;foreach (Form frmChild in this.MdiChildren){if (frmChild.GetType() == frmToShow.GetType()){frmToShow.Dispose();frmChild.Activate();this.Cursor = Cursors.Default;return;}}frmToShow.MdiParent = this;frmToShow.Show();this.Cursor = Cursors.Default;}private void frmManager_FormClosed(object sender, FormClosedEventArgs e){Application.Exit();}private void管理员信息管理ToolStripMenuItem_Click_1(object sender, EventArgs e) {ShowForm(new f rmSelectAdmin());}private void系统设置ToolStripMenuItem_Click_1(object sender, EventArgs e){ShowForm(new f rmSys());}private void关于ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAbout());}private void退出ToolStripMenuItem_Click_1(object sender, EventArgs e){Application.Exit();}}}4) 关于窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace prjTSGL.TSGL_UI{public partial class frmAbout : Form{public frmAbout(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){this.Close();}}}5) 新增图书窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{public partial class frmAddNewBook : Form{public frmAddNewBook(){InitializeComponent();}private bool ValidatInput(){if (textBox1.Text == ""){MessageBox.Show("请输入图书编号!", "输入提示", MessageBoxButtons.OK, rmation);textBox1.Focus();return false;}if (textBox2.Text == ""){MessageBox.Show("请输入图书名称!", "输入提示", MessageBoxButtons.OK, rmation);textBox2.Focus();return false;}if (textBox3.Text == ""){MessageBox.Show("请输入图书数目!", "输入提示", MessageBoxButtons.OK,rmation);textBox3.Focus();return false;}if (comboBox1.Text == ""){MessageBox.Show("请选择图书类别!", "输入提示", MessageBoxButtons.OK, rmation);textBox3.Focus();return false;}return true;}private void btnOK_Click_1(object sender, EventArgs e){if (ValidatInput()){//string id = textBox1.Text;//string name = textBox2.Text;//string Number = textBox3.Text;//string sore = comboBox1.Text;string sql = "SELECT *FROM Bmanage WHERE bId='" + textBox1.Text.Trim() + " '";DataTable dt = clsGlobalVar.GetDataTable(sql);if (dt.Rows.Count == 0){string SQL = "insert into Bmanage(bId,bName,bNumber,bSore)values('" + textBox1.Text.Trim() + " ','" + textBox2.Text.Trim() + " ','" + textBox3.Text.Trim() + " ','"+ comboBox1.Text.Trim() + " ')";try{bool result = clsGlobalVar.ExecSQL(SQL);if (result){MessageBox.Show("添加成功!", "操作提示", MessageBoxButtons.OK, rmation);textBox1.Text = "";textBox2.Text = "";textBox3.Text = "";comboBox1.Text = "";textBox1.Focus();}else{MessageBox.Show("添加失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch (Exception ex){MessageBox.Show("操作数据库出错!", "操作演示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}else{MessageBox.Show("图书编号已存在!", "操作提示", MessageBoxButtons.OK, rmation);textBox1.Focus();}}}private void btnCancel_Click(object sender, EventArgs e){this.Close();}}}6) 新增管理员、查找及修改窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{public partial class frmSelectAdmin : Form{public frmSelectAdmin(){InitializeComponent();}string name = "";string SQL = "";string PWD = "";string Age = "";string Sex = "";string Tel = "";string Role = "";private void SelectAdmin(){string strfilter = "";string SQL = "select mName AS 用户名,mPwd AS 密码,mAge AS 年龄,mSex AS 性别,mNumber AS 电话,mRole AS 角色from Madmin ";if (txtName.Text == "")strfilter = "";elsestrfilter = "where mName='" + txtName.Text.Trim() + "'";try{DataTable dt = clsGlobalVar.GetDataTable(SQL + strfilter);int intIndex = 0;if (dt.Rows.Count == 0){MessageBox.Show("抱歉,没有您要找的用户!", "结果提示", MessageBoxButtons.OK, rmation);txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";}else{{LV.Columns.Clear();LV.Items.Clear();LV.Columns.Add("序号", 100, HorizontalAlignment.Center);for (int intJ = 0; intJ < dt.Columns.Count; intJ++){LV.Columns.Add(dt.Columns[intJ].ColumnName, 200, HorizontalAlignment.Center);}for (int intI = 0; intI < dt.Rows.Count; intI++){intIndex = intI + 1;LV.Items.Add(intIndex.ToString());LV.Items[intI].SubItems.Add(dt.Rows[intI]["用户名"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["密码"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["年龄"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["性别"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["电话"].ToString().Trim());LV.Items[intI].SubItems.Add(dt.Rows[intI]["角色"].ToString().Trim());}}}}//连接数据库,将数据读取出放入MadminDatacatch (Exception ex){MessageBox.Show("查询数据库出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}private void btnSearch_Click(object sender, EventArgs e){SelectAdmin();//调用函数}//实现修改功能private void btnUpdata_Click(object sender, EventArgs e){if (txtName.Text == "" || cboRole.Text==""){MessageBox.Show("请选择要修改的用户!");}else{SQL = "UPDATE Madmin SET mName='" + txtName.Text.Trim() + "',mPwd='" + txtPWD.Text.Trim() + "',mAge='" + txtAge.Text.Trim() + "',mSex='" + cboSex.Text.Trim() +"',mNumber='" + txtTel.Text.Trim() + "',mRole='" + cboRole.Text.Trim() + "' where mName='" + name+ "'AND mPwd='" + PWD + "'AND mAge='" + Age + "'AND mSex='" + Sex + "'AND mNumber='" + Tel + "'AND mRole='" + Role + "'";try{bool result = clsGlobalVar.ExecSQL(SQL);if (result){//txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";MessageBox.Show("修改已成功");SelectAdmin();}else{MessageBox.Show("更新失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch (Exception ex){MessageBox.Show("操作数据库出错!", "操作演示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}}private void btnExit_Click(object sender, EventArgs e){this.Close();}private void LV_SelectedIndexChanged_1(object sender, EventArgs e){txtName.Text = LV.FocusedItem.SubItems[1].Text.Trim();txtPWD.Text = LV.FocusedItem.SubItems[2].Text.Trim();txtAge.Text = LV.FocusedItem.SubItems[3].Text.Trim();cboSex.Text = LV.FocusedItem.SubItems[4].Text.Trim();txtTel.Text = LV.FocusedItem.SubItems[5].Text.Trim();cboRole.Text = LV.FocusedItem.SubItems[6].Text.Trim();name = LV.FocusedItem.SubItems[1].Text.Trim();PWD = LV.FocusedItem.SubItems[2].Text.Trim();Age = LV.FocusedItem.SubItems[3].Text.Trim();Sex = LV.FocusedItem.SubItems[4].Text.Trim();Tel = LV.FocusedItem.SubItems[5].Text.Trim();Role = LV.FocusedItem.SubItems[6].Text.Trim();}private void frmSelectAdmin_Load(object sender, EventArgs e){this.btnSearch_Click(sender, e);}private void btnAdd_Click(object sender, EventArgs e){if (txtName.Text == "" || txtPWD.Text == "" || txtAge.Text == "" ||cboSex.Text =="" || txtTel.Text=="" ||cboRole.Text == ""){MessageBox.Show("请至少输入用户名,密码和角色!");}else{SQL = "SELECT mName,mPwd,mAge ,mSex,mNumber,mRole from Madmin WHERE mName='" + txtName.Text.Trim() + "' ";DataTable dt = clsGlobalVar.GetDataTable(SQL);if (dt.Rows.Count == 0){SQL = "INSERT INTO Madmin VALUES ('" + txtName.Text.Trim() + "','" +txtPWD.Text.Trim() + "','" + txtAge.Text.Trim() + "','" + cboSex.Text.Trim() + "','" +txtTel.Text.Trim() + "','" + cboRole.Text.Trim() + "')";if (clsGlobalVar.ExecSQL(SQL) == true){//txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";MessageBox.Show("成功添加新管理员!");SelectAdmin();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}else{MessageBox.Show("用户名已存在,请选择其他用户名!", "结果提示", MessageBoxButtons.OK, rmation);txtName.Text = "";}}}private void btnDelete_Click(object sender, EventArgs e){if (txtName.Text == "" || cboRole.Text == ""){MessageBox.Show("请选择要删除的管理员用户!");}else{DialogResult dr = MessageBox.Show("此操作不可撤销,确定要删除此用户信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);if (dr == DialogResult.Yes){SQL = "DELETE FROM Madmin WHERE mName='" + name + "'AND mPwd='" + PWD + "'ANDmAge='" + Age + "'AND mSex='" + Sex + "'AND mNumber='" + Tel + "'AND mRole='" + Role + "'";if (clsGlobalVar.ExecSQL(SQL) == true){MessageBox.Show("成功删除此管理信息!");SelectAdmin();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}}}private void btnReset_Click(object sender, EventArgs e){txtName.Text = "";txtPWD.Text = "";txtAge.Text = "";cboSex.Text = "";txtTel.Text = "";cboRole.Text = "";}}}7) 新增读者、查找及修改窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{public partial class frmUpdateReader : Form{public frmUpdateReader(){InitializeComponent();}string Sno = "";string Pwd = "";string Age = "";string name = "";string Sex = "";string State = "";string Adress = "";string Number = "";string Email = "";string Grade = "";string Class = "";string Role = "";//查找学生读者private void SelectStudent(){string strfilter = "";string SQL = "select rSno AS 读者编号,rName AS 读者姓名,rPwd AS 密码,rAge AS 年龄,rSex AS 性别,rState AS 借书状态,rAdress AS 地址,rNumber AS 电话,rEmail AS 邮箱,rGrade AS 年级,rClass AS 班级,rRole AS 角色from Reader ";if (txtReaderName.Text == "")strfilter = "";elsestrfilter = "where rName='" + txtReaderName.Text.Trim() + "'";try{DataTable dt = clsGlobalVar.GetDataTable(SQL + strfilter);int intIndex = 0;if (dt.Rows.Count==0){MessageBox.Show("抱歉,没有您要找的读者信息!", "结果提示", MessageBoxButtons.OK, rmation);}else{LV.Columns.Clear();LV.Items.Clear();LV.Columns.Add("序号", 100, HorizontalAlignment.Center);for (int intJ = 0; intJ < dt.Columns.Count; intJ++){LV.Columns.Add(dt.Columns[intJ].ColumnName, 200, HorizontalAlignment.Center);}for (int intI = 0; intI < dt.Rows.Count; intI++){intIndex = intI + 1;LV.Items.Add(intIndex.ToString());for (int j=1; j < dt.Columns.Count; j++){LV.Items[intI].SubItems.Add(dt.Rows[intI][j].ToString());}//LV.Items[intI].SubItems.Add(dt.Rows[intI]["读者编号"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["读者姓名"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["密码"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["年龄"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["性别"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["借书状态"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["地址"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["电话"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["邮箱"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["年级"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["班级"].ToString());//LV.Items[intI].SubItems.Add(dt.Rows[intI]["角色"].ToString());}}}catch (Exception ex){MessageBox.Show("查询数据库出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}//实现查找功能private void btnSearch_Click(object sender, EventArgs e){SelectStudent();}//实现修改功能private void btnUpdata_Click(object sender, EventArgs e){if (textBox2.Text == ""){MessageBox.Show("请选择要修改的用户!");}else//string sql = "SELECT * from Reader WHERE rSno='" + textBox2.Text.Trim() + "' ";//DataTable dt = clsGlobalVar.GetDataTable(sql);//if (dt.Rows.Count == 0)//{{string SQL = "UPDATE Reader SET rSno='" + textBox2.Text.Trim() + "',rPwd='" + textBox3.Text.Trim() + "',rAge='" + textBox1.Text.Trim() + "',rName='" +txtReaderName.Text.Trim() + "',rSex='" + cboSex.Text.Trim() + "',rState='" + textBox4.Text.Trim()+ "',rAdress='" + textBox5.Text.Trim() + "',rNumber='" + textBox6.Text.Trim() + "',rEmail='" + textBox7.Text.Trim() + "',rGrade='" + textBox8.Text.Trim() + "',rClass='" + textBox9.Text.Trim()+ "' ,rRole='" + cboRole.Text.Trim() + "'";string strfilter = "where rSno='" + Sno + "'";try{bool result = clsGlobalVar.ExecSQL(SQL + strfilter);if (result){textBox2.Text = "";textBox3.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";MessageBox.Show("修改已成功");SelectStudent();}else{MessageBox.Show("读者信息不存在!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);}}catch (Exception ex){MessageBox.Show("操作数据库出错!", "操作演示", MessageBoxButtons.OK, MessageBoxIcon.Error);Console.WriteLine(ex.Message);}}//}//else//{// MessageBox.Show("用户名已存在,请选择其他用户名!", "结果提示", MessageBoxButtons.OK, rmation);// textBox2.Text = "";//}}private void btnExit_Click(object sender, EventArgs e){this.Close();}private void LV_SelectedIndexChanged(object sender, EventArgs e) {textBox2.Text = LV.FocusedItem.SubItems[1].Text.Trim();txtReaderName.Text = LV.FocusedItem.SubItems[2].Text.Trim();textBox3.Text = LV.FocusedItem.SubItems[3].Text.Trim();textBox1.Text = LV.FocusedItem.SubItems[4].Text.Trim();cboSex.Text = LV.FocusedItem.SubItems[5].Text.Trim();textBox4.Text = LV.FocusedItem.SubItems[6].Text.Trim();textBox5.Text = LV.FocusedItem.SubItems[7].Text.Trim();textBox6.Text = LV.FocusedItem.SubItems[8].Text.Trim();textBox7.Text = LV.FocusedItem.SubItems[9].Text.Trim();textBox8.Text = LV.FocusedItem.SubItems[10].Text.Trim();textBox9.Text = LV.FocusedItem.SubItems[11].Text.Trim();cboRole.Text = LV.FocusedItem.SubItems[12].Text.Trim();Sno = LV.FocusedItem.SubItems[1].Text.Trim();name = LV.FocusedItem.SubItems[2].Text.Trim();Pwd = LV.FocusedItem.SubItems[3].Text.Trim();Age = LV.FocusedItem.SubItems[4].Text.Trim();Sex = LV.FocusedItem.SubItems[5].Text.Trim();State = LV.FocusedItem.SubItems[6].Text.Trim();Adress = LV.FocusedItem.SubItems[7].Text.Trim();Number = LV.FocusedItem.SubItems[8].Text.Trim();Email = LV.FocusedItem.SubItems[9].Text.Trim();Grade = LV.FocusedItem.SubItems[10].Text.Trim();Class= LV.FocusedItem.SubItems[11].Text.Trim();Role = LV.FocusedItem.SubItems[12].Text.Trim();}private void btnReset_Click(object sender, EventArgs e){textBox2.Text = "";textBox3.Text = "";txtReaderName.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";}private void btnAdd_Click(object sender, EventArgs e){string SQL="";if (textBox2.Text == "" || textBox3.Text == "" || txtReaderName.Text == "" ||textBox4.Text == "" || textBox5.Text == ""){MessageBox.Show("请至少输入读者姓名,用户名,密码,借书状态和角色!");}else{string sql = "SELECT * from Reader WHERE rSno='" + textBox2.Text.Trim() + "' ";DataTable dt = clsGlobalVar.GetDataTable(sql);if (dt.Rows.Count == 0){if(cboRole.Text.Trim()=="教师")SQL = "INSERT INTO Reader(rSno,rPwd,rName,rAge,rSex,rState,rAdress,rNumber,rEmail,rGrade,rClass,rRole)VALUES ('" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + txtReaderName.Text.Trim() + "','"+ textBox1.Text.Trim() + "','" + cboSex.Text.Trim() + "','" + textBox4.Text.Trim() + "','" +textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" + "NULL"+ "','" + "NULL" + "','" + cboRole.Text.Trim() + "')";elseSQL = "INSERT INTO Reader(rSno,rPwd,rName,rAge,rSex,rState,rAdress,rNumber,rEmail,rGrade,rClass,rRole)VALUES ('" + textBox2.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + txtReaderName.Text.Trim() + "','"+ textBox1.Text.Trim() + "','" + cboSex.Text.Trim() + "','" + textBox4.Text.Trim() + "','" +textBox5.Text.Trim() + "','" + textBox6.Text.Trim() + "','" + textBox7.Text.Trim() + "','" +textBox8.Text.Trim() + "','" + textBox9.Text.Trim() + "','" + cboRole.Text.Trim() + "')";if (clsGlobalVar.ExecSQL(SQL) == true){textBox2.Text = "";textBox3.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";MessageBox.Show("成功添加此用户!");SelectStudent();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}else{MessageBox.Show("用户名已存在,请选择其他用户名!", "结果提示", MessageBoxButtons.OK, rmation);textBox2.Text = "";}}}private void btnDel_Click(object sender, EventArgs e){if (textBox2.Text == ""){MessageBox.Show("请选择要删除的用户!");}else{DialogResult dt= MessageBox.Show("此操作不可撤销,确定要删除此用户信息吗?", " 提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);if (dt == DialogResult.Yes){string SQL = "DELETE FROM Reader where rSno='" + Sno + "'";if (clsGlobalVar.ExecSQL(SQL) == true){textBox2.Text = "";textBox3.Text = "";textBox1.Text = "";cboSex.Text = "";textBox4.Text = "";textBox5.Text = "";textBox6.Text = "";textBox7.Text = "";textBox8.Text = "";textBox9.Text = "";cboRole.Text = "";MessageBox.Show("删除此用户成功!");SelectStudent();}else{Exception ex = new Exception();MessageBox.Show(ex.Message.ToString());}}}}private void frmUpdateReader_Load(object sender, EventArgs e){SelectStudent();}}}8) 图书的查找及修改窗口using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using prjTSGL.ClassLib.DBAccess;namespace prjTSGL.TSGL_UI{。
附录:Default.aspx 用来显示主页<%@Page Language=”C#"MasterPageFile="~/common。
master"AutoEventWireup=”true”CodeFile="Default.aspx。
cs”Inherits="_Default"Title=”首页|第三波+书店”%>〈asp:Content ID=”Content1"ContentPlaceHolderID=”cphContent"Runat="Server"> <table width=”98%”border=”0"cellspacing="0”cellpadding=”0"〉<tr>〈td height="10"bgcolor="#BBE188"〉</td〉</tr〉〈/table><br/>〈table width=”98%”border=”0"cellspacing="0"cellpadding="0">〈tr><td align=”left”〉<img src="images/06default_1018_28。
gif"width="77”height=”18"/〉</td〉〈td align="right">&nbsp;</td></tr〉</table〉<br/〉<table width="98%”border=”0”cellspacing=”0"cellpadding=”0”><tr><td width=”120"height=”155”align="left”valign="top"><a href="BookDetail.asp x?bid=4943”target="_blank"〉<img src=”BookCover。
广西交通职业技术学院信息工程系作品设计报告书题目:《图书管理系统》班级网络2012-1班学号 20120404026姓名唐张森课程名称数据库应用技术指导教师乐文行二O一三年六月目录数据库课程设计报告书一、设计目标1.掌握计算机管理信息系统设计的一般方法,主要包括系统分析、系统设计的组织和实施。
2.关系型数据库管理系统的编程技术,并能独立完成一般小系统的程序设计、调试运行等工作。
3.培养把所学知识运用到具体对象,并能求出解决方案的能力。
二、数据库存储设计指导思想在数据库存储设计的无数选择中,简单是系统架构师和 DBA 的秘密武器。
简单,有时候就来自于对一个特定的表或表空间没有选择最优 I/O 特性,总有这么一种可能,一个富有经验的 DBA 拥有高超的存储技能并可以没有时间限制的去为一个非常重要的表或者索引配置一个存储。
然而这样做的问题是,就算能达到设计的最佳性能,为了维护原始对象,这也经常造成对一个系统的管理变得更加复杂。
好的数据库存储设计的要点是,在一个动态系统上,实现所有目标应该是最初的系统设计的一部分,并应该在数据库运行过程中长期进行。
这篇文档简单的最佳实践描述达到了这些目标并且几乎没有性能损失。
三、任务角色:读者、图书馆馆员、系统管理员;基础数据:读者信息、图书信息、操作员信息;业务数据:借还书记录登记、罚款登记;统计数据:书籍借阅情况统计或读者借阅情况统计。
基本要求:利用数据库技术,完成基础数据和业务数据的储存和操作,数据库设计合理1.设计报告:含E-R图、数据字典、关系模式、关系实例、查询描述、关系代数、SQL 实现的查询语言及查询结果。
2.上机实现。
1.问题描述1.1背景随着图书馆规模的不断扩大,图书数量也相应的增加,有关图书的各种信息量也成倍增加,面对着庞大的信息量,传统的人工方式管理会导致图书馆管理上的混乱,人力与物力过多浪费,图书馆管理费用的增加,从而使图书馆的负担过重,影响整个图书馆的运作和控制管理,因此,必须制定一套合理、有效,规范和实用的图书管理系统,对图书资料进行集中统一的管理。
图书管理系统代码//***********************//图书馆管理系统//***********************#include<stdio.h>#include<string.h>#include<malloc.h>#define null 0#define max 65536static int n;//*********************// 图书结构体//*********************typedef struct{char num[10]; //书号char name[9]; //书名char addr[31]; //作者int Nowcounter; //现存量int Allcounter; //总库存量}datatype;datatype *x[max]; //定义两个指针数组datatype *p;//*****************************//图书功能函数列表//*****************************void redo(); //主递归函数void creatlist(datatype *x[]); //图书建立函数int menu_select(); //功能菜单函数void find(datatype *x[],int n); //查找函数void delnode(datatype *x[]); //插入函数void printlist(datatype *x[]); //显示函数void jieyue(datatype *x[],int n); //借阅函数void guihuan(datatype *x[],int n); //归还函数//*****************************//主递归函数程序//*****************************void redo(){int i=0,j,n1,k=0,flage;for( ; ;){switch( menu_select()){case 1: //选项1的实现printf("***********************\n");printf("* 图书的建立*\n");printf("***********************\n");creatlist(x);break;case 2: //选项2的实现printf("***********************\n");printf("* 新图书信息的添加*\n");printf("***********************\n");printf(" 插入的个数:");scanf("%d",&n1); //输入插入新图书的个数for(i=0;i<n1;i++){flage=0;p=(datatype *)malloc(sizeof(datatype)); //分配一个节点空间printf(" 书名: ");scanf("%s",p->name); //输入插入书的书名if(flage==0){for(j=0;j<n;j++){if(strcmp(x[j]->name,p->name) == 0 )//调用比较函数查看书名是否已知{x[j]->Allcounter++;x[j]->Nowcounter++;flage=1;}}if(flage==0){n++;printf(" 第%d 个图书数据:\n",n); //插入新的图书p=(datatype *)malloc(sizeof(datatype));x[n-1]=p;printf(" 书名:");scanf("%s",x[n-1]->name); //输入书名printf(" 编号:");scanf(" %s",x[n-1]->num); //输入书号printf(" 作者:");scanf(" %s",x[n-1]->addr); // 输入作者名printf(" 总库存量:");scanf("%d",&x[n-1]->Allcounter); //输入总库存量x[n-1]->Nowcounter=x[n-1]->Allcounter;}}}break;case 3:printf("***********************\n");printf("* 图书信息的查询*\n");printf("***********************\n");find(x,n);break;case 4:printf("************************\n");printf("* 图书信息的删除*\n");printf("************************\n");delnode(x);break;case 5:printf("************************\n");printf("* 图书信息的显示*\n");printf("************************\n");printlist(x);break;case 6:printf("************************\n");printf(" 图书的借阅\n");printf("************************\n");jieyue(x,n);break;case 7:printf("************************\n");printf(" 图书的归还\n");printf("************************\n");guihuan(x,n);break;case 0:printf("\t 谢谢使用,再见! \n");return;}}//*************************//主函数程序//*************************void main (){redo(); //调用主递归函数}//*************************//功能菜单函数//*************************int menu_select(){int i;printf(" 欢迎进入图书管理系统!\n");printf("===========================\n");printf(" 1. 图书信息的采集\n");printf(" 2. 新图书的插入\n");printf(" 3. 图书信息的查询\n");printf(" 4. 图书的删除\n");printf(" 5. 图书的显示\n");printf(" 6. 图书的借阅\n");printf(" 7. 图书的归还\n");printf(" 0. 退出管理系统\n");printf("===========================\n");printf(" 请选择0-7: ");scanf("%d",&i);while(i<0||i>7){printf("\n\t输入出错,重选0-7: ");scanf("%d",&i);}return i;}//********************************// 建立链表图书建造函数//********************************void creatlist(datatype *x[]){int i;printf(" 请输入要建立图书的个数:");scanf("%d",&n);for(i=0;i<n;i++)printf(" 第%d 个图书数据:\n",i+1);p=(datatype *)malloc(sizeof(datatype)); //分配一个节点空间x[i]=p;printf(" 书名:"); //输入图书各项内容scanf("%s",x[i]->name);printf(" 编号:");scanf(" %s",x[i]->num);printf(" 作者:");scanf(" %s",x[i]->addr);printf(" 总库存量:");scanf("%d",&x[i]->Allcounter);x[i]->Nowcounter=x[i]->Allcounter;}}//**********************************// 查找函数程序//*********************************void find(datatype *x[],int n){char num[10];char name[9];int t,i;printf("=================\n"); //输出查找方式printf(" 1.按编号查询\n");printf(" 2.按书名查询\n");printf("=================\n");printf(" 请选择: ");scanf("%d",&t); //输入选择信息if(t==1){printf(" 请输入要查找者的编号: ");scanf("%s",num); //输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num)==0) //调用strcmp函数{printf(" 编号书名作者现库存量总库存量\n");//输出要查询书的信息printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);elsecontinue;}}else{printf(" 请输入要查询的书名: ");scanf("%s",name); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name)==0){printf("编号书名作者现库存量总库存量\n"); //输出要查询书的信息printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i ]->Nowcounter,x[i]->Allcounter);}elsecontinue;}}}//******************************//删除函数程序//******************************void delnode(datatype *x[]){char num1[10],name1[10]; //定义两个字符数组int i,j,m=1,p;printf(" 1.按编号删除\n"); //输出选择方式printf(" 2.按书名删除\n");printf(" 3.返回\n");printf(" 请选择:\n");scanf("%d",&p); //输入选择信息if(p>3||p<1){printf(" 您的输入有误,请重新输入!\n");scanf("%d",&p); //重新输入选择信息}switch(p) //实现删除程序{case 1:printf(" 输入要删除书的编号:\n");scanf(" %s",num1);for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0) //调用strcmp函数{m=0;n--;for(j=i;j<n;j++)x[j]=x[j+1]; //将该书信息删除printf(" 该书已删除!\n");}}if(m==1)printf(" 没有这样的的图书\n");break;case 2:printf(" 输入要删除书的名字:\n");scanf("%s",&name1);for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0) //调用strcmp函数{m=0;n--;for(j=i;j<n;j++) //将该书信息删除x[j]=x[j+1];printf(" 该书已删除!\n");}}if(m==1)printf(" 没有这样的的图书\n");break;case 3:break;}}//////////////////////////////借阅函数程序/////////////////////////void jieyue(datatype *x[],int n){int i,m=1,p;char name1[10],num1[10]; //定义两个字符数组printf(" 1.按名字借阅\n"); //输出选择方式printf(" 2.按编号借阅\n");printf(" 3.返回\n");printf(" 请选择\n");scanf("%d",&p); //输入选择信息if(p>3||p<1){printf(" 您的输入有误!\n");scanf("%d",&p); //重新输入选择信息}switch(p) //实现查询程序{case 1:printf(" 请输入你要的书的名字!\n");scanf("%s",&name1); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0) //调用strcmp函数{m=0;if(x[i]->Nowcounter!=0)x[i]->Nowcounter--;printf(" 借书成功!\n");if(x[i]->Nowcounter==0)printf(" 这本书已经没有了\n");}}if(m==1)printf(" 您要的书不存在!\n");break;case 2:printf(" 请输入你要的书的编号!\n");scanf("%s",&num1); // 输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0) //调用strcmp函数{m=0;if(x[i]->Nowcounter!=0)x[i]->Nowcounter--; //现存书数量减1printf(" 借书成功!\n");if(x[i]->Nowcounter==0)printf(" 这本书已经没有了\n");}}if(m==1)printf(" 您要的书不存在!\n");break;case 3:break;}}////////////////////////////归还程序//////////////////////void guihuan(datatype *x[],int n){int i,q,m=1;char name1[10],num1[10]; //定义两个字符数组printf(" 1.按书名归还\n"); //输出可选择方式printf(" 2.按书号归还\n");printf(" 3.返回\n");printf(" 请选择\n");scanf("%d",&q); //输入选择信息if(q>3||q<1){printf(" 您的输入有误!\n");scanf("%d",&q); //重新输入选择信息}switch(q) //实现归还程序{case 1:printf(" 输入归还书的书名: ");scanf("%s",&name1); // 输入书名for(i=0;i<n;i++){if(strcmp(x[i]->name,name1)==0){m=0;x[i]->Nowcounter++;printf("此书归还成功!\n");printf("此书的存储情况\n");printf("编号书名作者现存量总存量\n"); printf("===============================================\n");printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);printf("===============================================\n");}if(strcmp(x[i]->name,name1)==0)continue;}if(m==1)printf("此书不是图书馆的!\n");break;case 2:printf("输入归还书的书号\n");scanf("%s",&num1); // 输入书号for(i=0;i<n;i++){if(strcmp(x[i]->num,num1)==0){m=0;x[i]->Nowcounter++; //显存书增加1printf("此书归还成功!\n");printf("此书的存储情况\n");printf("编号书名作者现存量总存量\n"); printf("==============================================\n");printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i]->Nowcounter,x[i]->Allcounter);printf("==============================================\n");}if(strcmp(x[i]->num,num1)==0) //调用strcmp 函数continue;}if(m==1)printf("此书不是图书馆的!\n");break;case 3:break;}}//**************************************// 输出程序//**************************************void printlist(datatype *x[]){int i;printf("编号书名作者现存量总存量\n");//输出图书各项信息for(i=0;i<n;i++){printf(" %-10s%-10s%-10s%-10d%-10d\n",x[i]->num,x[i]->name,x[i]->addr,x[i ]->Nowcounter,x[i]->Allcounter);}printf("===============================================\n");}。
小型数据库应用系统开发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)进入主窗口后可进行修改密码、重新登录以及图书借阅查询的各种操作:。
广西交通职业技术学院信息工程系作品设计报告书题目:《图书管理系统》班级网络2012-1班学号***********姓名唐张森课程名称数据库应用技术指导教师乐文行二O一三年六月目录数据库课程设计报告书一、设计目标1.掌握计算机管理信息系统设计的一般方法,主要包括系统分析、系统设计的组织和实施。
2.关系型数据库管理系统的编程技术,并能独立完成一般小系统的程序设计、调试运行等工作。
3.培养把所学知识运用到具体对象,并能求出解决方案的能力。
二、数据库存储设计指导思想在数据库存储设计的无数选择中,简单是系统架构师和DBA 的秘密武器。
简单,有时候就来自于对一个特定的表或表空间没有选择最优I/O 特性,总有这么一种可能,一个富有经验的DBA 拥有高超的存储技能并可以没有时间限制的去为一个非常重要的表或者索引配置一个存储。
然而这样做的问题是,就算能达到设计的最佳性能,为了维护原始对象,这也经常造成对一个系统的管理变得更加复杂。
好的数据库存储设计的要点是,在一个动态系统上,实现所有目标应该是最初的系统设计的一部分,并应该在数据库运行过程中长期进行。
这篇文档简单的最佳实践描述达到了这些目标并且几乎没有性能损失。
三、任务角色:读者、图书馆馆员、系统管理员;基础数据:读者信息、图书信息、操作员信息;业务数据:借还书记录登记、罚款登记;统计数据:书籍借阅情况统计或读者借阅情况统计。
基本要求:利用数据库技术,完成基础数据和业务数据的储存和操作,数据库设计合理1.设计报告:含E-R图、数据字典、关系模式、关系实例、查询描述、关系代数、SQL 实现的查询语言及查询结果。
2.上机实现。
1.问题描述1.1背景随着图书馆规模的不断扩大,图书数量也相应的增加,有关图书的各种信息量也成倍增加,面对着庞大的信息量,传统的人工方式管理会导致图书馆管理上的混乱,人力与物力过多浪费,图书馆管理费用的增加,从而使图书馆的负担过重,影响整个图书馆的运作和控制管理,因此,必须制定一套合理、有效,规范和实用的图书管理系统,对图书资料进行集中统一的管理。
另一方面,IT产业和Internet获得了飞速发展,计算机应用已渗透到了各个领域,引起信息管理的革命,实现了信息的自动化处理,提高了处理的及时性和正确性。
提高图书管理工作效率,作到信息的规范管理,科学统计和快速查询,让图书馆更好的为学校,社会服务。
1.2数据需求图书馆管理信息系统需要完成功能主要有:1. 读者基本信息的输入,包括借书证编号、读者姓名、读者性别。
2.读者基本信息的查询、修改,包括读者借书证编号、读者姓名、读者性别等。
3.书籍类别标准的制定、类别信息的输入,包括类别编号、类别名称。
4.书籍类别信息的查询、修改,包括类别编号、类别名称。
5.书籍库存信息的输入,包括书籍编号、书籍名称、书籍类别、作者姓名、出版社名称、出版日期、登记日期。
6.书籍库存信息的查询,修改,包括书籍编号、书籍名称、书籍类别、作者姓名、出版社名称、出版日期登记日期等。
7.借书信息的输入,包括读者借书证编号、书籍编号、借书日期。
8.借书信息的查询、修改,包括借书证编号、读者编号、读者姓名、书籍编号、书籍名称、借书日期等。
9.还书信息的输入,包括借书证编号、书籍编号、还书日期。
10.还书信息的查询和修改,包括还书读者借书证编号、读者姓名、书籍编号、书籍名称、借书日期、还书日期等。
11.超期还书罚款输入,还书超出期限包括超出期限还书的读者借书证号,书籍编号,罚款金额。
12.超期还书罚款查询,删除,包括读者借书证编号、读者姓名、书籍编号、书籍名称,罚款金额等1.4关系模式(一)书籍类别(种类编号,种类名称)(二)读者(借书证编号,读者姓名,读者性别,读者种类,登记时期)(三)书籍(书籍编号,书籍名称,书籍类别,书记作者,出版社名称,出版日期,登记日期)(四)借阅(借书证编号,书籍编号,读者借书时间)(五)还书(借书证编号,书籍编号,读者还书时间)(六)罚款(借书证编号,读者姓名,借书证编号,书籍编号,读者借书时间)以上通过关系代数方法的进行运算得到所需要的结果,在实验结果中可以看到。
2.方案图表设计2.1 E-R图根据1)所要实现的功能设计,可能建立它们之间的关系,进而实现逻辑结构功能。
图书管理信息系统可以划分的实体有:书籍类别信息实体、读者信息实体、书籍信息实体、借阅记录信息实体,归还记录信息实体。
用E-R图一一描述这些实体。
2.1.1类别实体E-R图:图2-1类别实体E-R图2.1.2读者信息实体E-R图:图2-2 读者信息实体E-R图2.1.3信息实体E-R图:信息实体E-R图:图2-4 记录信息实体E-R图2.1.5记录信息实体E-R图:图2-5记录信息实体E-R图2.1.6罚款信息实体E-R图:图2-6罚款信息实体E-R图2.1.6总的信息实体E-R图:图2-7总的信息实体E-R图2.2数据流程图D2 D3图2-7系统的数据流程图2.3数据字典表2-1 book_sytle 书籍类别信息表表2-2 system_readers读者信息表格表2-3 system_book书籍信息表表2-4 borrow_record 借阅记录信息表表2-5 return_record 借阅记录信息表表2-6 reader_fee 罚款记录信息表2.4关系图:图2-8数据库存表关系图3.数据库源代码3.1数据库建立3.1.1创建数据库USE mastergoCREATE DATABASE tangzhangsentsgON(NAME= librarysystem,FILENAME='c:\tangzhangsenlibrary.mdf', SIZE= 10,MAXSIZE= 50,FILEGROWTH= 5)LOG ON(NAME='library',FILENAME='c:\tangzhangsenlibrary.ldf',SIZE= 5MB,MAXSIZE= 25MB,FILEGROWTH= 5MB)go3.1.2书本类别表建立create table book_style(bookstyleno varchar(30) primary key, bookstyle varchar(30))3.1.3创建书库表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), )3.1.4借书证表建立create table system_readers( readerid varchar(9)primary key,readername varchar(9)not null ,readersex varchar(2) not null,readertype varchar(10),regdate datetime)3.1.5借书记录表建立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), )3.1.6还书记录表建立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) )3.1.7罚款单表建立*/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))3.2数据初始化3.2.1将书籍类别加入表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','言情小说')3.2.2将已有的图书加入system_books表中insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub,bookpubdate, bookindate, isborrowed )values('20135678901','飘渺之旅','1','萧潜','鲜网','2005-09-01','2013-05-25','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub,bookpubdate, bookindate, isborrowed )values('20135678902','唐朝好男人','2','多一半','新星出版社','2008-05-09','2013-05-26','1');insertinto system_books(bookid ,bookname,bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('20135678903','鬼吹灯','3','天下霸唱','安徽文艺出版社','2007-09-18','2013-05-27','1');insertinto system_books(bookid ,bookname, bookstyleno,bookauthor,bookpub,bookpubdate, bookindate, isborrowed )values('20135678904','和空姐同居的日子','4','三十','中国海关出版社','2009-04-08','2013-05-28','1');insertinto system_books(bookid ,bookname,bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('20135678905','卡徒','5','方想','广西人民出版社','2009-10-11','2013-05-29','1'); insertinto system_books(bookid ,bookname,bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('20135678906','蜀山剑侠传','6','还珠楼主','山西人民出版社','1998-08-17','2013-05-30','1');insertinto system_books(bookid ,bookname,bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('20135678907','何以笙箫默','7','顾漫','朝华出版社','2007-04-09','2013-05-31','1'); insertinto system_books(bookid ,bookname,bookstyleno,bookauthor,bookpub, bookpubdate,bookindate, isborrowed )values('20135678908','步步惊心','2','桐华','民族出版社','2006-06-20','2013-05-30','1');3.2.3将已有图书证的读者加入system_readers表中*/insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q20120401','李雷','男','学生','2013-01-18 12:20')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q20120402','唐张森','男','学生','2013-01-19 13:15')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q20120403','韩梅梅','女','学生','2013-01-20 13:33')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q20120404','露西','女','学生','2013-01-21 12:01')insert into system_readers(readerid,readername,readersex,readertype,regdate) values('Q20120405','王强','男','学生','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')3.2.4添加已借书读者的记录,同时将在已借出的借阅标记置0*/insert into borrow_record(bookid,readerid,borrowdate)values('20135678901','Q20120401','2013-01-18 12:20')update system_booksset isborrowed=0where bookid='20135678901'insert into borrow_record(bookid,readerid,borrowdate) values('20135678902','Q20120402','2013-01-19 13:15') update system_booksset isborrowed=0where bookid='20135678902' and isborrowed='1'insert into borrow_record(bookid,readerid,borrowdate) values('20135678903','Q20120403','2013-01-20 13:33') update system_booksset isborrowed=0where bookid='20135678903' and isborrowed='1' insert into borrow_record(bookid,readerid,borrowdate) values('20135678904','Q20120404','2013-01-21 12:01') update system_booksset isborrowed=0where bookid='20135678904' and isborrowed='1' insert into borrow_record(bookid,readerid,borrowdate) values('20135678905','Q20120405','2013-01-22 15:23') update system_booksset isborrowed=0where bookid='20135678905' and isborrowed='1' insert into borrow_record(bookid,readerid,borrowdate) values('20135678907','201005','2013-01-23 18:50') update system_booksset isborrowed=0where bookid='20135678907' and isborrowed='1' insert into borrow_record(bookid,readerid,borrowdate) values('20135678908','201006','2013-01-24 18:25') update system_booksset isborrowed=0where bookid='20135678908' and isborrowed='1'4.结果数据处理4.1单表查询4.1.1表book_style中查询演示:查询语句:select*from book_style图4-1 表book_style中内容4.1.2表system_books中查询演示:查询语句:select*from system_books图4-2 表system_books中内容4.1.3将已有图书证的读者加入system_readers表中结果查询:查询语句:select*from system_readers图4-3 表system_readers中内容4.1.4借书纪录表borrow_record结果查询:查询语句:select*from borrow_record图4-4 表borrow_record中内容4.2超期处理4.2.1现在对已有借书证的读者进行查询借书是否超期查询语句:(这里归定30天):select system_readers.readerid 读者借书证编号,readername 读者姓名, system_books.bookid 书籍编号,bookname 书名,borrowdate 借书时间, datediff(day,convert(smalldatetime,borrowdate),getdate())-30 超过天数from borrow_record ,system_readers,system_bookswhere system_readers.readerid=borrow_record.readeridand system_books.bookid=borrow_record.bookidand datediff(day,convert(smalldatetime,borrowdate),getdate())>=30说明:当前的getdate()以当前的时间和日期计算图4-4 选出借出超过30天的读者4.2.2同时也可以用语句超过天数的读者进行罚款,加入到罚款单里面,一天以0.3元扣除计算:语句insert into reader_fee(readerid,readername,bookid,bookname,bookfee,borrowdate) select system_readers.readerid 读者借书证编号,readername 读者姓名,system_books.bookid 书籍编号,bookname 书名,0.03*(Datediff(day,convert(smalldatetime,borrowdate),getdate())-30)超过时间天数, borrowdate 借书时间from borrow_record ,system_readers ,system_bookswhere system_readers.readerid=borrow_record.readeridand system_books.bookid=borrow_record.bookidand Datediff(day,convert(smalldatetime,borrowdate),getdate())>=30 goselect readerid 书读者借书证编号,readername 读者姓名,bookid 书籍编号,bookfee 超期罚款from reader_fee图4-5查看罚款单4.3还书操作4.3.1现在对某一读者进行还书操作:1.首先还书要在还书纪录中添加一条还书纪录insert into return_record(bookid,readerid,returndate)select bookid,readerid,getdate()from borrow_recordwhere bookid='20135678901'(1 行受影响)查询语句:select bookid 书籍编号,readerid 读者借书证号,returndate 归还时间from return_record图4-6 增加了20135678901纪录2.其次删除相应书本的借阅纪录deletefrom borrow_recordwhere bookid='20135678901'(1 行受影响)查询语句:select bookid 书籍编号,readerid 读者借书证号,borrowdate 归还时间from borrow_record图4-7 20135678901这本书在借书纪录里没有了3.最后在书库中标记该本书为1,表示归还了未借,可供其他读者借阅update system_booksset isborrowed=1where bookid='20135678901'(1 行受影响)查询语句:select bookid 书籍编号,bookname 书籍名称,isborrowed 是否借出from system_bookswhere bookid='20135678901'图4-8 标记设为了‘1’说明:这本书重新回到未被借出标记为1其结果为还书成功,相应的各表都有变化,对于罚款单通过借阅记录表borrow_record中更新。