数据库宾馆系统.docx_第1页
数据库宾馆系统.docx_第2页
数据库宾馆系统.docx_第3页
数据库宾馆系统.docx_第4页
数据库宾馆系统.docx_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Myeclipse图,SQL图登陆界面:猫是登陆,welcome是退出密码错误的提示界面:系统主界面:点击预定按钮,弹出预定界面,显示的表为预定表中所有元组:数据库中yuding表的设计:数据库中yuding表中元组编辑:预定增加界面:添加成功提示:可以看到添加的“100,ii,”男元组在数据库中也可以看到新加的元组:修改房间类型界面:修改成功:数据库中也一样被修改:修改可以修改除了身份证号之外的属性删除按钮,选中要删除的元组,点击删除按钮就可以删除成功删除身份证号为003的一行元组界面:数据库中被删除后的所有元组:点击查询按钮的查询界面:输入所要查询的身份证号查询结果界面: 点击退出按钮,弹出主界面:点击入住按钮后的界面:点击退房按钮后的界面:输入要退房的房号以及该房间入住时间天数:数据库中ruzhu表的元组编辑:数据库中ruzhu的属性设置:数据库中zhangdan表中的属性设置:数据库中zhangdan表中元组设置:各房间类型的定价:退房金额查看:Myeclipse主要代码:Login按钮的监听器:登录名为sa,且密码为123才可登陆:login.addActionListener(new ActionListener()public void actionPerformed(ActionEvent evt)/login 事件处理String pass=new String(password.getPassword();if(username.getText().equals(sa)&pass.equals(123)welcome hello=new welcome();hello.setVisible(true);elseJOptionPane.showMessageDialog(null, 你输入的密码没有通过验证););主界面的三个按钮的监听器代码编写:JPanel cont1=new JPanel(new GridLayout(1,3);b1=new JButton(预定);b2=new JButton(入住);b3=new JButton(退房);cont1.add(b1);cont1.add(b2);cont1.add(b3);cont.add(cont1);b1.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) ydselect yd=new ydselect();yd.setVisible(true););b2.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) rzselect rz=new rzselect();rz.setVisible(true););b3.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) zdselect rz=new zdselect();rz.setVisible(true););预定界面的五个按钮:a1=new JButton(new ImageIcon(tianjia.png);a1.setToolTipText(添加);a1.setFocusable(false);a1.setHorizontalTextPosition(SwingConstants.CENTER);a1.setVerticalTextPosition(SwingConstants.BOTTOM);a2=new JButton(new ImageIcon(xiugai.png);a2.setToolTipText(修改);a2.setFocusable(false);a2.setHorizontalTextPosition(SwingConstants.CENTER);a2.setVerticalTextPosition(SwingConstants.BOTTOM);a3=new JButton(new ImageIcon(shanchu.png);a3.setToolTipText(删除);a3.setFocusable(false);a3.setHorizontalTextPosition(SwingConstants.CENTER);a3.setVerticalTextPosition(SwingConstants.BOTTOM);a4=new JButton(new ImageIcon(chaxun.png);a4.setToolTipText(查询);a4.setFocusable(false);a4.setHorizontalTextPosition(SwingConstants.CENTER);a4.setVerticalTextPosition(SwingConstants.BOTTOM);x1=new JButton(new ImageIcon(tuichu.png);x1.setToolTipText(退出);x1.setFocusable(false);x1.setHorizontalTextPosition(SwingConstants.CENTER);x1.setVerticalTextPosition(SwingConstants.BOTTOM);tool=new JToolBar();tool.add(a1);tool.add(a2);tool.add(a3);tool.add(a4);tool.add(x1);tool.setRollover(true);getContentPane().add(tool,BorderLayout.NORTH);/cont.add(y2);x1.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) welcome ys=new welcome();ys.setVisible(true););a1.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)yudingadd radd=new yudingadd();radd.setVisible(true);dispose(););a2.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)int i,j,index=0,count=0;db dbcon=new db();if(table.getCellEditor()!=null)table.getCellEditor().stopCellEditing();tryString sql=update yuding set 姓名=?,性别=?,入住时间=?,退房时间=?,房间类型=? where 身份证号=?;PreparedStatement presta=dbcon.PreparedStatement(sql);count=tablemodel.getEditedIndex().size();if(count0)for(i=0;icount;i+)for(j=1;j0)int selRowIndexs=table.getSelectedRows();java.sql.PreparedStatement presta=dbcon.PreparedStatement(delete from yuding where 身份证号=?);for(int i=0;iselRowIndexs.length;i+)selRowIndexsi=selRowIndexsi-i;presta.setString(1,table.getValueAt(selRowIndexsi,0).toString();presta.addBatch();DefaultTableModel tablemodel=(DefaultTableModel)table.getModel();tablemodel.removeRow(selRowIndexsi);presta.executeBatch();catch(SQLException sqle)System.out.println(sqle.toString(););a4.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)yuding radd=new yuding();radd.setVisible(true);dispose(););查询按钮的监听器:y1=new JButton(查询);/cont1.add(y1);cont.add(y1,east);/cont.add(y2);y1.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) ydsearch ys=new ydsearch();ys.setVisible(true););查询传递的身份证号:public static String getx()return id.getText().toString();查询结果表的代码:dbcon=new db();ResultSet rs=dbcon.executeQuery(select * from yuding );ResultSetMetaData rsmd=rs.getMetaData();int Colnum=rsmd.getColumnCount();int i;for(i=1;i=Colnum;i+)tableModel.addColumn(rsmd.getColumnName(i);ArrayList v=new ArrayList();while(rs.next()ydentity yd=new ydentity();yd.setId(rs.getString(身份证号);yd.setName(rs.getString(姓名);yd.setSex(rs.getString(性别);yd.setComedate(rs.getDate(入住时间);yd.setLeftdate(rs.getDate(退房时间);yd.setSize(rs.getString(房间类型);v.add(yd);System.out.print(yd.getId();rs.close();/yuding w=new yuding();String s=yuding.getx();System.out.print(s+aa);for(i=0;iv.size();i+)String m=v.get(i).getId().toString();System.out.print(m+aa);if(s.equals(m)/System.out.print(v.get(i).getId();tableModel.addRow(new Objectv.get(i).getId(),v.get(i).getName(),v.get(i).getSex(),v.get(i).getComedate(),v.get(i).getLeftdate(),v.get(i).getSize();/else break;/System.out.print(s);dbcon.closeConn();预定增加的代码:cont2.add(new JLabel(身份证号); /System.out.print(1);id=new JTextField(3);cont2.add(id);cont2.add(new JLabel(姓名);name=new JTextField(2);cont2.add(name);System.out.print(6);cont2.add(new JLabel(房间类型);size=new JTextField(2);cont2.add(size);System.out.print(1);System.out.print(2);cont2.add(new JLabel(性别);f=new JRadioButton (男,true);m=new JRadioButton (女);ButtonGroup bg=new ButtonGroup();bg.add(m);bg.add(f);sex=new JPanel(new GridLayout(1,2);sex.add(m);sex.add(f);cont2.add(sex);cont2.add(new JLabel(入住时间);year=new JTextField(10);month=new JComboBox();int i=1;for(i=1;i=12;i+)month.addItem(i);day=new JComboBox();for(i=1;i=31;i+)day.addItem(i);comedate=new JPanel();comedate.add(year);comedate.add(new JLabel(-);comedate.add(month);comedate.add(new JLabel(-);comedate.add(day);cont2.add(comedate);cont2.add(new JLabel(退房时间);year1=new JTextField(10);month1=new JComboBox();int x=1;for(x=1;x=12;x+)month1.addItem(x);day1=new JComboBox();for(x=1;x=31;x+)day1.addItem(x);leftdate=new JPanel();leftdate.add(year1);leftdate.add(new JLabel(-);leftdate.add(month1);leftdate.add(new JLabel(-);leftdate.add(day1);cont2.add(leftdate);ok=new JButton(添加);cancel=new JButton(取消);cont2.add(ok);cont2.add(cancel); System.out.print( 20);ok.addActionListener(new ActionListener()public void actionPerformed(ActionEvent evt)db dbcon=new db();System.out.print(9);tryString sql=insert into yuding values(?,?,?,?,?,?);PreparedStatement prestate=dbcon.PreparedStatement(sql);/prestate.setString(1,roomno.getText();System.out.print(roomno.getText();prestate.setString(1,id.getText();prestate.setString(2,name.getText();prestate.setString(3,(m.isSelected()?m.getText():f.getText();/prestate.setString(4,state.getText();prestate.setString(6,size.getText();System.out.print(8);prestate.setString(4,year.getText()+-+month.getSelectedItem()+-+day.getSelectedItem();/prestate.setString(1,roomno.getText();/prestate.setString(6,size.getText();System.out.print(8);prestate.setString(5,year1.getText()+-+month1.getSelectedItem()+-+day1.getSelectedItem();prestate.executeUpdate();JOptionPane.showMessageDialog(null,插入成功);System.out.print(3);dispose();ydselect rzs=new ydselect();rzs.setVisible(true);catch (SQLException e)System.out.println(e.toString(););预定实体类:private String id;private String name;private String sex;private Date comedate;private Date leftdate;private String size;入住与预定代码类似退房中房号与入住天数的输入以及传递的代码:public zdselect()super();this.setSize(300,200);this.setTitle(宾馆客房管理系统 退房);this.setLocationRelativeTo(getOwner();Container cont=getContentPane();cont.setLayout(new GridLayout(4,4);cont.add(new JLabel(房号:);roomno=new JTextField(3);x=roomno.getText();/x=getText;cont.add(roomno);cont.add(new JLabel(天数:);day=new JTextField(1);num=day.getText();cont.add(day);/JPanel cont1=new JPanel(new GridLayout(1,4);y1=new JButton(查询);/cont1.add(y1);cont.add(y1,east);/cont.add(y2);y1.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) zhangdan ys=new zhangdan();ys.setVisible(true););public static S

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论