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

📄 fakuanmanage.java

📁 简单的书店管理系统,是课设期间教师指导完成的,希望会对大家有帮助!
💻 JAVA
字号:
package book;

import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class FakuanManage extends Mb{
		private JLabel icon, bookNumber,bookName,readerNumber,readerName,jbookTime,yhbookTime,chaoTime,jsr,chaoqi;

		private ButtonIcon ok,xu,close,quxiao;

		private Table table;

		private PreparedStatement pstmt = null;
		
		private NowEditableModel dtm;
		
		private ArrayList List = new ArrayList();
		
		private JScrollPane scrool;
		FakuanManage(String s, int i, int j) throws SQLException {
			super(s, i, j);
			con.setLayout(null);
			shezhi();
			add();
		}
		
		private void shezhi() throws SQLException{	
			
			MainDAO dao = new MainDAO();
			dtm = (NowEditableModel) dao.getTableModel("select * from fakuanbiao where 是否已罚='未处罚'");
			table = new Table(dtm);
			scrool = new JScrollPane(table);
			scrool.setBounds(20, 80, 560, 250);
			table.setWidth();
			ListSelectionModel rowSM = table.getSelectionModel();
			rowSM.addListSelectionListener(new ListSelectionListener() {
				public void valueChanged(ListSelectionEvent e) {
					if (e.getValueIsAdjusting())
						return;
					ListSelectionModel lsm = (ListSelectionModel) e.getSource();
					if (lsm.isSelectionEmpty()) {
						System.out.println("No rows are selected.");
					} else {
						List = table.getSelectRow(lsm.getMinSelectionIndex(), table
								.getColumnCount());
					}
				}
				
			});
			setLabel();
			setButton();
			statr();
		}
		
		void setLabel(){
			
			icon=new JLabel(new ImageIcon("./data/image/heard/fakuanguanli.jpg"));
			icon.setBounds(0,5,600,50);
			
			bookName=new JLabel("过期未罚款读者");
			bookName.setBounds(250, 60, 200, 18);	
			
		}
		
		void setButton(){
			xu = new ButtonIcon("确定");
			xu.setBounds(400, 335, 70, 25);
			xu.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent arg0) {
					int n = JOptionPane.showConfirmDialog(table, "此读者超期"+List.get(6).toString()+"天,应罚款"+List.get(7).toString()+"元。是否现在进行处罚?", "退出",
								JOptionPane.YES_NO_OPTION); 
					
					if(n==0){
						try {
							MainDAO dao = new MainDAO();
							String str = "update fakuanbiao set 是否已罚='已处罚' where 罚款编号=?";
							pstmt = dao.getPreparedStatement(str);
							pstmt.setInt(1,Integer.parseInt(List.get(0).toString()));
							pstmt.executeUpdate();
							pstmt.close();
							dao.close();
							
							JOptionPane.showMessageDialog(table, "处罚成功!!!");
							table.Renovate("select * from fakuanbiao where 是否已罚='未处罚'");
							statr();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					}
					
				}
				
				
			});
			
			
			
			
			close = new ButtonIcon("关闭");
			close.setBounds(500, 335, 70, 25);
		}
		
		
	    void statr(){
	    	if(table.getRowCount()==0){
	    		xu.setEnabled(false);
	    	}
	    }
		
		void add(){		
			con.add(icon);
			con.add(bookName);
			con.add(xu);
			con.add(close);
			con.add(scrool);
			con.validate();
			table.getSelectionModel().setSelectionInterval(0, 0);
		}

	}

⌨️ 快捷键说明

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