package otcyan.java.view;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import javax.imageio.ImageIO;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import oracle.net.aso.p;
import otcyan.java.bean.FlightAddr;
import otcyan.java.bean.FlightInfo;
import otcyan.java.bean.Seat;
import otcyan.java.dao.DbHandle;
import otcyan.java.model.CheckInfo;
import otcyan.java.model.DataHandle;
import otcyan.java.model.FlightStateModel;
import otcyan.java.tools.DBHelp;
import otcyan.java.tools.ImagePanel;
import otcyan.java.tools.Tookit;
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