亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? commonquery.java

?? 一個簡單的JAVA程序
?? JAVA
字號:
package flight.query;

import flight.assist.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.*;
import java.sql.*;

public class CommonQuery extends JPanel implements ActionListener,ItemListener
{
	   //A bean used to connect to the database and execute SQL operation
    static SqlBean sqlBean = new SqlBean();
    
	private JTextField flightField = new JTextField(8);	
	
	private static DefaultComboBoxModel modelFlight = new DefaultComboBoxModel();
	private static JComboBox jcbFlight = new JComboBox(modelFlight);
	
	private JButton jbFlightQuery = new JButton("查詢");
	
	
	   //********************************************************************
	private static DefaultComboBoxModel modelAirFirm = new DefaultComboBoxModel();
	private static JComboBox jcbAirFirm = new JComboBox(modelAirFirm);
	
	private JButton jbAirFirmQuery = new JButton("查詢");
	
	
       //********************************************************************	
	private static DefaultComboBoxModel model_1 = new DefaultComboBoxModel();
	private static DefaultComboBoxModel modelStart = new DefaultComboBoxModel();
	private static DefaultComboBoxModel modelArrive = new DefaultComboBoxModel();
	private static JComboBox jcb1 = new JComboBox(model_1),
	                         jcbStart = new JComboBox(modelStart),
	                         jcbArrive = new JComboBox(modelArrive);
	                  
    private JButton jbPlaceQuery1 = new JButton("查詢"),
                    jbPlaceQuery2 = new JButton("查詢"); 
         
     
       //Used to store the flightNumber you have choosed
	private String flightNumber;
	   //Used to store the item you choosed inth combobox
	private String airfirm;
	   //Used to the items choosed from each combobox
    private String destination,start,arrive;
       
       //Setup GUI in the Constructor method               
    public CommonQuery()
    {
    	JPanel jpFlight = new JPanel();
    	jpFlight.setBorder(new TitledBorder("按航班號查詢"));
    	jpFlight.add(new JLabel("請輸入航班號或從列表選擇:"));
    	jpFlight.add(flightField);
    	jpFlight.add(jcbFlight);
    	jpFlight.add(jbFlightQuery);
    	
    	JPanel jpAirFirm = new JPanel();
    	jpAirFirm.setBorder(new TitledBorder("按航空公司查詢"));
    	jpAirFirm.add(new JLabel("請選擇想要查詢的航空公司:"));
    	jpAirFirm.add(jcbAirFirm);
    	jpAirFirm.add(new JLabel("       "));
    	jpAirFirm.add(jbAirFirmQuery);
    	
    	   //********************************************************************
    	       	
    	JPanel jp1 = new JPanel();
    	jp1.add(new JLabel("請選擇你想要到達的目的地:"));
    	jp1.add(jcb1);
    	jp1.add(new JLabel("                         "));
    	jp1.add(jbPlaceQuery1);
    	
    	JPanel jpPlace1 = new JPanel();
    	jpPlace1.setLayout(new BorderLayout());
    	jpPlace1.add(new JLabel("查詢方法一:"),BorderLayout.NORTH);
    	jpPlace1.add(jp1,BorderLayout.CENTER);
    	
    	JPanel jp2 = new JPanel(); 
    	jp2.add(new JLabel("出發城市:"));
    	jp2.add(jcbStart);
    	jp2.add(new JLabel("      抵達城市:"));
    	jp2.add(jcbArrive);
    	jp2.add(new JLabel("       "));
    	jp2.add(jbPlaceQuery2);
    	
    	JPanel jpPlace2 = new JPanel();
    	jpPlace2.setLayout(new BorderLayout());
    	jpPlace2.add(new JLabel("查詢方法二:"),BorderLayout.NORTH);
    	jpPlace2.add(new JLabel("請選擇起始城市和抵達城市進行查詢:"),BorderLayout.CENTER);
    	jpPlace2.add(jp2,BorderLayout.SOUTH);    	
    	
    	JPanel jpDestin = new JPanel();
    	jpDestin.setBorder(new TitledBorder("按目的地查詢"));
    	jpDestin.setLayout(new BorderLayout());
    	jpDestin.add(jpPlace1,BorderLayout.NORTH);
    	jpDestin.add(jpPlace2,BorderLayout.CENTER);
    	
    	   //********************************************************************
    	
    	this.setLayout(new BorderLayout());
    	this.add(jpFlight,BorderLayout.NORTH);
    	this.add(jpAirFirm,BorderLayout.CENTER);
    	this.add(jpDestin,BorderLayout.SOUTH);
    	
    	jcbFlight.addItemListener(this);
    	
    	jbFlightQuery.addActionListener(this);
    	jbAirFirmQuery.addActionListener(this);
    	jbPlaceQuery1.addActionListener(this);
    	jbPlaceQuery2.addActionListener(this);
    	
    }
    
       //Update the flght combobox in the other panels
    public static void updateFlightComboBox(String newFlightNum,int insertOrDelete)
	{
		if (insertOrDelete == 1)
		{
			if (modelFlight.getIndexOf(newFlightNum) == -1)
			   modelFlight.addElement(newFlightNum);
		}  
		else if (insertOrDelete == 2)
		{
			if (modelFlight.getIndexOf(newFlightNum) != -1)
			   modelFlight.removeElement(newFlightNum);			
		}		   
	}
	
	   //Update the airfirm combobox in the other panels
	public static void updateAirFirmComboBox(String newPlace,int insertOrDelete)
	{
		if (insertOrDelete == 1)
		{
			if (modelAirFirm.getIndexOf(newPlace) == -1)
			   jcbAirFirm.addItem(newPlace);
		}
		   
		else if (insertOrDelete == 2)
		{
			if (modelAirFirm.getIndexOf(newPlace) != -1)
			   jcbAirFirm.removeItem(newPlace);
		}		   
	}
	
	   //Update the city combobox in the other panels
	public static void updatePlaceComboBox(String newPlace,int insertOrDelete)
    {
    	if (insertOrDelete == 1)
    	{
    		if (model_1.getIndexOf(newPlace) == -1)
	    	   jcb1.addItem(newPlace);
	    	 
	    	if (modelStart.getIndexOf(newPlace) == -1)
	    	   jcbStart.addItem(newPlace);
	    	   
	    	if (modelArrive.getIndexOf(newPlace) == -1)
	    	   jcbArrive.addItem(newPlace);	
    	}
    	else if (insertOrDelete == 2)
    	{
    		if (model_1.getIndexOf(newPlace) != -1)
    		   jcb1.removeItem(newPlace);
    		
    		if (modelStart.getIndexOf(newPlace) != -1)
    	       jcbStart.removeItem(newPlace);
    		
    		if (modelArrive.getIndexOf(newPlace) != -1)
    		   jcbArrive.removeItem(newPlace);
    	}    	
    }    
    
       //Monitor for the jcbFlight,make sure that when you select one item in the combobox,
       //the textfield can display immediately
    public void itemStateChanged(ItemEvent e)
    {
    	if (e.getSource() == jcbFlight)
    	{
    		flightField.setText( (String)jcbFlight.getSelectedItem() );
    	}
    }
    
       //Monitor for the actionlistener
    public void actionPerformed(ActionEvent e)
    {
    	if (e.getSource() == jbFlightQuery)
    	{
    		this.flightNumber = flightField.getText().trim();	
		
			   //Haven't enter anything
			if (flightNumber.length() == 0)
			{
				JOptionPane.showMessageDialog(null,"請輸入航班號或者從列表中選擇",
				                              "錯誤信息",JOptionPane.ERROR_MESSAGE);
				return;
			}
			
			   //Do the query work
			executeFlightQuery();
    	}
    	
    	else if (e.getSource() == jbAirFirmQuery)
    	{
    		this.airfirm = (String)jcbAirFirm.getSelectedItem();
		
			   //Do the query work
			executeAirFirmQuery();
    	}
    	
    	else if (e.getSource() == jbPlaceQuery1)
    	{
    		   //Get the destination you want to query
    		destination = (String)jcb1.getSelectedItem();
    		   //Trim the space at the side of the string
    		destination = destination.trim();
    		
    		   //Do the query work,and diliver the flag=1,means that 
    		   //it is for the first kind of query
    		executeDestinQuery(1);
    	}
    	
    	else if (e.getSource() == jbPlaceQuery2)
    	{
    		   //Get the start place
    		start = (String)jcbStart.getSelectedItem();
    		start = start.trim();
    		   //Get the destionation
    		arrive = (String)jcbArrive.getSelectedItem();
    		arrive = arrive.trim();
    		
    		   //Do the query work,and diliver the flag=2,means that 
    		   //it is for the second kind of query
    		executeDestinQuery(2);
    	}    	
    }
    
    public void executeFlightQuery()
	{
		   //Form the sqlString 
		String sqlString = "SELECT DISTINCT * FROM " +
		                   "flight " +
		                   "WHERE flight=" + "\'" + flightNumber + "\'";
	
	    ResultSet rs = sqlBean.executeQuery(sqlString);		        
	
	    if (rs != null)
	    {
	    	   //Form result string
	        String result = "                                                 " + 
			                "航班號查詢" + "\n"; 
			result += "查詢的航班號:" + flightNumber + "\n";
			   //Form the specific result string according the message you give       
	        result += formResult(rs);    	
	        
	           //Display result in a dialog
	        showResult(result);
	    }	     
	    else 
	       JOptionPane.showMessageDialog(null,"沒有連接上數據庫!",
	                                    "錯誤信息",JOptionPane.ERROR_MESSAGE);
	}
	
	public void executeAirFirmQuery()
	{
		   //Form the sqlString
		String sqlString = "SELECT DISTINCT * FROM " +
		                   "flight " +
		                   "WHERE airfirm=" + "\'" + airfirm + "\'";
	                  
	    ResultSet rs = sqlBean.executeQuery(sqlString);
	     
	    if (rs != null)
        {
        	   //Form result string
	        String result = "                                                " + 
			                "航空公司查詢" + "\n"; 
			result += "查詢的航空公司:" + airfirm + "\n";
			   //Form the specific result string according the message you give       
	        result += formResult(rs);    	
	        
	           //Display result in a dialog
	        showResult(result);
        }	       
	    else 
	       JOptionPane.showMessageDialog(null,"沒有連接上數據庫!",
	                                    "錯誤信息",JOptionPane.ERROR_MESSAGE);
	}
	
	public void executeDestinQuery(int flag)
    {
    	   //Form the SQL string
    	String sqlString = "SELECT DISTINCT * FROM " + "flight ";
    	
    	   //The SQL string is different for the two kinds of query
    	if (flag == 1)
    	   sqlString += "WHERE destination=" + "\'" + destination + "\'";
    	else 
    	   sqlString += "WHERE start=" + "\'" + start + "\'" + " AND " +
    	                "destination=" + "\'" + arrive + "\'";
    	         
        ResultSet rs = sqlBean.executeQuery(sqlString);
        
        if (rs != null)
        {
        	String result = "                                                 " + 
		                    "目的地查詢 " + "\n";
		                
        	   //The result string is different for the two kinds of query
			if (flag == 1)
			   result += "到達 " + destination + " 的所有航班:" + "\n";
			else
			   result += "始發地: " + start + "------" + "目的地: " + arrive + "\n";
			   
			result += formResult(rs);
			   
			showResult(result);
        }
	       
	    else 
	       JOptionPane.showMessageDialog(null,"沒有連接上數據庫!",
	                                    "錯誤信息",JOptionPane.ERROR_MESSAGE);  
    }
	
	public String formResult(ResultSet rs)
	{
		String result = "航班號    航空公司            起飛地點  抵達地點  起飛時間  抵達時間  " + 
		                "兒童票價   成人票價   折扣    班期     " + "\n";
		   
		   //Used to determine whether there are no records found
		int originLength = result.length();
		
		String time1,time2;
		String childFare,adultFare,discount1,discount2,seat;	
		
		try
		{
			while(rs.next())
			{
				result += rs.getString("flight") + rs.getString("airfirm") + rs.getString("start") + 
				          rs.getString("destination");
				          
				    //When you get the time from the resultset,it is like "1200".
				    //So we should change it into the form "12:00".
				time1 = rs.getString("leaveTime");
				time2 = rs.getString("arriveTime");
				    //getTime(String time) is used to change the time form into standard one
				time1 = getTime(time1);
				time2 = getTime(time2);
				
				result += time1 + "     " + time2  + "     ";
					
				   //Make sure that the following items have the exactly bits,
				   //so that they can be display in a neat format
				childFare = String.valueOf(rs.getFloat("childFare"));
				adultFare = String.valueOf(rs.getFloat("adultFare"));
				discount1 = String.valueOf(rs.getFloat("discount1"));
				discount2 = String.valueOf(rs.getFloat("discount2"));
				seat = String.valueOf(rs.getInt("seat"));
				
				   //Make every item in a neat format
				while(childFare.length() != 11)
				   childFare += " ";
				while(adultFare.length() != 11)
				   adultFare += " ";
				while(discount1.length() != 8)
				   discount1 += " ";					
				   
				result += childFare + adultFare + discount1 +
				          rs.getString("week");
				result += "\n";
			}
		}
		catch(SQLException e)
		{
			e.printStackTrace();
		}
		
		   //Means there are no records found
		   //So give user message that couldn't find correlate infomation
		if (result.length() == originLength)
		{
			result += "                                     " +
			          "對不起,找不到你想要的航班信息!" + "\n";
		}	
		
		return result;
	}
	
	   //Show the result in a dialog
    public void showResult(String result)
    {
    	JOptionPane.showMessageDialog(null,result,"查詢結果",JOptionPane.PLAIN_MESSAGE);
    }          
	
	   //The method used to change the time form 
	private String getTime(String time)
	{
		String time1,time2;
		time1 = time.substring(0,2);
		time2 = time.substring(2,4);
		
		time1 = time1.concat(":");
		time1 = time1.concat(time2);
		
		return time1;
	}            
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美韩国日本综合| 色综合色综合色综合| 丁香婷婷深情五月亚洲| 99精品久久免费看蜜臀剧情介绍| 一本一本大道香蕉久在线精品 | 欧美色偷偷大香| 欧美一区二区精品久久911| 久久精品日韩一区二区三区| 中文字幕在线不卡视频| 午夜精品aaa| 国产精品一区一区三区| 亚洲欧洲在线观看av| 1024国产精品| 精品剧情v国产在线观看在线| 91香蕉视频在线| 9久草视频在线视频精品| 91丨porny丨中文| 日韩一区二区在线看片| 欧美一区二区三区视频免费| 亚洲三级在线免费观看| 亚洲欧洲日韩一区二区三区| 欧美精品xxxxbbbb| 久久久欧美精品sm网站| 1024成人网色www| 久久66热偷产精品| 91传媒视频在线播放| 久久一二三国产| 午夜免费久久看| 国产99久久久国产精品| 91麻豆精品久久久久蜜臀| 欧美韩国日本不卡| 免费不卡在线观看| 日本黄色一区二区| 国产精品少妇自拍| 精品在线观看免费| 欧美日韩在线精品一区二区三区激情 | 成人福利视频在线看| 91精品国产福利在线观看 | 色综合天天综合狠狠| 精品美女一区二区| 亚洲成a人片在线不卡一二三区| 99久久亚洲一区二区三区青草 | 91国偷自产一区二区三区成为亚洲经典 | 亚洲四区在线观看| 精品写真视频在线观看| 欧美日韩视频在线第一区| 国产精品久久久久久久久搜平片| 麻豆精品精品国产自在97香蕉| 色噜噜狠狠色综合中国| 欧美高清在线精品一区| 韩国成人在线视频| 欧美一区二区三区免费大片| 樱桃视频在线观看一区| 成人晚上爱看视频| 国产午夜精品一区二区三区嫩草| 精品一区二区三区免费观看| 51精品国自产在线| 亚洲高清中文字幕| 欧美一a一片一级一片| 亚洲男人天堂av网| 色吧成人激情小说| 亚洲人成精品久久久久久| 成人免费va视频| 中文子幕无线码一区tr | 国产精品久久久久影院老司| 国产在线播放一区三区四| 日韩欧美国产精品一区| 蜜桃av一区二区三区电影| 欧美一区二区三区白人 | 久久久欧美精品sm网站| 韩国精品久久久| 久久色.com| 国产精品亚洲一区二区三区妖精| 亚洲精品在线观| 国产成人免费xxxxxxxx| 中文字幕 久热精品 视频在线 | 亚洲色欲色欲www| 97久久人人超碰| 亚洲男人天堂一区| 欧美三区免费完整视频在线观看| 亚洲综合色噜噜狠狠| 欧美三级视频在线| 亚欧色一区w666天堂| 91精品在线一区二区| 久久er99热精品一区二区| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | www.视频一区| 亚洲蜜臀av乱码久久精品蜜桃| 91黄色激情网站| 日韩国产精品大片| 久久伊99综合婷婷久久伊| 成人手机在线视频| 亚洲免费伊人电影| 欧美精品九九99久久| 国产资源在线一区| 亚洲视频免费在线| 欧美三级三级三级| 极品少妇xxxx精品少妇偷拍| 亚洲国产精品v| 色婷婷综合久久久中文字幕| 亚洲国产欧美一区二区三区丁香婷| 欧美精品在线观看播放| 精品一区二区三区视频| 中文字幕在线观看不卡视频| 欧美私人免费视频| 精品影视av免费| 亚洲欧美日韩国产手机在线| 在线91免费看| 国产成人免费视| 亚洲18色成人| 中文字幕精品三区| 欧美乱熟臀69xxxxxx| 国产精品1区二区.| 一区二区成人在线| 日韩精品资源二区在线| 91在线国产福利| 蜜臀精品久久久久久蜜臀 | 一本一道久久a久久精品| 日韩av成人高清| 亚洲国产精品成人综合| 欧美日韩黄色影视| 国产·精品毛片| 亚洲成va人在线观看| 久久精品视频免费| 555夜色666亚洲国产免| 成人免费观看视频| 日韩成人免费在线| 亚洲欧洲日本在线| 欧美不卡一区二区三区| 91蝌蚪porny成人天涯| 另类综合日韩欧美亚洲| 中文字幕一区二区不卡| 日韩一本二本av| 色视频欧美一区二区三区| 久久97超碰色| 亚洲电影在线免费观看| 欧美国产乱子伦| 精品区一区二区| 欧美日韩精品高清| 北条麻妃国产九九精品视频| 人人狠狠综合久久亚洲| 亚洲美女偷拍久久| 亚洲国产精品精华液2区45| 欧美一区二区精品久久911| 日本高清成人免费播放| 国产成人午夜精品5599 | 国产日韩欧美一区二区三区乱码 | 麻豆国产91在线播放| 亚洲免费av观看| 国产精品美女视频| 久久影院午夜论| 欧美变态口味重另类| 欧美日本韩国一区| 色婷婷久久99综合精品jk白丝| 国产高清不卡一区| 久久国产精品露脸对白| 亚洲成人福利片| 一区二区三区视频在线看| 国产精品免费久久| 国产三级一区二区三区| 精品噜噜噜噜久久久久久久久试看| 精品视频一区 二区 三区| 91免费版pro下载短视频| 国产成人免费在线视频| 国产一区二区免费视频| 久久精品噜噜噜成人88aⅴ| 日韩主播视频在线| 亚洲风情在线资源站| 亚洲一区二区三区国产| 亚洲人成人一区二区在线观看| 国产精品国产三级国产专播品爱网| 久久久99久久| 久久久精品2019中文字幕之3| 久久综合精品国产一区二区三区| 日韩小视频在线观看专区| 91精品国产乱码久久蜜臀| 欧美一区二区三区日韩视频| 欧美狂野另类xxxxoooo| 欧美欧美午夜aⅴ在线观看| 欧美老肥妇做.爰bbww| 67194成人在线观看| 在线成人av网站| 日韩一区二区在线观看| 欧美精品三级在线观看| 777色狠狠一区二区三区| 欧美日韩国产综合一区二区 | 天天影视网天天综合色在线播放| 一区二区三区四区视频精品免费| 日韩理论片网站| 亚洲男同1069视频| 亚洲五月六月丁香激情| 午夜欧美视频在线观看| 日本不卡123| 激情综合色综合久久综合| 国产一区二区精品久久91| 国产盗摄一区二区| av不卡在线播放| 在线视频观看一区| 91麻豆精品久久久久蜜臀| 欧美成人女星排名|