⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookinfoframe.java

📁 微型图书信息管理系统 基本实现所有图书信息管理的功能。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
					JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
					}
				

				else if(!isNumeric(tfbooknum.getText())){
					String output = "请输入正确的编号!";
					JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
					}
					
					
				else {
					
					Bookinfo Books=new Bookinfo();
					Books.BookName = tfbookname.getText();
					Books.BookNum = Integer.parseInt(tfbooknum.getText().trim());
					Books.Classic = tfclassic.getText();
					Books.BookPub = tfbookpub.getText();
					Books.IsRent = false;
					Books.BookAuther = tfbookauther.getText();

					/*
					 *降新的数据添加进BookList
					 */
					
					operation.addup(Books);
					
					
						tfbookname.setText("");
						tfbooknum.setText("");
						tfclassic.setText("");
						tfbookpub.setText("");
						tfbookauther.setText("");
						
					}
					
				}//添加
				
				
/*********************添加成功后即可查询到 但要其生效需"保存"到文件*************************/
		
/*********************删除图书信息 可对编号或图书名进行检索并在BookList中删除并不在文件中生效*************************/		
			
			if(e.getActionCommand().equals("删除")||e.getSource()==MIdelete){
				
				
				
				if(!init){
					String output = "请首先装载!";
					JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
					}
				else if(tfbooknum.getText().equals("")&&tfbookname.getText().equals("")){
					String output = "请输入图书编号或图书名!";
					JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
					}
					
					
				else	{	
					Bookinfo Books=new Bookinfo();
					
					if(tfbooknum.getText().trim().equals(""))
						Books.BookNum=0;
						
					else if(!isNumeric(tfbooknum.getText())){
						String output = "请输入正确的编号!";
						JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
						}
					else Books.BookNum = Integer.parseInt(tfbooknum.getText().trim());
					
					Books.BookName = tfbookname.getText();
					/*
					 *从BookList删除选择数据
					 */
					operation.Delete(Books);
				
					}//else
					
				tfbookname.setText("");
				tfbooknum.setText("");
				tfclassic.setText("");
				}//删除
			
			
/*********************删除成功后 不会再查询到 但不会在储存文件中生效 保存后才能够生效*************************/


/*********************提供了3种查询方式:按书名、按编号和全部查询 用单选按钮选择方式*************************/	

		
			if(e.getSource()==btnLocate||e.getSource()==MIlocate){
				
				if(rdbLocate.isSelected())	flaglocate=3;
				if(rdbLocnum.isSelected())	flaglocate=2;
				if(rdbLocname.isSelected())	flaglocate=1;
				
				
				if(flaglocate==0){
					String output = "请首先选择查询方式!";
					JOptionPane.showMessageDialog(null,output,"Message",
								JOptionPane.INFORMATION_MESSAGE);			
					}
				
				/*
				 *按书名查询
				 */
				else if(flaglocate==1){
					Bookinfo Books=new Bookinfo();
					
					if(!init){
						String output = "请首先装载!";
						JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
						}
					if(tfbookname.getText().equals("")){
						String output = "请输入要查询书名!";
						JOptionPane.showMessageDialog(null,output,"Message",
									JOptionPane.INFORMATION_MESSAGE);
						}
					else	{
						Books.BookName = tfbookname.getText();
						/*
						 *返回所查询到的图书信息
						 */
						 
						 
						chosebook = operation.locateName(Books,chosebook);
							
						if(chosebook.BookName!=null){
							taCollect.setText("");
							taCollect.setForeground(Color.red);
							taCollect.append("图书编号\t图书名\t图书作者\t图书分类\t图书出版\t图书状态(是否出借)\n");
							taCollect.append(chosebook.BookNum+"\t"+chosebook.BookName+"\t"+
												chosebook.BookAuther+"\t"+chosebook.Classic+"\t"+
												chosebook.BookPub+"\t"+chosebook.IsRent+"\n");
							}//else
						}//else
						
						tfbookname.setText("");
						tfbooknum.setText("");
					}//flaglocate=1
			
				/*
				 *按编号查询
				 */
				else if (flaglocate==2){
					
					Bookinfo Books=new Bookinfo();
					
					if(!init){
						String output = "请首先装载!";
						JOptionPane.showMessageDialog(null,output,"ErrorMessage",
									JOptionPane.INFORMATION_MESSAGE);
						}
						
					else	{
						if(tfbooknum.getText().trim().equals("")){
							String output = "请输入要查询书的编号!";
							JOptionPane.showMessageDialog(null,output,"Message",
										JOptionPane.INFORMATION_MESSAGE);
							}
							
						else if(!isNumeric(tfbooknum.getText())){
							String output = "请输入正确的编号!";
							JOptionPane.showMessageDialog(null,output,"ErrorMessage",
									JOptionPane.INFORMATION_MESSAGE);
							}
						
						else	{ 
							Books.BookNum = Integer.parseInt(tfbooknum.getText().trim());
							/*
						 	 *返回所查询到的图书信息
						 	 */
						 	 String s="";
						chosebook = operation.locateNum(s+=Books.BookNum,chosebook);
															
							if(chosebook.BookName!=null){
								taCollect.setText("");
								taCollect.setForeground(Color.red);
								taCollect.append("图书编号\t图书名\t图书作者\t图书分类\t图书出版\t图书状态(是否出借)\n");
							taCollect.append(chosebook.BookNum+"\t"+chosebook.BookName+"\t"+
												chosebook.BookAuther+"\t"+chosebook.Classic+"\t"+
												chosebook.BookPub+"\t"+chosebook.IsRent+"\n");
								}//else
							}//else
						}//else
						
						tfbookname.setText("");
						tfbooknum.setText("");
					}//flaglocate=2
					
				/*
				 *全部数据查询
				 */	
				else if(flaglocate==3){
					Connection con=null;
					/*
					 *返回所查询到的图书信息
					 */
					 try{
					 	con = DriverManager.getConnection("jdbc:odbc:图书信息管理");
					 	
			 			String SQL = "SELECT 图书编号,图书名,图书作者,图书分类,图书出版,图书状态 FROM 图书管理信息";
			 			Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
     		 			ResultSet rs = stmt.executeQuery(SQL);
     		 
     		 			taCollect.setText("");
     		 			taCollect.setForeground(Color.red);
     		 			taCollect.append("图书编号\t图书名\t图书作者\t图书分类\t图书出版\t图书状态(是否出借)\n");
     		 			//获取查询结果集
     		
     		 			while (rs.next()) {
      		 			//将结果集中的数据添加到文本框中
      		 				taCollect.append(rs.getString("图书编号") + "\t");
       		  				taCollect.append(rs.getString("图书名") + "\t");
       		 				taCollect.append(rs.getString("图书作者") + "\t");
       		 				taCollect.append(rs.getString("图书分类") + "\t");
      		 				taCollect.append(rs.getString("图书出版") + "\t");
      		 				taCollect.append(rs.getString("图书状态") + "\n");
    		 				}
    					}
						catch(SQLException ex){
   			  				taCollect.setText(ex.getMessage());
  		 					}
  		 					finally{
  		 						try{
        							con.close();
        							}
        							catch(SQLException ex){
   										taCollect.setText(ex.getMessage());
   										}
   									}
   						}//flaglocate=3				
				
/*				data[0][0] = BookList.getLast().toString();
				JTable jt = new JTable(data,colHeads);
				contrainer.add(jt);
				jt.setBounds(16,200,450,400);
 */				
				
			}//查询	
				
/*********************查询结束会在汇总栏中显示信息 在下个版本中争取在table中实现*************************/

/*********************选中要修改的文件 目的是防止轻易的对数据进行修改*************************/	

		
			if(e.getActionCommand().equals("选中")){
				Bookinfo Books=new Bookinfo();
				
				if(!init){
					String output = "请首先装载!";
					JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
					}
				else if(tfbooknum.getText().equals("")&&tfbookname.getText().equals("")){
					String output = "没有选中任何图书!";
					JOptionPane.showMessageDialog(null,output,"Message",
								JOptionPane.INFORMATION_MESSAGE);
					}
				
				else	{
					if(tfbooknum.getText().trim().equals(""))
						Books.BookNum=0;
					
					else if(!isNumeric(tfbooknum.getText())){
						String output = "请输入正确的编号!";
						JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
						}	
					
					
					else Books.BookNum = Integer.parseInt(tfbooknum.getText().trim());
					
					Books.BookName = tfbookname.getText();
					/*
					 *返回所选中的图书信息
					 */
					chosebook = operation.chBook(Books,chosebook);
					
					
					if(chosebook.BookName!=null){	
						tfchosename.setText(chosebook.BookName);
						String   Booknum   =   String.valueOf(chosebook.BookNum);
						tfchosenum.setText(Booknum);
						if(chosebook.IsRent==true)
							tfchoseati.setText("已借出");
						else	tfchoseati.setText("在库中");
						}//else
					}//else
					
				tfbookname.setText("");
				tfbooknum.setText("");
				tfclassic.setText("");
				}//选中
				
				
				
/*********************选中后会在选中信息中体现 可以对选中的图书修改状态*************************/

/*********************确定并修改所选图书的状态 包括借出和还书*************************/	

			
			if(e.getActionCommand().equals("确定")){
				if(rdbRent.isSelected())	flagrent=true;
				if(rdbBack.isSelected())	flagrent=false;
				
				
				
				if(tfchosenum.getText().equals("")||tfchosename.getText().equals("")||tfchoseati.getText().equals("")){
					String output = "没有选中图书!";
					JOptionPane.showMessageDialog(null,output,"ErrorMessage",
								JOptionPane.INFORMATION_MESSAGE);
					}
					
				else	{
					chosebook.BookName = tfchosename.getText().trim();
					/*
					 *返回修改后的图书列表
					 */
				chosebook =	operation.buttOK(flagrent,chosebook);
				
				if(chosebook.BookName!=null){	
						tfchosename.setText(chosebook.BookName);
						String   Booknum   =   String.valueOf(chosebook.BookNum);
						tfchosenum.setText(Booknum);
						tfchoseati.setText("");
					//	if(chosebook.IsRent==true)
					if(rdbRent.isSelected())
							tfchoseati.setText("已借出");
						else	tfchoseati.setText("在库中");
						}//else
					}//else
					
				/*	if(chosebook.IsRent==true)
						tfchoseati.setText("已借出");
					else if(chosebook.IsRent==false)	tfchoseati.setText("在库中");
					}//else*/
				}//确定
				
				
/*********************确定修改后 会覆盖原有数据信息*************************/

/*********************About小型图书管理系统*************************/	
				
			if(e.getSource()==MIabout){
				/*
				 *版本信息
				 */
				operation.aboutInfo();
				}//关于	
				
/*********************关于小型图书管理系统*************************/	

/*********************小型图书管理系统使用帮助*************************/
				
			if(e.getSource()==MIhfile){
				/*
			 	 *File帮助信息
			     */
				operation.helpInfoFile();
				}
				
			if(e.getSource()==MIhoperation){	
				/*
				 *Operate帮助信息
			  	 */
				operation.helpInfoOperate();
				}
				
/*********************文件帮助和使用操作帮助*************************/

/*********************退出小型图书管理系统*************************/	
				
			if(e.getSource()==MIexit||e.getSource()==MIExit){
				System.exit(0);
				}
		
		}//actionPerformed()
		
	}//BookinfoDemo()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -