📄 sheji.java
字号:
int ctime;
String name,sex,age,paper,phone,gtime,num,hynum,jiezhang;
GL_b5_b1()
{
JPanel p=new JPanel();
p.setLayout(new FlowLayout());
JLabel l=new JLabel("输入住户姓名");
t=new JTextField(15);
ta=new JTextArea(50,50);
b=new JButton("查询");
b1=new JButton("退出");
p.add(l);
p.add(t);
p.add(b);
p.add(b1);
this.add(ta,BorderLayout.CENTER);
this.add(p,BorderLayout.NORTH);
this.setTitle("查询");
this.setSize(800,200);
this.setLocation(200,400);
this.setVisible(true);
this.show(true);
this.setModal(true);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==b)
{
//查询信息显示在文本区
try{connection();
; ResultSet rs;
String sql;
ta.setText("");
ta.append("您要查找的信息为:"+"\n");
ta.append("姓名\t性别\t年龄\t身份证号\t\t电话\t入住日期\t\t离店日期\t\t入住房号\t会员号码\t结账金额"+"\n");
sql="Select * from host where name='"+t.getText()+"';";
rs=stmt.executeQuery(sql);
while(rs.next())
{
name=rs.getString("name");
sex=rs.getString("sex");
age=rs.getString("age");
paper=rs.getString("paper");
phone=rs.getString("phone");
ctime=rs.getInt("ctime");
gtime=rs.getString("gtime");
num=rs.getString("num");
hynum=rs.getString("hynum");
jiezhang=rs.getString("jiezhang");
ta.append( name+"\t"+sex+"\t"+age+"\t"+paper+"\t"+phone+"\t"+ctime+"\t\t"+gtime+"\t\t"+num+"\t"+hynum+"\t"+jiezhang+"\n");
}
rs.close();
close();
}catch(SQLException sql){sql.printStackTrace();};
}
else if(e.getSource()==b1)
{
this.setVisible(false);
this.dispose();
}
}catch(Exception ex){ex.printStackTrace();}
}
}
//按房号查
class GL_b5_b2 extends JDialog implements ActionListener
{
JButton b,b1;
JTextField t;
JTextArea ta;
int ctime;
String name,sex,age,paper,phone,gtime,num,hynum,jiezhang;
GL_b5_b2()
{
JPanel p=new JPanel();
p.setLayout(new FlowLayout());
JLabel l=new JLabel("输入住户房号");
t=new JTextField(15);
ta=new JTextArea(50,50);
b=new JButton("查询");
b1=new JButton("退出");
p.add(l);
p.add(t);
p.add(b);
p.add(b1);
this.add(ta,BorderLayout.CENTER);
this.add(p,BorderLayout.NORTH);
this.setTitle("查询");
this.setSize(800,200);
this.setLocation(200,400);
this.setVisible(true);
this.show(true);
this.setModal(true);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==b)
{
//查询信息显示在文本区
try{
connection();
String sql;
ResultSet rs;
ta.setText("");
ta.append("您要查找的信息为:"+"\n");
ta.append("姓名\t性别\t年龄\t身份证号\t\t电话\t入住日期\t\t离店日期\t\t入住房号\t会员号码\t结账金额"+"\n");
sql="Select * from host where num='"+t.getText()+"';";
rs=stmt.executeQuery(sql);
while(rs.next())
{
name=rs.getString("name");
sex=rs.getString("sex");
age=rs.getString("age");
paper=rs.getString("paper");
phone=rs.getString("phone");
ctime=rs.getInt("ctime");
gtime=rs.getString("gtime");
num=rs.getString("num");
hynum=rs.getString("hynum");
jiezhang=rs.getString("jiezhang");
ta.append( name+"\t"+sex+"\t"+age+"\t"+paper+"\t"+phone+"\t"+ctime+"\t\t"+gtime+"\t\t"+num+"\t"+hynum+"\t"+jiezhang+"\n");
}
rs.close();
close();
}catch(SQLException sql){sql.printStackTrace();};
}
else if(e.getSource()==b1)
{
this.setVisible(false);
this.dispose();
}
}catch(Exception ex){ex.printStackTrace();}
}
}
//按入住日期查
class GL_b5_b3 extends JDialog implements ActionListener
{
JButton b,b1;
JTextField t;
JTextArea ta;
int ctime;
String name,sex,age,paper,phone,gtime,num,hynum,jiezhang;
GL_b5_b3()
{
JPanel p=new JPanel();
p.setLayout(new FlowLayout());
JLabel l=new JLabel("输入住户入住日期");
t=new JTextField(15);
ta=new JTextArea(50,50);
b=new JButton("查询");
b1=new JButton("退出");
p.add(l);
p.add(t);
p.add(b);
p.add(b1);
this.add(ta,BorderLayout.CENTER);
this.add(p,BorderLayout.NORTH);
this.setTitle("查询");
this.setSize(800,200);
this.setLocation(200,400);
this.setVisible(true);
this.show(true);
this.setModal(true);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==b)
{
//查询信息显示在文本区
try{
connection();
String sql;
ResultSet rs;
ta.setText("");
ta.append("您要查找的信息为:"+"\n");
ta.append("姓名\t性别\t年龄\t身份证号\t\t电话\t入住日期\t\t离店日期\t\t入住房号\t会员号码\t结账金额"+"\n");
sql="Select * from host where ctime='"+Integer.parseInt(t.getText())+"';";
rs=stmt.executeQuery(sql);
while(rs.next())
{
name=rs.getString("name");
sex=rs.getString("sex");
age=rs.getString("age");
paper=rs.getString("paper");
phone=rs.getString("phone");
ctime=rs.getInt("ctime");
gtime=rs.getString("gtime");
num=rs.getString("num");
hynum=rs.getString("hynum");
jiezhang=rs.getString("jiezhang");
ta.append( name+"\t"+sex+"\t"+age+"\t"+paper+"\t"+phone+"\t"+ctime+"\t\t"+gtime+"\t\t"+num+"\t"+hynum+"\t"+jiezhang+"\n");
}
rs.close();
close();
}catch(SQLException sql){sql.printStackTrace();};
}
else if(e.getSource()==b1)
{
this.setVisible(false);
this.dispose();
}
}catch(Exception ex){ex.printStackTrace();}
}
}
//按离店日期查
class GL_b5_b4 extends JDialog implements ActionListener
{
JButton b,b1;
JTextField t;
JTextArea ta;
int ctime;
String name,sex,age,paper,phone,gtime,num,hynum,jiezhang;
GL_b5_b4()
{
JPanel p=new JPanel();
p.setLayout(new FlowLayout());
JLabel l=new JLabel("输入住户离店日期");
t=new JTextField(15);
ta=new JTextArea(50,50);
b=new JButton("查询");
b1=new JButton("退出");
p.add(l);
p.add(t);
p.add(b);
p.add(b1);
this.add(ta,BorderLayout.CENTER);
this.add(p,BorderLayout.NORTH);
this.setTitle("查询");
this.setSize(800,200);
this.setLocation(200,400);
this.setVisible(true);
this.show(true);
this.setModal(true);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==b)
{
//查询信息显示在文本区
try{
connection();
String sql;
ResultSet rs;
ta.setText("");
ta.append("您要查找的信息为:"+"\n");
ta.append("姓名\t性别\t年龄\t身份证号\t\t电话\t入住日期\t\t离店日期\t\t入住房号\t会员号码\t结账金额"+"\n");
sql="Select * from host where gtime='"+t.getText()+"';";
rs=stmt.executeQuery(sql);
while(rs.next())
{
name=rs.getString("name");
sex=rs.getString("sex");
age=rs.getString("age");
paper=rs.getString("paper");
phone=rs.getString("phone");
ctime=rs.getInt("ctime");
gtime=rs.getString("gtime");
num=rs.getString("num");
hynum=rs.getString("hynum");
jiezhang=rs.getString("jiezhang");
ta.append( name+"\t"+sex+"\t"+age+"\t"+paper+"\t"+phone+"\t"+ctime+"\t\t"+gtime+"\t\t"+num+"\t"+hynum+"\t"+jiezhang+"\n");
}
rs.close();
close();
}catch(SQLException sql){sql.printStackTrace();};
}
else if(e.getSource()==b1)
{
this.setVisible(false);
this.dispose();
}
}catch(Exception ex){ex.printStackTrace();}
}
}
//操作员登陆的管理界面
class CZ_denglu extends JFrame implements ActionListener
{
JButton b1,b2,b3,b4,b5,b6,b7,b8;
CZ_denglu()
{
JLabel la=new JLabel("欢迎进入酒店客房管理系统");
la.setFont(new Font("TimesRoman",Font.BOLD,35));
JPanel p1=new JPanel();
JPanel p2=new JPanel();
b1=new JButton("预定客房");
b2=new JButton("退订客房");
b3=new JButton("入住客房");
b4=new JButton("退房结账");
b5=new JButton("客户信息查询");
b6=new JButton("房态查询");
b7=new JButton("统计月入住率");
b8=new JButton("退出");
p2.setLayout(new GridLayout(16,1));
p1.add(la);
p2.add(b1);p2.add(new JLabel());
p2.add(b2);p2.add(new JLabel());
p2.add(b3);p2.add(new JLabel());
p2.add(b4);p2.add(new JLabel());
p2.add(b5);p2.add(new JLabel());
p2.add(b6);p2.add(new JLabel());
p2.add(b7);p2.add(new JLabel());
p2.add(b8);p2.add(new JLabel());
this.add(p1,BorderLayout.NORTH);
this.add(p2,BorderLayout.WEST);
this.setTitle("管理员管理");
this.setSize(850,500);
this.setLocation(300,300);
this.setVisible(true);
this.setVisible(true);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==b1)
{
new GL_b1();
}
else if(e.getSource()==b2)
{
new GL_b2();
}
else if(e.getSource()==b3)
{
new GL_b3();
}
else if(e.getSource()==b4)
{
new GL_b4();
}
else if(e.getSource()==b5)
{
new GL_b5();
}
else if(e.getSource()==b6)
{
new GL_b6();
}
else if(e.getSource()==b7)
{
new CZ_b7();
}
else if(e.getSource()==b8)
{
this.setVisible(false);
this.dispose();
}
}catch(Exception ex){ex.printStackTrace();}
}
}
//统计管理 月入住率
class CZ_b7 extends JDialog implements ActionListener,ItemListener
{
JButton b,b1;
JTextField t;
Choice c=new Choice();
CZ_b7()
{
JLabel la1=new JLabel("查询月份");
c.add("1");
c.add("2");
c.add("3");
c.add("4");
c.add("5");
c.add("6");
c.add("7");
c.add("8");
c.add("9");
c.add("10");
c.add("11");
c.add("12");
JLabel la2=new JLabel("统计结果");
t=new JTextField(15);
b=new JButton("统计");
b1=new JButton("退出");
Panel p=new Panel();
Panel p1=new Panel();
p.add(la1);
p.add(c);
p1.add(la2);
p1.add(t);
p1.add(b);
p1.add(b1);
this.add(p,BorderLayout.EAST);
this.add(p1,BorderLayout.WEST);
this.setTitle("客房月入住率统计");
this.setSize(550,200);
this.setLocation(500,400);
this.show(true);
this.setModal(true);
b.addActionListener(this);
b1.addActionListener(this);
c.addItemListener(this);//单击事件
}
public void itemStateChanged(ItemEvent e)
{
try{
int all=0,result=0;
int people1=0,people2=0,people3=0;
connection();
if (e.getItem().equals("1"))
{
System.out.println("you select 1");
String sql,num;
ResultSet rs;
sql="select people from host,house where ctime>20070100 and ctime<20070132 and house.num='01'";
rs=stmt.executeQuery(sql);
while(rs.next())
{
people1=rs.getInt("people");
}
sql="select people from host,house where ctime>20070100 and ctime<20070132 and house.num='02'";
rs=stmt.executeQuery(sql);
while(rs.next())
{
people2=rs.getInt("people");
}
sql="select people from host,house where ctime>20070100 and ctime<20070132 and house.num='03'";
rs=stmt.executeQuery(sql);
while(rs.next())
{
people3=rs.getInt("people");
}
all =people1+people2+people3;
}
result=all/(31*3);
t.setText(""+result);
close();
}catch(Exception ex){ex.printStackTrace();}
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==b)
{
}
else if(e.getSource()==b1)
{
this.setVisible(false);
this.dispose();
}
}catch(Exception ex){ex.printStackTrace();}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -