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

📄 processthread.java

📁 JAVA图书馆管理系统 sqlserver2000 + SWING + look and feel
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			
			System.out.println(department);
			
			password = bfc.readLine();
			
			System.out.println(password);

			role = bfc.readLine();
			
			System.out.println(role);
			
			cardclass = bfc.readLine();
			
			System.out.println(cardclass);
			
			cardnumber = bfc.readLine();
			
			System.out.println(cardnumber);
			
			borrowdate = bfc.readLine();
			
			System.out.println(borrowdate);
			
			borrownumber = bfc.readLine();
			
			System.out.println(borrownumber);
			
			mobilephone = bfc.readLine();
			
			System.out.println(mobilephone);
			
			userclass = bfc.readLine();
			
			System.out.println(userclass);
			
			address = bfc.readLine();
			
			System.out.println(address);
			
			other = bfc.readLine();
			
			System.out.println(other);
			
			sex = bfc.readLine();
			
			System.out.println(sex);
			
			//连接数据库(不用类方法是为了避免代码重复)
	        String userName = "sa"; // Your Database user id

			String userPassword = "sa"; // Your Database password
			
			String JDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
			
			String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=library";
			
			Connection conn;
			
			Statement stmt;
			
			Class.forName(JDriver);
			
			conn = DriverManager.getConnection(url,userName,userPassword);
			
			//插入记录到数据库
			String sql = "update reader set ID='" + ID + "'"+",";
            sql += "name='" + name + "'"+",";
            sql += "department='" + department + "'"+",";
            sql += "password='" + password + "'"+",";
            sql += "role='" + role + "'"+",";
            sql += "cardclass='" + cardclass + "'"+",";
            sql += "cardnumber='" + cardnumber + "'"+",";
            sql += "borrowdate='" + borrowdate + "'"+",";
            sql += "borrownumber='" + borrownumber + "'"+",";
            sql += "mobilephone='" + mobilephone + "'"+",";
            sql += "userclass='" + userclass + "'"+",";
            sql += "address='" + address + "'"+",";
            sql += "other='" + other + "'"+",";
            sql += "sex='" + sex + "'";
            sql += "where ID = '" + ID + "'";
            
            stmt = conn.createStatement();
			
			int iRet = stmt.executeUpdate(sql);
			
			if(iRet != 0){
				
				ps.println("editOK");
				
			}else{
				
				ps.println("editError");
				
			}
			
			
		} catch (Exception e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
			
	}
	
	public void searchbook(){
		
		try {
			PrintStream ps = new PrintStream(cs.getOutputStream());
			
			String name = bfc.readLine();;
			
			String names = null;
	        
	        String writer = null;
	        
	        String ISBN = null;
	        
	        String publish = null;
	        
	        String place = null;
	        
	        String state = null; 
			
	        String userName = "sa"; // Your Database user id

			String userPassword = "sa"; // Your Database password
			
			String JDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
			
			String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=library";
			
			Connection conn;
			
			Statement stmt;
			
			Class.forName(JDriver);
			
			conn = DriverManager.getConnection(url,userName,userPassword);
		
			stmt = conn.createStatement();
			
			String sql = "select * from book where name LIKE '%" + name + "%'"; //查询书籍名
			
			ResultSet rs = stmt.executeQuery(sql);
			
			while(rs.next()){
				
				names = rs.getString("name");
				
				writer = rs.getString("writer");
				
				ISBN = rs.getString("ISBN");
				
				publish = rs.getString("publish");
				
				place = rs.getString("place");
				
				state = rs.getString("state");
				
				System.out.println("\n"+ names + " " + writer + " " + ISBN + " " + publish + " " + place + " " + state);
				
				ps.println("S");
				
				ps.println(names);
                
                ps.println(writer);
                
                ps.println(ISBN);
                
                ps.println(publish);
                
                ps.println(place);
                
                ps.println(state);
		            
		        rs.close();
		               
		        conn.close();
		            
		        stmt.close();
	
			}	
			
		} catch (Exception e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		
	}
	
	public void addbook(){
		
		try {
			
			PrintStream ps = new PrintStream(cs.getOutputStream());
			
			String name;
			
			String writer;
			
			String ISBN;
			
			String publish;
			
			String place;
			
			String state;
			
			name = bfc.readLine();
			
			System.out.println(name);
			
			writer = bfc.readLine();
			
			System.out.println(writer);
			
			ISBN = bfc.readLine();
			
			System.out.println(ISBN);
			
			publish = bfc.readLine();
			
			System.out.println(publish);
	
			place = bfc.readLine();
			
			System.out.println(place);
			
			state = bfc.readLine();
			
			System.out.println(state);
			
			//连接数据库(不用类方法是为了避免代码重复)
	        String userName = "sa"; // Your Database user id

			String userPassword = "sa"; // Your Database password
			
			String JDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
			
			String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=library";
			
			Connection conn;
			
			Statement stmt;
			
			Class.forName(JDriver);
			
			conn = DriverManager.getConnection(url,userName,userPassword);
		
			stmt = conn.createStatement();
			
			String sql = "insert into book values('" + name +"'" + "," + "'" +
            writer + "'" +"," + "'" + ISBN +"'" + "," + "'"+ publish +"'" + "," + "'" + place + "'" + "," + "'" + state + "'" + ")";
			
			int iRet = stmt.executeUpdate(sql);
			
			if(iRet != 0){
				
				ps.println("addbookOK");
				
			}
			
			
		} catch (Exception e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();			
			
		}
		
	}
	
	public void add(){
		
		try {
			
			PrintStream ps = new PrintStream(cs.getOutputStream());
		
			String ID;
			
			String name;
			
			String department;
			
			String password;
			
			String role;
			
			String cardclass;
			
		    String cardnumber;
			
			String borrowdate;
			
			String borrownumber;
			
			String mobilephone;
			
			String userclass;
			
			String address;
			
			String other;
			
			String sex;
			
			ID = bfc.readLine();
			
			System.out.println(ID);
			
			name = bfc.readLine();
			
			System.out.println(name);
			
			department = bfc.readLine();
			
			System.out.println(department);
			
			password = bfc.readLine();
			
			System.out.println(password);
	
			role = bfc.readLine();
			
			System.out.println(role);
			
			cardclass = bfc.readLine();
			
			System.out.println(cardclass);
			
			cardnumber = bfc.readLine();
			
			System.out.println(cardnumber);
			
			borrowdate = bfc.readLine();
			
			System.out.println(borrowdate);
			
			borrownumber = bfc.readLine();
			
			System.out.println(borrownumber);
			
			mobilephone = bfc.readLine();
			
			System.out.println(mobilephone);
			
			userclass = bfc.readLine();
			
			System.out.println(userclass);
			
			address = bfc.readLine();
			
			System.out.println(address);
			
			other = bfc.readLine();
			
			System.out.println(other);
			
			sex = bfc.readLine();
			
			System.out.println(sex);
			
			//连接数据库(不用类方法是为了避免代码重复)
	        String userName = "sa"; // Your Database user id

			String userPassword = "sa"; // Your Database password
			
			String JDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
			
			String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=library";
			
			Connection conn;
			
			Statement stmt;
			
			Class.forName(JDriver);
			
			conn = DriverManager.getConnection(url,userName,userPassword);
		
			stmt = conn.createStatement();
			
			//插入记录到数据库
			String sql = "insert into reader values('" + ID +"'" + "," + "'" +
                            name + "'" +"," + "'" + department +"'" + "," + "'"+ password +"'" + "," + "'" + role + "'" + "," + "'" + cardclass + "'" +
                            "," + "'"+ cardnumber + "'" + "," + "'" + borrowdate + "'" + "," + "'" + borrownumber + "'" + 
                            "," + "'" + mobilephone + "'" + "," + "'" + userclass + "'" + "," + "'" + address + "'" + 
                            "," + "'" + other + "'" + "," + "'" + sex + "'" + ")";
			
			int iRet = stmt.executeUpdate(sql);
			
			if(iRet != 0){
				
				ps.println("addOK");
				
			}

		} catch (Exception e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
	
	}
	
	public void searchm(){
		
		try {
			
			PrintStream ps = new PrintStream(cs.getOutputStream());
			
			String ID = bfc.readLine();
	        
	        String readerID = null;
	        
	        String readerName = null;
	        
	        String readerDep = null;
	        
	        String readerPhone = null;
	        
	        String readeraddress = null;
	        
	        String readerother = null;  
	        
	        BorrowBook[] borrowBooks = new BorrowBook[10];
			
	        //连接数据库(不用类方法是为了避免代码重复)
	        String userName = "sa"; // Your Database user id

			String userPassword = "sa"; // Your Database password
			
			String JDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
			
			String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=library";
			
			Connection conn;
			
			Statement stmt;
			
			Class.forName(JDriver);
			
			conn = DriverManager.getConnection(url,userName,userPassword);
		
			stmt = conn.createStatement();
			
			//搜索信息
			
			String sql = "select * from reader where ID LIKE '%" + ID + "%'"; //查询读者名
            
			String sql1 = "select * from borrow where readerID LIKE " + "'%" + ID + "%'"; //查询借阅日期和还书日期
			
            String sql2 = "select * from book where ISBN in(select bookISBN from borrow where readerID LIKE " + "'%" + ID + "%'" + ")"; //查询书名
            
            ResultSet rs = stmt.executeQuery(sql);
            
            while(rs.next()){
                
            	readerID = rs.getString("ID");
            	
            	readerName = rs.getString("name");
                
                readerDep = rs.getString("department");               
                
                readerPhone = rs.getString("mobilephone");     
                
                readeraddress = rs.getString("address");
                
                readerother = rs.getString("other");
                
                System.out.println("\n"+ readerID + " " + readerName + " " + readerDep + " " + readerPhone + " " + readeraddress + " " + readerother);
                
                ps.println("N");
                
                ps.println(readerID);
                
                ps.println(readerName);
                
                ps.println(readerDep);
                
                ps.println(readerPhone);
                
                ps.println(readeraddress);
                
                ps.println(readerother);

⌨️ 快捷键说明

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