Java项目:飞机订票系统(java+swing+Oracle)

功能简介:

机票查询、改签处理、航班动态、退票处理、销售统计、后台管理、退出系统

 

 

 

用户信息服务类:

public class Userinformodification extends JDialog implements MouseListener{
	private ImagePanel ip;
	JLabel userId;
	JLabel userPasswd1;
	JLabel userPasswd ;
	JLabel userName;
	JLabel userSex;
	JRadioButton boy;
	JRadioButton girl;
	JLabel tel;
	JLabel addr;
	JLabel email;
	JLabel identity;
	private User user ;
	Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
	public Userinformodification(JFrame jFrame,User user){
		this.user= user ;
		this.init();
	}
	public void init(){	
		
		this.setSize(600, 700) ;
		this.setModal(true);
		this.setLocationRelativeTo(null) ;
		this.setResizable(false) ;
		this.setTitle("用户信息修改") ;
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) ;
		ImagePanel jPanel = null;
		try {
			jPanel = new ImagePanel(ImageIO.read(new File("image/171go.jpg")), dimension);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JPanel jpAll=new JPanel();
		jpAll.setLayout(new BorderLayout());
		jpAll.setOpaque(false) ;
		JPanel jopJPanel=new JPanel();
		JLabel jluser=new JLabel("用户信息修改");
//		jluser.setForeground(new Color(0xC4C43B));
		jluser.setFont(Tookit.getFont2());
		jopJPanel.add(jluser);
		jpAll.add(jopJPanel,BorderLayout.NORTH);
		jPanel.add(jpAll);
		jopJPanel.setOpaque(false);
		
		JPanel infoPanel = new JPanel(new GridLayout(9, 2,2,20)) ;
		infoPanel.setOpaque(false) ;
		infoPanel.setPreferredSize(new Dimension(450, 500)) ;
		userId = new JLabel("用户名:",JLabel.CENTER);
		
		userId.setFont(Tookit.getFont1()) ;
		infoPanel.add(userId) ;
		final JTextField userIdField = new JTextField(user.getU_id()) ;
		userIdField .setEnabled(false) ;
		infoPanel.add(userIdField) ;
		userPasswd = new JLabel("密码:",JLabel.CENTER);
		userPasswd.setFont(Tookit.getFont1()) ;
		infoPanel.add(userPasswd) ;
		final JPasswordField userPasswdField = new JPasswordField(user.getU_password()) ;
		infoPanel.add(userPasswdField) ;
		userName = new JLabel("姓名:",JLabel.CENTER);
		userName.setFont(Tookit.getFont1()) ;
		infoPanel.add(userName) ;
		final JTextField userNameField = new JTextField(user.getU_name()) ;
		infoPanel.add(userNameField) ;
		userSex = new JLabel("性别:",JLabel.CENTER) ;
		userSex.setFont(Tookit.getFont1()) ;
		JPanel jSex = new JPanel() ;
		jSex.setOpaque(false) ;
		boy = new JRadioButton("男") ;
		boy.setOpaque(false) ;
		boy.setFont(Tookit.getFont1()) ;
		girl = new JRadioButton("女") ;
		girl.setOpaque(false) ;
		girl.setFont(Tookit.getFont1()) ;
		ButtonGroup gbGroup = new ButtonGroup();
		gbGroup.add(boy) ;
		gbGroup.add(girl) ;
		jSex.add(boy) ;
		jSex.add(girl) ;
		if(user.getU_sex().equals("男")){
			boy.setSelected(true) ;
		}
		if (user.getU_sex().equals("女")) {
			girl.setSelected(true);
		}
		infoPanel.add(userSex);
		infoPanel.add(jSex) ;
		tel = new JLabel("电话号码:",JLabel.CENTER);
		tel.setFont(Tookit.getFont1()) ;
		infoPanel.add(tel) ;
		final JTextField telField = new JTextField(user.getU_telephone()) ;
		infoPanel.add(telField) ;
		addr = new JLabel("地址:",JLabel.CENTER);
		addr.setFont(Tookit.getFont1()) ;
		infoPanel.add(addr) ;
		final JTextField addrField = new JTextField(user.getU_address()) ;
		infoPanel.add(addrField) ;
		email = new JLabel("电子邮件:",JLabel.CENTER);
		email.setFont(Tookit.getFont1()) ;
		infoPanel.add(email) ;
		final JTextField emailField = new JTextField(user.getU_email()) ;
		infoPanel.add(emailField) ;
		identity = new JLabel("身份证号:",JLabel.CENTER);
		identity.setFont(Tookit.getFont1()) ;
		infoPanel.add(identity) ;
		final JTextField identityField = new JTextField(user.getU_idcard()) ;
		infoPanel.add(identityField) ;
		jpAll.add(infoPanel,BorderLayout.CENTER);
		
		JPanel jButtom =new JPanel();
		JButton affirm = new JButton("确认") ;
		affirm.setFont(Tookit.getFont1()) ;
		jButtom.add(affirm);
		JButton cancel = new JButton("取消") ;
		cancel.setFont(Tookit.getFont1()) ;
		jButtom.add(cancel);
		jpAll.add(jButtom,BorderLayout.SOUTH);
		jButtom.setOpaque(false);
//		jPanel.add(Box.createRigidArea(new Dimension(dimension.width, 50))) ;
		jPanel.add(jpAll) ;
		this.add(jPanel) ;	
		affirm.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				String uId=userIdField.getText().trim();
				String uPassword=String.valueOf(userPasswdField.getPassword());
				String uName = userNameField.getText().trim();
				String uSex  = null;
				if(boy.isSelected()){
					uSex=boy.getText().trim();
				}
				if(girl.isSelected()){
					uSex=girl.getText().trim();
				}
				String uTelephone=telField.getText().trim();
				String uAddress  =addrField.getText().trim();
				String uEmail   = emailField.getText().trim();
				String uIdcard = identityField.getText().trim();
				
				//判断所有的是否为空
				if(uId.isEmpty()||uPassword.isEmpty()||uName.isEmpty()||uSex.isEmpty()||uTelephone.isEmpty()||uAddress.isEmpty()||uEmail.isEmpty()||uIdcard.isEmpty()){
					JOptionPane.showMessageDialog(null, "所填项不能为空!");
					return;
				}
				//创建一个User
				User user = new User(uId, uPassword, uName, uSex, uTelephone, uAddress, uEmail, uIdcard, "0");
				CheckInfo checkInfo =new CheckInfo() ;
				boolean b = checkInfo.check(user) ;
				System.out.println(b);
				if(b==true){
					//表示 数据 格式 是 正确的  此时连接数据库操作
					String sql="update users set u_password=?,u_name=?,u_sex=?,u_telephone=?,u_address=?,u_email=?,u_idcard=?  where u_id=?";
					String[] ss={ uPassword, uName, uSex, uTelephone, uAddress, uEmail, uIdcard,uId};
					
					DataHandle dataHandle=new DataHandle();
					boolean iss=dataHandle.update(sql, ss);
					if(iss){
						JOptionPane.showMessageDialog(null, "修改成功!请重新登录");
						Userinformodification.this.dispose() ;
						new LoginView().setVisible(true) ;
					}else{
						JOptionPane.showMessageDialog(null, "修改失败!");
						return;
					}					
				}
				
			}
		});
		cancel.addActionListener(new ActionListener() {		
			@Override
			public void actionPerformed(ActionEvent e) {
				Userinformodification.this.dispose() ;
//				userIdField.setText("") ;
//				userNameField.setText("") ;
//				userPasswdField.setText("") ;
//				telField.setText("") ;
//				addrField.setText("") ;
//				emailField.setText("") ;
//				identityField.setText("") ;
			}
		});
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub	
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub		
	}
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub	
	}
	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub		
	}
	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub		
	}
}

登录服务类:

public class LoginView extends JFrame implements MouseListener{
	
	private JTextField userNameField = null;
	private JPasswordField userPasswdField = null ;
    private  JPanel jp ;
    private FileOperation fileOperation  ;
    private Vector<String> loginNames ;
   // private JScrollPane autoTipPane ;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new LoginView().setVisible(true);
	}
	
	public LoginView(){
		UIManager.put("TextField.font", Tookit.getFont1()) ;
		UIManager.put("Label.font", Tookit.getFont1()) ;
		UIManager.put("Button.font", Tookit.getFont1()) ;
		fileOperation = new FileOperation();
		//从文件中加载用户名过来
		loginNames = fileOperation.loading("path/loginName") ;
		this.init();
	}

	private void init() {
		//上面 的panel
		JPanel top = new JPanel() ;
		JLabel jTop = new JLabel(new ImageIcon("image/logo.gif")) ;
		top.add(jTop) ;
		this.add(top,BorderLayout.NORTH) ;
		//下面的panel
		JPanel buttom = new JPanel(new BorderLayout()) ;
		//左边
		buttom.add(this.leftPanel()) ;
		//右边
		buttom.add(this.rightPanel(),BorderLayout.EAST);
		 
		this.add(buttom) ;
		this.setSize(823, 500) ;
		this.setLocationRelativeTo(null) ;
		this.setResizable(false) ;
		this.setIconImage(new ImageIcon("image/1.png").getImage()) ;
		this.setTitle("飞机订票系统") ;
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
	}
	/**
	 * 处理左边登录面板
	 * @return
	 */
	public JPanel leftPanel(){
		JPanel jPanel = new JPanel(new BorderLayout()) ;
		//上面
		JLabel jLogin = new JLabel(new ImageIcon("image/enter_font1.jpg"),JLabel.CENTER) ;
		jPanel.add(jLogin,BorderLayout.NORTH) ;//加一个jlable
		//中间
		MyLoginPanel myPanel = new MyLoginPanel() ;
		myPanel.setLayout(null) ;
	
		final JLabel userName = new JLabel("登录名:",JLabel.CENTER) ;
		userName.setBounds(135, 70, 65, 15) ;
		userName.setFont(Tookit.getFont1()) ;
		myPanel.add(userName) ;
		//加一个面板   可以 存入多个jlabel
		jp = new JPanel() ;
		jp.setOpaque(false) ;
		//jp.setPreferredSize(new Dimension(140, 200)) ;
		//autoTipPane = new JScrollPane(jp) ;
		jp.setBounds(200, 89, 140, 200) ;
		//autoTipPane.setOpaque(false) ;
		//autoTipPane.getViewport().setOpaque(false) ;
		myPanel.add(jp) ;
		userNameField = new JTextField(12) ;
		userNameField.setBounds(200, 68, 140, 21) ;
		
		userNameField.getDocument().addDocumentListener(new DocumentListener() {
			
			//创建一个存入 jlabel的集合
			//Vector<JLabel> jLabels = new Vector<JLabel>() ;
			
			@Override
			public void removeUpdate(DocumentEvent e) {
				//每删除一个 字母
				LoginView.this.autoTip() ;
			}
			
			@Override
			public void insertUpdate(DocumentEvent e) {
				
				LoginView.this.autoTip() ;
			}
			
			@Override
			public void changedUpdate(DocumentEvent e) {
					
			}
		}) ;
		
		myPanel.add(userNameField) ;
		if(userNameField.getText().trim().equals("")){
			
		}
//		center.add(userName) ;
//		center.add(userNameField) ;
		JLabel userPasswd = new JLabel("密    码:",JLabel.CENTER) ;
		userPasswd.setFont(Tookit.getFont1()) ;
		userPasswd.setBounds(135, 124, 65, 15) ;
		userPasswdField = new JPasswordField(12) ;
		userPasswdField.setBounds(200, 124, 140, 21) ;
		myPanel.add(userPasswd) ;
		myPanel.add(userPasswdField) ;
		
		JLabel userGrade = new JLabel("身    份:",JLabel.CENTER) ;
		userGrade.setFont(Tookit.getFont1()) ;
		userGrade.setBounds(135, 166, 65, 15) ;
		final JComboBox jcb = new JComboBox(new String[]{"旅客","管理员"}) ;
		jcb.setBounds(200, 163, 71, 27) ;
		myPanel.add(userGrade) ;
		jcb.setFont(Tookit.getFont1()) ;
		myPanel.add(jcb) ;

		JButton login = new JButton("登录");
		login.setBounds(151, 215, 81, 30) ;
		myPanel.add(login) ;
		login.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {

				//取出用户名跟密码以及角色
				if(userName.getText().trim().equals("") ||String.valueOf(userPasswdField.getPassword()).trim().equals("")){
					JOptionPane.showMessageDialog(LoginView.this, "用户名或密码不能为空!!") ;
					return ;
				}
				//发送数据到数据库验证  数据库处理   
				DataHandle loginHandle = new DataHandle() ;
				//权限
				String power = ((String)jcb.getSelectedItem()).equals("旅客")?"0":"1" ;
				//用户名
				String userId = userNameField.getText().trim() ;
				//密码
				String userPasswd = String.valueOf(userPasswdField.getPassword()) ;
				User user = loginHandle.getUser(
						"select * from users where u_id=?",
						new String[] { userId });
				if(user!=null && user.getU_password().equals(userPasswd) && user.getU_power().equals(power)){
					//表示验证成功
					//得到用户姓名
					String userName = user.getU_name() ;
					String userSex = user.getU_sex() ;
					String userCall = userSex.equals("男")?"先生":"女士" ;
					if(power.equals("0")){
						//表示旅客
						JOptionPane.showMessageDialog(LoginView.this, "欢迎旅客"+userName+userCall+"登录") ;
						new GuestMainView(user).setVisible(true) ;
					}else {
						JOptionPane.showMessageDialog(LoginView.this, "欢迎管理员"+userName+userCall+"登录") ;
						new MangerMainView(user).setVisible(true) ;
					}
					//登录成功  将用户名加入到集合里  
					if(!loginNames.contains(userId)){
						//表示文件这个Id不存在
						loginNames.add(userId) ;
					}
					//序列到文件
					boolean b = fileOperation.save("path/loginName", loginNames) ;
					if(!b){
						JOptionPane.showMessageDialog(LoginView.this, "序列化文件失败");
						return ;
					}
					LoginView.this.dispose() ;
					
				}else{
					//验证不成功
					JOptionPane.showMessageDialog(LoginView.this, "用户名、密码与身份不匹配!!") ;
					userPasswdField.setText("") ;
				}
				
			}
		}) ;
		login.setPreferredSize(new Dimension(80, 30)) ;
		login.setBackground(new Color(0x71B8EC)) ;
		JButton exit = new JButton("退出");
		exit.setBounds(265, 215, 81, 30) ;
		myPanel.add(exit) ;
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				//可以在这里加一个滚动条  ??
				System.exit(0) ;
			}
		}) ;
		exit.setPreferredSize(new Dimension(80, 30)) ;
		exit.setBackground(new Color(46,116,188)) ;
		jPanel.add(myPanel) ;
		return jPanel ;
	}
/**
 * 将右边设置为卡片布局
 * @return
 */
	public JPanel rightPanel(){
		
		final CardLayout card = new CardLayout() ;
		final JPanel right = new JPanel(card) ;
		right.setBorder(new TitledBorder(new EtchedBorder(), "新用户注册")) ;
		right.setPreferredSize(new Dimension(269, 363)) ;
		//right.setBackground(new Color(0xFFFFCC)) ;
		
		Box box = Box.createVerticalBox() ;
		box.add(Box.createHorizontalStrut(32)) ;
		
		JLabel jLabel = new JLabel() ;
		jLabel.setText("<html>" +"<h2>新用户注册</h2><hr>"+
				"1、免费注册<br> 2、实名注册 <br>3、注册用户可享受个性化服务<br><br> " +
				"</html>") ;
		box.add(jLabel) ;
		
		JButton regist = new JButton("注册") ;
		regist.setPreferredSize(new Dimension(100, 30)) ;
		regist.setBackground(new Color(0xFFFFCC)) ;
		box.add(regist) ;
		JPanel jpOne = new JPanel() ;
		jpOne.setOpaque(false) ;
		jpOne.add(box) ;
		right.add(jpOne,"one") ;
		//第二个panel
		JPanel jpTwo = new JPanel() ;
		jpTwo.setOpaque(false) ;
		jpTwo.setLayout(new BorderLayout()) ;
		String info ="<html>1、服务条款的确认<br>您点击服务条款页面下的“我同意”按钮,<br>即视为您已阅读、了解并完全同意服务条款<br>中的各项内容,包括本网站对服务条款所<br>作的任何修改。除另行明确声明外,本网站<br>任何服务范围或功能的变化均受服务条款约束。<br>2、服务条款的修改<br>本网站在必要时可修改服务条款,并在网站<br>进行公告,一经公告,立即生效。如您继续<br>使用服务,则视为您已接受修订的服务条款。<br>3、用户注册<br>考虑到本网站用户服务的重要性,您同意在<br>注册时提供真实、完整及准确的个人资料,<br>并及时更新。 如您提供的资料不准确,或<br>本网站有合理的理由认为该资料不真实、不<br>完整、不准确,本网站有权暂停或终止您的<br>注册身份及资料,并拒绝您<br>使用本网站的服务。4、用户资料及保密<br>注册时,请您选择填写用户名和密码,<br>并按页面提示提交相关信息。您负有对用户<br>名和密码保密的义务,并对该用户名和密<br>码下发生的所有活动承担责任。您同意邮件<br>服务的使用由您自己承担风险。本网站不<br>会向您所使用服务所涉及相关方之外的其他<br>方公开或透露您的个人资料,法律法规规定除外。 <html>" ;
		JLabel jLabel2 = new JLabel(info) ;
		jLabel2.setFont(Tookit.getFont1()) ;
		jpTwo.add(jLabel2) ;
		JPanel jpButton = new JPanel() ;
		jpButton.setOpaque(false) ;
		JButton accept = new JButton("同意") ;
		accept.setPreferredSize(new Dimension(100, 30)) ;
		accept.setBackground(new Color(0xFFFFCC)) ;
		jpButton.add(accept) ;
		JButton unaccept = new JButton("不同意") ;
		unaccept.setPreferredSize(new Dimension(100, 30)) ;
		unaccept.setBackground(new Color(0xFFFFCC)) ;
		jpButton.add(unaccept) ;
		jpTwo.add(jpButton,BorderLayout.SOUTH);
		right.add(new JScrollPane(jpTwo),"two") ;
		//第三个panel
		JPanel jpThree = new JPanel(new BorderLayout()) ;
		//jpThree.setOpaque(false) ;
		//jpThree.setPreferredSize(new Dimension(269,300)) ;
		JPanel infoPanel = new JPanel(new GridLayout(9, 2)) ;
		JLabel userId = new JLabel("用户名:",JLabel.CENTER);
		userId.setFont(Tookit.getFont1()) ;
		infoPanel.add(userId) ;
		final JTextField userIdField = new JTextField() ;
		infoPanel.add(userIdField) ;
		JLabel userPasswd = new JLabel("密码:",JLabel.CENTER);
		userPasswd.setFont(Tookit.getFont1()) ;
		infoPanel.add(userPasswd) ;
		final JPasswordField userPasswdField = new JPasswordField() ;
		infoPanel.add(userPasswdField) ;
		JLabel userPasswd1 = new JLabel("确认密码:",JLabel.CENTER);
		userPasswd1.setFont(Tookit.getFont1()) ;
		infoPanel.add(userPasswd1) ;
		final JPasswordField userPasswd1Field = new JPasswordField() ;
		infoPanel.add(userPasswd1Field) ;
		JLabel userName = new JLabel("姓   名:",JLabel.CENTER);
		userName.setFont(Tookit.getFont1()) ;
		infoPanel.add(userName) ;
		final JTextField userNameField = new JTextField() ;
		infoPanel.add(userNameField) ;
		//用户性别
		JLabel userSex = new JLabel("性别:",JLabel.CENTER) ;
		userSex.setFont(Tookit.getFont1()) ;
		JPanel jSex = new JPanel() ;
		jSex.setOpaque(false) ;
		final JRadioButton boy = new JRadioButton("男") ;
		boy.setOpaque(false) ;
		boy.setFont(Tookit.getFont1()) ;
		final JRadioButton girl = new JRadioButton("女") ;
		girl.setOpaque(false) ;
		girl.setFont(Tookit.getFont1()) ;
		ButtonGroup gbGroup = new ButtonGroup();
		gbGroup.add(boy) ;
		gbGroup.add(girl) ;
		jSex.add(boy) ;
		jSex.add(girl) ;
		infoPanel.add(userSex);
		infoPanel.add(jSex) ;
		JLabel tel = new JLabel("电话号码:",JLabel.CENTER);
		tel.setFont(Tookit.getFont1()) ;
		infoPanel.add(tel) ;
		final JTextField telField = new JTextField() ;
		infoPanel.add(telField) ;
		JLabel addr = new JLabel("地址:",JLabel.CENTER);
		addr.setFont(Tookit.getFont1()) ;
		infoPanel.add(addr) ;
		final JTextField addrField = new JTextField() ;
		infoPanel.add(addrField) ;
		JLabel email = new JLabel("电子邮件:",JLabel.CENTER);
		email.setFont(Tookit.getFont1()) ;
		infoPanel.add(email) ;
		final JTextField emailField = new JTextField() ;
		infoPanel.add(emailField) ;
		JLabel identity = new JLabel("身份证号:",JLabel.CENTER);
		identity.setFont(Tookit.getFont1()) ;
		infoPanel.add(identity) ;
		final JTextField identityField = new JTextField() ;
		infoPanel.add(identityField) ;
		jpThree.add(infoPanel) ;

		JPanel subMitPanel = new JPanel() ;
		JButton submit = new JButton("提交注册信息") ;
		submit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				//得到所有的数据   9个数据
				String uId=userIdField.getText().trim();
				String uPassword=String.valueOf(userPasswdField.getPassword());
				String uName = userNameField.getText().trim();
				String uSex  = null;
				if(boy.isSelected()){
					uSex=boy.getText().trim();
				}
				if(girl.isSelected()){
					uSex=girl.getText().trim();
				}
				String uTelephone=telField.getText().trim();
				String uAddress  =addrField.getText().trim();
				String uEmail   = emailField.getText().trim();
				String uIdcard = identityField.getText().trim();
				
				//判断所有的是否为空
				if(uId.isEmpty()||uPassword.isEmpty()||userPasswd1Field.getPassword().toString().equals("")||uName.isEmpty()||uSex.isEmpty()||uTelephone.isEmpty()||uAddress.isEmpty()||uEmail.isEmpty()||uIdcard.isEmpty()){
					JOptionPane.showMessageDialog(null, "所填项不能为空!");
					return;
				}
				System.out.println(String.valueOf(userPasswd1Field.getPassword())+"-------"+uPassword);
				//做出判断   二次密码是 不是一样
				if(String.valueOf(userPasswd1Field.getPassword()).equals(uPassword)==false){
					JOptionPane.showMessageDialog(null, "两次密码不一致!");
					return;
				}
				//创建一个User
				User user = new User(uId, uPassword, uName, uSex, uTelephone, uAddress, uEmail, uIdcard, "0");
				CheckInfo checkInfo =new CheckInfo() ;
				boolean b = checkInfo.checkRegistInfo(user) ;
				System.out.println(b);
				if(b==true){
					//表示 数据 格式 是 正确的  此时连接数据库操作
					String sql="insert into users values(?,?,?,?,?,?,?,?,?)";
					String[] ss={uId, uPassword, uName, uSex, uTelephone, uAddress, uEmail, uIdcard, 0+""};
					
					DataHandle dataHandle=new DataHandle();
					boolean iss=dataHandle.update(sql, ss);
					if(iss){
						 JOptionPane.showConfirmDialog(null, "注册成功!是否继续?");
						card.show(right, "one") ;
					}else{
						JOptionPane.showMessageDialog(null, "注册失败!");
						return;
					}
				}	
//				}else{
//					JOptionPane.showMessageDialog(null, "格式不正确");
//				}
			}
		}) ;
		submit.setFont(Tookit.getFont1()) ;
		//submit.setPreferredSize(new Dimension(100, 30)) ;
		submit.setBackground(new Color(0xFFFFCC)) ;
		subMitPanel.add(submit) ;
		JButton reset = new JButton("重置") ;
		reset.setFont(Tookit.getFont1()) ;
		reset.setPreferredSize(new Dimension(100, 30)) ;
		reset.setBackground(new Color(0xFFFFCC)) ;
		subMitPanel.add(reset) ;
		jpThree.add(subMitPanel,BorderLayout.SOUTH) ;
		right.add(jpThree,"three") ;
		
		reset.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				userIdField.setText("") ;
				userNameField.setText("") ;
				userPasswdField.setText("") ;
				userPasswd1Field.setText("") ;
				telField.setText("") ;
				addrField.setText("") ;
				emailField.setText("") ;
				identityField.setText("") ;
			}
		}) ;
		regist.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				//点击了注册 
				card.show(right, "two") ;
			}
		}) ;
		accept.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				card.show(right, "three") ;
			}
		}) ;
		unaccept.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				card.show(right, "one") ;
			}
		}) ;
		return right ;
	}
	
	public void autoTip(){
		System.out.println("===");
		//清除面板所有 的 组件
		jp.removeAll() ;
		//jLabels.removeAllElements() ;
		//得到 文本域 的名
		String str = userNameField.getText().trim() ;
		
		for(String loginName :loginNames){
			if(loginName.startsWith(str) && !str.equals("")){
				//创建一个jlabel
				JLabel jLabel = new JLabel(loginName) ;
				jLabel.addMouseListener(LoginView.this) ;
				jLabel.setPreferredSize(new Dimension(140, 20));
				//jLabels.add(jLabel) ;
				jp.add(jLabel) ;	
			}
		}
		jp.repaint() ;
		//autoTipPane.repaint() ;
		jp.validate() ;//刷新界面
	//	autoTipPane.validate() ;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		userNameField.setText(((JLabel)e.getSource()).getText()) ;
		//设置面板属性	
		jp.removeAll() ;
		this.remove(jp) ;
		this.repaint() ;
		this.validate() ;

		//设置面板的宽度
		//jp.setBackground(Color.red) ;
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		JLabel jLabel = (JLabel)e.getSource() ;
		jLabel.setForeground(Tookit.getColor()) ;
		jLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		JLabel jLabel = (JLabel)e.getSource() ;
		jLabel.setForeground(Color.black) ;
		jLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)) ;
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}

查询票的服务类:

public class TicketSearchPanel extends JPanel implements ActionListener,MouseListener{

	private ImagePanel ticketSearchPanel = null ;
	private HashMap<String, Bank> map= null ;//一个票Id是用什么 银行账号买的 
	private CardLayout card = null ;
	private JButton queryButton = null ;
	private JButton resetButton = null ;
	private JButton order ;
	private JTextField jtf1,jtf2,jtf3,jtf1_1,jtf2_1,jtf3_1, idField,priceField;
	private JComboBox jcBox,jcBox_1, boxType ;
	private JLabel jl1 ,jl2,jl3,jl4,jlTop;
	private JTable jTable ;
	private DataHandle dataHandle ;
	private Vector<FlightInfo> fInfos  ;
	private Vector<Vector<Seat>> seats ;
	private FlightInfo selectFlightInfo = null ; 
	private Vector<String> remainType = null ;
	private Vector<Seat> selectSeat =  null ; 
	private SearchTableModel stmModel ;
	private boolean isGoing  = false ;
	private JScrollPane jsp ;
	private String currenTime ,bankName;
	private User user ;
	private JPanel c ;
	private CheckInfo checkInfo ;
	public TicketSearchPanel(User user){
		checkInfo = new CheckInfo() ;
		map = new HashMap<String, Bank>() ;
		dataHandle = new DataHandle() ;
		this.user = user ;
		UIManager.put("Label.font", Tookit.getFont1()) ;
		UIManager.put("Button.font", Tookit.getFont1()) ;
		UIManager.put("ComboBox.font", Tookit.getFont1()) ;
		UIManager.put("CheckBox.font", Tookit.getFont1()) ;
		remainType = new Vector<String>() ;
		currenTime = Tookit.getDateFormat("yyyy-MM-dd").format(new Date()) ;
		card = new CardLayout() ;
		this.init();
	}
	/**
	 * 第一张面板
	 * @return
	 */
	public JPanel onePanel(){
		JPanel jPanel = new JPanel(new BorderLayout()) ;
		jPanel.setOpaque(false) ;
		
		//控制北边
		JPanel north = new JPanel() ;
		north.setPreferredSize(new Dimension(1028,145)) ;
		north.setOpaque(false) ;
		jPanel.add(north,BorderLayout.NORTH) ;
		
		JPanel center = new JPanel(null) ;
		center.setOpaque(false) ;
		
		 jl1= new JLabel("出发城市:");
		jl1.setBounds(200, 20, 74, 20) ;
		jl1.setFont(Tookit.getFont1()) ;
		 jtf1= new JTextField(12) ;
		jtf1.setBounds(275, 20, 130, 20) ;
	     jl2 = new JLabel("到达城市:");
		jl2.setBounds(200, 70, 74, 20) ;
		jl2.setFont(Tookit.getFont1()) ;
	    jtf2 = new JTextField() ;
		jtf2.setBounds(275, 70, 130, 20) ;
		 jl3 = new JLabel("出发日期:",JLabel.RIGHT);
		jl3.setFont(Tookit.getFont1()) ;
		jl3.setBounds(200, 120, 74, 20) ;
		 jtf3 = new JTextField(currenTime) ;
		jtf3.setBounds(275, 120, 130, 20) ;
		 jl4 = new JLabel("出发时间:",JLabel.RIGHT);
		jl4.setBounds(200, 175, 74, 20) ;
		jl4.setFont(Tookit.getFont1()) ;
		jcBox = new JComboBox(new String[]{"全部时间段","00:00-06:00","06:00-12:00","12:00-18:00","18:00-24:00"}) ;
		jcBox.setFont(Tookit.getFont1()) ;
		jcBox.setBounds(275, 170, 100, 30) ;

		queryButton = new JButton("开始查询");
		queryButton.addActionListener(this) ;
		queryButton.setFont(Tookit.getFont1()) ;
		queryButton.setBounds(180, 220, 120, 30) ;
		queryButton.setBackground(new Color(0xA9CAF3)) ;
		resetButton = new JButton("重新查询") ;
		resetButton.addActionListener(this) ;
		resetButton.setBackground(new Color(0xA9CAF3)) ;
		resetButton.setFont(Tookit.getFont1()) ;
		resetButton.setBounds(320, 220, 120, 30) ;
		
		center.add(jl1) ;
		center.add(jtf1) ;
		center.add(jl2) ;
		center.add(jtf2) ;
		center.add(jl3) ;
		center.add(jtf3) ;
		center.add(jl4) ;
		center.add(jcBox) ;
		center.add(queryButton) ;
		center.add(resetButton) ;
		
		jPanel.add(center) ;
		//控制南边
		JPanel south = new JPanel() ;
		south.setPreferredSize(new Dimension(1028,200)) ;
		south.setOpaque(false) ;
		jPanel.add(south,BorderLayout.SOUTH) ;
		
		return jPanel ;
	}
	
	public JPanel twoPanel(){
		JPanel jPanel = new JPanel(new BorderLayout()) ;
		jPanel.setOpaque(false) ;
		JPanel north = new JPanel() ;
		north.setOpaque(false) ;
		//得到所有 TextField值
		//加入到北边面板里
		jl1= new JLabel("出发城市:");
		jl1.setFont(Tookit.getFont1()) ;
		  jtf1_1 = new JTextField(12) ;
	     jl2 = new JLabel("到达城市:");
		jl2.setFont(Tookit.getFont1()) ;
		 jtf2_1 = new JTextField(12) ;
		 jl3 = new JLabel("出发日期:",JLabel.RIGHT);
		jl3.setFont(Tookit.getFont1()) ;
		 jtf3_1 = new JTextField() ;
		 jtf3_1.setPreferredSize(new Dimension(137, 23)) ;
		 jl4 = new JLabel("出发时间:",JLabel.RIGHT);
		jl4.setFont(Tookit.getFont1()) ;
		  jcBox_1 = new JComboBox(new String[]{"全部时间段","00:00-06:00","06:00-12:00","12:00-18:00","18:00-24:00"}) ;
		 jcBox_1.setFont(Tookit.getFont1()) ;

		queryButton = new JButton("开始查询");
		queryButton.addActionListener(this) ;
		queryButton.setFont(Tookit.getFont1()) ;
		queryButton.setBackground(new Color(0xA9CAF3)) ;
		
		order = new JButton("预订");
		order.addActionListener(this) ;
		order.setFont(Tookit.getFont1()) ;
		order.setBounds(180, 220, 120, 30) ;
		order.setBackground(new Color(0xA9CAF3)) ;
		
		north.add(jl1) ;
		north.add(jtf1_1) ;
		north.add(jl2) ;
		north.add(jtf2_1) ;
		north.add(jl3) ;
		north.add(jtf3_1) ;
		north.add(jl4) ;
		north.add(jcBox_1) ;
		north.add(queryButton) ;
		north.add(order) ;
		JPanel bank = new JPanel() ;//空面板
		bank.setOpaque(false) ;
		bank.setPreferredSize(new Dimension(1028,96)) ;
		JPanel top = new JPanel(new GridLayout(2,1)) ;
		top.setOpaque(false) ;
		top.add(bank)  ;
		top.add(north) ;
		jPanel.add(top,BorderLayout.NORTH) ;
	
		jsp = new JScrollPane() ;
		//jScrollPane设置透明
		jsp.setOpaque(false) ;
		jsp.getViewport().setOpaque(false) ;
		jPanel.add(jsp) ;
		return jPanel ;
	}
	
	private void init() {
		try {
			ticketSearchPanel = new ImagePanel(ImageIO.read(new File("image/ticketsearch.jpg")),new Dimension(Tookit.getScreen().width-100,Tookit.getScreen().height-100)) ;
			ticketSearchPanel.setLayout(card);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		ticketSearchPanel.add(this.onePanel(),"one") ;
		ticketSearchPanel.add(this.twoPanel(),"two") ;
		ticketSearchPanel.add(this.threePanel(),"three") ;
		ticketSearchPanel.add(this.fourPanel(),"four") ;
	}
	public JPanel getJPanel() {
		return ticketSearchPanel;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		
		if(e.getActionCommand().equals("开始查询")){
			if(!isGoing){
				jtf3_1.setText(jtf3.getText().trim()) ;
				jtf2_1.setText(jtf2.getText().trim());
				jtf1_1.setText(jtf1.getText().trim()) ;
			}
			this.query() ;
		}
		
		if(e.getActionCommand().equals("重新查询")){
			this.clear() ;
		}
		if(e.getActionCommand().equals("预订")){
			this.order();
		}
		if(e.getActionCommand().equals("重新选择")){
			card.show(ticketSearchPanel, "two") ;
		}
		if(e.getActionCommand().equals("取消订单")){
			card.show(ticketSearchPanel, "two") ;
		}
		if(e.getActionCommand().equals("提交订单")){
			
			//赋值
			jlTop.setText("<html>应付金额:<font color=#FF0000 size=7>"+priceField.getText().trim()+"</font>元</html>") ;
			
			//得到所有 的这个用户的银行信息
			Vector<String> v = dataHandle.queryStringVector("select b_name from bank where b_u_name=? and b_u_card=?", new String[]{user.getU_name(),user.getU_idcard()}) ;
			//判断 有没有该账号
			if(v.size()==0){
				//表示 该用户没有网上银行
				JOptionPane.showMessageDialog(null, "没有网上银行,请注册!") ;
				//跳转
				card.show(ticketSearchPanel, "two") ;
				return ;
			}
			System.out.println(v);
			c.removeAll() ;//清除面板所有组件
			
			for(String bankNames:v){	
				Box box = Box.createVerticalBox() ;
				JLabel jl_bank =  new JLabel(bankNames,JLabel.CENTER);
				jl_bank.setFont(Tookit.getFont3()) ;
				box.add(jl_bank) ;
				jl_bank.addMouseListener(TicketSearchPanel.this) ;
				jl_bank.setEnabled(false) ;
				JLabel jl_picture = new JLabel(new ImageIcon("image/"+bankNames+".jpg")) ;
				box.add(jl_picture) ;
				c.add(box) ;
			}
			//跳到付款页面
			card.show(ticketSearchPanel, "four") ;
		}
		if(e.getActionCommand().equals("网上支付")){
			//判断钱是不是足够的
			String sql = "select b_balance from bank where b_u_name=? and b_u_card=? and b_name=?" ;
			String balanceString = dataHandle.queryOneString(sql, new String[]{user.getU_name(),user.getU_idcard(),bankName}) ;
			sql = "select b_account from bank where b_u_name=? and b_u_card=? and b_name=?" ;
			String account = dataHandle.queryOneString(sql, new String[]{user.getU_name(),user.getU_idcard(),bankName}) ;
			
			System.out.println(balanceString);	
			if(balanceString==null){
					JOptionPane.showMessageDialog(null, "请选择网上银行") ;
					return ;
				}
			double balance = Double.parseDouble(balanceString) ;
			//得到 当前票价
			double currentPrice = Double.parseDouble(priceField.getText().trim());
			if(balance<currentPrice){
				JOptionPane.showMessageDialog(TicketSearchPanel.this, "余额不足,无法支付!") ;
				//跳转
				card.show(ticketSearchPanel, "four") ;
				return ;
			}
			sql = "select t_seatId from tickets where t_date=? and t_f_number =? and t_type=?" ;
			//得到已卖座位号
			System.out.println(jtf3_1.getText().trim()+selectFlightInfo.getF_number()+(String)boxType.getSelectedItem());
			Vector<String> seatIds = dataHandle.queryStringVector(sql, new String[]{jtf3_1.getText().trim(),selectFlightInfo.getF_number(),(String)boxType.getSelectedItem()}) ;
			//分配座位 
			//得到 选择舱位的总数 
			int seatTotalNum = 0 ;
		     for(Seat seat : selectSeat){
		    	 if(seat.getS_type().equals((String)boxType.getSelectedItem())){
		    		 seatTotalNum = Integer.parseInt(seat.getS_number()) ;
		    		 break ;
		    	 }
		     }
		     //卖到 的座位号
		     int sellSeatNum = -1 ;
		     System.out.println("座位总数:"+seatTotalNum+"已卖出:"+seatIds);
		     
		     for (int i = 1; i <=seatTotalNum; i++) {
				
		    	 if(!seatIds.contains(i+"")){
		    		 sellSeatNum = i ;
		    		 break ;
		    	 }
			}	    
		    System.out.println(sellSeatNum);
		    System.out.println(selectFlightInfo.getF_number());
			//插入一个票务表
			sql = "insert into tickets values(?||seq_tickets.nextval,?,?,?,?,?)" ;
			boolean b1 = dataHandle.update(sql, new String[]{"e",selectFlightInfo.getF_number(),user.getU_id(),sellSeatNum+"",(String)boxType.getSelectedItem(),jtf3_1.getText().trim()}) ;
			//插入一个订单表
			sql = "select t_id from tickets where t_date=? and t_seatId=? and t_type=?" ;
		    String sellTicketId = dataHandle.queryOneString(sql, new String[]{jtf3_1.getText().trim(),sellSeatNum+"",(String)boxType.getSelectedItem()}) ;
			System.out.println("卖出的票的id:"+sellTicketId);
		    boolean b2 = dataHandle.update("insert into orders values(?||seq_orders.nextval,?,?,?)", new String[]{"O",user.getU_id(),sellTicketId,currenTime}) ;
			//更新  bank表
			String remainBalance = (balance-currentPrice)+"" ;
			boolean b3 = dataHandle.update("update bank set b_balance=? where b_name=? and b_u_name=? and b_u_card=?", new String[]{remainBalance,bankName,user.getU_name(),user.getU_idcard()}) ;
		    System.out.println(b1+"  "+b2+"  "+b3+" ");
			if(b1 && b2 && b3){
				JOptionPane.showMessageDialog(null, "<html>恭喜"+user.getU_name()+"订票成功"+"<br>票号为:"+sellTicketId+"<br>座位号:"+(String)boxType.getSelectedItem()+"   ZX"+sellSeatNum+"<br>登机时间:"+jtf3_1.getText().trim()+"   "+selectFlightInfo.getF_start_time()+"<br>票价 :"+priceField.getText()+"</html>") ;
				//产生一个票
				FileOperation fileOperation = new FileOperation() ;
				boolean b4 = fileOperation.saveTickets(selectSeat.get(0), user, "   ZX"+sellSeatNum, (String)boxType.getSelectedItem(), jtf3_1.getText().trim(),sellTicketId) ;
				if(b4){
					JOptionPane.showMessageDialog(null, "票已保存在path/"+sellTicketId+"下") ;
				}else {
					JOptionPane.showMessageDialog(null, "票保存失败!!") ;
				}
				//将   这个 票的id 跟  银行卡号加入到一个hashMap里。。方便以后 退票
				Bank bank = dataHandle.queryOneBank("select * from bank where b_u_name=? and b_u_card=? and b_name=?", new String[]{user.getU_name(),user.getU_idcard(),bankName},user) ;
				//加载map信息
				HashMap<String, Bank> map = fileOperation.loadBank() ;
				if(map==null){
					map = new HashMap<String, Bank>() ;//防止 第一次的时候 没有值 
				}
				map.put(sellTicketId, bank) ;//放一个值 
				//保存到文件 里
				fileOperation.saveBank(map) ;
				
			}else{
				JOptionPane.showMessageDialog(null, "订票失败") ;
			}
			card.show(ticketSearchPanel, "two") ;
			this.query() ;
		}
	}
	
	public void clear(){
		this.jtf1.setText("") ;
		this.jtf2.setText("") ;
		this.jtf3.setText("") ;
		this.jcBox.setSelectedIndex(0) ;
	}
	
	public JPanel threePanel(){
		
		JPanel jPanel = new JPanel(new BorderLayout()) ;
		jPanel.setOpaque(false) ;
		//上面是一个空panel
		JPanel blankTop = new JPanel() ;
		blankTop.setOpaque(false) ;
		blankTop.setPreferredSize(new Dimension(Tookit.getScreen().width,103)) ;
		jPanel.add(blankTop,BorderLayout.NORTH) ;
		
		JPanel center = new JPanel(new BorderLayout()) ;
		center.setOpaque(false) ;
		JPanel top = new JPanel(new GridLayout(2, 7, 63, 30)) ;
		top.setOpaque(false) ;
		JLabel id = new JLabel("航班号",JLabel.CENTER) ;
		JLabel type = new JLabel("舱位",JLabel.CENTER) ;
		JLabel price = new JLabel("价格",JLabel.CENTER) ;
		JLabel name = new JLabel("姓名",JLabel.CENTER);
		JLabel cardType = new JLabel("证件类型",JLabel.CENTER) ;
		JLabel cardNum = new JLabel("证件号码") ;
		JLabel telNum = new JLabel("手机号码") ;
		
		idField = new JTextField() ;
		idField.setEditable(false) ;
		boxType = new JComboBox(remainType) ;//录用数据
	    priceField = new JTextField() ;
		priceField.setEditable(false) ;
		JTextField nameField = new JTextField(user.getU_name()) ;
		nameField.setEditable(false) ;
		JComboBox boxCardType = new JComboBox(new String[]{"身份证","学生证","居民证"}) ;
		JTextField cardNumField = new JTextField(user.getU_idcard()) ;
		cardNumField.setEditable(false) ;
		JTextField telNumField = new JTextField(user.getU_telephone()) ;
		telNumField.setEditable(false) ;
		top.add(id) ;
		top.add(type) ;
		top.add(price) ;
		top.add(name) ;
		top.add(cardType) ;
		top.add(cardNum) ;
		top.add(telNum) ;
		
		top.add(idField) ;
		top.add(boxType) ;
		top.add(priceField) ;
		top.add(nameField) ;
		top.add(boxCardType) ;
		top.add(cardNumField) ;
		top.add(telNumField) ;
		//top.setOpaque(false) ;
		center.add(top,BorderLayout.NORTH) ;
		//监听 
		boxType.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				if(remainType.size()!=0){
					//有舱位
					String string = (String)boxType.getSelectedItem() ;
					for(Seat seat :selectSeat){
						if(seat.getS_type().equals(string)){
							priceField.setText(seat.getS_price()+"") ;
							break ;
						}
					}
				}
			}
		}) ;
		
		//中间是一个
		//JPanel c = new JPanel() ;
		String s = "<html>1.一张有效身份证件同一乘车日期同一车次只能购买一张车票。 <br>2.购票时可使用的有效身份证件包括:中华人民共和国居民身份证、港澳居民来往内地通行证、台湾居民来往大陆通行证和按规定可使用的有效护照。<br>3. 购买儿童票时,乘车儿童有有效身份证件的,请填写本人有效身份证件信息。乘车儿童没有有效身份证件的,应使用同行成年人的有效身份证件信息;购票时不受前条限制,<br>4.但购票后、开车前须办理换票手续方可进站乘车。 <br>5.购买学生票时,须在我的常用联系人中登记乘车人的学生详细信息。学生票乘车时间限为每年的暑假6月1日至9月30日、寒假12月1日至3月31日。购票后、开车前,须办理换票手续方可进站乘车。换票时,新生凭录取通知书,毕业生凭学校书面证明,其他凭学生优惠卡。 <br>购买残疾军人(伤残警察)优待票的,须在购票后、开车前办理换票手续方可进站乘车。换票时,不符合规定的减价优待条件,没有有效中华人民共和国残疾军人证或中华<br>人民共和国伤残人民警察证的,不予换票,所购车票按规定办理退票手续。</html>";
		JLabel text = new JLabel(s) ;
		center.add(text) ;
		
		JPanel bottom = new JPanel() ;
		bottom.setOpaque(false) ;
		JButton reSelect = new JButton("重新选择");
		reSelect.addActionListener(this) ;
		reSelect.setFont(Tookit.getFont1()) ;
		reSelect.setBackground(new Color(0xA9CAF3)) ;
		JButton cancelSelect = new JButton("取消订单");
		cancelSelect.addActionListener(this) ;
		cancelSelect.setFont(Tookit.getFont1()) ;
		cancelSelect.setBackground(new Color(0xA9CAF3)) ;
		JButton subSelect = new JButton("提交订单");
		subSelect.addActionListener(this) ;
		subSelect.setFont(Tookit.getFont1()) ;
		subSelect.setBounds(180, 220, 120, 30) ;
		subSelect.setBackground(new Color(0xA9CAF3)) ;
		bottom.add(reSelect) ;
		bottom.add(cancelSelect) ;
		bottom.add(subSelect) ;
		center.add(bottom,BorderLayout.SOUTH) ;
		jPanel.add(center) ;
		//下面是一个空panel
		JPanel blankbottom = new JPanel() ;
		blankbottom.setOpaque(false) ;
		blankbottom.setPreferredSize(new Dimension(Tookit.getScreen().width,103)) ;
		jPanel.add(blankbottom,BorderLayout.SOUTH) ;
		return jPanel ;
	}
	
	public JPanel fourPanel(){
		
		JPanel jPanel = new JPanel(new BorderLayout()) ;
		jPanel.setOpaque(false) ;
		//上面是一个空panel
		JPanel blankTop = new JPanel() ;
		blankTop.setOpaque(false) ;
		blankTop.setPreferredSize(new Dimension(Tookit.getScreen().width,103)) ;
		jPanel.add(blankTop,BorderLayout.NORTH) ;
		
		JPanel center = new JPanel(new BorderLayout()) ;
		center.setOpaque(false) ;
		 jlTop = new JLabel() ;
		jlTop.setOpaque(false) ;
		
		center.add(jlTop,BorderLayout.NORTH) ;//中间北部
		
		//中间是一个janel
		//上面
		 c = new JPanel() ;
		 c.setOpaque(false) ;
		 center.add(c) ;//中间的中间
		 //中间的南部
		 JPanel jPanel3 = new JPanel(new GridLayout(2, 1)) ;
		  jPanel3.setOpaque(false) ;
		  
		 JLabel jlBottom = new JLabel("<html>1.请您选择支付银行。建议使用中国工商银行、中国农业银行、中国银行、招商银行、中国建设银行的银行卡,支付请直接点击相应银行的<br>按钮;如果您使用其他银行的银行卡,请点击“中国银联”按钮。<br>2.您点击支付银行后,将进入银行页面。请遵守相关银行规定进行操作。您在银行页面上进行的任何操作及其产生的任何法律后果,将按照<br>您与银行之间签订的合同处理。本网站不承担任何责任。</html>") ;
		 jPanel3.add(jlBottom) ;
		 
	 	JPanel jPanel2 = new JPanel() ;
	 	jPanel2.setOpaque(false) ;
		JButton reSelect1 = new JButton("重新选择");
		reSelect1.addActionListener(this) ;
		reSelect1.setFont(Tookit.getFont1()) ;
		reSelect1.setBackground(new Color(0xA9CAF3)) ;
		
		JButton onLine = new JButton("网上支付");
		onLine.addActionListener(this) ;
		onLine.setFont(Tookit.getFont1()) ;
		onLine.setBounds(180, 220, 120, 30) ;
		onLine.setBackground(new Color(0xA9CAF3)) ;
		jPanel2.add(reSelect1) ;
		jPanel2.add(onLine) ;
		jPanel3.add(jPanel2) ;
		
		//jPanel3.add(jlBottom) 
		center.add(jPanel3,BorderLayout.SOUTH) ;
		
		jPanel.add(center) ;
		//下面是一个空panel
		JPanel blankbottom = new JPanel() ;
		blankbottom.setOpaque(false) ;
		blankbottom.setPreferredSize(new Dimension(Tookit.getScreen().width,103)) ;
		jPanel.add(blankbottom,BorderLayout.SOUTH) ;
		return jPanel ;
	}
	/**
	 * 开始查询
	 */
	public void query (){
		
		String startCity = null ,endCity = null,startDate = null,startTime ;
		if(!isGoing){
			//表示 是第一个页面进入
			System.out.println("-------");
			startCity = this.jtf1.getText().trim() ;
			 endCity = this.jtf2.getText().trim();
			 startDate = this.jtf3.getText().trim() ;//需要作 判断
			 startTime  = (String)this.jcBox.getSelectedItem() ;
			
		}else {
			startCity = this.jtf1_1.getText().trim() ;
			 endCity = this.jtf2_1.getText().trim();
			 startDate = this.jtf3_1.getText().trim() ;//需要作 判断
			 startTime  = (String)this.jcBox_1.getSelectedItem() ;
		}
		//拆分
		System.out.println(startTime);
		String str[] = startTime.split("-") ;
		//判断 是不是全为空
		if(startCity.equals("") || endCity.equals("") || startDate.equals("")){
			JOptionPane.showMessageDialog(TicketSearchPanel.this, "请输入数据!!") ;
			return ;
		}
		//检查日期是不是有误
		if(!checkInfo.isTrue(startDate)){
			JOptionPane.showMessageDialog(null, "日期不正确,请重新输入!") ;
			return ;
		}
		isGoing = true ;
		card.show(ticketSearchPanel, "two") ;

		//首先根据 出发城市跟到达城市 查出所有 这个路线的航班地点表的Id
	
		String sql = "select * from flight_addr where a_city=?" ;
		String[] paraStartCity = {startCity} ;
		String[] paraEndCity = {endCity};
		//查出所有 出发城市的航班地点Id号
		Vector<FlightAddr> startCityIds = dataHandle.quertyMulInfo(sql, paraStartCity) ;
		//如果为空null,,表示 没有该起点城市 机场。。。。。需要转承、、、、
		//查出所有 到达城市的航班地点Id号
		Vector<FlightAddr> endCityIds = dataHandle.quertyMulInfo(sql, paraEndCity) ;
		
		//查出所有 的  从出发城市到到达城市 航班 飞机信息
		fInfos = dataHandle.queryMulFlightInfo(startCityIds, endCityIds,str) ;
		
		if(fInfos.size()==0){
			//表示没有直达的飞机
			JLabel jLabel = new JLabel("<html>没有直达飞机,是否<font color=#FF0000 size=7>转承</font></html>",JLabel.CENTER) ;
			
			jLabel.setFont(Tookit.getFont2()) ;
			jsp.setViewportView(jLabel) ;
			//预订按钮不可见
			order.setEnabled(false) ;
		}else {
			order.setEnabled(true) ;
			//查出所有 这个航班飞机的座位详细信息
			seats = new Vector<Vector<Seat>>() ;
			for(FlightInfo fInfo:fInfos){
				Vector<Seat> seat = dataHandle.querySeatsInfo("select * from seat where f_number=?", new String[]{fInfo.getF_number()},fInfo) ;
				seats.add(seat) ;
//				System.out.println(fInfo.getF_number()+"   "+fInfo.getF_start().getA_city()+"    "+fInfo.getF_start().getA_air()+"   "+fInfo.getF_end().getA_city()+"   " +fInfo.getF_end().getA_air()+"   "+fInfo.getF_start_time()+"  "+fInfo.getF_end_time());
			}
			//创建一个数据模型
			//放一个jtable 
			jTable = new JTable();
			stmModel = new SearchTableModel(seats,startDate) ;
			this.jTable.setModel(stmModel) ;
			//MyButtonRenderer   buttonRenderer= new MyButtonRenderer(jTable, 12) ;
			
			//jTable.getColumn("购票").setCellRenderer(buttonRenderer) ;//设置 一个button 在Jtable上
			jTable.setRowHeight(60) ;
			jTable.setBackground(new Color(0xA9CAF3)) ;
			jsp.setViewportView(jTable);
		}	
	}
	
	public void order(){
		

		//得到 选中的行
		int selectedRow = jTable.getSelectedRow() ;
		if(selectedRow==-1){
			JOptionPane.showMessageDialog(null, "至少选 中一行进行预订") ;
			return ;
		}
	
		//跳到第三个面板 上
		//得到User信息 
		//得到 Seat信息
		String selectFlightId = (String)stmModel.getValueAt(selectedRow, 0) ;
		//判断这个jtf3_1.getText().trim()日期  是否有航班动态 
		String state =dataHandle.queryOneString("select fs_state from state where fs_date=? and fs_number=?", new String[]{jtf3_1.getText().trim(),selectFlightId}) ;
		System.out.println(state);
		if(state!=null){
			if(state.matches(".*取消.*|.*延迟.*|.*推迟.*")){
				JOptionPane.showMessageDialog(null, "此航班在"+jtf3_1.getText().trim()+"已被取消,请关注航班动态信息") ;
				return ;
			}
		}
		for(FlightInfo fInfo: fInfos){
			if(fInfo.getF_number().equals(selectFlightId)){
				selectFlightInfo = fInfo ;
				break;
			}
		}
		for (Vector<Seat> v : seats) {
			for(Seat seat:v){
				if(seat.getfInfo().equals(selectFlightInfo)){
					selectSeat = v ;
					break ;
				}
			}
		}
		if(selectFlightInfo==null || selectSeat==null){
			JOptionPane.showMessageDialog(null, "数据出错!!") ;
			return ;
		}
		//选择的余数  经济舱  商务舱  头等舱
		String num1 = (String)stmModel.getValueAt(selectedRow, 8) ;
		String num2 = (String)stmModel.getValueAt(selectedRow, 9) ;
		String num3 = (String)stmModel.getValueAt(selectedRow, 10) ;
		//JOptionPane.showMessageDialog(null,jTable.getColumnName(8) ) ;
		//System.out.println(num1+"  "+num2+"  "+num3);
		remainType.removeAllElements() ;//移除所有 的元 素  防止 返回再次点入
		if(num1.matches("[1-9][0-9]*")){
			//表示 经济舱有票
			System.out.println(num1);
			remainType.add(jTable.getColumnName(8)) ;
		}
		if(num2.matches("[1-9][0-9]*")){
			//表示 经济舱有票
			remainType.add(jTable.getColumnName(9)) ;
		}
		if(num3.matches("[1-9][0-9]*")){
			//表示 经济舱有票
			remainType.add(jTable.getColumnName(10)) ;
		}
		System.out.println(remainType.size());
		boxType.setSelectedIndex(0) ;
		idField.setText(selectFlightId)  ;
		
		card.show(ticketSearchPanel, "three") ;
		//得到 
	
	}
	@Override
	public void mouseClicked(MouseEvent e) {
		
		if(e.getSource() instanceof JLabel){
			
			bankName = ((JLabel)e.getSource()).getText().trim() ; 
		}
		
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		
		if(e.getSource() instanceof JLabel){
			JLabel mjlJLabel = ((JLabel)e.getSource()) ;
			mjlJLabel.setEnabled(true) ;
			mjlJLabel.setForeground(Tookit.getColor()) ;
			mjlJLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
		}
		
	}
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource() instanceof JLabel){
			JLabel mjlJLabel = ((JLabel)e.getSource()) ;
			mjlJLabel.setEnabled(false) ;
			mjlJLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)) ;
		}
	}
	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}

航班面板服务类: 

public class BackManagerPanel extends JPanel implements MouseListener,ActionListener{
	
	private JLabel jl1 ,jl2,jl3,jl4;
	private CardLayout card ;
	private ImagePanel ip;
	private JButton jbReset ,jbConfirm ;//createFlight()
	private JCheckBox boxType1,boxType2,boxType3;
	private JComboBox boxStartAir,boxEndAir,boxCompany ;
	private JTextField txtCancelNum ;
	private JButton jbCancel,jbConfirm2;//cancelFlight()
	private JButton jbConfirm3;//modifyFlight()
	private JComboBox boxModiStartAir ,boxModiEndAir, boxModiCompany ;
	private JCheckBox boxModiType1,boxModiType2,boxModiType3;
	private JLabel jlReturn3,jlReturn,jlUpReturn;//modify     createFlight()
	private JButton jbUpCreate ,jbUpDelete;  //updateState()   ,jbUpDelete,jbUpModify
	private JTextField txtModiType,txtModiStartTime,txtModiEndTime,txtModiNum2,txtModiNum1,txtModiPrice1,txtModiPrice2,txtModiNum3, txtModiPrice3;
	private JComboBox cbModiNum;
	private JTable jTable ;
	private JScrollPane jsp ;
	private FlightStateModel fModel;
	private Vector<Vector<String>> states = null ; 
	//数量
	private JTextField txtNum1,txtNum2,txtNum3,txtNum,txtType,txtStartTime,txtEndTime;
	private JTextField txtPrice1,txtPrice2,txtPrice3;
//	private String num1="",num2="",num3="" ;
//	private String price1=null,price2=null,price3=null ;
	String num1,num2,num3,price1,price2,price3 ;
	Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
	DataHandle dataHandle = null ;
	FlightInfo flightInfo= null;
	public BackManagerPanel(){
		UIManager.put("Label.font", Tookit.getFont1()) ;
		UIManager.put("Button.font", Tookit.getFont1()) ;
		UIManager.put("ComboBox.font", Tookit.getFont1()) ;
		UIManager.put("CheckBox.font", Tookit.getFont1()) ;
		dataHandle = new DataHandle() ;
		card = new CardLayout() ;
		this.init();
	}
	/**
	 * 第一个主面板
	 * @return
	 */
	public JPanel onePanel(){
		JPanel jPanel = new JPanel(new BorderLayout()) ;
		//jPanel.setBackground(Color.red);
		jPanel.setPreferredSize(new Dimension(355, 255)) ;
		JLabel jLabel = new JLabel("飞机订票系统后台管理");
		jLabel.setForeground(Color.yellow) ;
		jLabel.setFont(new Font("微软雅黑", Font.BOLD, 32)) ;
		jPanel.add(jLabel,BorderLayout.NORTH) ;
		
		JPanel center = new JPanel(new GridLayout(4,1,20,60)) ;
		center.setOpaque(false) ;
		//center.setBackground(Color.red) ;
		center.setPreferredSize(new Dimension(315,155)) ;
		jl1= new JLabel("创建航班") ;
		jl1.setFont(Tookit.getFont6()) ;
		jl1.setEnabled(false) ;
		jl1.addMouseListener(this) ;
		center.add(Box.createRigidArea(new Dimension(120, 200))) ;
		center.add(jl1) ;
		jl2 = new JLabel("取消航班") ;
		jl2.setFont(Tookit.getFont6()) ;
		jl2.addMouseListener(this);
		jl2.setEnabled(false);
		center.add(Box.createRigidArea(new Dimension(120, 200))) ;
		center.add(jl2) ;
		jl3 = new JLabel("航班修改") ;
		jl3.setFont(Tookit.getFont6()) ;
		jl3.addMouseListener(this);
		jl3.setEnabled(false) ;
		center.add(Box.createRigidArea(new Dimension(120, 200))) ;
		center.add(jl3) ;
		jl4 = new JLabel("航班动态管理") ;
		jl4.setFont(Tookit.getFont6()) ;
		jl4.addMouseListener(this);
		jl4.setEnabled(false);
		center.add(Box.createRigidArea(new Dimension(120, 200))) ;
		center.add(jl4) ;
		
		center.setOpaque(false) ;
		jPanel.add(center) ;
		jPanel.setOpaque(false) ;
		//创建 一个空面板
		JPanel blank = new JPanel() ;
		blank.setOpaque(false) ;
		blank.setPreferredSize(new Dimension(1000, 254)) ;
		jPanel.add(blank,BorderLayout.SOUTH) ;
		return jPanel ;
	}
	/**
	 * 创建 航班面板 
	 * @return
	 */
	public JPanel createFlight(){
		JPanel totalPanel = new JPanel() ;
		totalPanel.setOpaque(false) ;//设置透明
		
		JPanel jpAll=new JPanel();
		jpAll.setOpaque(false);//设置透明
		jpAll.setLayout(new BorderLayout());
		
		JPanel head=new JPanel();
		JLabel jlHead=new JLabel("创建航班");
		jlHead.setForeground(Color.yellow);
		jlHead.setFont(Tookit.getFont5());
		head.add(jlHead);
		head.setOpaque(false) ;//设置透明
		jpAll.add(head,BorderLayout.NORTH);
		
		JPanel jp = new JPanel(new GridLayout(14, 2, 7, 7)) ;
		jp.setOpaque(false) ;//设置透明
		JLabel jl1 = new JLabel("航班号:") ;
		jl1.setForeground(Color.yellow);
		jl1.setFont(Tookit.getFont4());
		jp.add(jl1) ;
		txtNum = new JTextField() ;
		jp.add(txtNum);
		JLabel jl2 = new JLabel("机型:") ;
		jl2.setForeground(Color.yellow);
		jl2.setFont(Tookit.getFont4());
		jp.add(jl2);
		txtType = new JTextField() ;
		jp.add(txtType);
		JLabel jl3 = new JLabel("出发时间:") ;
		jl3.setForeground(Color.yellow);
		jl3.setFont(Tookit.getFont4());
		jp.add(jl3);
		txtStartTime = new JTextField() ;
		jp.add(txtStartTime);
		JLabel jl4 = new JLabel("到达时间:") ;
		jl4.setForeground(Color.yellow);
		jl4.setFont(Tookit.getFont4());
		jp.add(jl4);
		txtEndTime = new JTextField() ;
		jp.add(txtEndTime);
		Vector<String> allAir = dataHandle.queryAllInfo("select a_air from flight_addr where 1 =?",new String[]{"1"}) ;
		JLabel jl5 = new JLabel("出发机场:") ;
		jl5.setForeground(Color.yellow);
		jl5.setFont(Tookit.getFont4());
		jp.add(jl5);
		boxStartAir = new JComboBox(allAir) ;//数据从数据库得到
		jp.add(boxStartAir);
		JLabel jl6 = new JLabel("到达机场:") ;
		jl6.setForeground(Color.yellow);
		jl6.setFont(Tookit.getFont4());
		jp.add(jl6);
		boxEndAir = new JComboBox(allAir) ;//数据从数据库得到
		jp.add(boxEndAir);
		JLabel jl7 = new JLabel("航空公司:") ;
		jl7.setForeground(Color.yellow);
		jl7.setFont(Tookit.getFont4());
		jp.add(jl7);
		//得到 所有 航空公司 从数据库中
		Vector<String> allCompany = dataHandle.queryAllInfo("select f_company from flight_info where 1=?",new String[]{"1"}) ;
		
		boxCompany = new JComboBox(allCompany) ;
		jp.add(boxCompany);
		JLabel jl8= new JLabel("舱位类型:") ;
		jl8.setForeground(Color.yellow);
		jl8.setFont(Tookit.getFont4());
		jp.add(jl8);
		JPanel jpType = new JPanel() ;
		jpType.setOpaque(false) ;
		jp.add(jpType);
		boxType1= new JCheckBox("头等舱") ;
		boxType1.setForeground(Color.yellow);
		boxType1.setOpaque(false);
		boxType1.setSelected(true) ;
		
		boxType2 = new JCheckBox("商务舱") ;
		boxType2.setForeground(Color.yellow);
	//	boxType2.addItemListener(this) ;
		boxType2.setOpaque(false);
		boxType2.setSelected(true) ;
		
		boxType3 = new JCheckBox("经济舱") ;
		boxType3.setForeground(Color.yellow);
		//boxType3.addItemListener(this) ;
		boxType3.setOpaque(false);
		boxType3.setSelected(true) ;
		
		jpType.add(boxType1) ;
		jpType.add(boxType2) ;
		jpType.add(boxType3) ;
		JLabel jl9 = new JLabel("头等舱数量:") ;
		jl9.setForeground(Color.yellow);
		jl9.setFont(Tookit.getFont4());
		jp.add(jl9);
		 txtNum1= new JTextField() ;
		jp.add(txtNum1);
		JLabel jl10 = new JLabel("头等舱价格:") ;
		jl10.setForeground(Color.yellow);
		jl10.setFont(Tookit.getFont4());
		jp.add(jl10);
		txtPrice1= new JTextField() ;
		jp.add(txtPrice1);
		JLabel jl11 = new JLabel("商务舱数量:") ;
		jl11.setForeground(Color.yellow);
		jl11.setFont(Tookit.getFont4());
		jp.add(jl11);
		 txtNum2 = new JTextField() ;
		jp.add(txtNum2);
		JLabel jl12 = new JLabel("商务舱价格:") ;
		jl12.setForeground(Color.yellow);
		jl12.setFont(Tookit.getFont4());
		jp.add(jl12);
		 txtPrice2 = new JTextField() ;
		jp.add(txtPrice2);
		JLabel jl13 = new JLabel("经济舱数量:") ;
		jl13.setForeground(Color.yellow);
		jl13.setFont(Tookit.getFont4());
		jp.add(jl13);
		 txtNum3 = new JTextField() ;
		jp.add(txtNum3);
		JLabel jl14 = new JLabel("经济舱价格:") ;
		jl14.setForeground(Color.yellow);
		jl14.setFont(Tookit.getFont4());
		jp.add(jl14);
		 txtPrice3 = new JTextField() ;
		jp.add(txtPrice3);
		boxType1.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				// TODO Auto-generated method stub
				BackManagerPanel.this.jCheckBoxOpera(boxType1, txtNum1, txtPrice1) ;

			}
		});
		boxType2.addItemListener(new ItemListener() {
					
					@Override
					public void itemStateChanged(ItemEvent e) {
						// TODO Auto-generated method stub
						BackManagerPanel.this.jCheckBoxOpera(boxType2, txtNum2, txtPrice2) ;
//						}
					}
				});
		boxType3.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				// TODO Auto-generated method stub
				BackManagerPanel.this.jCheckBoxOpera(boxType3, txtNum3, txtPrice3) ;

			}
		});
		jp.setPreferredSize(new Dimension(450, 555)) ;
		jl1.setHorizontalAlignment(JLabel.CENTER);
		jl2.setHorizontalAlignment(JLabel.CENTER);
		jl3.setHorizontalAlignment(JLabel.CENTER);
		jl3.setHorizontalAlignment(JLabel.CENTER);
		jl4.setHorizontalAlignment(JLabel.CENTER);
		jl5.setHorizontalAlignment(JLabel.CENTER);
		jl6.setHorizontalAlignment(JLabel.CENTER);
		jl7.setHorizontalAlignment(JLabel.CENTER);
		jl8.setHorizontalAlignment(JLabel.CENTER);
		jl9.setHorizontalAlignment(JLabel.CENTER);
		jl10.setHorizontalAlignment(JLabel.CENTER);
		jl11.setHorizontalAlignment(JLabel.CENTER);
		jl12.setHorizontalAlignment(JLabel.CENTER);
		jl13.setHorizontalAlignment(JLabel.CENTER);
		jl14.setHorizontalAlignment(JLabel.CENTER);
		
		 jbConfirm= new JButton("确    定");
		 jbConfirm.addActionListener(this);
		 jbReset = new JButton("重    置");
		 jbReset.addActionListener(this);
		 jlReturn = new JLabel("返回上级菜单");
		 jlReturn.setFont(Tookit.getFont4());
		 jlReturn.addMouseListener(this);
		
		JPanel jpButtom=new JPanel();
		jpButtom.setOpaque(false) ;
		jpButtom.add(jbConfirm);
		jpButtom.add(jbReset);
		jpButtom.add(jlReturn);
		jpAll.add(jpButtom,BorderLayout.SOUTH);
		
		jpAll.add(jp,BorderLayout.CENTER);
		//jpAll.setOpaque(false) ;
		totalPanel.add(jpAll) ;
		//实现上一级菜单的返回
		jlReturn.addMouseListener(this);
		return totalPanel ;
	}
	
	/**
	 * 取消航班
	 * @return
	 */
	public JPanel cancelFlight(){
		JPanel jpAll2=new JPanel();
		jpAll2.setLayout(null);
		jpAll2.setOpaque(false);
		//jpAll.setBackground(Color.yellow);
		
		//JPanel jpHead=new JPanel();
		JLabel jlHead2=new JLabel("取消航班");
		jlHead2.setBounds(400, 100, 150, 40);
		jlHead2.setForeground(Tookit.getColor());
		jlHead2.setFont(Tookit.getFont5());
		
		jbCancel=new JButton("取    消");
		jbConfirm2=new JButton("确    定");
		
		JLabel lbNum=new JLabel("航班号:");
		lbNum.setForeground(Color.yellow);
		lbNum.setFont(Tookit.getFont4());
		lbNum.setBounds(340, 250, 100, 30);
		txtCancelNum=new JTextField();//cancelFlight()
		txtCancelNum.setBounds(450, 250, 150, 30);
		
		jbConfirm2.setBounds(350, 400, 100, 30);
		jbCancel.setBounds(500, 400, 100,30);
		//jlReturn2.setBounds(600, 400, 100, 30);
		
		//jlReturn2.addMouseListener(this);
		
		jpAll2.add(jlHead2);
		jpAll2.add(lbNum);
		jpAll2.add(txtCancelNum);
		jpAll2.add(jbConfirm2);
		jpAll2.add(jbCancel);
		
		jbConfirm2.addActionListener(this);
		jbCancel.addActionListener(this);
		
		//jpAll2.add(jlReturn2);	
		return jpAll2; 
	}
	
	/**
	 *修改航班
	 */
	public JPanel modifyFlight(){
		JPanel modifyPanel = new JPanel() ;
		modifyPanel.setOpaque(false) ;//设置透明
		JPanel jpAll3=new JPanel();
		jpAll3.setOpaque(false);//设置透明
		jpAll3.setLayout(new BorderLayout());
		
		JPanel headPane=new JPanel();
		JLabel jlHead=new JLabel("修改航班");
		jlHead.setForeground(Color.yellow);
		jlHead.setFont(Tookit.getFont5());
		headPane.add(jlHead);
		//head.setPreferredSize(new Dimension(1000,200));
		headPane.setOpaque(false) ;//设置透明
		jpAll3.add(headPane,BorderLayout.NORTH);
		
		JPanel jPane = new JPanel(new GridLayout(14, 2, 7, 3)) ;
		jPane.setOpaque(false) ;//设置透明
		JLabel lbNum = new JLabel("航班号:") ;
		lbNum.setForeground(Color.yellow);
		lbNum.setFont(Tookit.getFont4());
		jPane.add(lbNum) ;
		Vector<String> allFlightNum=dataHandle.queryStringVector("select f_number from flight_info where 1=?", new String[]{"1"});
		cbModiNum = new JComboBox(allFlightNum);
		cbModiNum.addActionListener(this) ;
		cbModiNum.setActionCommand("fid") ;
		jPane.add(cbModiNum);
		JLabel lbType = new JLabel("机型:") ;
		lbType.setForeground(Color.yellow);
		lbType.setFont(Tookit.getFont4());
		jPane.add(lbType);
		txtModiType = new JTextField() ;
		jPane.add(txtModiType);
		JLabel lbStartTime = new JLabel("出发时间:") ;
		lbStartTime.setForeground(Color.yellow);
		lbStartTime.setFont(Tookit.getFont4());
		jPane.add(lbStartTime);
		txtModiStartTime = new JTextField() ;
		jPane.add(txtModiStartTime);
		JLabel lbEndTime = new JLabel("到达时间:") ;
		lbEndTime.setForeground(Color.yellow);
		lbEndTime.setFont(Tookit.getFont4());
		jPane.add(lbEndTime);
		txtModiEndTime = new JTextField() ;
		jPane.add(txtModiEndTime);
		Vector<String> allAir = dataHandle.queryAllInfo("select a_air from flight_addr where 1=?",new String[]{"1"}) ;
		JLabel lbStartAir = new JLabel("出发机场:") ;
		lbStartAir.setForeground(Color.yellow);
		lbStartAir.setFont(Tookit.getFont4());
		jPane.add(lbStartAir);
		boxModiStartAir= new JComboBox(allAir) ;//数据从数据库得到
		jPane.add(boxModiStartAir);
		JLabel lbEndAir = new JLabel("到达机场:") ;
		lbEndAir.setForeground(Color.yellow);
		lbEndAir.setFont(Tookit.getFont4());
		jPane.add(lbEndAir);
		boxModiEndAir= new JComboBox(allAir) ;//数据从数据库得到
		jPane.add(boxModiEndAir);
		JLabel lbCompany = new JLabel("航空公司:") ;
		lbCompany.setForeground(Color.yellow);
		lbCompany.setFont(Tookit.getFont4());
		jPane.add(lbCompany);
		//得到 所有 航空公司 从数据库中
		Vector<String> allCompany = dataHandle.queryAllInfo("select f_company from flight_info where 1=?",new String[]{"1"}) ;
		boxModiCompany = new JComboBox(allCompany) ;
		jPane.add(boxModiCompany);
		JLabel lbSeatType= new JLabel("舱位类型:") ;
		lbSeatType.setForeground(Color.yellow);
		lbSeatType.setFont(Tookit.getFont4());
		jPane.add(lbSeatType);
		JPanel jpType1 = new JPanel() ;
		jpType1.setOpaque(false) ;
		jPane.add(jpType1);
		boxModiType1= new JCheckBox("头等舱") ;
		boxModiType1.setForeground(Color.yellow);
		boxModiType1.setOpaque(false);
		boxModiType2 = new JCheckBox("商务舱") ;
		boxModiType2.setForeground(Color.yellow);
		boxModiType2.setOpaque(false);
		boxModiType3 = new JCheckBox("经济舱") ;
		boxModiType3.setForeground(Color.yellow);
		boxModiType3.setOpaque(false);
		jpType1.add(boxModiType1) ;
		jpType1.add(boxModiType2) ;
		jpType1.add(boxModiType3) ;
		JLabel lbModiNum1 = new JLabel("头等舱数量:") ;
		lbModiNum1.setForeground(Color.yellow);
		lbModiNum1.setFont(Tookit.getFont4());
		jPane.add(lbModiNum1);
		txtModiNum1 = new JTextField() ;
		jPane.add(txtModiNum1);
		JLabel lbModiPrice1 = new JLabel("头等舱价格:") ;
		lbModiPrice1.setForeground(Color.yellow);
		lbModiPrice1.setFont(Tookit.getFont4());
		jPane.add(lbModiPrice1);
		txtModiPrice1 = new JTextField() ;
		jPane.add(txtModiPrice1);
		JLabel lbModiNum2 = new JLabel("商务舱数量:") ;
		lbModiNum2.setForeground(Color.yellow);
		lbModiNum2.setFont(Tookit.getFont4());
		jPane.add(lbModiNum2);
		txtModiNum2 = new JTextField() ;
		jPane.add(txtModiNum2);
		JLabel lbModiPrice2 = new JLabel("商务舱价格:") ;
		lbModiPrice2.setForeground(Color.yellow);
		lbModiPrice2.setFont(Tookit.getFont4());
		jPane.add(lbModiPrice2);
		txtModiPrice2 = new JTextField() ;
		jPane.add(txtModiPrice2);
		JLabel lbModiNum3 = new JLabel("经济舱数量:") ;
		lbModiNum3.setForeground(Color.yellow);
		lbModiNum3.setFont(Tookit.getFont4());
		jPane.add(lbModiNum3);
		txtModiNum3 = new JTextField() ;
		jPane.add(txtModiNum3);
		JLabel lbModiPrice3 = new JLabel("经济舱价格:") ;
		lbModiPrice3.setForeground(Color.yellow);
		lbModiPrice3.setFont(Tookit.getFont4());
		jPane.add(lbModiPrice3);
		txtModiPrice3 = new JTextField() ;
		jPane.add(txtModiPrice3);
		jPane.setPreferredSize(new Dimension(450, 555)) ;
		
		boxModiType1.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				if(!boxModiType1.isSelected()){
					txtModiNum1.setText("--") ;
					txtModiNum1.setEditable(false) ;
					txtModiPrice1.setText(0+"") ;
					txtModiPrice1.setEditable(false) ;
				}else{
					txtModiNum1.setEditable(true) ;
					txtModiPrice1.setEditable(true) ;
				}
			}
		}) ;

		boxModiType2.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				if(!boxModiType2.isSelected()){
					txtModiNum2.setText("--");
					txtModiNum2.setEditable(false);
					txtModiPrice2.setText(0+"");
					txtModiPrice2.setEditable(false);
				}else{
					txtModiNum2.setEditable(true);
					txtModiPrice2.setEditable(true);
				}
			}
		}) ;

		boxModiType3.addItemListener(new ItemListener() {
			
			@Override
			public void itemStateChanged(ItemEvent e) {
				if(!boxModiType3.isSelected()){
					txtModiNum3.setText("--");
					txtModiNum3.setEditable(false);
					txtModiPrice3.setText(0+"");
					txtModiPrice3.setEditable(false);
				}else{
					txtModiNum3.setEditable(true);
					txtModiPrice3.setEditable(true);
				}
			}
		}) ;
		
		lbNum.setHorizontalAlignment(JLabel.CENTER);
		lbType.setHorizontalAlignment(JLabel.CENTER);
		lbStartTime.setHorizontalAlignment(JLabel.CENTER);
		lbEndTime.setHorizontalAlignment(JLabel.CENTER);
		lbStartAir.setHorizontalAlignment(JLabel.CENTER);
		lbEndAir.setHorizontalAlignment(JLabel.CENTER);
		lbCompany.setHorizontalAlignment(JLabel.CENTER);
		lbSeatType.setHorizontalAlignment(JLabel.CENTER);
		lbModiNum1.setHorizontalAlignment(JLabel.CENTER);
		lbModiPrice1.setHorizontalAlignment(JLabel.CENTER);
		lbModiNum2.setHorizontalAlignment(JLabel.CENTER);
		lbModiPrice2.setHorizontalAlignment(JLabel.CENTER);
		lbModiNum3.setHorizontalAlignment(JLabel.CENTER);
		lbModiPrice3.setHorizontalAlignment(JLabel.CENTER);
		
		cbModiNum.addMouseListener(this);
		jlReturn3=new JLabel("返回上级菜单");
		jlReturn3.setFont(Tookit.getFont4());
		jbConfirm3=new JButton("确定修改");
		jbConfirm3.addActionListener(this);
		
		JPanel jpButtom1=new JPanel();
		jpButtom1.setOpaque(false) ;
		jpButtom1.add(jbConfirm3);
//		jpButtom1.add(jbReset3);
		jpButtom1.add(jlReturn3);
		jpAll3.add(jpButtom1,BorderLayout.SOUTH);
		
		jpAll3.add(jPane,BorderLayout.CENTER);
		//jpAll.setOpaque(false) ;
		modifyPanel.add(jpAll3) ;
		//实现上一级菜单的返回
		jlReturn3.addMouseListener(this);
		return modifyPanel ;
	}
	/**
	 * 修改航班动态
	 * @return
	 */
	public JPanel updateState(){
		
		JPanel jp = new JPanel(new BorderLayout());
		jp.setOpaque(false) ;
		//北边
		JPanel north = new JPanel() ;
		north.setOpaque(false) ;
		north.setPreferredSize(new Dimension(Tookit.getScreen().width,94)) ;
		jp.add(north,BorderLayout.NORTH) ;
		
		//中间
		JPanel center = new JPanel(new BorderLayout());
		center.setOpaque(false) ;
		JLabel jlName = new JLabel("航班动态管理",JLabel.CENTER);
		jlName.setFont(Tookit.getFont5()) ;
		jlName.setForeground(Color.YELLOW) ;
		center.add(jlName,BorderLayout.NORTH) ;
		jsp = new JScrollPane() ;
		
		
		StringBuffer sb=new StringBuffer();
		sb.append("select fi.F_number, fa.a_city,fa1.a_city,s.fs_date,s.fs_state ");
		sb.append("from  flight_info fi,flight_addr  fa, flight_addr  fa1,state s ");
		sb.append("where s.fs_number=fi.f_number  and  fa.a_id= fi.f_start and fa1.a_id=fi.f_end and 1=?");
		final String sql = sb.toString() ;
		new Thread(){
			
			public void run() {
				
				while(true){
					
					states = new DbHandle().getState(sql,new String[]{"1"}) ;
					fModel = new FlightStateModel(states) ;
//					for(Vector<String> v: states){
//						System.out.println(v);
//					}
					jTable = new JTable() ;
					jTable.setModel(fModel) ;//......
					jTable.setRowHeight(60) ;
					jTable.setBackground(new Color(0xA9CAF3)) ;
					//怎样拿到数据放到表格中
					jsp.setViewportView(jTable) ;
					//重绘
//					jsp.validate() ;
//					jsp.repaint() ;
					try {
						Thread.sleep(2000) ;
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					//移除组件
				}
			};
		}.start() ;
		
		//jScrollPane设置透明
		jsp.setOpaque(false) ;
		jsp.getViewport().setOpaque(false) ;
		center.add(jsp) ;
		jp.add(center,BorderLayout.CENTER) ;
		
		//
		JPanel jpBottom = new JPanel() ;
		jpBottom.setOpaque(false) ;
		jbUpCreate= new JButton("创建航班动态");
		jbUpCreate.addActionListener(this) ;
		jbUpCreate.setFont(Tookit.getFont1()) ;
		jbUpCreate.setBackground(new Color(0xA9CAF3)) ;
		jbUpDelete = new JButton("删除航班动态") ;
		jbUpDelete.addActionListener(this) ;
		jbUpDelete.setBackground(new Color(0xA9CAF3)) ;
		jbUpDelete.setFont(Tookit.getFont1()) ;
//		jbUpModify=new JButton("修改动态");
//		jbUpModify.addActionListener(this);
//		jbUpModify.setFont(Tookit.getFont1());
//		jbUpModify.setBackground(new Color(0xA9CAF3));
		jlUpReturn=new JLabel("返回上级菜单");
		jlUpReturn.setFont(Tookit.getFont4());
		jlUpReturn.addMouseListener(this);
		jpBottom.add(jbUpCreate) ;
		jpBottom.add(jbUpDelete) ;
//		jpBottom.add(jbUpModify) ;
		jpBottom.add(jlUpReturn);
		jp.add(jpBottom,BorderLayout.SOUTH) ;
		
		return jp ;
	
		}

	private void init() {
		
		try {
			ip = new ImagePanel(ImageIO.read(new File("image/171go.jpg")), dimension) ;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		ip.setLayout(card) ;
		ip.add(this.onePanel(),"one") ;
		//创建一个创建航班面板。加入到ip里
		ip.add(this.createFlight(),"create") ;
		//创建一个取消航班面板。。。。。。
		ip.add(this.cancelFlight(),"cancel");
		//创建一个修改航班面板
		ip.add(this.modifyFlight(),"modify");
		//创建一个修改航班动态面板
		ip.add(this.updateState(),"update") ;
		
		ip.setSize(1008,680) ;
		ip.setBackground(new Color(0x498DF8)) ;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		if(e.getSource() instanceof JLabel){
			//鼠标点击
			if(((JLabel)e.getSource())==jl1){
				//创建航班
				card.show(ip, "create") ;
			}
			if((JLabel)e.getSource()==jl2){
				card.show(ip, "cancel");
			}
			if((JLabel)e.getSource()==jl3){
				card.show(ip, "modify");
			}
			if((JLabel)e.getSource()==jl4){
				card.show(ip, "update");
			}
			//createFlight()
			if((JLabel)e.getSource()==jlReturn){
				card.show(ip, "one");
			}
			//modifyFlight()
			if((JLabel)e.getSource()==jlReturn3){
				card.show(ip, "one");
			}
			if((JLabel)e.getSource()==jlUpReturn){
				card.show(ip, "one");
			}
		}
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// 鼠标进入
		if(e.getSource() instanceof JLabel){
			if(((JLabel)e.getSource())==jl1){
				jl1.setForeground(Tookit.getColor()) ;
				jl1.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jl1.setEnabled(true);
			}
			if(((JLabel)e.getSource())==jl2){
				jl2.setForeground(Tookit.getColor()) ;
				jl2.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jl2.setEnabled(true);
			}
			if(((JLabel)e.getSource())==jl3){
				jl3.setForeground(Tookit.getColor()) ;
				jl3.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jl3.setEnabled(true);
			}
			if(((JLabel)e.getSource())==jl4){
				jl4.setForeground(Tookit.getColor()) ;
				jl4.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jl4.setEnabled(true);
			}
			//createFlight()里的返回上一级菜单的   标签
			if(((JLabel)e.getSource())==jlReturn){
				jlReturn.setForeground(Tookit.getColor()) ;
				jlReturn.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jlReturn.setEnabled(true);
			}
			//modifyFlight()里的返回上一级菜单的   标签
			if(((JLabel)e.getSource())==jlReturn3){
				jlReturn3.setForeground(Tookit.getColor()) ;
				jlReturn3.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jlReturn3.setEnabled(true);
			}
			//updateState()里的返回上一级菜单的   标签
			if(((JLabel)e.getSource())==jlUpReturn){
				jlUpReturn.setForeground(Tookit.getColor()) ;
				jlUpReturn.setCursor(new Cursor(Cursor.HAND_CURSOR)) ;
				jlUpReturn.setEnabled(true);
			}
		}
	}

	@Override
	public void mouseExited(MouseEvent e) {
		
		if(e.getSource() instanceof JLabel){
			if(((JLabel)e.getSource())==jl1){
				jl1.setEnabled(false);
			}
			if(((JLabel)e.getSource())==jl2){
				jl2.setEnabled(false);
			}
			if(((JLabel)e.getSource())==jl3){
				jl3.setEnabled(false);
			}
			if(((JLabel)e.getSource())==jl4){
				jl4.setEnabled(false);
			}
			//createFlight()里的'返回上一级'菜单的标签
			if(((JLabel)e.getSource())==jlReturn){
				jlReturn.setEnabled(false);
			}
			//modifyFlight()里的'返回上一级'菜单的标签
			if(((JLabel)e.getSource())==jlReturn3){
				jlReturn3.setEnabled(false);
			}
			//updateState()里的'返回上一级'菜单的标签
			if(((JLabel)e.getSource())==jlUpReturn){
				jlUpReturn.setEnabled(false);
			}
		}
		
		// 修改航班:输入航班号时触发事件
//		if(e.getSource() instanceof JTextField){
//			String fNumber=txtModiNum.getText().trim();
//			String fType=null;
//			String fStartTime=null;
//			String fEndTime=null;
//			FlightAddr fStart=null;
//			FlightAddr fEnd=null;
//			String fCompany=null;
//			//flightInfo=new FlightInfo();
//			//获得航班号
//			StringBuffer sql=new StringBuffer();
//			sql.append("select ");
//			sql.append("* ");
//			sql.append("from flight_info ");
//			sql.append("where f_number=?");
//			FlightInfo flightInfo=new FlightInfo(String fNumber, String fType, String fStartTime,
//					String fEndTime, FlightAddr fStart, FlightAddr fEnd, String fCompany);
//            flightInfo=dataHandle.queryFlightInfo(sql.toString(), new String[]{"sFlightNum"});
//            txtModiNum.setEditable(false);
//            System.out.println("the info is:"+flightInfo);//null
//            txtModiType.setText(flightInfor.get(1));
//			txtModiStartTime.setText(flightInfor.get(2));
//			txtModiEndTime.setText(flightInfor.get(3));
//            for(String s:flightInfor){
//            	System.out.println(s);
//            }
//			
//		}
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	public ImagePanel getIp() {
		return ip;
	}
	/**
	 * JCheckBox的操作
	 * @param jCheckBox
	 * @param txtNum
	 * @param txtPrice
	 */
	public void jCheckBoxOpera(JCheckBox jCheckBox,JTextField txtNum ,JTextField txtPrice){
		if(!jCheckBox.isSelected()){
			//头等舱数量 
			txtNum.setEditable(false) ;
			txtPrice.setEditable(false) ;
		}
		if(jCheckBox.isSelected()){
			//头等舱数量 
			txtNum.setEditable(true) ;
			txtPrice.setEditable(true) ;
		}
	}
	public boolean checkSeatInfo(String num,String price){
		
		if(num.matches("\\d+") && price.matches("\\d+|(\\d+\\.\\d\\d)")){
			return true;
		}
		return false ;
	}
	
	public void clear(){
		txtNum.setText("") ;
		txtType.setText("") ;
		txtStartTime.setText("") ;
		txtEndTime.setText("") ;
		boxStartAir.setSelectedIndex(0) ;
		boxEndAir.setSelectedIndex(0) ;
		boxCompany.setSelectedIndex(0) ;
		boxType1.setSelected(true) ;
		boxType2.setSelected(true) ;
		boxType3.setSelected(true) ;
		txtNum1.setText("");
		txtNum2.setText("");
		txtNum3.setText("");
		txtPrice1.setText("") ;
		txtPrice2.setText("") ;
		txtPrice3.setText("") ;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		//createFlight()里的确定创建按钮
		if(e.getSource() == jbConfirm){
			
			//出发机场
			String flightNum = txtNum.getText().trim() ;
			String flightType = txtType.getText().trim() ;
			String startTime = txtStartTime.getText().trim() ;
			String endTime = txtEndTime.getText().trim() ;
			
			int startIndex = boxStartAir.getSelectedIndex() ;
			int endIndex = boxEndAir.getSelectedIndex() ;
			String startAir = (String)boxStartAir.getSelectedItem() ;
			String endAir = (String)boxEndAir.getSelectedItem() ;
			String company = (String)boxCompany.getSelectedItem() ;
			//首先检测 数据 格式 是否正确 
			if(flightNum.equals("")||flightType.equals("")||startTime.equals("")||endTime.equals("")||startIndex==0||endIndex==0){
				JOptionPane.showMessageDialog(null, "数据不能为空") ;
				return ;
			}
			//00:00 01  02 .....09
			//10  11.....19
			//20  24
			if(!startTime.matches("([0-1][0-9]|[2][0-4]):[0-5][0-9]")){
				JOptionPane.showMessageDialog(null, "出发时间格式不对") ;
				txtStartTime.setText("") ;
				return ;
			}
			if(!endTime.matches("([0-1][0-9]|[2][0-4]):[0-5][0-9]")){
				JOptionPane.showMessageDialog(null, "到达时间格式不对") ;
				txtEndTime.setText("") ;
				return ;
			}
			//时间输入是不是正确   可以不做 这个判断
//			if(startTime.compareTo(endTime)>=0){
//				JOptionPane.showMessageDialog(null, "出发时间跟到达时间不合理!") ;
//				txtEndTime.setText("") ;
//				txtStartTime.setText("") ;
//				return ;
//			}
			if(startAir.equals(endAir)){
				JOptionPane.showMessageDialog(null, "出发机场不能和到达相同!!") ;
				return ;
			}
			
			//对头等舱处理
			if(boxType1.isSelected()){
				num1 = txtNum1.getText().trim() ;//得到头等舱数量 
				price1 = txtPrice1.getText().trim() ;//得到 头等舱的价格
				//判断格式
				boolean b = BackManagerPanel.this.checkSeatInfo(num1, price1) ;
				if(b==false){
					JOptionPane.showMessageDialog(null, "头等舱数量或价格格式有误") ;
					txtNum1.setText("") ;
					txtPrice1.setText("") ;
					return ;
				}
			}else{
				num1 = "--" ;//没有数量 
				price1 = "0" ;//价钱 为0
				
			}
			//商务等舱处理
			if(boxType2.isSelected()){
				 num2 = txtNum2.getText().trim() ;//得到头等舱数量 
				 price2 = txtPrice2.getText().trim() ;//得到 头等舱的价格
				//判断格式
					boolean b = BackManagerPanel.this.checkSeatInfo(num2, price2) ;
					if(b==false){
						JOptionPane.showMessageDialog(null, "商务舱数量或价格格式有误") ;
						txtNum2.setText("") ;
						txtPrice2.setText("") ;
						return ;
					}
			}else {
				num2 = "--" ;//没有数量 
				price2= "0" ;//价钱 为0
			}
			//经济等舱处理
			if(boxType3.isSelected()){
				 num3 = txtNum3.getText().trim() ;//得到头等舱数量 
				 price3 = txtPrice3.getText().trim() ;//得到 头等舱的价格
				//判断格式
					boolean b = BackManagerPanel.this.checkSeatInfo(num3, price3) ;
					System.out.println(b);
					if(b==false){
						JOptionPane.showMessageDialog(null, "经济舱数量或价格格式有误") ;
						txtNum3.setText("") ;
						txtPrice3.setText("") ;
						return ;
					}
			}else {
				num3 = "--" ;//没有数量 
				price3= "0" ;//价钱 为0
			}
			if (num1.equals("") || num2.equals("") || num3.equals("")
					|| price1.equals("") || price2.equals("")
					|| price3.equals("")) {
					JOptionPane.showMessageDialog(BackManagerPanel.this, "数据不能为空!!!") ;
					return ;
			}
			
			//验证文件框 信息成功
			//验证 这个航班 Id号是不是已经存在
			CheckInfo cInfo = new CheckInfo() ;
			boolean b = cInfo.checkisExist("select * from flight_info where 1=? ", new String[]{"1"}, flightNum) ;
			if(b){
				JOptionPane.showMessageDialog(null, "航班号已经存在!重新输入") ;
				txtNum.setText("") ;
				return ;
			}
		
			//将信息插入到航班表 和 Seat表       ????需要作事物处理    应该自动返回加入一个返回航班 
			String startAirId = dataHandle.queryOneString("select  a_id from flight_addr where a_air=?", new String[]{startAir}) ;
			String endAirId = dataHandle.queryOneString("select  a_id from flight_addr where a_air=?", new String[]{endAir}) ;
			System.out.println(startAir+"   "+endAirId);
			boolean b1  = dataHandle.update("insert into flight_info values(?,?,?,?,?,?,?)", new String[]{flightNum,flightType,startTime,endTime,startAirId,endAirId,company}) ;
			 //航班插入成功
			 boolean b2 = dataHandle.update("insert into seat values(?,?,?,"+Float.parseFloat(price3)+")", new String[]{flightNum,"经济舱",num3}) ;
			 boolean b3 = dataHandle.update("insert into seat values(?,?,?,"+Float.parseFloat(price2)+")", new String[]{flightNum,"商务舱",num2}) ;
			 boolean b4 = dataHandle.update("insert into seat values(?,?,?,"+Float.parseFloat(price1)+")", new String[]{flightNum,"头等舱",num1}) ;
			 if(b1&&b2&&b3&&b4){
				//进入第主页面
				int n = JOptionPane.showConfirmDialog(null, "航班插入成功!是否继续?") ;
				 if(n==JOptionPane.YES_OPTION){
					  card.show(ip, "create") ;
				 }else {
					card.show(ip, "one") ;
				}
				 BackManagerPanel.this.clear() ;
				 //插入成功!!
			 }else {
				JOptionPane.showMessageDialog(null, "航班插入失败") ;
			}	
		}
		
		//createFlight()里的重置按钮
		if(e.getSource()==jbReset){
			clear();
		}
		//点击取消就返回上一级cancelFlight()里 的取消按钮
		if(e.getSource()==jbCancel){
			card.show(ip, "one");
		}
		//点击确认就按照航班号先删除所在的座位数和航班信息表中的该条记录
		if(e.getSource()==jbConfirm2){
			String fNumber=txtCancelNum.getText().trim();
			//判断该航班号是否为空
			if(fNumber.equals("")){
				JOptionPane.showMessageDialog(null, "数据不能为空!");
				return;
			}
			//先判断该航班号是否存在
			Vector<String> fNums = dataHandle.queryStringVector("select f_number from flight_info where 1=? ", new String[]{"1"}) ;
			if(!fNums.contains(fNumber)){
				//表示不存在
				JOptionPane.showMessageDialog(null, fNumber+"航班号不存在!") ;
				txtCancelNum.setText("") ;
				return ;
			}
			Connection conn=null;
			Statement st=null;
			int b1=0,b2=0;
			try {
				
				DBHelp  dbHelp=new DBHelp();
				conn =dbHelp.getConnection();
				st =conn.createStatement();
				conn.setAutoCommit(false);
				String sql="delete from seat where f_number='"+fNumber+"'";
				b1=st.executeUpdate(sql);
				//String[] paras=new String[]{fNumber};	
			
				//DataHandle dataHandle=new DataHandle();
				//boolean b1=dataHandle.update(sql, paras);
			
				sql="delete from flight_info where f_number='"+fNumber+"'";
			
				b2 = st.executeUpdate(sql);
			} catch (SQLException e2) {
				try {
					conn.rollback();
					JOptionPane.showMessageDialog(null, "取消航班失败!");
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
			//boolean b2=dataHandle.update(sql, paras);
			System.out.println(b1+" "+b2);
			if(b1>0 && b2>0){
				try {
					conn.commit();
					JOptionPane.showMessageDialog(null, "取消航班成功!");
					txtCancelNum.setText("") ;
					card.show(ip, "one") ;
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
			}else{
				try {
					conn.rollback();
					JOptionPane.showMessageDialog(null, "取消航班失败!");
				} catch (SQLException e1) {
					JOptionPane.showMessageDialog(null, "取消航班失败!");
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			
			}
			
		}
		//点击  航班号  时所触发的事件,将该航班的所有信息赋值
		if(e.getActionCommand().equals("fid")){
			JOptionPane.showMessageDialog(null, cbModiNum.getSelectedItem()) ;
			//航班id号
			String selectFlightId = (String)cbModiNum.getSelectedItem() ;
			//根据Id查到 起始机场
			String startAirplane = dataHandle.queryOneString("select f_start from flight_info where f_number=?", new String[]{selectFlightId}) ; 
			String endAirplane = dataHandle.queryOneString("select f_end from flight_info where f_number=?", new String[]{selectFlightId}) ; 
			System.out.println("起始机场:"+startAirplane+"    end:"+endAirplane);
			
			//先得到  FlightAddr ----------->>>>?????????
			FlightAddr startAddr=dataHandle.queryOneFlightAddr("select * from flight_addr where a_id=?", new String[]{startAirplane});
			System.out.println("FlightAddr:"+startAddr);
			String startCity=startAddr.getA_city();
			FlightAddr endAddr=dataHandle.queryOneFlightAddr("select * from flight_addr where a_id=?", new String[]{endAirplane});
			String endCity=endAddr.getA_city();
			System.out.println("起始城市:"+startCity+"    end:"+endCity);
			
			//通过起始地址和目的地得到FlightInfo 
			String sql="select * from flight_info where f_number=?";
			FlightInfo fInfo=dataHandle.queryFlightById(sql, new String[]{selectFlightId}, startAddr, endAddr);
			if(fInfo==null){
				JOptionPane.showMessageDialog(null, "数据为空!");
				return ;
			}
			txtModiType.setText(fInfo.getF_type());
			txtModiStartTime.setText(fInfo.getF_start_time());
			txtModiEndTime.setText(fInfo.getF_end_time());
			boxModiStartAir.setSelectedItem(fInfo.getF_start().getA_air());
//			boxModiStartAir.setEditable(false);
			boxModiEndAir.setSelectedItem(fInfo.getF_end().getA_air());
//			boxModiEndAir.setEditable(false);
			boxModiCompany.setSelectedItem(fInfo.getF_company());
			//Seat
			sql="select * from seat where f_number=?";
			Vector<Seat> selectSeat=dataHandle.querySeatById(sql, new String[]{selectFlightId}, fInfo, startAddr);
			System.out.println("---座位信息----"+selectSeat.get(0)+"   "+selectSeat.get(1)+selectSeat.get(2));
			for(Seat s:selectSeat){
				if(s.getS_type().equals("头等舱")){		
					if(s.getS_number().matches("\\d+")){
						boxModiType1.setSelected(true);
					}
					txtModiNum1.setText(s.getS_number());
					txtModiPrice1.setText(s.getS_price()+"");
				}
				if(s.getS_type().equals("商务舱")){
					if(s.getS_number().matches("\\d+")){
						boxModiType2.setSelected(true);
					}
					txtModiNum2.setText(s.getS_number());
					txtModiPrice2.setText(s.getS_price()+"");
				}
				if(s.getS_type().equals("经济舱")){
					if(s.getS_number().matches("\\d+")){
						boxModiType3.setSelected(true);
					}
					txtModiNum3.setText(s.getS_number());
					txtModiPrice3.setText(s.getS_price()+"");
				}
			}
		}
		//点击确认修改的按钮
		if(e.getSource()==jbConfirm3){
			String flightId = (String)cbModiNum.getSelectedItem() ;//航班ID
			String fType=txtModiType.getText();
			String fStartTime=txtModiStartTime.getText();
			String fEndTime=txtModiEndTime.getText();
			String startAirString = (String)boxModiStartAir.getSelectedItem() ;
			String endAirString = (String) boxModiEndAir.getSelectedItem() ;
			String fComp=String.valueOf(boxModiCompany.getSelectedItem());
			String fNum1=txtModiNum1.getText();
			String fPrice1=txtModiPrice1.getText();
			String fNum2=txtModiNum2.getText();
			String fPrice2=txtModiPrice2.getText();
			String fNum3=txtModiNum3.getText();
			String fPrice3=txtModiPrice3.getText();
			
			//先得到  FlightAddr ----------->>>>?????????
			FlightAddr startAddr=dataHandle.queryOneFlightAddr("select * from flight_addr where a_air=?", new String[]{startAirString});
			System.out.println("FlightAddr:"+startAddr);
			FlightAddr endAddr=dataHandle.queryOneFlightAddr("select * from flight_addr where a_air=?", new String[]{endAirString});
			if(startAddr==null&&endAddr==null){
				JOptionPane.showMessageDialog(null, "目的地或出发地不存在!!");
				return ;
			}
			//要修改两张表1.flightInfo 
			String sql="update flight_info set f_Type=?,f_start_time=?,f_end_time=?,f_company=?,f_start=?,f_end=? where f_number=?";
			
			boolean bInfo=dataHandle.update(sql, new String[]{fType,fStartTime,fEndTime,fComp,startAddr.getA_id(),endAddr.getA_id(),flightId});
			
			//2.Seat  修改航班舱位表?
			sql="update seat set s_number=?,s_price=? where f_number=? and s_type=?";
			boolean bSeat1=dataHandle.update(sql, new String[]{fNum1,fPrice1,flightId,"头等舱"});
			sql="update seat set s_number=?,s_price=? where f_number=? and s_type=?";
			boolean bSeat2=dataHandle.update(sql, new String[]{fNum2,fPrice2,flightId,"商务舱"});
			sql="update seat set s_number=?,s_price=? where f_number=? and s_type=?";
			boolean bSeat3=dataHandle.update(sql, new String[]{fNum3,fPrice3,flightId,"经济舱"});
			System.out.println("boolean:"+bInfo+"  "+bSeat1+"  "+bSeat2+"  "+bSeat3);
			if(bInfo && bSeat1 && bSeat2 && bSeat3){
				int n = JOptionPane.showConfirmDialog(null, "修改成功!数据已录入数据中,是否继续修改?");
				if(n==JOptionPane.NO_OPTION){
					card.show(ip,"one");
				}
			}else{
				JOptionPane.showMessageDialog(null, "修改失败!");
			}
		}
		//点击航班动态管理的创建按钮
		if(e.getSource()==jbUpCreate){
			StateAddDialog sad = new StateAddDialog();
			sad.setVisible(true);
		}
		if(e.getSource()==jbUpDelete){
			//删除航班
			int selectRow = jTable.getSelectedRow() ;
			//得到 航班Id号跟动态日期
			String selectId = (String)jTable.getValueAt(selectRow, 0) ;
			String selectStateDate = (String)jTable.getValueAt(selectRow, 3) ;
			int num = JOptionPane.showConfirmDialog(null, "确认删除?") ;
			if(num==JOptionPane.YES_OPTION){
				boolean b = dataHandle.update("delete from state where fs_number=? and fs_date=?", new String[]{selectId,selectStateDate}) ;
				if(b){
					JOptionPane.showMessageDialog(null, selectId+"  "+selectStateDate+"动态已删除") ;
				}else {
					JOptionPane.showMessageDialog(null, "未知错误!删掉失败!") ;
				}
			}
		}
	}
//	@Override
//	public void itemStateChanged(ItemEvent e) {
//		
//		if(e.getSource() instanceof JCheckBox){
//			
//			JCheckBox jcb = ((JCheckBox)e.getSource());
//			if(jcb.)
//		}
//	}
	
	
}

猜你喜欢

转载自blog.csdn.net/m0_59687645/article/details/121761843