版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
.PAGE.XX建筑大學(xué)計算機(jī)科學(xué)與技術(shù)學(xué)院程序設(shè)計實用案例選講大作業(yè)說明書題目:房地產(chǎn)中介管理系統(tǒng)課程:程序設(shè)計實用案例選講院〔部:計算機(jī)科學(xué)與技術(shù)專業(yè):網(wǎng)絡(luò)工程班級:網(wǎng)絡(luò)131學(xué)生__高雷學(xué)號:20131113033指導(dǎo)袁衛(wèi)華完成日期:2014/01/08..目錄房地產(chǎn)中介管理系統(tǒng)1一、問題描述1二、設(shè)計思想1三、系統(tǒng)結(jié)構(gòu)1四、程序流程〔或模塊劃分2五、源程序3六、系統(tǒng)測試及操作界面22結(jié)論30參考文獻(xiàn)31房地產(chǎn)中介管理系統(tǒng)一、問題描述某房屋中介公司主要的業(yè)務(wù)包括房屋出租和二手房買賣,請編程實現(xiàn)"房屋中介管理系統(tǒng)",具體要求如下:一、房源基本信息管理,〔房屋編號,戶型〔如兩室一廳,三室兩廳,具體地址〔坐落位置,建造年月,狀態(tài)〔待售,待出租,已售,已出租等,價格〔租金/月或售價,房主姓名,聯(lián)系方式等,請編程實現(xiàn)這些基本信息的增、刪、改、查等操作。二、房屋出租操作,對于所有"待出租"狀態(tài)的房屋,可以執(zhí)行出租操作,其狀態(tài)轉(zhuǎn)換為"已出租",根據(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;uttonfunction1,function2,function3,function4;uttonend;ThreadscollWorsThread;booleanstopScorlling;BuildingSystem<>{ f1=newJFrame<"--房屋中介管理系統(tǒng)--">; p1=newJPanel<>; p1.setBackground<Color.white>; p1.setLayout<newGridLayout<5,1,5,5>>; function1=newutton<"[管理員登錄通道]">; p1.add<function1>; function1.setBackground<Color.getHSBColor<100,152,188>>; function1.addActionListener<this>; function2=newutton<"[普通用戶登陸通道]">; function2.setBackground<Color.getHSBColor<100,152,188>>; p1.add<function2>; function2.addActionListener<this>; function3=newutton<"[新用戶注冊]">; p1.add<function3>; function3.setBackground<Color.getHSBColor<100,152,188>>; function3.addActionListener<this>; function4=newutton<"[系統(tǒng)信息]">; p1.add<function4>; function4.setBackground<Color.getHSBColor<100,152,188>>; function4.addActionListener<this>; end=newutton<"[退出程序]">; 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; uttonfunction1,function2,function3,function4; uttonend; ThreadscollWorsThread; booleanstopScorlling; BuildingSystem<>{ f1=newJFrame<"--房屋中介管理系統(tǒng)--">; p1=newJPanel<>; p1.setBackground<Color.white>; p1.setLayout<newGridLayout<5,1,5,5>>; function1=newutton<"[管理員登錄通道]">; p1.add<function1>; function1.setBackground<Color.getHSBColor<100,152,188>>; function1.addActionListener<this>; function2=newutton<"[普通用戶登陸通道]">; function2.setBackground<Color.getHSBColor<100,152,188>>; p1.add<function2>; function2.addActionListener<this>; function3=newutton<"[新用戶注冊]">; p1.add<function3>; function3.setBackground<Color.getHSBColor<100,152,188>>; function3.addActionListener<this>; function4=newutton<"[系統(tǒng)信息]">; p1.add<function4>; function4.setBackground<Color.getHSBColor<100,152,188>>; function4.addActionListener<this>; end=newutton<"[退出程序]">; 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; utton1,2,3,4,5,6,7,8; 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>; 1=newutton<"錄入">; 2=newutton<"修改">; 3=newutton<"刪除">; 4=newutton<"查詢">; 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<1>; jp1.add<2>; jp1.add<3>; jp1.add<4>; 1.addActionListener<this>; 2.addActionListener<this>; 3.addActionListener<this>; 4.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ū)動器表達(dá)式 }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ū)動器表達(dá)式 }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ū)動器表達(dá)式 }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ū)動器表達(dá)式 }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<>==1>{ insert<>;} if<e.getSource<>==2>{ xiugai<>; } if<e.getSource<>==3>{ delete<>; } if<e.getSource<>==4>{ search<>; }}}RegisterExceptionpackagegaolei;publicclassRegisterExceptionextendsRuntimeException{ publicRegisterException<>{ super<"用于登錄異常的情況,例如密碼兩次輸入不一致等情況">; }}Userpackagegaolei;publicclassUserextendsJFrameimplementsActionListener{ JLabeljl1,jl2; JTextFieldjf1,jf2; JPaneljp1,jp2,jp3; utton; 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>; =newutton<"登陸">; jp3.add<>; add<jp3>; .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<>==>{ Selects<>; }}}User1packagegaolei;publicclassUser1extendsJFrameimplementsActionListener{ JFramef; JLabeljl,j2,j3,j4,j5,j6; JTextFieldjf1,jf2,jf3,jf4,jf5,jf6; utton3,4,5,6,7,8; 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>; 3=newutton<"輸出全部文件">; 4=newutton<"查詢">; 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<3>; jp1.add<4>; 3.addActionListener<this>; 4.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ū)動器表達(dá)式 }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<>==3>{ try{ last<>; }catch<IOExceptione1>{ //TODOAuto-generatedcatchblock e1.printStackTrace<>; } } if<e.getSource<>==4>{ search<>; }}}ZhuCepackagegaolei;publicclassZhuCeextendsJFrameimplementsActionListener{ JFramef; JPaneljp1,jp2,jp3,jp4,jp5,jp6,jp7; JLabeljl1,jl2,jl3,jl4,jl5,jl6; JTextFieldjf1,jf2,jf3,jf4,jf5; utton,1,2; 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<"請確認(rèn)密碼">; 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<"請再次檢查所填信息,確保真實準(zhǔn)確!">; jp7.add<jl6>; add<jp7>; =newutton<"確定">; jp6.add<>; 1=newutton<"返回主界面">; jp6.add<1>; add<jp6>; jf1.addActionListener<this>; jf2.addActionListener<this>; jf3.addActionListener<this>; jf4.addActionListener<this>; jf5.addActionListener<this>; .addActionListener<this>; 1.addActionListener<this>; setSize<400,400>; setLocation<300,2
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度綠色餐廳設(shè)計建造與運營合同3篇
- 2025年度網(wǎng)絡(luò)安全服務(wù)履約保函反擔(dān)保協(xié)議4篇
- 二零二四夏令營營地活動策劃與代理商執(zhí)行合同范本3篇
- 二零二五版二手房銷售代理與裝修設(shè)計服務(wù)合同3篇
- 二零二五版兼職研發(fā)人員知識產(chǎn)權(quán)保護(hù)與保密合同3篇
- 2025年度金融衍生品居間服務(wù)協(xié)議書4篇
- 一年級數(shù)學(xué)計算題專項練習(xí)集錦
- 家庭商業(yè)氛圍對孩子未來職業(yè)選擇的影響
- 溝通藝術(shù)與學(xué)生口頭表達(dá)能力培養(yǎng)
- 2025年人教A版高一物理下冊階段測試試卷含答案
- 2024年智能科技項目開發(fā)戰(zhàn)略合作框架協(xié)議
- 精神科健康宣教手冊-各種精神疾病宣教
- 人才交流中心聘用合同模板
- 騰訊云人工智能工程師認(rèn)證考試題(附答案)
- 2024版新能源汽車充電樁建設(shè)與運營合作框架協(xié)議3篇
- 掛靠免責(zé)協(xié)議書范本
- 廣東省廣州市天河區(qū)2023-2024學(xué)年高一上學(xué)期期末考試數(shù)學(xué)試卷(解析版)
- 鋼構(gòu)樓板合同范例
- 四年級全一冊《勞動與技術(shù)》第四單元 活動4《飼養(yǎng)動物的學(xué)問》課件
- 2024-2025學(xué)年人教版(2024)信息技術(shù)四年級上冊 第11課 嘀嘀嗒嗒的秘密 說課稿
- 2024中考物理真題匯編:電與磁(含解析)
評論
0/150
提交評論