本文目录一览:
- 1、求一个 java + oracle 数据库实现的 酒店客房管理系统,求好心人发我一个呀
- 2、诚心求教!java实现酒店客房管理系统(不用数据库),如能解惑,感谢之至!
- 3、如何用java编写比较完善的宾馆管理系统
求一个 java + oracle 数据库实现的 酒店客房管理系统,求好心人发我一个呀
酒店客房管理系统
java web开发
struts2+spring+hibernate
服务器:tomcat
诚心求教!java实现酒店客房管理系统(不用数据库),如能解惑,感谢之至!
那你能说说为什么你自己尝试编写总是不成功呢?为什么别的组已经完成了,而你们组没完成呢?如坐针毡?那别人在好好学习的时候,你在玩,怎么就不如坐针毡了?
如何用java编写比较完善的宾馆管理系统
package room;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.njit.HelloHotel;
import com.wind.util.DbUtil;
import java.io.UnsupportedEncodingException;
import java.sql.*;
public class roomadd extends JFrame
{
private JTextField roomno,roomcost,roomstatus,roomtype;
//private JComboBox roomtype;
private JButton ok,cancel,return1,chakan;
private Container contain;
public roomadd()
{
super();
this.setSize(350,450);
this.setTitle("添加信息");
this.setLocationRelativeTo(getOwner()); //居中
//设置组件布局
Container contain=getContentPane();
contain.setLayout(new BoxLayout(contain,BoxLayout.Y_AXIS));
//添加组件
JPanel cont=new JPanel (new GridLayout(4,2));
//添加组件
/*cont.add(new JLabel("客房类型"));
roomtype=new JComboBox();
roomtype.addItem("单人间");
roomtype.addItem("双人间");
roomtype.addItem("三人房");
roomtype.addItem("四人间");
cont.add(roomtype);*/
cont.add(new JLabel("客房号"));
roomno=new JTextField(10);
cont.add(roomno);
cont.add(new JLabel("房间类型"));
roomtype=new JTextField(10);
cont.add(roomtype);
cont.add(new JLabel("客房价格"));
roomcost=new JTextField(10);
cont.add(roomcost);
cont.add(new JLabel("客房状态"));
roomstatus=new JTextField(10);
cont.add(roomstatus);
//按钮
JPanel cont1=new JPanel(new FlowLayout());
ok=new JButton("添加");
cancel=new JButton("取消");
chakan=new JButton("查看");
return1=new JButton("返回");
cont1.add(ok);
cont1.add(cancel);
cont1.add(chakan);
cont1.add(return1);
contain.add(cont);
contain.add(cont1);
//注册监听器
ok.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//ok事件处理
DbUtil util = new DbUtil();
Connection con=null;
try {
con = (Connection) util.getCon();
} catch (Exception e2) {
e2.printStackTrace();
}
String sql="insert into room values(?,?,?,?)";
PreparedStatement pstmt = null;
try {
pstmt = (PreparedStatement)con.prepareStatement(sql);
} catch (SQLException e2) {
e2.printStackTrace();
}
try {
pstmt.setString(1,roomno.getText());
pstmt.setString(2,roomtype.getText());
pstmt.setString(3,roomcost.getText());
pstmt.setString(4,roomstatus.getText());
pstmt.executeUpdate();
} catch (SQLException e1) {
e1.printStackTrace();
}
JOptionPane.showMessageDialog(null, " 注册成功!");
}
});
//查看添加的预订信息
chakan.addActionListener(new ActionListener(){
private JTable table;
public void actionPerformed(ActionEvent e) {
if(e.getSource()==chakan){
Connection con = null;
ResultSet rs=null;
DbUtil util = new DbUtil();
String[][] a;
String[] name = { "", "", "", ""};
int row = 0;
try {
con = (Connection) util.getCon();
}
catch (Exception e1) {
e1.printStackTrace();
}
try {
String roomno = null;
rs=(ResultSet) util.sroom(con, roomno);
} catch (Exception e1) {
e1.printStackTrace();
}
try {
while(rs.next()){
row++;
}
a = new String[row + 1][4];
a[0][0] = " 客房号";
a[0][1] = " 客房类型";
a[0][2] = " 客房价格 ";
a[0][3] = " 客房状态";
table = new JTable(a,name);
int i = 0;
String roomno = null;
rs=(ResultSet)util.sroom(con,roomno);
while (rs.next()) {
// 往表中填充查询到的数据
i++;
int j = 0;
table.setValueAt(new String(rs.getString("roomno").getBytes("ISO-8859-1"),"GBK") + "", i, j);
table.setValueAt(new String(rs.getString("roomtype").getBytes("ISO-8859-1"),"GBK") + "", i, ++j);
table.setValueAt(new String(rs.getString("roomcost").getBytes("ISO-8859-1"),"GBK") + "", i, ++j);
table.setValueAt(new String(rs.getString("roomstatus").getBytes("ISO-8859-1"),"GBK") + "", i, ++j);
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
JFrame b5=new JFrame("顾客预订信息");
b5.setLayout(new BorderLayout());
b5.add(table);
b5.setBounds(200, 200, 500, 300);
b5.setVisible(true);
b5.setResizable(true);
b5.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}
});
cancel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
return1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
HelloHotel hello=new HelloHotel();
hello.setVisible(true);
dispose();
}
});
pack();
}
public static void main(String[] args) {
roomadd w=new roomadd();
w.setVisible(true);
}
}
大概改改就可以是你的需要的了
发布于 2022-10-10 21:54:20 回复
发布于 2022-10-10 21:40:57 回复