java实现客房管理系统
本文实例为大家分享了java实现客房管理系统的具体代码,供大家参考,具体内容如下
AddClient.java
importjava.awt.BorderLayout; importjava.awt.Color; importjava.awt.Container; importjava.awt.FlowLayout; importjava.awt.GridLayout; importjava.awt.event.ActionEvent; importjava.awt.event.ActionListener; importjava.sql.Connection; importjava.sql.DriverManager; importjava.sql.ResultSet; importjava.sql.Statement; importjava.util.Calendar; importjavax.naming.spi.DirStateFactory.Result; importjavax.swing.BorderFactory; importjavax.swing.Box; importjavax.swing.ButtonGroup; importjavax.swing.JButton; importjavax.swing.JDialog; importjavax.swing.JFrame; importjavax.swing.JLabel; importjavax.swing.JOptionPane; importjavax.swing.JPanel; importjavax.swing.JRadioButton; importjavax.swing.JTextField; importjavax.swing.UIManager; importjavax.swing.UIManager.LookAndFeelInfo; publicclassAddClientextendsJFrameimplementsActionListener{ JTextFieldsname,ID,age,home_addr,employer,phone,cno,rno,intime,outtime,days,cashpledge; JButtonsave,cancel,save1; JPanelpl,pl1,pl2,pl3,pl4,pl5,pl6,pl7,pl8,pl9,pl10,pl11,pl12,pl13,pl14,pl15,pl16; JRadioButtonman,wuman,yes,no; ButtonGroupgroup,group1; Stringsex,vip; intk,k1,k2; publicAddClient(){ pl=newJPanel(); pl1=newJPanel(); pl2=newJPanel(); pl3=newJPanel(); pl4=newJPanel(); pl5=newJPanel(); pl6=newJPanel(); pl7=newJPanel(); pl8=newJPanel(); pl9=newJPanel(); pl10=newJPanel(); pl11=newJPanel(); pl12=newJPanel(); pl13=newJPanel(); pl14=newJPanel(); pl15=newJPanel(); pl16=newJPanel(newFlowLayout(FlowLayout.CENTER,20,20)); sname=newJTextField(15); ID=newJTextField(15); age=newJTextField(15); home_addr=newJTextField(15); employer=newJTextField(15); phone=newJTextField(15); cno=newJTextField(15); rno=newJTextField(15); intime=newJTextField(15); outtime=newJTextField(15); days=newJTextField(15); cashpledge=newJTextField(15); group=newButtonGroup(); group1=newButtonGroup(); man=newJRadioButton("男",true); wuman=newJRadioButton("女",false); yes=newJRadioButton("是",true); no=newJRadioButton("否",false); group.add(man); group.add(wuman); group1.add(yes); group1.add(no); pl1.add(newJLabel("姓名:",JLabel.RIGHT)); pl1.add(sname); pl2.add(newJLabel("身份证号:",JLabel.RIGHT)); pl2.add(ID); pl3.add(newJLabel("性别:",JLabel.RIGHT)); pl3.add(man); pl3.add(wuman); pl4.add(newJLabel("VIP客户:")); pl4.add(yes); pl4.add(no); pl5.add(newJLabel("年龄:",JLabel.RIGHT)); pl5.add(age); pl6.add(newJLabel("家庭地址:",JLabel.RIGHT)); pl6.add(home_addr); pl7.add(newJLabel("工作单位:",JLabel.RIGHT)); pl7.add(employer); pl8.add(newJLabel("手机号:",JLabel.RIGHT)); pl8.add(phone); pl.setBorder(BorderFactory.createTitledBorder("客户信息")); pl.setLayout(newGridLayout(4,2,10,10)); pl.add(pl1); pl.add(pl2); pl.add(pl3); pl.add(pl4); pl.add(pl5); pl.add(pl8); pl.add(pl7); pl.add(pl6); pl9.add(newJLabel("房号:",JLabel.RIGHT)); pl9.add(rno); pl10.add(newJLabel("入住时间:",JLabel.RIGHT)); pl10.add(intime); pl11.add(newJLabel("预离店时间",JLabel.RIGHT)); pl11.add(outtime); pl12.add(newJLabel("入住天数:",JLabel.RIGHT)); pl12.add(days); pl13.add(newJLabel("预交押金:",JLabel.RIGHT)); pl13.add(cashpledge); pl14.add(newJLabel("入住序号:",JLabel.RIGHT)); pl14.add(cno); pl15.setBorder(BorderFactory.createTitledBorder("客户入住信息")); pl15.setLayout(newGridLayout(3,2,15,15)); pl15.add(pl14); pl15.add(pl9); pl15.add(pl10); pl15.add(pl11); pl15.add(pl12); pl15.add(pl13); save=newJButton("登记入住"); cancel=newJButton("取消"); save1=newJButton("添加家属"); save.addActionListener(this); cancel.addActionListener(this); save1.addActionListener(this); pl16.add(save); pl16.add(save1); pl16.add(cancel); add(pl,BorderLayout.NORTH); add(pl15,BorderLayout.CENTER); add(pl16,BorderLayout.SOUTH); setBounds(600,300,600,600); setTitle("客户入住信息"); setVisible(true); } @Override publicvoidactionPerformed(ActionEvente){ if(e.getSource()==save){ intresult=JOptionPane.showConfirmDialog(null,"确认提交吗","温馨提示",JOptionPane.YES_NO_OPTION); if(result==0){ if(man.isSelected()){ sex="男"; } else{ sex="女"; } if(yes.isSelected()){ vip="是"; } else{ vip="否"; } try { Class.forName(Url.driver); Connectioncon=DriverManager.getConnection(Url.url,Url.username,Url.userpwd); Statementsql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); k=sql.executeUpdate("insertintoClientvalues('"+sname.getText()+"','"+ID.getText()+"','"+sex+"','"+age.getText()+"','"+home_addr.getText()+"','"+employer.getText()+"','"+vip+"','"+phone.getText()+"')"); k1=sql.executeUpdate("insertintoCheck_in(Cno,Rno,Intime,Outtime,Dayss,Cashpledge)values('"+cno.getText()+"','"+rno.getText()+"','"+intime.getText()+"','"+outtime.getText()+"','"+days.getText()+"','"+cashpledge.getText()+"')"); k2=sql.executeUpdate("insertintoType_invalues('"+cno.getText()+"','"+ID.getText()+"')"); if(k==1&&k1==1&&k2==1){ intresult1=JOptionPane.showConfirmDialog(null,"入住成功!是否添加家属信息?","温馨提示",JOptionPane.YES_NO_OPTION); if(result1==0){ ID.setText(""); sname.setText(""); age.setText(""); home_addr.setText(""); phone.setText(""); employer.setText(""); } else{ dispose(); } } }catch(Exceptione1){ JOptionPane.showMessageDialog(this,"入住失败"); } } } if(e.getSource()==cancel){ dispose(); } if(e.getSource()==save1){ intresult=JOptionPane.showConfirmDialog(null,"确认提交吗","温馨提示",JOptionPane.YES_NO_OPTION); if(result==0){ if(man.isSelected()){ sex="男"; } else{ sex="女"; } if(yes.isSelected()){ vip="是"; } else{ vip="否"; } try { Class.forName(Url.driver); Connectioncon=DriverManager.getConnection(Url.url,Url.username,Url.userpwd); Statementsql=con.createStatement(); k=sql.executeUpdate("insertintoClientvalues('"+sname.getText()+"','"+ID.getText()+"','"+sex+"','"+age.getText()+"','"+home_addr.getText()+"','"+employer.getText()+"','"+vip+"','"+phone.getText()+"')"); k2=sql.executeUpdate("insertintoType_invalues('"+cno.getText()+"','"+ID.getText()+"')"); if(k==1&&k2==1){ intresult1=JOptionPane.showConfirmDialog(null,"入住成功!是否继续添加家人信息?","温馨提示",JOptionPane.YES_NO_OPTION); if(result1==0){ ID.setText(""); sname.setText(""); age.setText(""); home_addr.setText(""); phone.setText(""); employer.setText(""); } else{ dispose(); } } }catch(Exceptione1){ JOptionPane.showMessageDialog(this,"添加失败"); } } } } }
AdminFrame.java
importjava.awt.BorderLayout; importjava.awt.Container; importjava.awt.event.ActionEvent; importjava.awt.event.ActionListener; importjavax.swing.ImageIcon; importjavax.swing.JDialog; importjavax.swing.JFrame; importjavax.swing.JLabel; importjavax.swing.JMenu; importjavax.swing.JMenuBar; importjavax.swing.JMenuItem; importjavax.swing.JPanel; classAdminFrameextendsJDialogimplementsActionListener{ JLabellabel=newJLabel(); JMenuBarmBar=newJMenuBar(); privateJMenuQuarto,message,Clinet; privateJMenuItemitem1,item2,item3,item4,item5,item6,item7,item8,item9; JPanelpl1; Containercon; AdminFrame(){ pl1=newJPanel(); setJMenuBar(mBar); ImageIconicon=newImageIcon("src/picture/1.jpg"); label.setIcon(icon); label.setBounds(0,0,600,500); pl1.add(label); add(pl1); setBounds(600,300,600,500); Quarto=newJMenu("客房操作"); message=newJMenu("信息查询"); Clinet=newJMenu("统计客房相关信息"); mBar.add(Quarto); mBar.add(message); mBar.add(Clinet); item3=newJMenuItem("查询客房"); item1=newJMenuItem("入住登记"); item2=newJMenuItem("退房操作"); Quarto.add(item1); Quarto.addSeparator(); Quarto.add(item2); Quarto.addSeparator(); Quarto.add(item3); item4=newJMenuItem("客人信息查询"); item5=newJMenuItem("客房时间查询"); item6=newJMenuItem("客人费用查询"); message.add(item4); message.addSeparator(); message.add(item5); message.addSeparator(); message.add(item6); item7=newJMenuItem("各类房型入住情况"); item8=newJMenuItem("各月份客房收入"); Clinet.add(item7); Clinet.addSeparator(); Clinet.add(item8); item1.addActionListener(this); item2.addActionListener(this); item3.addActionListener(this); item4.addActionListener(this); item5.addActionListener(this); item6.addActionListener(this); item7.addActionListener(this); item8.addActionListener(this); setVisible(false); setTitle("客房管理系统"); validate(); } @Override publicvoidactionPerformed(ActionEvente){ if(e.getSource()==item1){ AddClientstu=newAddClient(); stu.setVisible(true); } if(e.getSource()==item2){ Leftleft=newLeft(); left.setVisible(true); } if(e.getSource()==item3){ QueryRoomqr=newQueryRoom(); qr.setVisible(true); } if(e.getSource()==item4){ QueryClientqc=newQueryClient(); qc.setVisible(true); } if(e.getSource()==item5){ QueryTimeqt=newQueryTime(); qt.setVisible(true); } if(e.getSource()==item6){ QueryCostqc=newQueryCost(); qc.setVisible(true); } if(e.getSource()==item7){ StatisticsInformationsi=newStatisticsInformation(); si.setVisible(true); } if(e.getSource()==item8){ Incomeincome=newIncome(); income.setVisible(true); } } }
完整代码:java实现客房管理系统
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。