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

📄 resetinfpane.java

📁 学生宿舍管理系统
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.beans.Statement;
import java.sql.*;
import java.util.*;
import javax.swing.*;

import com.sun.corba.se.pept.transport.Connection;

public class ResetInfPane extends JPanel{
	Box baseBox,boxV1,boxV2;
	TextField SBD,SEX,idNum,name,address,major,SNB=new TextField("学号");
	Label enter=new Label("学生入住:");
	Label  hy=new Label("欢迎");
	
	
	Icon icon3=new ImageIcon("image/小孩.jpg");
	JButton xixi=new JButton("",icon3);
	
	Label exit=new Label("学生搬出:");
	Label EXIT=new Label("搬出学生的学号:");
	Icon icon1 = new ImageIcon("image/weixiao.GIF");
	Icon icon4 = new ImageIcon("image/yun.GIF");
	JButton enTER=new JButton("入住",icon1);
	Icon icon2 = new ImageIcon("image/baibai.gif");
	JButton exIT=new JButton("搬出",icon4);
	JButton btn=new JButton("退出",icon2);
	
//(this);
//	Statement sql;
//	Connection con;
	JDBCAdapter database=new JDBCAdapter("jdbc:odbc:information",
			"sun.jdbc.odbc.JdbcOdbcDriver",
			"",
			"");
		
	ResetInfPane() {
		boxV1=Box.createVerticalBox();
		boxV1.add(new Label("楼栋:"));
		boxV1.add(Box.createVerticalStrut(8));
		boxV1.add(new Label("寝室:"));
		boxV1.add(Box.createVerticalStrut(8));
		boxV1.add(new Label("姓名:"));
		boxV1.add(Box.createVerticalStrut(8));
		boxV1.add(new Label("性别:"));
		boxV1.add(Box.createVerticalStrut(8));
		boxV1.add(new Label("学号:"));
		boxV1.add(Box.createVerticalStrut(8));
		boxV1.add(new Label("专业:"));
		
		boxV2=Box.createVerticalBox();
		boxV2.add(SBD=new TextField("楼栋"));
		boxV2.add(Box.createVerticalStrut(8));
		boxV2.add(address=new TextField("寝室号"));
		boxV2.add(Box.createVerticalStrut(8));
		boxV2.add(name=new TextField("姓名"));
		boxV2.add(Box.createVerticalStrut(8));
		boxV2.add(SEX=new TextField("性别"));
		boxV2.add(Box.createVerticalStrut(8));
		boxV2.add(idNum=new TextField("学号"));
		boxV2.add(Box.createVerticalStrut(8));		
		boxV2.add(major =new TextField("南昌航空大学"));
		
		baseBox=Box.createHorizontalBox();
		baseBox.add(boxV1);
		baseBox.add(Box.createHorizontalStrut(10));
		baseBox.add(boxV2);
		
		add(baseBox);
		baseBox.setBounds(15,30,150,250);
		
		setLayout(null);//设置一空布局
		add(enter);//学生搬入标签
		enter.setBounds(0,0,100,30);
		
		add(hy);//欢迎标签
		hy.setBounds(200,10,100,50);
		hy.setForeground(Color.RED);
		hy.setFont(new Font("姚体",Font.ITALIC|Font.BOLD,45));
		
		setBackground(Color.green);//背景颜色
		add(xixi);//插入图片
		xixi.setBounds(465,15,100,100);
		
		add(btn);//退出按钮
		btn.setBounds(185, 170, 100, 35);
		btn.addActionListener(new ActionListener()
		{

			public void actionPerformed(ActionEvent e) {
				System.exit(0);// TODO Auto-generated method stub
				
			}
			
		});
		//add(tn);
		//tn.setBounds()
		
		
		
		add(exit);//学生搬出的标签
		exit.setBounds(335,0,100,30);
		
		add(EXIT);//搬出学生的学号标签
		EXIT.setBounds(335,100,100,30);
		
		add(SNB);//搬出学生的学号输入文本框
	    SNB.setBounds(335,150,100,30);
	    
		add(enTER);//入住按钮
		enTER.setBounds(185,125,100,35);
		final JPanel t=this;
		enTER.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
				boolean flag[]={false,false,false,false,false,false,};
				if(!SBD.getText().equals("楼栋"))
					flag[0]=true;
				if(!address.getText().equals("寝室号") )
					flag[1]=true;
				if(!name.getText().equals("姓名") )
					flag[2]=true;
				if(!SEX.getText().equals("性别") )
					flag[3]=true;
				if(!idNum.getText().equals("学号") )
					flag[4]=true;
				if(!major.getText().equals("南昌航空大学") )
					flag[5]=true;
				if(flag[0]&&flag[1]&&(flag[2]||flag[4]))
					{
					String recode="("+"'"+SBD.getText()+"'"+","+"'"+address.getText()+"'"
					+","+"'"+name.getText()+"'"+","+"'"+SEX.getText()+"'"
					+","+"'"+idNum.getText()+"'"+","+"'"+major.getText()+"'"
					+","+1+")";
					String query="INSERT INTO StudentInf VALUES "+recode;
					
					try {
						database.executeInser(query);
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					JOptionPane.showMessageDialog(t,"入住成功","恭喜",JOptionPane.WARNING_MESSAGE);
					}
			}			
		});
		
		add(exIT);//搬出按钮
		exIT.setBounds(350,250,100,35);
		final JPanel p=this;
		exIT.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
				if(!SNB.getText().equals("学号"))
				{
				String query="DELETE FROM StudentInf WHERE SNB='"+SNB.getText()+"'";
				try {
					database.executeDel(query);
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			JOptionPane.showMessageDialog(p,"搬出成功","恭喜",JOptionPane.WARNING_MESSAGE);
			//(this,"入住失败","抱歉",JOptionPane.WARNING_MESSAGE);
				
				}
				
			}
		});
		setVisible(true);
	}
}

⌨️ 快捷键说明

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