版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
资料内容仅供您学习参考,如有不当之处,请联系改正或者删除。山东建筑大学计算机科学与技术学院程序设计实用案例选讲大作业说明书题目:房地产中介管理系统课程:程序设计实用案例选讲院(部):计算机科学与技术专业:网络工程班级:网络131学生姓名:高雷学号:1113033指导教师:袁卫华完成日期:/01/08目录房地产中介管理系统 1一、问题描述 1二、设计思想 1三、系统结构 1四、程序流程(或模块划分) 2五、源程序 3六、系统测试及操作界面 22结论 30参考文献 31房地产中介管理系统一、问题描述某房屋中介公司主要的业务包括房屋出租和二手房买卖,请编程实现”房屋中介管理系统”,具体要求如下:一、房源基本信息管理,(房屋编号,户型(如两室一厅,三室两厅),具体地址(坐落位置),建造年月,状态(待售,待出租,已售,已出租等),价格(租金/月或售价),房主姓名,联系方式等),请编程实现这些基本信息的增、删、改、查等操作。二、房屋出租操作,对于所有”待出租”状态的房屋,能够执行出租操作,其状态转换为”已出租”,根据出租的月数,计算租金,并征收中介费(中介费一般等于一个月的租金);处于”已出租”状态的房屋不能执行该操作。房屋出售操作,对于所有”待出售”状态的房屋,能够执行出手操作,其状态转换为”已售”,根据房价和中介费计算方法(自己查),计算应该征收的中介费二、设计思想此管理系统主要实现对房源的增删改查四个主要功能,以及将数据输出保存文件。本系统分为管理员和普通用户两个类别用户,管理员能够对房源信息的增删改查等操作,普通用户无法更改信息,能够查询信息。另外,针对大量的用户,能够注册新的用户。管理员在添加新的房源信息时需要确保输入每一个信息,否则会提醒管理员输入完整。修改信息能够修改一个信息,也能够同时修改多个信息,修改成功会依次提示。查询时主要能够经过查询户型以及房屋状态查询。用户查询到需要的房源时经过管理员修改房源信息,并将房屋的状态改变出租或出售给用户。系统结构房地产管理系统包括7个主要类:BuildingSystem.Java:主操作界面,登录界面、选择用户类型等信息Admin.java管理员登录界面Admin1.java管理员操作界面RegisterException.java用于两次密码不一致时抛异常User.java普通用户登录界面User1.java普通用户操作界面ZhuCe.java新用户注册四、程序流程(或模块划分)图4-1程序流程图五、源程序BuildingStystempackagegaolei;publicclassBuildingSystemimplementsRunnable,ActionListener{ JFramef1; JPanelp1,p2,p3,p4; JLabell21; JButtonfunction1,function2,function3,function4; JButtonend; ThreadscollWorsThread; booleanstopScorlling; BuildingSystem(){ f1=newJFrame("--房屋中介管理系统--"); p1=newJPanel(); p1.setBackground(Color.white); p1.setLayout(newGridLayout(5,1,5,5)); function1=newJButton("【管理员登录通道】"); p1.add(function1); function1.setBackground(Color.getHSBColor(100,152,188)); function1.addActionListener(this); function2=newJButton("【普通用户登陆通道】"); function2.setBackground(Color.getHSBColor(100,152,188)); p1.add(function2); function2.addActionListener(this); function3=newJButton("【新用户注册】"); p1.add(function3); function3.setBackground(Color.getHSBColor(100,152,188)); function3.addActionListener(this); function4=newJButton("【系统信息】"); p1.add(function4); function4.setBackground(Color.getHSBColor(100,152,188)); function4.addActionListener(this); end=newJButton("【退出程序】"); p1.add(end); end.setBackground(Color.getHSBColor(100,152,188)); end.addActionListener(this); f1.add(BorderLayout.EAST,p1); p2=newJPanel(); p2.setBackground(Color.getHSBColor(100,10,255)); p2.setLayout(newGridLayout(3,1)); JLabelempty1=newJLabel(""); p2.add(empty1); l21=newJLabel("高雷房地产公司欢迎您O(∩_∩)O~"); l21.setForeground(Color.DARK_GRAY); l21.setFont(newFont("华文行楷",1,17)); p2.add(l21); JLabelempty2=newJLabel(""); p2.add(empty2); f1.add(BorderLayout.NORTH,p2); p3=newJPanel(){ privatestaticfinallongserialVersionUID=1L; publicvoidpaint(Graphicsg){ ImageIconicon=newImageIcon("F:\\Javainformation\\12.png"); Imageimage=icon.getImage(); g.drawImage(image,0,0,null); }}; p3.setBackground(Color.white); JLabelnn=newJLabel(""); p3.add(nn); f1.add(BorderLayout.SOUTH,p3); p4=newJPanel(){ privatestaticfinallongserialVersionUID=1L; publicvoidpaint(Graphicsg){ ImageIconicon=newImageIcon("F:\\Javainformation\\12.png"); Imageimage=icon.getImage(); g.drawImage(image,0,0,null);} }; p4.setBackground(Color.white); f1.add(BorderLayout.CENTER,p4); scollWorsThread=newThread(this); scollWorsThread.start(); f1.setResizable(false); f1.setSize(470,285); f1.setVisible(true); f1.setLocation(400,180); f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);} publicvoidrun(){ while(true){ intx=l21.getBounds().x; inty=l21.getBounds().y; x+=5; l21.setLocation(x,y); if(x>420){ x=0; l21.setLocation(x,y);} try{ Thread.sleep(1000); }catch(InterruptedExceptione){} if(stopScorlling==true){ return;} }} publicvoidactionPerformed(ActionEvente){ try{ if(e.getSource()==function1){ newAdmin(); }elseif(e.getSource()==function2){ newUser(); }elseif(e.getSource()==function3){ newZhuCe(); }elseif(e.getSource()==function4){ JOptionPane.showMessageDialog(null,this,"系统简介",3); }elseif(e.getSource()==end){ System.exit(1);} }catch(Exceptione1){ e1.printStackTrace(); }} publicstaticvoidmain(String[]args)throwsException{ newBuildingSystem(); }}Adminpackagegaolei;publicclassBuildingSystemimplementsRunnable,ActionListener{ JFramef1; JPanelp1,p2,p3,p4; JLabell21; JButtonfunction1,function2,function3,function4; JButtonend; ThreadscollWorsThread; booleanstopScorlling; BuildingSystem(){ f1=newJFrame("--房屋中介管理系统--"); p1=newJPanel(); p1.setBackground(Color.white); p1.setLayout(newGridLayout(5,1,5,5)); function1=newJButton("【管理员登录通道】"); p1.add(function1); function1.setBackground(Color.getHSBColor(100,152,188)); function1.addActionListener(this); function2=newJButton("【普通用户登陆通道】"); function2.setBackground(Color.getHSBColor(100,152,188)); p1.add(function2); function2.addActionListener(this); function3=newJButton("【新用户注册】"); p1.add(function3); function3.setBackground(Color.getHSBColor(100,152,188)); function3.addActionListener(this); function4=newJButton("【系统信息】"); p1.add(function4); function4.setBackground(Color.getHSBColor(100,152,188)); function4.addActionListener(this); end=newJButton("【退出程序】"); p1.add(end); end.setBackground(Color.getHSBColor(100,152,188)); end.addActionListener(this); f1.add(BorderLayout.EAST,p1); p2=newJPanel(); p2.setBackground(Color.getHSBColor(100,10,255)); p2.setLayout(newGridLayout(3,1)); JLabelempty1=newJLabel(""); p2.add(empty1); l21=newJLabel("高雷房地产公司欢迎您O(∩_∩)O~"); l21.setForeground(Color.DARK_GRAY); l21.setFont(newFont("华文行楷",1,17)); p2.add(l21); JLabelempty2=newJLabel(""); p2.add(empty2); f1.add(BorderLayout.NORTH,p2); p3=newJPanel(){ privatestaticfinallongserialVersionUID=1L; publicvoidpaint(Graphicsg){ ImageIconicon=newImageIcon("F:\\Javainformation\\12.png"); Imageimage=icon.getImage(); g.drawImage(image,0,0,null);}}; p3.setBackground(Color.white); JLabelnn=newJLabel(""); p3.add(nn); f1.add(BorderLayout.SOUTH,p3); p4=newJPanel(){ privatestaticfinallongserialVersionUID=1L; publicvoidpaint(Graphicsg){ ImageIconicon=newImageIcon("F:\\Javainformation\\12.png"); Imageimage=icon.getImage(); g.drawImage(image,0,0,null); } }; p4.setBackground(Color.white); f1.add(BorderLayout.CENTER,p4) scollWorsThread=newThread(this); scollWorsThread.start(); f1.setResizable(false); f1.setSize(470,285); f1.setVisible(true); f1.setLocation(400,180); f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } publicvoidrun(){ while(true){ intx=l21.getBounds().x; inty=l21.getBounds().y; x+=5; l21.setLocation(x,y); if(x>420){ x=0; l21.setLocation(x,y);} try{ Thread.sleep(1000); }catch(InterruptedExceptione){} if(stopScorlling==true){ return; }}} publicvoidactionPerformed(ActionEvente){ try{ if(e.getSource()==function1){ newAdmin(); }elseif(e.getSource()==function2){ newUser(); }elseif(e.getSource()==function3){ newZhuCe(); }elseif(e.getSource()==function4){ JOptionPane.showMessageDialog(null,this,"系统简介",3); }elseif(e.getSource()==end){ System.exit(1);} }catch(Exceptione1){ e1.printStackTrace(); }} publicstaticvoidmain(String[]args)throwsException{ newBuildingSystem(); } }Admin1packagegaolei;;publicclassAdmin1extendsJFrameimplementsActionListener{ JFramef; JLabeljl,j2,j3,j4,j5,j6,j7,j8; JTextFieldjf1,jf2,jf3,jf4,jf5,jf6,jf7,jf8; JButtonjb1,jb2,jb3,jb4,jb5,jb6,jb7,jb8; JPaneljp1; intid; intm=0; JTextArearesult; StringDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; StringconnectionStr="jdbc:odbc:HouseInfo1"; Statementstmt=null,s1=null; Connectioncon=null; ResultSetrs=null; PreparedStatementstmt1=null,stmt2=null,stmt3=null,stmt4=null; publicAdmin1(){ f=newJFrame("房源基本信息"); jp1=newJPanel(); jp1.setLayout(newGridLayout(5,2)); jl=newJLabel("编号:"); j2=newJLabel("房主姓名:"); j3=newJLabel("联系方式:"); j4=newJLabel("坐落位置:"); j5=newJLabel("建造年月:"); j6=newJLabel("价格:"); j7=newJLabel("户型"); j8=newJLabel("房屋状态"); jf1=newJTextField(10); jf2=newJTextField(10); jf3=newJTextField(10); jf4=newJTextField(10); jf5=newJTextField(10); jf6=newJTextField(10); jf7=newJTextField(10); jf8=newJTextField(10); jb1=newJButton("录入"); jb2=newJButton("修改"); jb3=newJButton("删除"); jb4=newJButton("查询"); jp1.add(jl); jp1.add(jf1); jp1.add(j2); jp1.add(jf2); jp1.add(j3); jp1.add(jf3); jp1.add(j4); jp1.add(jf4); jp1.add(j5); jp1.add(jf5); jp1.add(j6); jp1.add(jf6); jp1.add(j7); jp1.add(jf7); jp1.add(j8); jp1.add(jf8); jp1.add(jb1); jp1.add(jb2); jp1.add(jb3); jp1.add(jb4); jb1.addActionListener(this); jb2.addActionListener(this); jb3.addActionListener(this); jb4.addActionListener(this); f.add(BorderLayout.NORTH,jp1); result=newJTextArea(60,100); result.setEditable(false); JScrollPanejScrollPane=newJScrollPane(result); f.add(BorderLayout.CENTER,jScrollPane); f.setSize(500,600); f.setLocation(600,80); f.setVisible(true); f.validate();} publicvoidinsert(){ intm=0; try{ Class.forName(DBDriver);//加载驱动器表示式 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} Stringid=jf1.getText(); Stringname=jf2.getText(); Stringtel=jf3.getText(); Stringloc=jf4.getText(); Stringriqi=jf5.getText(); Stringprice=jf6.getText(); Stringtype=jf7.getText(); Stringzt=jf8.getText(); if(!id.equals("")&&!name.equals("")&&!tel.equals("")&&!loc.equals("")&&!riqi.equals("")&&!price.equals("")&&!type.equals("")&&!zt.equals("")){ try{ con=DriverManager.getConnection(connectionStr,"","");//建立数据库连接 Stringsql1="INSERTINTOhouse(id,name,tel,loc,riqi,price,type,zt)values(?,?,?,?,?,?,?,?)"; PreparedStatementstmt1=con.prepareStatement(sql1); stmt1.setString(1,id); stmt1.setString(2,name); stmt1.setString(3,tel); stmt1.setString(4,loc); stmt1.setString(5,riqi); stmt1.setString(6,price); stmt1.setString(7,type); stmt1.setString(8,zt); stmt1.execute(); stmt1.close(); con.close(); m=1;} catch(SQLExceptione1){ e1.printStackTrace();}} if(m==1){ JOptionPane.showMessageDialog(this,"信息已经成功录入"); } if(m==0){ JOptionPane.showMessageDialog(this,"您输入的不符合要求");}} publicvoidxiugai(){ try{ Class.forName(DBDriver);//加载驱动器表示式 }catch(ClassNotFoundExceptione1){ e1.printStackTrace(); } intn=0; Stringid=jf1.getText(); Stringname=jf2.getText(); Stringtel=jf3.getText(); Stringloc=jf4.getText(); Stringriqi=jf5.getText(); Stringprice=jf6.getText(); Stringtype=jf7.getText(); Stringzt=jf8.getText(); if(!id.equals("")){ try{ con=DriverManager.getConnection(connectionStr,"","");//建立数据库连接 if(!name.equals("")){ Stringsql2="Updatehousesetname=?whereid=?"; stmt1=con.prepareStatement(sql2); stmt1.setString(2,id); stmt1.setString(1,name); stmt1.execute(); JOptionPane.showMessageDialog(this,"房主姓名已经成功修改"); } if(!tel.equals("")){ Stringsql3="Updatehousesettel=?whereid=?"; stmt1=con.prepareStatement(sql3); stmt1.setString(2,id); stmt1.setString(1,tel); stmt1.execute(); stmt1.close(); JOptionPane.showMessageDialog(this,"联系方式已经成功修改"); } if(!loc.equals("")){ Stringsql3="Updatehousesetloc=?whereid=?"; stmt1=con.prepareStatement(sql3); stmt1.setString(2,id); stmt1.setString(1,loc); stmt1.execute(); stmt1.close(); JOptionPane.showMessageDialog(this,"坐落位置已经成功修改"); } if(!riqi.equals("")){ Stringsql3="Updatehousesetriqi=?whereid=?"; stmt1=con.prepareStatement(sql3); stmt1.setString(2,id); stmt1.setString(1,riqi); stmt1.execute(); stmt1.close(); JOptionPane.showMessageDialog(this,"建造日期已经成功修改"); } if(!price.equals("")){ Stringsql3="Updatehousesetprice=?whereid=?"; stmt1=con.prepareStatement(sql3); stmt1.setString(2,id); stmt1.setString(1,price); stmt1.execute(); stmt1.close(); JOptionPane.showMessageDialog(this,"价格已经成功修改"); } if(!type.equals("")){ Stringsql3="Updatehousesettype=?whereid=?"; stmt1=con.prepareStatement(sql3); stmt1.setString(2,id); stmt1.setString(1,type); stmt1.execute(); stmt1.close(); JOptionPane.showMessageDialog(this,"户型已经成功修改"); } if(!zt.equals("")){ Stringsql3="Updatehousesetzt=?whereid=?"; stmt1=con.prepareStatement(sql3); stmt1.setString(2,id); stmt1.setString(1,zt); stmt1.execute(); stmt1.close(); JOptionPane.showMessageDialog(this,"房屋状态已经成功修改"); } con.close(); n=1; }catch(SQLExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace(); } } if(n==0){ JOptionPane.showMessageDialog(this,"您输入的不符合要求"); }} publicvoiddelete(){ intn=0; try{ Class.forName(DBDriver);//加载驱动器表示式 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} Stringid=jf1.getText(); Stringname=jf2.getText(); Stringtel=jf3.getText(); Stringloc=jf4.getText(); Stringriqi=jf5.getText(); Stringprice=jf6.getText(); Stringtype=jf7.getText(); Stringzt=jf8.getText(); if(!id.equals("")||!name.equals("")||!tel.equals("")||!loc.equals("")||!riqi.equals("")||!price.equals("")||!type.equals("")||!zt.equals("")) try{ con=DriverManager.getConnection(connectionStr,"","");//建立数据库连接 Stringsql2="deletefromhousewhereid=?"; stmt1=con.prepareStatement(sql2); stmt1.setString(1,id); stmt1.execute(); stmt1.close(); con.close(); n=1; }catch(SQLExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace();} if(n==1){ JOptionPane.showMessageDialog(this,"信息已经成功删除"); } if(n==0){ JOptionPane.showMessageDialog(this,"对不起,您输入的信息有误,未成功删除。"); } } publicvoidsearch(){ intn=0; try{ Class.forName(DBDriver);//加载驱动器表示式 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} Stringid=jf1.getText(); Stringname=jf2.getText(); Stringtel=jf3.getText(); Stringloc=jf4.getText(); Stringriqi=jf5.getText(); Stringprice=jf6.getText(); Stringtype=jf7.getText(); Stringzt=jf8.getText(); if(!id.equals("")||!name.equals("")||!tel.equals("")||!loc.equals("")||!riqi.equals("")||!price.equals("")||!type.equals("")||!zt.equals("")) try{ con=DriverManager.getConnection(connectionStr,"","");//建立数据库连接 Statementstmt=con.createStatement(); Stringsql="Select*fromhousewhereid="; sql=sql+"'"+id+"'"; rs=stmt.executeQuery(sql); while(rs.next()){ Stringid1=rs.getString("id"); Stringname1=rs.getString("name"); Stringtel1=rs.getString("tel"); Stringloc1=rs.getString("loc"); Stringriqi1=rs.getString("riqi"); Stringprice1=rs.getString("price"); Stringtype1=rs.getString("type"); Stringzt1=rs.getString("zt"); Stringstr="房屋编号"+id1+"\n客户姓名"+name1+"\n联系方式"+tel1 +"\n坐落位置"+loc1+"\n建造日期"+riqi1+"\n价格"+price1+"\n户型"+type1+"\n房屋状态"+zt1; result.append(str); result.append("\n"); } JOptionPane.showMessageDialog(this,"成功查询到所需信息"); stmt.close(); con.close(); n=1; }catch(SQLExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace();} if(n==0){ JOptionPane.showMessageDialog(this,"对不起,您所查询的信息不存在");}} publicstaticvoidmain(Stringargs[]){ newAdmin1();}publicvoidactionPerformed(ActionEvente){ if(e.getSource()==jb1){ insert();} if(e.getSource()==jb2){ xiugai(); } if(e.getSource()==jb3){ delete(); } if(e.getSource()==jb4){ search(); }}}RegisterExceptionpackagegaolei;publicclassRegisterExceptionextendsRuntimeException{ publicRegisterException(){ super("用于登录异常的情况,例如密码两次输入不一致等情况"); }}Userpackagegaolei;publicclassUserextendsJFrameimplementsActionListener{ JLabeljl1,jl2; JTextFieldjf1,jf2; JPaneljp1,jp2,jp3; JButtonjb; StringDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; StringconnectionStr="jdbc:odbc:NewUser"; Statementstmt=null,s1=null; Connectioncon=null; intnumber=0; User(){ number=0; setTitle("普通用户登陆"); setLayout(newFlowLayout()); jp1=newJPanel(); jp2=newJPanel(); jp3=newJPanel(); jl1=newJLabel("请输入账户ID:"); jp1.add(jl1); jf1=newJTextField(20); jp1.add(jf1); add(jp1); jl2=newJLabel("请输入密码:"); jp2.add(jl2); jf2=newJTextField(20); jp2.add(jf2); add(jp2); jb=newJButton("登陆"); jp3.add(jb); add(jp3); jb.addActionListener(this); jf1.addActionListener(this); jf2.addActionListener(this); setSize(350,200); setLocation(300,200); setVisible(true); validate();} publicvoidSelects(){ intm=0; try{ Class.forName(DBDriver);//加载驱动器 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} Stringid=jf1.getText(); Stringpassword=jf2.getText(); try{ con=DriverManager.getConnection(connectionStr,"",""); Statementstmt=con.createStatement(); ResultSetrs=null; if(!id.equals("")&&!password.equals("")){ StringselectsExpression1="select*fromuserwhereid="; selectsExpression1=selectsExpression1+"'"+id+"'"; rs=stmt.executeQuery(selectsExpression1); while(rs.next()){ Stringpassword1=rs.getString("password"); if(password1.equals(password)){ newUser1(); m=1; }} if(m==0){ JOptionPane.showMessageDialog(this,"没有该用户或者密码错误");} }else{ JOptionPane.showMessageDialog(this,"请输入完整信息!");} stmt.close(); con.close(); }catch(SQLExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace(); } publicvoidactionPerformed(ActionEvente){ if(e.getSource()==jb){ Selects(); }}}User1packagegaolei;publicclassUser1extendsJFrameimplementsActionListener{ JFramef; JLabeljl,j2,j3,j4,j5,j6; JTextFieldjf1,jf2,jf3,jf4,jf5,jf6; JButtonjb3,jb4,jb5,jb6,jb7,jb8; JPaneljp1; intid; intm=0; JTextArearesult; StringDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; StringconnectionStr="jdbc:odbc:HouseInfo1"; Statementstmt=null,s1=null; Connectioncon=null; ResultSetrs=null; PreparedStatementstmt1=null,stmt2=null,stmt3=null,stmt4=null; publicUser1(){ f=newJFrame("房源信息一览"); jp1=newJPanel(); jp1.setLayout(newGridLayout(6,2)); jl=newJLabel("坐落位置:"); j2=newJLabel("建造年月:"); j3=newJLabel("价格:"); j4=newJLabel("户型:"); j5=newJLabel("状态:"); jf1=newJTextField(10); jf2=newJTextField(10); jf3=newJTextField(10); jf4=newJTextField(10); jf5=newJTextField(10); jb3=newJButton("输出全部文件"); jb4=newJButton("查询"); jp1.add(jl); jp1.add(jf1); jp1.add(j2); jp1.add(jf2); jp1.add(j3); jp1.add(jf3); jp1.add(j4); jp1.add(jf4); jp1.add(j5); jp1.add(jf5); jp1.add(jb3); jp1.add(jb4); jb3.addActionListener(this); jb4.addActionListener(this); jf3.addActionListener(this); jf4.addActionListener(this); f.add(BorderLayout.NORTH,jp1); result=newJTextArea(60,100); result.setEditable(false); JScrollPanejScrollPane=newJScrollPane(result); f.add(BorderLayout.CENTER,jScrollPane); f.setSize(500,600); f.setLocation(600,80); f.setVisible(true); f.validate();} publicvoidsearch(){ intn=0; try{ Class.forName(DBDriver);//加载驱动器表示式 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} Stringloc=jf1.getText(); Stringriqi=jf2.getText(); Stringprice=jf3.getText(); Stringtype=jf4.getText(); Stringzt=jf5.getText(); if(!loc.equals("")||!riqi.equals("")||!price.equals("")||!type.equals("")||!zt.equals("")) try{ con=DriverManager.getConnection(connectionStr,"","");//建立数据库连接 Statementstmt=con.createStatement(); Stringsql="Select*fromhousewherezt="; sql=sql+"'"+zt+"'"; rs=stmt.executeQuery(sql); while(rs.next()){ Stringid1=rs.getString("id"); Stringname1=rs.getString("name"); Stringtel1=rs.getString("tel"); Stringloc1=rs.getString("loc"); Stringriqi1=rs.getString("riqi"); Stringprice1=rs.getString("price"); Stringtype1=rs.getString("type"); Stringzt1=rs.getString("zt"); Stringstr="房屋编号"+id1+"\n客户姓名"+name1+"\n联系方式"+tel1 +"\n坐落位置"+loc1+"\n建造日期"+riqi1+"\n价格"+price1+"\n户型"+type1+"\n房屋状态"+zt1; result.append(str); result.append("\n");} JOptionPane.showMessageDialog(this,"成功查询到所需信息"); stmt.close(); con.close(); n=1; }catch(SQLExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace();} if(n==0){ JOptionPane.showMessageDialog(this,"对不起,您所查询的信息不存在"); }} publicvoidlast()throwsIOException{ ResultSetrs=null; try{ Class.forName(DBDriver);//加载驱动器 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} try{ con=DriverManager.getConnection(connectionStr,"",""); Statementstmt=con.createStatement(); StringsqlExpression1="Select*fromhouse"; rs=stmt.executeQuery(sqlExpression1); FileWriterfw=newFileWriter("F:\\Javainformation\\h\\数据信息.txt"); BufferedWriterbw=newBufferedWriter(fw); while(rs.next()){ Stringid=rs.getString("id"); Stringname=rs.getString("name"); Stringtel=rs.getString("tel"); Stringloc=rs.getString("loc"); Stringriqi=rs.getString("riqi"); Stringprice=rs.getString("price"); StringresultStr2="房屋编号"+id+"\n客户姓名"+name+"\n联系方式"+tel +"\n坐落位置"+loc+"\n建造日期"+riqi+"\n价格"+price; bw.newLine(); bw.write(resultStr2); } bw.flush(); bw.close(); JOptionPane.showInputDialog(this,"客户信息已成功保存在文件E:/gaoleiTxt.txt里"); stmt.close(); con.close(); }catch(SQLExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace();}} publicstaticvoidmain(Stringargs[]){ newUser1();}publicvoidactionPerformed(ActionEvente){ if(e.getSource()==jb3){ try{ last(); }catch(IOExceptione1){ //TODOAuto-generatedcatchblock e1.printStackTrace(); } } if(e.getSource()==jb4){ search(); }}}ZhuCepackagegaolei;publicclassZhuCeextendsJFrameimplementsActionListener{ JFramef; JPaneljp1,jp2,jp3,jp4,jp5,jp6,jp7; JLabeljl1,jl2,jl3,jl4,jl5,jl6; JTextFieldjf1,jf2,jf3,jf4,jf5; JButtonjb,jb1,jb2; Stringid,password,passwordnum,personid,tel; StringDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; StringconnectionStr="jdbc:odbc:NewUser"; Statementstmt=null,s1=null; Connectioncon=null; ZhuCe(){ JFramef=newJFrame(); setTitle("--新用户注册--"); setLayout(newFlowLayout()); jp1=newJPanel(); jp2=newJPanel(); jp3=newJPanel(); jp4=newJPanel(); jp5=newJPanel(); jp6=newJPanel(); jp7=newJPanel(); jl1=newJLabel("请输入用户名"); jf1=newJTextField(15); jp1.add(jl1); jp1.add(jf1); add(jp1); jl2=newJLabel("请输入密码"); jf2=newJTextField(15); jp2.add(jl2); jp2.add(jf2); add(jp2); jl3=newJLabel("请确认密码"); jf3=newJTextField(15); jp3.add(jl3); jp3.add(jf3); add(jp3); jl4=newJLabel("请输入身份证号码"); jf4=newJTextField(15); jp4.add(jl4); jp4.add(jf4); add(jp4); jl5=newJLabel("请输入联系方式"); jf5=newJTextField(15); jp5.add(jl5); jp5.add(jf5); add(jp5); jl6=newJLabel("请再次检查所填信息,确保真实准确!"); jp7.add(jl6); add(jp7); jb=newJButton("确定"); jp6.add(jb); jb1=newJButton("返回主界面"); jp6.add(jb1); add(jp6); jf1.addActionListener(this); jf2.addActionListener(this); jf3.addActionListener(this); jf4.addActionListener(this); jf5.addActionListener(this); jb.addActionListener(this); jb1.addActionListener(this); setSize(400,400); setLocation(300,200); setVisible(true); validate(); publicvoidAdd(){ ResultSetrs=null; try{ C
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 泳池安全协议书
- 泌尿外科肾结石治疗方案探讨
- 更年期综合征的综合治疗与护理方案
- 特殊教育发音训练
- 妇科肿瘤手术后康复训练方案培训
- 眼科护理查房流程
- 2026华侨城集团春季校园招聘备考题库及1套参考答案详解
- 重症医学科(ICU)意识障碍护理规范
- 2026北京大学房地产管理部招聘1名劳动合同制人员备考题库附答案详解(综合卷)
- 2026安徽安庆市皖宜项目咨询管理有限公司招聘派遣人员3人备考题库带答案详解(黄金题型)
- 纺织行业的纺织品生产技术培训资料
- 医院整形科室管理制度
- 高考生物解题技巧1-题干信息的分析技巧
- 涉氨制冷企业安全管理培训
- 3、4号锅炉引风机更换叶轮施工方案
- 大众标准目录(中文)
- 如何进行网络招聘和电话邀约讲义课件
- 连续性血液净化设备技术要求
- 行政法与行政诉讼法培训教案
- 译林版六年级下册英语单元课文填空
- 小学科学粤教粤科版六年级下册《第5课设计与制作:鸡蛋包装盒》课件
评论
0/150
提交评论