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

📄 hotel.java

📁 酒店管理系统
💻 JAVA
字号:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;

public class Hotel extends JFrame
{	
	private static final long serialVersionUID = -3505405399475136096L;
	//添加工具栏;
	static JButton jb1=new JButton(" 客人定房 ");
	static JButton jb2=new JButton(" 客人退房 ");
	static JButton jb3=new JButton(" 客人查询 ");
	static JButton jb4=new JButton(" 客房查询 ");
	static JButton jb5=new JButton(" 业务报表 ");
	static JButton jb6=new JButton(" 系统管理 ");
	static JButton jb7=new JButton(" 退出系统 ");
	static JToolBar tb=new JToolBar();
	static JPanel jp=new JPanel();
	static Paneldemo1 jp3=new Paneldemo1();
	static Welcome wel=new Welcome();
	static Paneldemo2 jp4=new Paneldemo2();
	static Paneldemo3 jp5=new Paneldemo3();
	static Paneldemo4 jp6=new Paneldemo4();
	static Paneldemo1 jp7=new Paneldemo1();
	static Paneldemo5 jp8=new Paneldemo5();
	static Paneldemo6 jp9=new Paneldemo6();
	static Paneldemo7 jp10=new Paneldemo7();//???????????
	static Paneldemo8 jp11=new Paneldemo8();
	static Paneldemo9 jp12=new Paneldemo9();
	static Paneldemo10 jp13=new Paneldemo10();
	static CardLayout cd=new CardLayout();

	//添加菜单栏;
	//菜单的选项;
	static JMenuItem jmi1=new JMenuItem("退出系统");
	static JMenuItem jmi2=new JMenuItem("客人定房");
	static JMenuItem jmi3=new JMenuItem("客人退房");
	static JMenuItem jmi4=new JMenuItem("客房查询");
	static JMenuItem jmi5=new JMenuItem("搜索客人");
	static JMenuItem jmi6=new JMenuItem("修改状态");
	static JMenuItem jmi7=new JMenuItem("收入汇总表");
	static JMenuItem jmi8=new JMenuItem("客房介绍");
	static JMenuItem jmi9=new JMenuItem("最近公告");
	static JMenuItem jmi10=new JMenuItem("实现概况");
	//static JMenuItem jmi11=new JMenuItem("信息修改");
	//static JMenuItem jmi11=new JMenuItem("帮助主题");
	//static JMenuItem jmi12=new JMenuItem("客房介绍");
	//菜单的目录;
	static JMenu jm1=new JMenu("酒店系统(A)");
	static JMenu jm2=new JMenu("客人定房(B)");
	static JMenu jm3=new JMenu("客人信息(C)");
	static JMenu jm4=new JMenu("业务报表(D)");
	static JMenu jm5=new JMenu("系统信息(E)");
	static JMenu jm6=new JMenu("帮助(H)");
	//static JMenu jm7=new JMenu("系统操作(G)");
	//static JMenu jm8=new JMenu("帮助信息(H)");

	/////////////////////////////////////////////////////////////////////
	////对话框里分了两个面板,分别放上部和其他(JButton)的;
	static JPanel jp1=new JPanel();
	static JPanel jp2=new JPanel();
	//对话框里的上部;
	static JLabel jl1=new JLabel("用户名:");
	static JLabel jl2=new JLabel("密码:");
	static JTextField tfd=new JTextField("用户");
	static JPasswordField jpw=new JPasswordField();
	///对话框的下部(JButton)
	static JButton jb=new JButton("登陆");
	
	static JMenuBar jmb=new JMenuBar();
	static String s1=null;
	//构造函数;
	public Hotel(String str)
	{
		super(str);

		/////////////////设置窗体;
	}
	
	
	public static void main(String args[])
	{
		for(int i=0;i<100;i++){
		System.out.println("软件,我编死你!!!,hoho~~~~~~~~");
		System.out.println("吃东西~~~~饿死了~~~老朱请吃饭~~~~!!!,hoho~~~~~~~~");}
		//菜单选项事件监听;
		jmi1.addActionListener(new Wdl());
		jmi2.addActionListener(new Wdl());
		jmi3.addActionListener(new Wdl());
		jmi4.addActionListener(new Wdl());
		jmi5.addActionListener(new Wdl());
		jmi6.addActionListener(new Wdl());
		jmi7.addActionListener(new Wdl());
		jmi8.addActionListener(new Wdl());
		jmi9.addActionListener(new Wdl());
		jmi10.addActionListener(new Wdl());
		//jmi11.addActionListener(new Wdl());
		//jmi11.addActionListener(new Wdl());
		//jmi12.addActionListener(new Wdl());
		//jmi13.addActionListener(new wdl());
		//jmi14.addActionListener(new wdl());
		
		///////对菜单选项进行添加;
		jm1.add(jmi1);
		jm2.add(jmi2);
		jm2.add(jmi3);
		jm2.add(jmi4);/////
		jm3.add(jmi5);
		jm3.add(jmi6);
		//jm3.add(jmi11);
		jm4.add(jmi7);
		jm5.add(jmi8);
		jm5.add(jmi9);
		jm6.add(jmi10);
		//jm6.add(jmi11);
		//jm6.add(jmi12);
		//jm5.add(jmi7);
		//jm5.add(jmi7);
		
		//把菜单目录添加到菜单条里;
		jmb.add(jm1);
		jmb.add(jm2);
		jmb.add(jm3);
		jmb.add(jm4);
		jmb.add(jm5);
		jmb.add(jm6);
		jmb.setBorder(null);
		//jmb.add(jm7);
		//jmb.add(jm8);
		
		Hotel h=new Hotel("酒店管理系统");////实现类的对象;
		//设定菜单栏;
		h.setJMenuBar(jmb);
		//对话框;
		final JDialog jdg=new JDialog(h,"用户登陆",true);
		jdg.addWindowListener(new WindowListener()
		{
			public void windowClosing(WindowEvent e)
				{
					if(e.getSource()==jdg)
					{
						Button b=new Button("对不起,请关闭b");
						final JDialog d=new JDialog(jdg,"返回",true);
						
						d.add(b);
						d.setLocation(500,500);
						d.setBounds(420,310,100,80);
						
						b.addActionListener(new ActionListener()
						{
							public void actionPerformed(ActionEvent e)
							{
								System.exit(0);
							}});
							d.addWindowListener(new WindowListener()
							{
								public void windowClosing(WindowEvent e){System.exit(0);}
								public void windowOpened(WindowEvent e){}
								public void windowClosed(WindowEvent e){}
								public void windowIconified(WindowEvent e){}
								public void windowDeiconified(WindowEvent e){}
								public void windowActivated(WindowEvent e){}
								public void windowDeactivated(WindowEvent e){}
						});
							d.setVisible(true);	
					}
				}
			public void windowOpened(WindowEvent e){}
			public void windowClosed(WindowEvent e){}
			public void windowIconified(WindowEvent e){}
			public void windowDeiconified(WindowEvent e){}
			public void windowActivated(WindowEvent e){}
			public void windowDeactivated(WindowEvent e){}			
			});
		
		jdg.add(jp1);
		jdg.add(jp2);//加入了两个Panel;对对话框进行隔离
		jdg.setLayout(new GridLayout(2,1));
		
		jp1.add(jl1);
		jp1.add(tfd);
		jp1.add(jl2);
		jp1.add(jpw);//JPanel对象1已经添加完毕;
		jp1.setLayout(new GridLayout(2,2));
		
		//////////////////////////////////
		jb.addKeyListener(new KeyListener(){

			public void keyPressed(KeyEvent e) {
				
			}
			public void keyReleased(KeyEvent e) {
				connection2(jdg);
			}
			private void connection2(final JDialog jdg) {
				try
				{
					//加载驱动程序;
					Class.forName("oracle.jdbc.driver.OracleDriver");
					System.out.println("加载驱动成功,hoho~~~~");
					//建立连接;
					Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","abcd");
					System.out.println("连接成功,hoho~~~~");
					String sqlStr="SELECT 密码 FROM 管理员 where 用户名 =?";
					PreparedStatement st=con.prepareStatement(sqlStr);
					System.out.println("创建st成功,hoho~~~~");
					String s=tfd.getText();
					st.setString(1,s);
					System.out.println("设置参数成功,hoho~~~~");
					
					ResultSet rs1=st.executeQuery();
					System.out.println("执行成功,hoho~~~~");
					if(rs1.next())
					{
						s1=rs1.getString("密码");
						//System.out.print(s1);
						if(String.valueOf(jpw.getPassword()).equals(s1))
						{	
							jdg.dispose();
						}
						else
						System.exit(0);
					}
				}
			
			catch(java.lang.Exception e1)
			{
				System.out.print("something is error!");
			}
			}

			public void keyTyped(KeyEvent e) {
				
			}
			
		});
		jb.addActionListener(new ActionListener()
		{public void actionPerformed(ActionEvent e)
			{////////////////////////
			connection1(jdg);
			}

		private void connection1(final JDialog jdg) {
			try
			{
				//加载驱动程序;
				Class.forName("oracle.jdbc.driver.OracleDriver");
				System.out.println("加载驱动成功,hoho~~~~");
				//建立连接;
				Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","abcd");
				System.out.println("连接成功,hoho~~~~");
				String sqlStr="SELECT 密码 FROM 管理员 where 用户名 =?";
				PreparedStatement st=con.prepareStatement(sqlStr);
				System.out.println("创建st成功,hoho~~~~");
				String s=tfd.getText();
				st.setString(1,s);
				System.out.println("设置参数成功,hoho~~~~");
			
				ResultSet rs=st.executeQuery();
				System.out.println("执行成功,hoho~~~~");
				if(rs.next())
				{
					s1=rs.getString("密码");
					//System.out.print(s1);
					if(String.valueOf(jpw.getPassword()).equals(s1))
					{	
						System.out.println("进入界面,hoho~~~~");
						jdg.dispose();
					}
					else
					System.exit(0);
				}
			}
		
		catch(java.lang.Exception e1)
		{
			System.out.print("something is error!");
		}
		}});

			
		
		jp2.setLayout(null);
		jp2.add(jb);		////JPanel对象2已经添加完毕;
		jb.setBounds(50,13,80,30);
	
		jdg.setBounds(400,300,200,150);//对对话框进行设置;
		jdg.setVisible(true);
		
		tb.add(jb1);
		tb.add(jb2);
		tb.add(jb3);
		tb.add(jb4);
		tb.add(jb5);
		tb.add(jb6);
		tb.add(jb7);
		jb1.addActionListener(new Wdl());
		jb2.addActionListener(new Wdl());
		jb3.addActionListener(new Wdl());
		jb4.addActionListener(new Wdl());
		jb5.addActionListener(new Wdl());
		jb6.addActionListener(new Wdl());
		jb7.addActionListener(new Wdl());
		
		h.add(jp,BorderLayout.CENTER);
		h.add(tb,BorderLayout.NORTH);		
		
		jp.setLayout(cd);
		//jp.setBackground(Color.yellow);
		jp.add("zero",wel);
		jp.add("frist",jp3);
		jp.add("second",jp4);
		jp.add("third",jp5);
		jp.add("fourth",jp6);
		jp.add("fifth",jp7);
		jp.add("sixth",jp8);
		jp.add("seventh",jp9);
		jp.add("eighth",jp10);
		jp.add("ninth",jp11);
		jp.add("tenth",jp12);
		jp.add("eleventh",jp13);
		

		h.setJMenuBar(jmb);
		h.setLocation(220,60);
		h.addWindowListener(new Wdl());
		h.setSize(700,650);
		h.setVisible(true);
	}

}

⌨️ 快捷键说明

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