




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
PAGE山東建筑大學(xué)計算機科學(xué)與技術(shù)學(xué)院程序設(shè)計實用案例選講大作業(yè)說明書題目:房地產(chǎn)中介管理系統(tǒng)課程:程序設(shè)計實用案例選講院(部):計算機科學(xué)與技術(shù)專業(yè):網(wǎng)絡(luò)工程班級:網(wǎng)絡(luò)131學(xué)生姓名:高雷學(xué)號:20131113033指導(dǎo)教師:袁衛(wèi)華完成日期:2014/01/08山東建筑大學(xué)計算機學(xué)院大作業(yè)設(shè)計說明書PAGEI目錄TOC\o”1—3”\h\z\uHYPERLINK\l”_Toc344062152"房地產(chǎn)中介管理系統(tǒng)1HYPERLINK\l”_Toc344062153”一、問題描述1HYPERLINK\l”_Toc344062154”二、設(shè)計思想1_Toc344062156”四、程序流程(或模塊劃分)2HYPERLINK\l”_Toc344062157”五、源程序3六、系統(tǒng)測試及操作界面22HYPERLINK\l”_Toc344062159”結(jié)論30,根據(jù)出租的月數(shù),計算租金,并征收中介費(中介費一般等于一個月的租金);處于“已出租”狀態(tài)的房屋不能執(zhí)行該操作。房屋出售操作,對于所有“待出售”狀態(tài)的房屋,可以執(zhí)行出手操作,其狀態(tài)轉(zhuǎn)換為“已售”,根據(jù)房價和中介費計算方法(自己查),計算應(yīng)該征收的中介費二、設(shè)計思想此管理系統(tǒng)主要實現(xiàn)對房源的增刪改查四個主要功能,以及將數(shù)據(jù)輸出保存文件。本系統(tǒng)分為管理員和普通用戶兩個類別用戶,管理員可以對房源信息的增刪改查等操作,普通用戶無法更改信息,可以查詢信息.另外,針對大量的用戶,可以注冊新的用戶。管理員在添加新的房源信息時需要確保輸入每一個信息,否則會提醒管理員輸入完整。修改信息可以修改一個信息,也可以同時修改多個信息,修改成功會依次提示。查詢時主要可以通過查詢戶型以及房屋狀態(tài)查詢。用戶查詢到需要的房源時通過管理員修改房源信息,并將房屋的狀態(tài)改變出租或出售給用戶.系統(tǒng)結(jié)構(gòu)房地產(chǎn)管理系統(tǒng)包括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("—-房屋中介管理系統(tǒng)-—”); 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("【系統(tǒng)信息】"); 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(”高雷房地產(chǎn)公司歡迎您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,”系統(tǒng)簡介”,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(”—-房屋中介管理系統(tǒng)—-”); 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(”【系統(tǒng)信息】”); 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(”高雷房地產(chǎn)公司歡迎您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,”系統(tǒng)簡介",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(”聯(lián)系方式:”); j4=newJLabel(”坐落位置:"); j5=newJLabel(”建造年月:”); j6=newJLabel("價格:”); j7=newJLabel("戶型"); j8=newJLabel(”房屋狀態(tài)”); 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);//加載驅(qū)動器表達式 }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,””,””);//建立數(shù)據(jù)庫連接 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,”信息已經(jīng)成功錄入”); } if(m==0){ JOptionPane.showMessageDialog(this,"您輸入的不符合要求”);}} publicvoidxiugai(){ try{ Class。forName(DBDriver);//加載驅(qū)動器表達式 }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,””,””);//建立數(shù)據(jù)庫連接 if(!name.equals(””)){ Stringsql2=”Updatehousesetname=?whereid=?”; stmt1=con.prepareStatement(sql2); stmt1.setString(2,id); stmt1.setString(1,name); stmt1。execute(); JOptionPane。showMessageDialog(this,”房主姓名已經(jīng)成功修改”); } 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,"聯(lián)系方式已經(jīng)成功修改”); } 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,”坐落位置已經(jīng)成功修改”); } 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,"建造日期已經(jīng)成功修改”); } 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,”價格已經(jīng)成功修改”); } 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,”戶型已經(jīng)成功修改”); } 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,"房屋狀態(tài)已經(jīng)成功修改”); } con。close(); n=1; }catch(SQLExceptione1){ //TODOAuto—generatedcatchblock e1。printStackTrace(); } } if(n==0){ JOptionPane。showMessageDialog(this,”您輸入的不符合要求”); }} publicvoiddelete(){ intn=0; try{ Class.forName(DBDriver);//加載驅(qū)動器表達式 }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,"","”);//建立數(shù)據(jù)庫連接 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,"信息已經(jīng)成功刪除”); } if(n==0){ JOptionPane.showMessageDialog(this,”對不起,您輸入的信息有誤,未成功刪除。"); } } publicvoidsearch(){ intn=0; try{ Class.forName(DBDriver);//加載驅(qū)動器表達式 }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,"”,””);//建立數(shù)據(jù)庫連接 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聯(lián)系方式———-—”+tel1 +”\n坐落位置--—--"+loc1+”\n建造日期—--——”+riqi1+”\n價格——--—"+price1+”\n戶型-———-”+type1+"\n房屋狀態(tài)-—-——————"+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);//加載驅(qū)動器 }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(”狀態(tài):"); 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);//加載驅(qū)動器表達式 }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,"”,””);//建立數(shù)據(jù)庫連接 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聯(lián)系方式-——--"+tel1 +"\n坐落位置—-—-—"+loc1+"\n建造日期—-—--”+riqi1+"\n價格-—-—--———”+price1+"\n戶型—-——-————”+type1+”\n房屋狀態(tài)-———”+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);//加載驅(qū)動器 }catch(ClassNotFoundExceptione1){ e1。printStackTrace();} try{ con=DriverManager.getConnection(connectionStr,”",””); Statementstmt=con.createStatement(); StringsqlExpression1="Select*fromhouse"; rs=stmt。executeQuery(sqlExpression1); FileWriterfw=newFileWriter("F:\\Javainformation\\h\\數(shù)據(jù)信息。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聯(liá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("請輸入聯(lián)系方式”); 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{ Class.forName(DBDriver);//加載驅(qū)動器 }catch(ClassNotFoundExceptione1){ e1.printStackTrace();} inta=0; try{ con=DriverManager。getConnection(connectionStr,””,"”); St
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 民用航空概論試題及答案
- 網(wǎng)店經(jīng)營權(quán)轉(zhuǎn)讓與電商平臺數(shù)據(jù)分析及優(yōu)化合同
- 獨家影視特效化妝高端假體租賃與推廣合作合同
- 2025年中國微孔格柵市場調(diào)查研究報告
- 2025年中國巡更管理系統(tǒng)市場調(diào)查研究報告
- 2025年中國家庭防盜報警主機市場調(diào)查研究報告
- 2025年中國太陽能多晶電池片市場調(diào)查研究報告
- 2025年中國多功能智能爐市場調(diào)查研究報告
- 2025年中國吸塑冰淇淋盒市場調(diào)查研究報告
- 2025年中國雙輥噴風(fēng)米機市場調(diào)查研究報告
- 吸脂手術(shù)護士的配合
- 數(shù)字貿(mào)易學(xué) 課件 第10章 開放型全球數(shù)字貿(mào)易平臺
- 肥厚型心肌病合并心衰
- 2014-2023年高考數(shù)學(xué)真題分享匯編:概率統(tǒng)計多選、填空題(理科)(解析版)(全國通用)
- 鉛鋅礦的礦石加工與冶煉技術(shù)改進
- 2024年安徽職校(中職組)中式烹飪賽項參考試題庫(含答案)
- 2024年上海鐵路局集團招聘筆試參考題庫附帶答案詳解
- 醫(yī)患溝通技巧與人文關(guān)懷課件
- 招投標顧問服務(wù)協(xié)議
- 蘇教版二年級下冊數(shù)學(xué)《認識角》教學(xué)設(shè)計(市級公開課)
- 過水箱涵施工方案
評論
0/150
提交評論