RFID图书管理系统程序源代码

合集下载

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

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

图书管理系统数据库源代码//创建工程及设计主界面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);}}}。

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

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

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

h〉#include<conio。

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

图书馆管理系统源代码

图书馆管理系统源代码

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

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

图书馆管理系统完整代码

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

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

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

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

主窗口界面import java.awt。

*;import java.awt。

event.*;import javax。

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

Font;import javax.swing。

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

RFID图书管理系统程序源代码

RFID图书管理系统程序源代码

登陆界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Labrary{public partial class FormLogin : Form{public FormLogin(){InitializeComponent();}页脚内容1///<summary>///验¨¦证¡è控?件t///</summary>///<returns></returns>private bool ValidControl(){if (this.tbID.Text == ""){MessageBox.Show("请填写用户名!ê?");this.tbID.Focus();return false;}if (this.tbID.Text != "admin"){if (!UserManage.ObjUser.IsHasID(All.dbo, this.tbID.Text)){页脚内容2MessageBox.Show("不存在此用户!ê?");this.tbID.Text = "";this.tbID.Focus();return false;}}if (this.tbID.Text != "admin"){UserManage.ObjUser user= new UserManage.ObjUser(this.tbID.Text, All.dbo);if (user.PWD != this.tbPWD.Text){MessageBox.Show("密码错误!ê?");this.tbPWD.Text = "";this.tbPWD.Focus();return false;}页脚内容3}else{if (this.tbPWD.Text != "123456"){MessageBox.Show("密码错误!");this.tbPWD.Text = "";this.tbPWD.Focus();return false;}}return true;}private void gbtnCancel_Click(object sender, EventArgs e) {页脚内容4this.Close();}private void gbtnOK_Click(object sender, EventArgs e){//如¨?果?验¨¦证¡è控?件t通ª¡§过yif (ValidControl()){if (this.tbID.Text != "admin"){erLogin = new UserManage.ObjUser(this.tbID.Text, All.dbo);}else{erLogin = new UserManage.ObjUser(All.dbo);erLogin.ID = "admin"; = "管理员";页脚内容5}this.DialogResult = DialogResult.OK;this.Close();}}}}主界面using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;页脚内容6namespace Labrary{public partial class FormMain : Form{public const int WM_USER = 0x0400;public const int WM_GETBUFFER_LOOP = WM_USER + 2;private RFID_dll.Reader rdr;private RFID_dll.RFID rfid;List<string> rfids = new List<string>();int directionFlag = 0;//1进;出?FormInAndOut fiao = new FormInAndOut();public FormMain(){InitializeComponent();页脚内容7this.rdr = new RFID_dll.Reader();//this.rfid = new RFID_dll.RFID(rdr);}private void FormMain_Load(object sender, EventArgs e) {Init();}///<summary>///初始化///</summary>private void Init(){fiao.StartPosition = FormStartPosition.Manual;//多窗体在不同时间显示Screen[] screens = Screen.AllScreens;页脚内容8if (screens.Length == 2){List<Screen> listScreen = new List<Screen>();foreach (Screen screen in Screen.AllScreens){if (screen.Primary == false){listScreen.Add(screen);}}fiao.Location = listScreen[0].WorkingArea.Location;}SetMenJin("PicIn");fiao.Show();//toolStripStatusLabel2显示登陆用户名? toolStripStatusLabel2.Text = ;页脚内容9this.panel1.BackgroundImage = null;//菜单栏全部显示º?this.用®?户¡ì管¨¹理¤¨ªToolStripMenuItem.Visible = true; this.系¦Ì统ª3初?始º?化¡¥CToolStripMenuItem.Visible = true;this.应®|用®?模¡ê式º?ToolStripMenuItem.Visible = true;this.图ª?书º¨¦管¨¹理¤¨ªToolStripMenuItem.Visible = true; this.退ª?办㨬卡¡§ToolStripMenuItem.Visible = true; this.借¨¨阅?ToolStripMenuItem.Visible = true;this.门?禁?ToolStripMenuItem.Visible = true;SetPurview();this.toolStrip1.Visible = false;this.toolStrip2.Visible = false;this.toolStrip3.Visible = false;页脚内容10//rfid.OpenSerial();////是º?否¤?找¨°到Ì?门?禁?设¦¨¨备À?//if (rfid.ChangeWorkModel(2))//{// rfid.StartInventory(this.Handle.ToInt32(),2);//}}///<summary>///权限设置///</summary>private void SetPurview(){if (erLogin.ID == "admin"){this.应®|用®?模¡ê式º?ToolStripMenuItem.Visible = false;页脚内容11}else{this.用户管理¨ªToolStripMenuItem.Visible = false;this.系统初始化¡¥CToolStripMenuItem.Visible = false;this.读书管理¨ªToolStripMenuItem.Visible = false;this.退办卡¡§ToolStripMenuItem.Visible = false;this.借阅ToolStripMenuItem.Visible = false;this.门禁?ToolStripMenuItem.Visible = false;for (int i = 0; i < erLogin.Purview.Count; i++){string purview = erLogin.Purview[i];if (purview == "1"){this.图书管理¨ªToolStripMenuItem.Visible = true;}页脚内容12else if (purview == "2"){this.办退卡¡§ToolStripMenuItem.Visible = true;}else if (purview == "3"){this.借阅?ToolStripMenuItem.Visible = true;}else if (purview == "4"){this.门禁ToolStripMenuItem.Visible = true;}}}}private void用户管理¨ªToolStripMenuItem_Click(object sender, EventArgs e)页脚内容13{UserManage.FormUserList ful = new UserManage.FormUserList(All.conn);ful.ShowDialog();}private void修改密码?ToolStripMenuItem_Click(object sender, EventArgs e){UserManage.FormUserPwd fup = new UserManage.FormUserPwd(All.conn, erLogin);fup.ShowDialog();}private void tsbtnBookType_Click(object sender, EventArgs e){FormBookTypeList fbtl = new FormBookTypeList();fbtl.ShowDialog();}private void tsbtnBookAdd_Click(object sender, EventArgs e)页脚内容14{FormBookAdd fba = new FormBookAdd();fba.ShowDialog();}private void tsbtnBookManage_Click(object sender, EventArgs e){FormBookInfoList fbil = new FormBookInfoList();fbil.ShowDialog();}private void tsbtnBookStatistics_Click(object sender, EventArgs e){FormBookStatistics fbs = new FormBookStatistics();fbs.ShowDialog();}private void退ª?出?XToolStripMenuItem_Click(object sender, EventArgs e)页脚内容15{this.Close();}private void tsbtnCardAdd_Click(object sender, EventArgs e){FormCardInfo fci = new FormCardInfo(1, new ObjCardInfo());fci.ShowDialog();}private void tsbtnCardManage_Click(object sender, EventArgs e) {FormCardList fcl = new FormCardList();fcl.ShowDialog();}private void tsbtnAddTime_Click(object sender, EventArgs e){页脚内容16string rfid = RfidOperate.GetCard();if (rfid == ""){MessageBox.Show("请把借阅卡放到桌面读写器上!"); }else{if (ObjCardInfo.IsHas(rfid)){ObjCardInfo oci = new ObjCardInfo(rfid);FormCardInfo fci = new FormCardInfo(5, oci);fci.ShowDialog();}else{MessageBox.Show("没有此借阅卡信息");}页脚内容17}}private void tsbtnCardDelete_Click(object sender, EventArgs e) {string rfid = RfidOperate.GetCard();if (rfid == ""){MessageBox.Show("请把借阅卡到读写器上?");}else{if (ObjCardInfo.IsHas(rfid)){ObjCardInfo oci = new ObjCardInfo(rfid);int count = oci.NotReturnCount();页脚内容18if (count == 0){if (MessageBox.Show("是否决定退卡!ê?", "", MessageBoxButtons.YesNo) == DialogResult.Yes){oci.Delete();MessageBox.Show("退卡成功|!ê?");}}else{MessageBox.Show( + "还有一本" + count.ToString() + " 本书未归还不能退卡?");}}else{MessageBox.Show("没有此借阅信息?");页脚内容19}}}private void tsbtnJie_Click(object sender, EventArgs e){FormBookJie fbj = new FormBookJie(1);fbj.ShowDialog();}private void tsbtnHuan_Click(object sender, EventArgs e){FormBookHuan fbh = new FormBookHuan();fbh.ShowDialog();}private void图ª?书º¨¦管¨¹理¤¨ªToolStripMenuItem_Click(object sender, EventArgs e) {页脚内容20this.toolStrip1.Visible = true;this.toolStrip2.Visible = false;this.toolStrip3.Visible = false;this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\1.jpg");}private void退ª?办㨬卡¡§ToolStripMenuItem_Click(object sender, EventArgs e){this.toolStrip1.Visible = false;this.toolStrip2.Visible = true;this.toolStrip3.Visible = false;this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\2.jpg");}private void借¨¨阅?ToolStripMenuItem_Click(object sender, EventArgs e){页脚内容21this.toolStrip1.Visible = false;this.toolStrip2.Visible = false;this.toolStrip3.Visible = true;this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\3.jpg");}private void门?禁?ToolStripMenuItem_Click(object sender, EventArgs e){//MenJinInit();//this.toolStrip1.Visible = false;//this.toolStrip2.Visible = false;//this.toolStrip3.Visible = false;//this.panel1.BackgroundImage = null;//rfid.OpenSerial();页脚内容22////是否找到门禁设备?//if (rfid.IsOpen)//{// rfid.StartInventory(this.Handle.ToInt32());//}}private void注销²ToolStripMenuItem_Click(object sender, EventArgs e) {erLogin = null;FormLogin fl = new FormLogin();if (fl.ShowDialog() != DialogResult.OK){this.Close();}else{页脚内容23Init();}}private void帮助¨²ToolStripMenuItem1_Click(object sender, EventArgs e){}private void系统初始化¡¥CToolStripMenuItem_Click(object sender, EventArgs e){if (MessageBox.Show("是否初始化数据库?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) {All.dbo.excuteSql("delete from lendtable");All.dbo.excuteSql("delete from bookinfo");All.dbo.excuteSql("delete from booktype");All.dbo.excuteSql("delete from librarycard");All.dbo.excuteSql("delete from usertable");页脚内容24MessageBox.Show("初始化完成?");}}private void关于ToolStripMenuItem_Click(object sender, EventArgs e){FormAbout fa = new FormAbout();fa.ShowDialog();}protected override void DefWndProc(ref System.Windows.Forms.Message m) {if (m.Msg == WM_GETBUFFER_LOOP){//启动if (this.timer1.Tag.ToString() == "0")页脚内容25{this.timer1.Start();this.timer1.Tag = "1";}string uid = "";string direction = "";bool personWithMultCard = false;rdr.GetLoopGetBufferData(m, ref uid, ref direction, ref personWithMultCard); if (uid != "0000000000000000"){//进if (direction == "In"){this.directionFlag = 1;this.rfids.Add(uid);}页脚内容26//出if (direction == "Out"){this.directionFlag = 2;this.rfids.Add(uid);}if (uid == "FFFFFFFFFFFFFFFF"){}}}base.DefWndProc(ref m);}页脚内容27private void timer1_Tick(object sender, EventArgs e){if (this.directionFlag == 1){for (int i = 0; i < this.rfids.Count; i++){if (ObjCardInfo.IsHas(this.rfids[i])){ObjCardInfo oci = new ObjCardInfo(this.rfids[i]);if (oci.IsOverTime()){SetMenJin("PicInOutTime");MenJinInit();return;}else页脚内容28{SetMenJin("PicIn");MenJinInit();return;}}}SetMenJin("PicInNoCard");MenJinInit();}else if (this.directionFlag == 2){for (int i = 0; i < this.rfids.Count; i++){if (ObjBookInfo.IsHas(this.rfids[i])){页脚内容29ObjBookInfo obi = new ObjBookInfo(this.rfids[i]);if (obi.LendStatus == "为借出?"){this.rdr.WarningOutput(false, false, true, false, false);SetMenJin("PicOut");MenJinInit();return;}}}MenJinInit();}}///<summary>///门禁初始化///</summary>页脚内容30private void MenJinInit(){this.rfids.Clear();this.directionFlag = 0;this.timer1.Tag = "0";this.timer1.Stop();}private void SetMenJin(string message){this.fiao.Controls.Clear();UserControlMenJin ucmj = new UserControlMenJin(message);ucmj.Dock = DockStyle.Fill;this.fiao.Controls.Add(ucmj);}页脚内容31private void FormMain_FormClosing(object sender, FormClosingEventArgs e) {//this.rfid.StopInventory();//this.rfid.CloseSerial();}}}图书统计using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;页脚内容32namespace Labrary{public partial class FormBookStatistics : Form{private int boolShelf;public FormBookStatistics(){InitializeComponent();BindTreeView();this.boolShelf = 0;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo");this.cboBookLendStatus.SelectedIndex = 0;}页脚内容33private void BindTreeView(){this.treeView1.Nodes.Clear();TreeNode nodeRoot = new TreeNode();nodeRoot.Text = "全部书架¹";this.treeView1.Nodes.Add(nodeRoot);for (int i = 0; i < 4; i++){TreeNode nodeChild = new TreeNode();if (i == 0){nodeChild.Text = "第一书架¹";}if (i == 1){nodeChild.Text = "第二书架¨¹";页脚内容34}if (i == 2){nodeChild.Text = "第三书架¨¹";}if (i == 3){nodeChild.Text = "第四书架¨¹";}nodeRoot.Nodes.Add(nodeChild);}nodeRoot.Expand();}private void BindListView(string sql){this.listView1.Items.Clear();页脚内容35this.listView1.Columns.Clear();string[] headerText = new string[] { "标签,100", "所属分类¤¨¤,100", "书名,150", "作者,80", "借阅状态,80", "所在书架,80" };for (int i = 0; i < headerText.Length; i++){ColumnHeader header = new ColumnHeader();string headerName = headerText[i].Split(',')[0];int headerWidth = Convert.ToInt32(headerText[i].Split(',')[1]);header.Text = headerName;header.Width = headerWidth;this.listView1.Columns.Add(header);}DataTable dtb = All.dbo.getDataTable(sql);页脚内容36for (int i = 0; i < dtb.Rows.Count; i++){ObjBookInfo bookInfo = new ObjBookInfo(dtb.Rows[i]["RFID"].ToString());ListViewItem item = new ListViewItem(new string[] { bookInfo.RFID, , , bookInfo.Author, bookInfo.LendStatus, bookInfo.BookShelf });this.listView1.Items.Add(item);}ListViewItem itemCount = new ListViewItem(new string[] { "统ª3计?", "", "", "", "",dtb.Rows.Count.ToString() + "本À?" });this.listView1.Items.Add(itemCount);}private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e){if (e.Node.Text == "全部书架¨¹")页脚内容37{this.boolShelf = 0;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo"));}if (e.Node.Text == "第一书架¨¹"){this.boolShelf = 1;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='1'"));}if (e.Node.Text == "第二书架¨¹"){this.boolShelf = 2;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='2'"));}if (e.Node.Text == "第三书架¨¹")页脚内容38{this.boolShelf = 3;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='3'"));}if (e.Node.Text == "第四书架¨¹"){this.boolShelf = 4;BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='4'"));}}private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e){if (this.boolShelf == 0){if (this.cboBookLendStatus.SelectedIndex == 0)页脚内容39{BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo"));}if (this.cboBookLendStatus.SelectedIndex == 1){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where LendStatus='1'"));}if (this.cboBookLendStatus.SelectedIndex == 2){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where LendStatus='0'"));}}if (this.boolShelf > 0){if (this.cboBookLendStatus.SelectedIndex == 0)页脚内容40{BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}'", this.boolShelf.ToString()));}if (this.cboBookLendStatus.SelectedIndex == 1){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}' and LendStatus='1'", this.boolShelf.ToString()));}if (this.cboBookLendStatus.SelectedIndex == 2){BindListView(string.Format("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}' and LendStatus='0'", this.boolShelf.ToString()));}}}}}页脚内容41借阅卡管理using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Labrary{public partial class FormCardList : Form{public FormCardList(){InitializeComponent();SetListView();页脚内容42}private void SetListView(){this.listView1.Items.Clear();List<ObjCardInfo> listCard = ObjCardInfo.GetAllCard();for (int i = 0; i < listCard.Count; i++){ObjCardInfo oci = listCard[i];ListViewItem item = new ListViewItem(oci.Rfid);item.Tag = oci;ListViewItem.ListViewSubItem subitem1 = new ListViewItem.ListViewSubItem();subitem1.Text = ;item.SubItems.Add(subitem1);页脚内容43ListViewItem.ListViewSubItem subitem2 = new ListViewItem.ListViewSubItem(); subitem2.Text = oci.Sex;item.SubItems.Add(subitem2);ListViewItem.ListViewSubItem subitem3 = new ListViewItem.ListViewSubItem(); subitem3.Text = oci.Brithday.ToString("yyyy年¨ºMM月?dd日¨?");item.SubItems.Add(subitem3);ListViewItem.ListViewSubItem subitem4 = new ListViewItem.ListViewSubItem(); subitem4.Text = oci.SID;item.SubItems.Add(subitem4);ListViewItem.ListViewSubItem subitem5 = new ListViewItem.ListViewSubItem(); subitem5.Text = oci.StartTime.ToString();item.SubItems.Add(subitem5);ListViewItem.ListViewSubItem subitem6 = new ListViewItem.ListViewSubItem(); subitem6.Text = oci.EndTime.ToString();页脚内容44item.SubItems.Add(subitem6);ListViewItem.ListViewSubItem subitem7 = new ListViewItem.ListViewSubItem();subitem7.Text = ;item.SubItems.Add(subitem7);this.listView1.Items.Add(item);}}private void SetListView(List<ObjCardInfo> listCard){this.listView1.Items.Clear();for (int i = 0; i < listCard.Count; i++){ObjCardInfo oci = listCard[i];页脚内容45ListViewItem item = new ListViewItem(oci.Rfid);item.Tag = oci;ListViewItem.ListViewSubItem subitem1 = new ListViewItem.ListViewSubItem(); subitem1.Text = ;item.SubItems.Add(subitem1);ListViewItem.ListViewSubItem subitem2 = new ListViewItem.ListViewSubItem(); subitem2.Text = oci.Sex;item.SubItems.Add(subitem2);ListViewItem.ListViewSubItem subitem3 = new ListViewItem.ListViewSubItem(); subitem3.Text = oci.Brithday.ToString("yyyy年¨ºMM月?dd日¨?");item.SubItems.Add(subitem3);ListViewItem.ListViewSubItem subitem4 = new ListViewItem.ListViewSubItem(); subitem4.Text = oci.SID;item.SubItems.Add(subitem4);页脚内容46ListViewItem.ListViewSubItem subitem5 = new ListViewItem.ListViewSubItem();subitem5.Text = oci.StartTime.ToString();item.SubItems.Add(subitem5);ListViewItem.ListViewSubItem subitem6 = new ListViewItem.ListViewSubItem();subitem6.Text = oci.EndTime.ToString();item.SubItems.Add(subitem6);ListViewItem.ListViewSubItem subitem7 = new ListViewItem.ListViewSubItem();subitem7.Text = ;item.SubItems.Add(subitem7);this.listView1.Items.Add(item);}}private void tsbtnExit_Click(object sender, EventArgs e)页脚内容47{this.Close();}private void tsbtnInsert_Click(object sender, EventArgs e){FormCardInfo fci = new FormCardInfo(1, new ObjCardInfo());if (fci.ShowDialog() == DialogResult.OK){SetListView();IsEnabled(false);}}private void IsEnabled(bool Enabled){//this.tsbtnAddTime.Enabled = Enabled;this.tsbtnUpdate.Enabled = Enabled;页脚内容48this.tsbtnDelete.Enabled = Enabled;this.tsbtnRecord.Enabled = Enabled;}private void listView1_SelectedIndexChanged(object sender, EventArgs e) {if (this.listView1.SelectedItems.Count > 0){IsEnabled(true);}else{IsEnabled(false);}}private void tsbtnAddTime_Click(object sender, EventArgs e){页脚内容49if (this.listView1.SelectedItems.Count > 0){ObjCardInfo oci = this.listView1.SelectedItems[0].Tag as ObjCardInfo;FormCardInfo fci = new FormCardInfo(5, oci);if (fci.ShowDialog() == DialogResult.OK){SetListView();IsEnabled(false);}}}private void tsbtnUpdate_Click(object sender, EventArgs e){if (this.listView1.SelectedItems.Count > 0){ObjCardInfo oci = this.listView1.SelectedItems[0].Tag as ObjCardInfo;页脚内容50。

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

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

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

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

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

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

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

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

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

图书借阅管理系统代码图书管理系统源代码#include#include#include#define num 7 //全局定义void showmain() //显示菜单{printf("\n\n 欢迎使用图书借阅管理系统\n\n");printf(" 1、查询所有图书\n\n");printf(" 2、归还现有图书\n\n");printf(" 3、租借现有图书\n\n");printf(" 0、退出借书系统\n\n");printf(" 请输入您所需的服务编号:");}void viewbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num]){int i;int j;for(i=1;i<7;i++) //设置编号score[i]=i;yajin[1]=26.00; //将原图书的各项值保存yajin[2]=28.50;yajin[3]=98.00;yajin[4]=79.80;yajin[5]=49.00;yajin[6]=15.00;for(i=1;i<7;i++) //将原图书的各项值保存free[i]=30;jiage[i]=0.5;}flag[1]=0; //flag为0代表已借出,为1代表未借出flag[2]=1;flag[3]=1;flag[4]=0;flag[5]=1;flag[6]=1;printf("编号\t|书名\t |作者\t|押金\t|免费天数\t|收费价格\t|出租状态\n"); //制表同时输出printf("---------------------------------------------------------------------------\n");for(i=1;i<7;i++){printf("%d\t|%s\t|%s\t|%.2lf\t|%d\t|%.2lf\t|",score[i],name[i], writter[i],yajin[i],free[i],jiage[i]);if(flag[i]==0){printf("已借出\n"); //通过设置flag来判定是否被借出}else{printf("未借出\n");}}}void returnbooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num])int bianhao;int panding=0; //设置一个值来判断该操作是否会成功int i;printf("\n 请输入要归还图书的编号:");scanf("%d",&bianhao);for(i=1;i<7;i++){if(score[i]==bianhao){if(flag[i]==0) //库中存在该书且已经被借出{printf("\n 操作成功...\n");printf("%s %s %.2lf %d %.2lf ",name[i],writter[i],yajin[i],free[i],jiage[i]);flag[i]=1;panding=1; //操作成功的提示printf("已归还\n");}}}if(panding==0)printf("\n 操作失败\n\n 该图书未借出!\n");}void jiebooks(int score[num],char name[num][100],char writter[num][100],double yajin[num],int free[num],double jiage[num],int flag[num]){int bianhao;int panding=0; //设置一个值来判断该操作是否会成功int i;printf("\n 请输入要租借图书的编号:");scanf("%d",&bianhao);for(i=1;i<7;i++){if(score[i]==bianhao){if(flag[i]==1) //库中存在该书且仍未被借出{printf("\n 操作成功...\n");printf("%s %s %.2lf %d %.2lf ",name[i],writter[i],yajin[i],free[i],jiage[i]);flag[i]=0;panding=1; //操作成功的提示printf("已借出\n");}}}if(panding==0)printf("\n 操作失败\n\n 该图书已借出!\n");}int main(){int choose; //用户的选择int score[7];char name[7][100]={"0","C语言设计","Java程序设计","C#入门经典","Visual Basic","Linux 标准教程","会计基础"}; //二维数组的初始化char writter[7][100]={"0","谭浩强","王志文","karli Watson","Bryan Newsome","IT 同路人","中国会计学会"}; //二维数组的初始化double yajin[7];int free[7];double jiage[7];int flag[7];while(1) //每次选择后返回主菜单{showmain();scanf("%d",&choose);switch(choose){case 1: //查询所有图书viewbooks(score,name,writter,yajin,free,jiage,flag);break;case 2: //归还现有图书returnbooks(score,name,writter,yajin,free,jiage,flag);break;case 3: //租借现有图书jiebooks(score,name,writter,yajin,free,jiage,flag);break;case 0: //退出系统printf("\n 感谢您的使用!\n");exit(0);break;default: printf("\n 感谢您的使用!\n"); exit(0);break;}}return 0;}。

图书管理系统程序代码

图书管理系统程序代码

#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{。

图书管理系统源码(java实现)

图书管理系统源码(java实现)

【图书管理系统】【MainPro包】1.系统登录页面public class Login extends Frame {private static final long serialVersionUID = -1758475247807861408L;TextField text_user;TextField text_pass;public Login() {1 this.setTitle("登录");this.setLayout(null);//默认流式布局this.setSize(260, 170);/* 定义标签与文本框*/Label lbUser = new Label("用户名:");text_user = new TextField();Label lbPass = new Label("密码:");text_pass = new TextField();Button btn_ok = new Button("确定");Button btn_cancel = new Button("取消");lbUser.setBounds(40, 53, 60, 20);//x,y,width,heightlbPass.setBounds(40, 83, 60, 20);text_user.setBounds(100, 50, 120, 20);text_pass.setBounds(100, 80, 120, 20);btn_ok.setBounds(45, 120, 80, 25); // 确定按钮btn_cancel.setBounds(135, 120, 80, 25); // 取消按钮/* 添加标签与文本框*/add(lbUser);add(lbPass);add(text_user);add(text_pass);add(btn_ok);add(btn_cancel);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置this.setVisible(true); // 使窗体可见btn_ok.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {btn_okActionPerformed(e);//自定义确定按钮触发的实施过程}}));btn_cancel.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}}));this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);} }); }public void btn_okActionPerformed(ActionEvent e) {String user = text_user.getText();String pass = text_pass.getText();String is_admin;// 如果用户名或密码任一为空,则终止后续操作if (user.equals("")||pass.equals("")) {JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");return;}try {// 核对用户名和密码String sql = "select * from user where username=" + "'" + user + "' and password=" + "'" + pass + "'";ResultSet rs = DbOp.executeQuery(sql);// 如果此用户存在,则记录其状态(否:不是管理员,是:是管理员)if (rs.next()) {is_admin = rs.getString("is_admin");} else {JOptionPane.showMessageDialog(null, "用户名或密码不正确!");return;}GlobalVar.login_user = user; // 记录登录的用户名ShowMain show = new ShowMain(); // 调用主程序// 只有管理员才能使用"基础管理"和"借阅管理"菜单show.setRights(is_admin);// 释放窗体及其全部组件的屏幕资源,即使释放登录窗体dispose(); // 释放当前窗体} catch (SQLException e1) {JOptionPane.showMessageDialog(null, "用户数据库有误!");}}}2.系统首页页面public class ShowMain extends Frame {private static final long serialVersionUID = 5003296786441785470L;MenuBar menuBar;Menu jcwh, jcwh_book, jcwh_reader;//基础维护:图书维护、读者维护Menu jywh, cxgl, xtgl;//借阅维护、查询管理、系统管理MenuItemjcwh_book_add,jcwh_book_update,jcwh_book_delete,jcwh_reader_add,jcwh_reader_update,jcwh_reader_delete;MenuItem jywh_borrow, jywh_back;MenuItem cxgl_book, cxgl_reader;MenuItem xtgl_update_pass, xtgl_exit;public void setRights(String rights) {// 如果不是管理员,则禁止用户维护图书信息和读者信息以及禁止进行借阅管理,即只能查询if (rights.equals("否")) {jywh.setEnabled(false);jcwh.setEnabled(false);}}public ShowMain() {setTitle("图书管理系统");setLayout(new BorderLayout());setSize(640, 480);menuBar = new MenuBar();jcwh = new Menu("基础维护");// 基础维护菜单jcwh_book = new Menu("图书维护");// 图书维护菜单jcwh_book_add = new MenuItem("添加");// 添加图书菜单jcwh_book_update = new MenuItem("修改");// 修改图书菜单jcwh_book_delete = new MenuItem("删除");// 删除图书菜单jcwh_reader = new Menu("读者维护");// 读者维护菜单jcwh_reader_add = new MenuItem("添加读者");// 添加读者菜单jcwh_reader_update = new MenuItem("修改读者");jcwh_reader_delete = new MenuItem("删除读者");jywh = new Menu("借阅管理");jywh_borrow = new MenuItem("借书管理");jywh_back = new MenuItem("还书管理");cxgl = new Menu("查询管理");cxgl_book = new MenuItem("图书查询");cxgl_reader = new MenuItem("读者查询");xtgl = new Menu("系统管理");xtgl_update_pass = new MenuItem("修改密码");xtgl_exit = new MenuItem("退出系统");// 添加图书菜单jcwh_book.add(jcwh_book_add);jcwh_book.add(jcwh_book_update);jcwh_book.add(jcwh_book_delete);jcwh.add(jcwh_book);jcwh_reader.add(jcwh_reader_add);jcwh_reader.add(jcwh_reader_update);jcwh_reader.add(jcwh_reader_delete);jcwh.add(jcwh_reader);jywh.add(jywh_borrow);jywh.add(jywh_back);cxgl.add(cxgl_book);cxgl.add(cxgl_reader);xtgl.add(xtgl_update_pass);xtgl.add(xtgl_exit);menuBar.add(jcwh);menuBar.add(jywh);menuBar.add(cxgl);menuBar.add(xtgl);setMenuBar(menuBar);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见jcwh_book_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("save");} });jcwh_book_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("update");} });jcwh_book_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("delete");} });jcwh_reader_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("save");} });jcwh_reader_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("update");} });jcwh_reader_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("delete");} });jywh_borrow.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Borrow();} });jywh_back.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Back();} });cxgl_book.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookQuery();} });cxgl_reader.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderQuery();} });xtgl_update_pass.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new UpdatePassword();} });xtgl_exit.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});}}3.图书管理public class BookManeger extends JFrame {private static final long serialVersionUID = 377287301994613384L;private Label lbbookid_c = new Label("图书编号");private TextField tf_bookid_c = new TextField();private Label lbbookid = new Label("图书编号");private TextField tf_bookid = new TextField();private Label lbbookname = new Label("图书名称");private TextField tf_bookname = new TextField();private Label lbbooktype = new Label("图书类别");private Choice tf_booktype = new Choice();private Label lbauthor = new Label("作者");private TextField tf_author = new TextField();private Label lbtranslator = new Label("译者");private TextField tf_translator = new TextField();private Label lbpublisher = new Label("出版社");private TextField tf_publisher = new TextField();private Label lbpublish_time = new Label("出版时间");private TextField tf_publish_time = new TextField();private Label lbprice = new Label("定价");private TextField tf_price = new TextField();private Label lbstock = new Label("库存数量");private TextField tf_stock = new TextField();private Button queryBtn = new Button("查询");private Button saveBtn = new Button("保存");private Button closeBtn = new Button("关闭");private String optionStr;BookManeger(String str) {optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid);map.put("bookname", tf_bookname);map.put("booktype", tf_booktype);map.put("author", tf_author);map.put("translator", tf_translator);map.put("publisher", tf_publisher);map.put("publish_time", tf_publish_time);map.put("price", tf_price);map.put("stock", tf_stock);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delActionPerformed(e, map);}else{i = Jcwh.btn_saveActionPerformed(e, map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "图书添加成功!";}else if(optionStr.equals("update")){showInfo = "图书修改成功!";}else if(optionStr.equals("delete")){showInfo = "图书删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});/* 关闭窗口*/this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setSize(500, 320);lbbookid.setBounds(50, 40, 50, 20); // 图书编号tf_bookid.setBounds(110, 40, 100, 20);lbbookname.setBounds(240, 40, 50, 20); // 图书名称tf_bookname.setBounds(300, 40, 100, 20);lbbooktype.setBounds(50, 80, 50, 20); // 图书类别tf_booktype.setBounds(110, 80, 100, 20);tf_booktype.add("科技");tf_booktype.add("文学");tf_booktype.add("社科");tf_booktype.add("其他");lbauthor.setBounds(240, 80, 50, 20); // 作者tf_author.setBounds(300, 80, 100, 20);lbtranslator.setBounds(50, 120, 50, 20); // 设置译者tf_translator.setBounds(110, 120, 100, 20);lbpublisher.setBounds(240, 120, 50, 20); // 出版社tf_publisher.setBounds(300, 120, 100, 20);lbpublish_time.setBounds(50, 160, 50, 20); // 出版时间tf_publish_time.setBounds(110, 160, 100, 20);lbprice.setBounds(240, 160, 50, 20); // 定价tf_price.setBounds(300, 160, 100, 20);lbstock.setBounds(50, 200, 50, 20); // 库存数量tf_stock.setBounds(110, 200, 100, 20);saveBtn.setBounds(150, 240, 80, 25); // 保存按钮closeBtn.setBounds(280, 240, 80, 25);// 关闭按钮if(str.equals("save")){setTitle("添加图书");}else if(str.equals("update")){setTitle("修改图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbbookid);add(tf_bookid);add(lbbookname);add(tf_bookname);add(lbbooktype);add(tf_booktype);add(lbauthor);add(tf_author);add(lbtranslator);add(tf_translator);add(lbpublisher);add(tf_publisher);add(lbpublish_time);add(tf_publish_time);add(lbprice);add(tf_price);add(lbstock);add(tf_stock);add(saveBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见}private void clearAllTextfield() {tf_bookid.setText("");tf_bookname.setText("");tf_author.setText("");tf_translator.setText("");tf_publisher.setText("");tf_publish_time.setText("");tf_price.setText("");tf_stock.setText("");}}4.读者管理public class ReaderManeger extends JFrame {private static final long serialVersionUID = -2399939451497711745L;Label lbreaderid_c = new Label("读者编号");TextField tf_readerid_c = new TextField();Label lbreaderid = new Label("读者编号");TextField tf_readerid = new TextField();Label lbreadername = new Label("读者姓名");TextField tf_readername = new TextField();Label lbreadertype = new Label("读者类别");Choice tf_readertype = new Choice();Label lbsex = new Label("性别");Choice tf_sex = new Choice();Label lbmax_num = new Label("可借数量");TextField tf_max_num = new TextField();Label lbdays_num = new Label("可借天数");TextField tf_days_num = new TextField();Button queryBtn = new Button("查询");Button saveBtn = new Button("保存");Button closeBtn = new Button("关闭");private String optionStr;//保存、修改、删除ReaderManeger(String str){optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid);map.put("readername", tf_readername);map.put("readertype", tf_readertype);map.put("sex", tf_sex);map.put("days_num", tf_days_num);map.put("max_num", tf_max_num);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delReaderActionPerformed(e, map);}else{i = Jcwh.btn_saveReaderActionPerformed(e,map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "读者添加成功!";}else if(optionStr.equals("update")){showInfo = "读者修改成功!";}else if(optionStr.equals("delete")){showInfo = "读者删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setTitle("添加读者信息");setSize(500, 230);lbreaderid.setBounds(50, 50, 50, 20);tf_readerid.setBounds(110, 50, 100, 20);lbreadername.setBounds(240, 50, 50, 20);tf_readername.setBounds(300, 50, 100, 20);lbreadertype.setBounds(50, 80, 50, 20);tf_readertype.setBounds(110, 80, 100, 20);tf_readertype.add("教师");tf_readertype.add("学生");tf_readertype.add("职工");lbsex.setBounds(240, 80, 50, 20);tf_sex.setBounds(300, 80, 100, 20);tf_sex.add("男");tf_sex.add("女");lbmax_num.setBounds(50, 110, 50, 20);tf_max_num.setBounds(110, 110, 100, 20);lbdays_num.setBounds(240, 110, 50, 20);tf_days_num.setBounds(300, 110, 100, 20);saveBtn.setBounds(150, 150, 80, 25);closeBtn.setBounds(280, 150, 80, 25);if(str.equals("save")){setTitle("添加读者");}else if(str.equals("update")){setTitle("修改读者");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbreaderid);add(lbreadername);add(lbreadertype);add(lbsex);add(lbmax_num);add(lbdays_num);add(tf_readerid);add(tf_readername);add(tf_max_num);add(tf_days_num);add(tf_readertype);add(tf_sex);add(saveBtn);add(closeBtn);setLocationRelativeTo(null);setVisible(true);}private void clearAllTextfield() {tf_readerid.setText("");tf_readername.setText("");tf_max_num.setText("");tf_days_num.setText("");}public static void main(String[] args) {ReaderManeger r = new ReaderManeger("update");}}5.借书public class Borrow extends Frame {private static final long serialVersionUID = -1036076990599464079L;String SepLine = "-------------------------------------------------";Label lbbookid = new Label("图书编号");Label lbreaderid = new Label("读者编号");TextField tf_bookid = new TextField();TextField tf_readerid = new TextField();Button queryBtn = new Button("查询");Label lbbookinfo = new Label(SepLine + "图书信息" + SepLine); Label lbbookname = new Label("图书名称:");Label tf_bookname = new Label("xx");Label lbauthor = new Label("作者:");Label tf_author = new Label("xx");Label lbpublisher = new Label("出版社:");Label tf_publisher = new Label("xx");Label lbpublish_time = new Label("出版时间:");Label tf_publish_time = new Label("xx");Label lbprice = new Label("定价:");Label tf_price = new Label("xx");Label lbstock = new Label("库存数量:");Label tf_stock = new Label("xx");Label lbreaderinfo = new Label(SepLine + "读者信息" + SepLine); Label lbreadername = new Label("读者姓名:");Label tf_readername = new Label("xx");Label lbreadertype = new Label("读者类型:");Label tf_readertype = new Label("xx");Label lbmax_num = new Label("最大可借数:");Label tf_max_num = new Label("xx");Label lbdays_num = new Label("最大可借天数:");Label tf_days_num = new Label("xx");Label lbborrowinfo = new Label(SepLine + "借阅信息" + SepLine); Label lbborrowednum = new Label("该读者已借图书数量:"); Label tf_borrowednum = new Label("xx");Label lbif_borrow = new Label("该读者是否可借所选图书:"); Label tf_if_borrow = new Label("xx");Label lbborrow_date = new Label("借阅日期:");Label tf_borrow_date = new Label("xx");Button borrowBtn = new Button("借出");Button closeBtn = new Button("关闭");public Borrow() {setLayout(null);setTitle("借阅图书");setSize(500, 420);this.setForeground(Color.BLACK); // 设置前景色为黑色lbbookid.setBounds(30, 40, 50, 25); // 图书编号tf_bookid.setBounds(90, 40, 90, 20);lbreaderid.setBounds(200, 40, 50, 25); // 读者编号tf_readerid.setBounds(260, 40, 90, 20);queryBtn.setBounds(370, 40, 80, 25); // 查询按钮lbbookinfo.setBounds(30, 70, 440, 25); // 图书信息提示条lbbookname.setBounds(30, 100, 60, 25); // 图书名称tf_bookname.setBounds(90, 100, 200, 25);lbauthor.setBounds(310, 100, 60, 25); // 作者tf_author.setBounds(370, 100, 90, 25);lbpublisher.setBounds(30, 125, 60, 25); // 出版社tf_publisher.setBounds(90, 125, 200, 25);lbpublish_time.setBounds(310, 125, 60, 25); // 出版时间tf_publish_time.setBounds(370, 125, 90, 25);lbprice.setBounds(30, 150, 60, 25); // 定价tf_price.setBounds(90, 150, 200, 25);lbstock.setBounds(310, 150, 60, 25); // 库存数量tf_stock.setBounds(370, 150, 90, 25);lbreaderinfo.setBounds(30, 180, 440, 25); // 读者信息提示条lbreadername.setBounds(30, 205, 60, 25); // 读者姓名tf_readername.setBounds(90, 205, 90, 25);lbreadertype.setBounds(310, 205, 60, 25); // 读者类型tf_readertype.setBounds(370, 205, 90, 25);lbmax_num.setBounds(30, 230, 75, 25); // 最大可借数tf_max_num.setBounds(105, 230, 90, 25);lbdays_num.setBounds(310, 230, 85, 25); // 最大可借天数tf_days_num.setBounds(395, 230, 70, 25);lbborrowinfo.setBounds(30, 260, 440, 25); // 借阅信息提示条lbborrowednum.setBounds(30, 285, 120, 25);// 已借图书数量tf_borrowednum.setBounds(150, 285, 50, 25);lbif_borrow.setBounds(30, 310, 145, 25); // 是否可借tf_if_borrow.setBounds(175, 310, 50, 25);lbborrow_date.setBounds(30, 335, 60, 25);// 借书日期tf_borrow_date.setBounds(90, 335, 100, 25);borrowBtn.setBounds(160, 365, 80, 25);// 借出按钮borrowBtn.setEnabled(false); // 开始时禁用借出按钮closeBtn.setBounds(260, 365, 80, 25);// 关闭按钮queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_querywActionPerformed(e); } }); borrowBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_borrowActionPerformed(e); } });closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { setForeground(Color.BLACK); dispose(); } }); this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {setForeground(Color.BLACK); // 设置前景色为黑色dispose(); // 关闭窗体}});add(lbbookid);add(lbreaderid);add(queryBtn);add(lbbookinfo);add(lbbookname);add(lbauthor);add(lbpublisher);add(lbpublish_time);add(lbprice);add(lbstock);add(lbreaderinfo);add(lbreadername);add(lbreadertype);add(lbmax_num);add(lbdays_num);add(lbborrowinfo);add(lbborrowednum);add(lbif_borrow);add(lbborrow_date);add(borrowBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见setForeground(Color.RED); // 设置前景色为红色add(tf_bookid);add(tf_readerid);add(tf_bookname);add(tf_author);add(tf_publisher);add(tf_publish_time);add(tf_price);add(tf_stock);add(tf_readername);add(tf_readertype);add(tf_max_num);add(tf_days_num);add(tf_borrowednum);add(tf_if_borrow);add(tf_borrow_date);}// 图书和读者查询private void btn_querywActionPerformed(ActionEvent e) {String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();// 如果图书编号或读者编号两者均为空,或者有一个为空,则返回if (bookid.equals("") || readerid.equals("")) {JOptionPane.showMessageDialog(null, "图书编号和读者编号均不能为空!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询图书,结果存入book对象中Book book = BookSelect.SelectBookById(bookid);if (book != null) { // 如果查询到结果,将其显示在各文本框中tf_bookname.setText(book.getBookname());tf_author.setText(book.getAuthor());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf((book.getPrice())));tf_stock.setText(String.valueOf(book.getStock()));} else {JOptionPane.showMessageDialog(null, "图书编号有误,查无此书!");init(); // 重新初始化各参数并禁止借出按钮return;}if (book.getStock() == 0) {JOptionPane.showMessageDialog(null, "图书已无库存,无法借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询读者,结果存入reader对象中Reader reader = ReaderSelect.selectReaderById(readerid);// 如果查询到结果,将其显示在各文本框中if (reader != null) {tf_readername.setText(reader.getReadername());tf_readertype.setText(reader.getReadertype());tf_max_num.setText(String.valueOf(reader.getMax_num()));tf_days_num.setText(String.valueOf(reader.getDays_num()));} else {JOptionPane.showMessageDialog(null, "读者编号有误,查无此人!");init(); // 重新初始化各参数并禁止借出按钮return;}// 查询指定读者是否已借过指定图书且未归还if (IfBorrowBack.findbook(bookid, readerid)) {JOptionPane.showMessageDialog(null, "该读者已借阅所选图书,且未归还!");init(); // 重新初始化各参数并禁止借出按钮return;}// 统计读者所借图书数量int borrowednum = statborrowednum(readerid);tf_borrowednum.setText(String.valueOf(borrowednum));// 如果读者已借图书尚未超出其允许最大借书量,则允许其继续借阅所选图书if (borrowednum < reader.getMax_num()) {tf_if_borrow.setText("是");// 创建一个简单日期格式对象,注意:MM一定要用大写SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 创建日期变量,其内容为当前日期Date currentdate = new Date();// 将日期按指定格式输出String borrowdate = sdf.format(currentdate);tf_borrow_date.setText(borrowdate);borrowBtn.setEnabled(true); // 使借出按钮有效} else {JOptionPane.showMessageDialog(null, "该读者借书过多,无法继续借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}}// 填写借出图书记录private void btn_borrowActionPerformed(ActionEvent e) {String sql;String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();String borrowdate = tf_borrow_date.getText();// 为borrow表增加借书记录sql = "insert into borrow (book_id,reader_id,"+ "borrow_date,if_back) values('" + bookid + "','" + readerid + "','" + borrowdate + "','否')";。

书籍管理 php源代码

书籍管理 php源代码

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

图书管理系统(源代码)

图书管理系统(源代码)

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

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

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

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

图书管理系统代码

图书管理系统代码

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

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

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

#include<stdio。

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

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

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

登陆界面using System;using;using ;using ;using ;using Labrary{public partial class FormLogin : Form{public FormLogin(){InitializeComponent();}}SetMenJin("PicIn");();户ì管¨1理¤¨ = true;this.系|ì统a3初始o化¥= true;this.应|用模ê式o = true;this.图a书o¨|管¨1理¤¨ = true; this.退a办¨卡§ = true;this.借¨¨阅= true;this.门禁= true; SetPurview();= false;= false;= false;|用模ê式o = false;}else{this.用户管理¨ = false;this.系统初始化¥= false;this.读书管理¨ = false;this.退办卡§ = false;this.借阅= false;this.门禁= false;for (int i = 0; i < i++){string purview = if (purview == "1"){this.图书管理¨ = true;}else if (purview == "2"){this.办退卡§ = true;}else if (purview == "3"){this.借阅= true;}else if (purview == "4"){this.门禁= true;}}}}private void用户管理¨aToolStripMenuItem_Click(object sender, EventArgs e) {ful = new ;();}private void修改密码ToolStripMenuItem_Click(object sender, EventArgs e) {fup = new , ;();}private void tsbtnBookType_Click(object sender, EventArgs e){FormBookTypeList fbtl = new FormBookTypeList();();}private void tsbtnBookAdd_Click(object sender, EventArgs e){FormBookAdd fba = new FormBookAdd();();}private void tsbtnBookManage_Click(object sender, EventArgs e){FormBookInfoList fbil = new FormBookInfoList();();}private void tsbtnBookStatistics_Click(object sender, EventArgs e){FormBookStatistics fbs = new FormBookStatistics();();}private void退a出XToolStripMenuItem_Click(object sender, EventArgs e) {();}private void tsbtnCardAdd_Click(object sender, EventArgs e){FormCardInfo fci = new FormCardInfo(1, new ObjCardInfo());();}private void tsbtnCardManage_Click(object sender, EventArgs e){FormCardList fcl = new FormCardList();();}private void tsbtnAddTime_Click(object sender, EventArgs e){string rfid = ();if (rfid == ""){("请把借阅卡放到桌面读写器上!");}else{if (rfid)){ObjCardInfo oci = new ObjCardInfo(rfid);FormCardInfo fci = new FormCardInfo(5, oci);();}else{("没有此借阅卡信息");}}}private void tsbtnCardDelete_Click(object sender, EventArgs e) {string rfid = ();if (rfid == ""){("请把借阅卡到读写器上");}else{if (rfid)){ObjCardInfo oci = new ObjCardInfo(rfid);int count = ();if (count == 0){if ("是否决定退卡!ê", "", =={();("退卡成功|!ê");}}else{+ "还有一本" + () + " 本书未归还不能退卡");}}else{("没有此借阅信息");}}}private void tsbtnJie_Click(object sender, EventArgs e){FormBookJie fbj = new FormBookJie(1);();}private void tsbtnHuan_Click(object sender, EventArgs e){FormBookHuan fbh = new FormBookHuan();();}private void图a书o¨|管¨1理¤¨aToolStripMenuItem_Click(object sender, EventArgs e) {= true;= false;= false;= + "\\pic\\");}private void退a办¨卡§ToolStripMenuItem_Click(object sender, EventArgs e) {= false;= true;= false;= + "\\pic\\");}private void借¨¨阅ToolStripMenuItem_Click(object sender, EventArgs e){= false;= false;= true;= + "\\pic\\");}private void门禁ToolStripMenuItem_Click(object sender, EventArgs e){plit(',')[0];int headerWidth = (headerText[i].Split(',')[1]);= headerName;= headerWidth;}DataTable dtb = for (int i = 0; i < i++){ObjBookInfo bookInfo = new ObjBookInfo[i]["RFID"].ToString());ListViewItem item = new ListViewItem(new string[] { , , , , });}ListViewItem itemCount = new ListViewItem(new string[] { "统a3计", "", "", "", "", + "本à" });}private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e){if== "全部书架¨1"){= 0;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo"));}if== "第一书架¨1"){= 1;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='1'"));}if== "第二书架¨1"){= 2;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='2'"));}if== "第三书架¨1"){= 3;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='3'"));}if== "第四书架¨1"){= 4;BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='4'"));}}private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e){if== 0){if== 0){BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo"));}if== 1){BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where LendStatus='1'"));}if== 2){BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where LendStatus='0'"));}}if> 0){if== 0){BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}'", }if== 1){BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}' and LendStatus='1'", }if== 2){BindListView("select RFID,BookType_ID,Name,Author,LendStatus,BookShelf from BookInfo where BookShelf='{0}' and LendStatus='0'", }}}}}借阅卡管理using System;using;using ;using ;using ;using Labrary{public partial class FormCardList : Form{public FormCardList(){InitializeComponent();SetListView();}private void SetListView(){List<ObjCardInfo> listCard = ();for (int i = 0; i < ; i++){ObjCardInfo oci = listCard[i];ListViewItem item = new ListViewItem;= oci;subitem1 = new ();= ;subitem2 = new ();= ;subitem3 = new ();= "yyyy年¨oMM月dd日¨");subitem4 = new ();= ;subitem5 = new ();= subitem6 = new ();= subitem7 = new ();= }}private void SetListView(List<ObjCardInfo> listCard){for (int i = 0; i < ; i++){ObjCardInfo oci = listCard[i];ListViewItem item = new ListViewItem;= oci;subitem1 = new ();= ;subitem2 = new ();= ;subitem3 = new ();= "yyyy年¨oMM月dd日¨");subitem4 = new ();= ;subitem5 = new ();= subitem6 = new ();= subitem7 = new ();= }}private void tsbtnExit_Click(object sender, EventArgs e){();}private void tsbtnInsert_Click(object sender, EventArgs e){FormCardInfo fci = new FormCardInfo(1, new ObjCardInfo());if () =={SetListView();IsEnabled(false);}}private void IsEnabled(bool Enabled){oString());= ;subitem1 = new ();= row["lendtime"].ToString();subitem2 = new ();= row["returntime"].ToString();}}private void tsbtnExit_Click(object sender, EventArgs e){();}}}图书管理using System;using;using ;using ;using ;using Labrary{public partial class FormBookInfoList : Form{public FormBookInfoList(){InitializeComponent();}private void SetCboBookType(){string sql = "select * from booktype";DataTable dt = = dt;= "Name";= "ID";}private void SetListView(){IsEnabled(false);List<ObjBookInfo> listBookInfo = for (int i = 0; i < ; i++){ObjBookInfo obi = listBookInfo[i];ListViewItem item = new ListViewItem();= ;= obi;subLendStatus = new ();= ;subBookName = new ();= ;subPress = new ();= ;subPrice = new ();= ;subAddPerson = new ();= subAddTime = new ();= }}private void tsbtnExit_Click(object sender, EventArgs e){();}private void tscboBookType_DropDown(object sender, EventArgs e){SetCboBookType();}private void tscboBookType_DropDownClosed(object sender, EventArgs e) {SetListView();}private void tsbtnInsert_Click(object sender, EventArgs e){FormBookAdd fba = new FormBookAdd();if () =={}}private void listView1_SelectedIndexChanged(object sender, EventArgs e) {if> 0){IsEnabled(true);}else{IsEnabled(false);}}private void IsEnabled(bool enabled){= enabled;= enabled;}private void tsbtnUpdate_Click(object sender, EventArgs e){if> 0){FormBookInfo fbi = new FormBookInfo(3, as ObjBookInfo);if () =={SetListView();}}}private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) {if> 0){FormBookInfo fbi = new FormBookInfo(4, as ObjBookInfo);();}}private void tsbtnBookRecord_Click(object sender, EventArgs e){if> 0){FormBookRecord fbr = new FormBookRecord as ObjBookInfo);();}}}}图书上架using System;using;using ;using ;using ;using Labrary{public partial class FormBookAdd : Form{List<string> listAllRfid = new List<string>();List<ObjBookInfo> listBookInfo = new List<ObjBookInfo>();public FormBookAdd(){InitializeComponent();= 0;}private bool ValidControl(){{("请读取图书RFID!ê");return false; }if== ""){("请选择图书分类");return false; }if== ""){("请填写书名");return false; }if== ""){("请填写作者");return false; }if== ""){("请填写定价");return false; }{("请填写出版社");return false;}if== 0){("请选择书架");return false;}return true;}private void gbtnCancel_Click(object sender, EventArgs e) {();}private void btnReadRFID_Click(object sender, EventArgs e) {List<string> listRfid = ();for (int i = 0; i < ; i++){oString();}oString());= ;subitem1 = new ();= row["lendtime"].ToString();subitem2 = new ();= row["returntime"].ToString();}}private void tsbtnExit_Click(object sender, EventArgs e){();}}}。

相关文档
最新文档