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

📄 returnmain.java

📁 it is basic library management
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				else
				{
					amount_fine_text.setText("0.00");
					day_overdue_text.setText(String.valueOf(a));
				}
				
				String query3 = "SELECT * FROM patronmaster WHERE id = '" + mid + "'";
				
				ResultSet rs3 = satemt.executeQuery(query3);
				
				try
				{
					rs3.next();
					patron_no_text.setText(rs3.getString("id"));
					name_text.setText(rs3.getString("name"));
					passport_text.setText(rs3.getString("ic"));
					group_type_text.setText(rs3.getString("group_type"));
					expiry_date_text.setText(rs3.getString("expiry_date"));
					status_text.setText(rs3.getString("status"));
					loan_duration_text.setText("21");
					
				}
				catch(SQLException sqlex)
				{
					sqlex.printStackTrace();
				}
				
				String query4 = "SELECT * FROM Item WHERE item_id = '" + iid + "'";
				
				ResultSet rs4 = satemt.executeQuery(query4);
				
				try
				{
					rs4.next();
					book_no_text.setText(rs4.getString("item_id"));
					book_title_text.setText(rs4.getString("title"));
					book_type_text.setText(rs4.getString("type"));
					location_text.setText(rs4.getString("location"));
					author_text.setText(rs4.getString("author"));
					subject_text.setText(rs4.getString("year"));
					publisher_text.setText(rs4.getString("permission"));
					
				}
				catch(SQLException sqlex)
				{
					sqlex.printStackTrace();
				}
			}
			catch(SQLException sqlex)
			{
				//sqlex.printStackTrace();
			}
		}
		
		catch(SQLException sqlex)
		{
			//sqlex.printStackTrace();
		}
	}
		} );
		
		
        gbc.gridx = 1;
        rent_date_text.setEditable(false);
        rtn_ent.add(rent_date_text, gbc);
        gbc.gridx = 2;
        rent_due_date_text.setEditable(false);
        rtn_ent.add(rent_due_date_text, gbc);
        gbc.gridx = 3;
        tag_text.setEditable(false);
        rtn_ent.add(tag_text, gbc);
        gbc.gridx = 4;
        day_overdue_text.setEditable(false);
        rtn_ent.add(day_overdue_text, gbc);
        
        gbc.gridy = 6;
        gbc.gridx = 2;
        rtn_ent.add(fine_collection, gbc);
        gbc.gridy = 7;
        rtn_ent.add(amount_fine, gbc);
        gbc.gridy = 8;
        rtn_ent.add(amount_collected, gbc);
        
        gbc.gridy = 7;
        gbc.gridx = 3;
        amount_fine_text.setEditable(false);
        rtn_ent.add(amount_fine_text, gbc);
        gbc.gridy = 8;
        rtn_ent.add(amount_collected_text, gbc);
        gbc.gridx = 4;
        
        //dump1.setText("");
        yeah.setVisible(false);
        rtn_ent.add(yeah, gbc);
        up.add(rtn_ent);
        
        JPanel upPanel = new JPanel();
        upPanel.add(up);
                
        c.add(upPanel, BorderLayout.CENTER);
        tab.addTab("Patron Info", icon, down, "Patron Info");
        tab.addTab("Book Info", icon, down2, "Book Info");
		tab.setSelectedIndex(0);
        c.add(tab, BorderLayout.SOUTH);
    
    }
    
    public void returnitem()
    {
    	try
    	{
    		Statement stmt = connection.createStatement();
    		
    		String q1 = "UPDATE Item SET avail = 'IN' WHERE item_id = '" + book_ac_no_text.getText() + "'";
    		String q3 = "SELECT * FROM reservation WHERE bookID = '" + book_ac_no_text.getText() + "'";
    		
    		int res = stmt.executeUpdate(q1);
    		ResultSet rs = stmt.executeQuery(q3);
    		
    		while (rs.next())
    		{
    			temp2.setText(rs.getString("patronID"));
    			temp.setText(rs.getString("status"));
				chk = temp.getText();
				chk2 = temp2.getText();    		
    		}
    		
    		if (chk.equals("Reserved"))
    		{
    			JOptionPane.showMessageDialog(null, "This item has been reserved by " +chk2);
    		}
    		else
    		{
    			int conf = JOptionPane.showConfirmDialog(null, "would you like to renew the book?", "confirm renewal", JOptionPane.YES_NO_OPTION);
    			
    			if(conf == JOptionPane.YES_OPTION)
    			{
    				JOptionPane.showMessageDialog(null, "wait lah wei");
    				bookSQL bsql = new bookSQL();
    				bsql.loan();
    				JOptionPane.showMessageDialog(null, "Book has been renewed");
    				
    			}
    			else
    			{
    				String q2 = "DELETE * FROM loan WHERE item_id = '" + book_ac_no_text.getText() + "'";
    		
    		int res2 = stmt.executeUpdate(q2);
    		
    			}
    		}
    				book_no_text.setText("");
					book_title_text.setText("");
					book_type_text.setText("");
					location_text.setText("");
					author_text.setText("");
					subject_text.setText("");
					publisher_text.setText("");
					
					patron_no_text.setText("");
					name_text.setText("");
					passport_text.setText("");
					group_type_text.setText("");
					expiry_date_text.setText("");
					status_text.setText("");
					loan_duration_text.setText("");
					
					rent_date_text.setText("");
					rent_due_date_text.setText("");
					amount_fine_text.setText("");
					day_overdue_text.setText("");
					book_ac_no_text.setText("");
					day_overdue_text.setText("");
					amount_collected_text.setText("");
					day_overdue_text.setText("");
    	}
    	catch(SQLException sqlex)
    	{
    		sqlex.printStackTrace();
    	}
    	
    	
    }
    
    
      protected void addButtons(JToolBar toolBar) {
        JButton button = null;

        //first button
        button = new JButton(new ImageIcon("new.gif"));
        button.setToolTipText("New");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            	book_no_text.setText("");
					book_title_text.setText("");
					book_type_text.setText("");
					location_text.setText("");
					author_text.setText("");
					subject_text.setText("");
					publisher_text.setText("");
					
					patron_no_text.setText("");
					name_text.setText("");
					passport_text.setText("");
					group_type_text.setText("");
					expiry_date_text.setText("");
					status_text.setText("");
					loan_duration_text.setText("");
					
					rent_date_text.setText("");
					rent_due_date_text.setText("");
					amount_fine_text.setText("");
					day_overdue_text.setText("");
					book_ac_no_text.setText("");
					day_overdue_text.setText("");
					amount_collected_text.setText("");
					day_overdue_text.setText("");
            }
        });

        toolBar.add(button);
        
        //second button
        button = new JButton(new ImageIcon("save.gif"));
        button.setToolTipText("Save");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) 
            {
            	if (amount_fine_text.getText().equals("0.00") || (amount_collected_text.getText().equals(amount_fine_text.getText())))
            		returnitem();
            	else
            		JOptionPane.showMessageDialog(null, "Please Pay outstanding amount");
            }
        });
        toolBar.add(button);

        
         //forth button
        button = new JButton(new ImageIcon("clear.gif"));
        button.setToolTipText("Clear");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            	book_no_text.setText("");
					book_title_text.setText("");
					book_type_text.setText("");
					location_text.setText("");
					author_text.setText("");
					subject_text.setText("");
					publisher_text.setText("");
					
					patron_no_text.setText("");
					name_text.setText("");
					passport_text.setText("");
					group_type_text.setText("");
					expiry_date_text.setText("");
					status_text.setText("");
					loan_duration_text.setText("");
					
					rent_date_text.setText("");
					rent_due_date_text.setText("");
					amount_fine_text.setText("");
					day_overdue_text.setText("");
					book_ac_no_text.setText("");
					day_overdue_text.setText("");
					amount_collected_text.setText("");
					day_overdue_text.setText("");
            }
        });
        toolBar.add(button);
        }  
}

⌨️ 快捷键说明

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