




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
PAGEII《Java程序設計》結課報告課程名稱JAVA程序設計設計題目同學信息管理系統(tǒng)專業(yè)班級信科101班學號09同學姓名XX教師彭潔信息工程系《Java程序設計》結課報告?目錄TOC\o"1-2"\h\uHYPERLINK\l"_Toc355627604"目錄?PAGEREF_Toc355627604\hIIHYPERLINK\l”_Toc355627605"第1章系統(tǒng)簡介 PAGEREF_Toc355627605\h3HYPERLINK\l"_Toc355627606”1.1系統(tǒng)功能 PAGEREF_Toc355627606\h3HYPERLINK\l"_Toc355627607”1.2系統(tǒng)引用例子?PAGEREF_Toc355627607\h3HYPERLINK\l”_Toc355627608”第2章表的設計?PAGEREF_Toc355627608\h4HYPERLINK\l"_Toc355627609"2.1系統(tǒng)數(shù)據(jù)庫表結構?PAGEREF_Toc355627609\h4HYPERLINK\l"_Toc355627610"第3章連接數(shù)據(jù)庫的實現(xiàn)?PAGEREF_Toc355627610\h5HYPERLINK\l”_Toc355627611"3.1SQLServer數(shù)據(jù)庫連接的關鍵代碼?PAGEREF_Toc355627611\h5HYPERLINK\l"_Toc355627612"第4章系統(tǒng)簡略設計?PAGEREF_Toc355627612\h6HYPERLINK\l"_Toc355627613"4。1 系統(tǒng)登錄模塊設計?PAGEREF_Toc355627613\h6HYPERLINK\l”_Toc355627614"4。2系統(tǒng)主界面簡略設計 PAGEREF_Toc355627614\h9HYPERLINK4。3同學信息增刪改模塊設計?PAGEREF_Toc355627615\h10_Toc355627617”4.5注冊子管理員模塊設計?PAGEREF_Toc355627617\h15HYPERLINK第4章系統(tǒng)簡略設計 HYPERLINK\l"_Toc293570566”4。1 系統(tǒng)登錄模塊設計4。1.1、運行效果圖圖4.1登錄主界面效果圖4.1.2、主要代碼publicclassloginextendsJDialog{stat(yī)icPreparedStatementSQL; privatestat(yī)icfinallongserialVersionUID=1L;privat(yī)eJLabell_Id=newJLabel(”登陸賬戶”,JLabel.CENTER);privateJLabell_pw=newJLabel("登陸密碼",JLabel。CENTER);privateJTextFieldt_Id=newJTextField(10);privateJPasswordFieldt_pw=newJPasswordField(10);privateJButtonbtnLogin;privat(yī)eJButtonbtnAdd;privateJButtonbtnClose;intnum=3;publiclogin(){super();DimensionscreenSize=Toolkit.getDefaultToolkit()。getScreenSize();this.setLocation((screenSize.width-300)/2,(screenSize.height-200)/2);this。setResizable(false);getContentPane().setBackground(newColor(225,225,225));getContentPane()。setLayout(null);initialize();}protectedvoidinitialize(){ setTitle("系統(tǒng)登錄”);?l_Id。setBounds(48,43,53,25); t_Id.setBounds(110,43,150,25); l_pw.setBounds(48,93,53,25);?t_pw。setBounds(110,93,150,25);?getContentPane().add(l_Id);?getContentPane()。add(l_pw);getContentPane().add(t_Id);getContentPane()。add(t_pw);btnLogin=newJButton();btnLogin。setText("登錄”);btnLogin.setBounds(20,142,85,28);btnLogin.setBackground(newColor(244,243,239)); ?btnLogin。addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){? ? ???addBtnLoginActionListener(); } }); getContentPane()。add(btnLogin);btnAdd=newJButton();btnAdd.setText("注冊”);btnAdd。setBounds(105,142,85,28);btnAdd。addActionListener(newActionListener(){??publicvoidactionPerformed(ActionEvente){??addNewzc=newaddNew();? setVisible(false);? zc.setVisible(true); }});getContentPane()。add(btnAdd);btnClose=newJButton();btnClose。setText(”關閉”);btnClose。setBounds(190,142,85,28);btnClose.addActionListener(newActionListener(){ ?publicvoidactionPerformed(ActionEvente){ ??dispose(); ??System.exit(-1); }});getContentPane()。add(btnClose);}privatevoidaddBtnLoginActionListener(){Stringid=t_Id.getText();Stringpassword=newString(t_pw.getPassword());if(id。equals(””)){ JOptionPane。showMessageDialog(this,"帳號不行為空","提示",?JOptionPane.WARNING_MESSAGE); return;}elseif(password.equals(”")){?JOptionPane.showMessageDialog(this,"密碼不行為空",”提示",?JOptionPane。WARNING_MESSAGE); return;}else{ toolst=newtools();?booleansuccess=false;//TODO:數(shù)據(jù)校驗??success=t.eqes(id,password); if(success){//如果數(shù)據(jù)校驗成功顯示主界面?? JOptionPane.showMessageDialog(this,"成功登錄”,”提示", ?JOptionPane.INFORMATION_MESSAGE); ?newmainView(); this.dispose();? }else{???--num; ?if(num==0){??? JOptionPane。showMessageDialog(this,”用戶名或者密碼錯誤!您沒有機會了");? ? System。exit(0);? }else{? ?JOptionPane.showMessageDialog(this,"用戶名或者密碼錯誤!您還有”+num+"次機會"); ?} ?}?}}publicDimensiongetPreferredSize(){returnnewDimension(320,170);}publicvoidshow(){Toolkittk=Toolkit。getDefaultToolkit();Dimensionscreen=tk.getScreenSize();Dimensiond=getSize();this.setLocation((screen.width—d.width)/2,(screen.height-d.height)/2); //輸入密碼后回車相當于點擊了登錄按鈕 getRootPane().setDefaultButton(btnLogin);t_pw.requestFocus();setDefaultCloseOperation(DISPOSE_ON_CLOSE);?setSize(300,220); super.show();} publicstaticvoidmain(String[]args){DButilutil=newDButil();?util。getconn();?loginloginFrame=newlogin();loginFrame。setVisible(true);}}HYPERLINK\l"_Toc293570567"4。2 系統(tǒng)主界面簡略設計 4。2。1、運行效果圖圖4.2登錄后系統(tǒng)界面效果圖4。2.2、主要代碼publicmainView(){ super();??setTitle("全部同學信息");? setBounds(350,150,700,400); setDefaultCloseOperat(yī)ion(JFrame.EXIT_ON_CLOSE);? setVisible(true); finalJScrollPanescrollPane=newJScrollPane(); con=db.getconn(); ?VectortableValueV,columnNameV;//存放列名? columnNameV=newVector();??columnNameV.a(chǎn)dd(”學號"); columnNameV.a(chǎn)dd("名字");??columnNameV。add(”性別");??columnNameV.add("年齡"); ?tableValueV=newVector();scrollPane.setViewportView(table);? finalJPanelpanel=newJPanel(); getContentPane().add(panel,BorderLayout.SOUTH);??panel。add(newJLabel(”編號:"));? aTextField=newJTextField(”",5);??panel。add(aTextField); ?panel.add(newJLabel(”姓名:")); ?bTextField=newJTextField("",5); ?panel。add(bTextField); ?panel。add(newJLabel(”性別:"));? cTextField=newJTextField("",5);? panel.add(cTextField); ?panel。add(newJLabel("年齡:"));? dTextField=newJTextField(””,5);?panel.a(chǎn)dd(dTextField);}HYPERLINK\l"_Toc293570568"4.3?同學信息增刪改模塊設計 4。3。1、增加信息(121,白娘子,M,22)后運行效果圖如下:圖4.3增加一個記錄效果圖4。3.2、主要代碼finalJButtonaddButton=newJButton(”添加");addButton.addActionListener(newActionListener(){ publicvoidactionPerformed(ActionEvente){ userDaoadd=newuserDaoImpl(); useru=newuser();? u。setSno(Integer.parseInt(aTextField.getText())); u.setsName(bTextField.getText());??u.setSsex(cTextField.getText()); u。setSage(Integer.parseInt(dTextField.getText()));? add.addUser(u);??setVisible(false); ?newmainView();?}});panel.a(chǎn)dd(addButton);4.3.3、刪除信息編號為120的同學信息后結果如下:圖4.4刪除一個記錄效果圖4.3.4、主要代碼:?finalJButtondelButton=newJButton("刪除”); delButton.addActionListener(newActionListener(){??publicvoidactionPerformed(ActionEvente){? userDaodel=newuserDaoImpl();? ?userud=newuser();? ?intselectedRow=table。getSelectedRow();//獲得被選中行的索引? if(selectedRow?。健?)//推斷是否存在被選中行? del.deleUser(Integer.parseInt(aTextField。getText()));??? setVisible(false);?? tableModel.removeRow(selectedRow);? ?} });?panel。add(delButton);4。3.5、修改信息(105,關美眉,F,41)為(105,關大俠,M,30)后運行效果圖如下:圖4.5修改一個記錄效果圖4.3。6、主要代碼:panel。add(searchButton);finalJButtonupdButton=newJButton("修改");updButton.a(chǎn)ddActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){userDaoupdate=newuserDaoImpl(); ?userupe=newuser(); ?aTextField.setEditable(false); intselectedRow=table.getSelectedRow();//獲得被選中行的索引 if(selectedRow!=-1){//推斷是否存在被選中行???upe。setSno(Integer。parseInt(aTextField。getText()));? upe.setsName(bTextField.getText());? ?upe。setSsex(cTextField。getText());? upe。setSage(Integer.parseInt(dTextField.getText())); ?updat(yī)e.updateUser(upe); ??setVisible(false); ?newmainView();? } }});panel。add(updButton);HYPERLINK\l”_Toc293570569"4.4同學信息查詢模塊設計?4.4.1、運行效果圖圖4。6查詢記錄集效果圖查詢姓趙的人信息:圖4。7查詢結果圖查詢名字帶“山”的人信息:圖4。8查詢結果圖4.4。2、主要代碼:publicsearch(){?setTitle(”依據(jù)姓名查詢同學信息”); setLayout(newBorderLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); validat(yī)e();?setBounds(350,150,650,400);?finalJPanelpane=newJPanel(); jl=newJLabel("輸入姓或者名查詢");?TextField=newJTextField("",5);?jb1=newJButton("查詢");?jb2=newJButton(”返回"); pane。add(jl); pane.a(chǎn)dd(TextField); pane.add(jb1); pane.add(jb2); getContentPane().add(pane,BorderLayout.NORTH); jb1.addActionListener(this);?jb2.addActionListener(this); setVisible(true);}publicvoidactionPerformed(ActionEvente){?if(e.getActionCommand().equals(”查詢”)){??JScrollPanejsp=newJScrollPane(); ?VectortableValueV,columnNameV;??columnNameV=newVector(); ?columnNameV。add(”學號");??columnNameV.add(”名字"); ?columnNameV。add(”性別");? columnNameV.add("年齡"); ?tableValueV=newVector(); userDaouser=newuserDaoImpl();??useru=user.searchByName(TextField.getText());? VectorrowV=newVector();??rowV.add(u.getSno()); rowV.add(u。getsName());??rowV。add(u。getSsex());? rowV。add(u.getSage()); ?tableValueV.a(chǎn)dd(rowV); ?tableModel=newDefaultTableModel(tableValueV,columnNameV);??table=newJTable(tableModel);??jsp=newJScrollPane(table);? jsp.setViewportView(table); ?getContentPane()。add(jsp,BorderLayout.CENTER);??setVisible(true); }?if(e.getActionCommand().equals("返回")){??newmainView(); }}HYPERLINK\l”_Toc293570569”4.5注冊子管理員模塊設計?4.5。1、運行效果圖圖4。9注冊子管理員效果圖4.5.2、主要代碼:publicaddNew(){ setDefaultCloseOperation(EXIT_ON_CLOSE);? load();? this.setVisible(true); ?DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();? this.setLocation((screenSize。width-300)/2, ? (screenSize。height-200)/2);??this.setResizable(false); ?this.setTitle("注冊子管理員界面”);??this.setVisible(true);? this.a(chǎn)ddWindowListener(newWindowAdapter(){ ??publicvoidwindowClosing(WindowEvente){? ? System。exit(0); }??});?} publicvoidload(){??Pane=(JPanel)getContentPane(); Pane.setLayout(null);??setSize(newDimension(410,300));? setTitle(”管理員登入界面”); t1。setBounds(70,50,100,30); ?t2.setBounds(70,80,100,30);? t3。setBounds(70,110,100,30); t4.setBounds(250,50,100,30);? t5。setBounds(250,80,100,30);??f1.setBounds(150,50,100,20);? f2。setBounds(150,80,100,20); ?f3。setBounds(150,110,100,20); b1。setFont(newjava.awt.Font(”Botton”,Font.BOLD,12)); ?b1。setBounds(120,140,60,50);??b2.setFont(newjava。awt。Font(”Dialog",Font.BOLD,12)); b2.setBounds(200,140,60,50);? Pane。add(t1);??Pane.a(chǎn)dd(t2); ?Pane.a(chǎn)dd(t3); ?Pane.add(t4);? Pane。add(t5); Pane.a(chǎn)dd(f1); ?Pane.add(f2); Pane。add(f3); ?Pane。add(b1);??Pane.a(chǎn)dd(b2); ?b1。addActionListener(this); b2.addActionListener(this); }4。5。3、當注冊名已經(jīng)存在時效果如下:圖4.10驗證注冊界面4。5.4、成功注冊時效果如下:(用戶名:qunqun;密碼:qunqun)圖4.11注冊成功界面4.5.5、主要代碼publicvoidactionPerformed(ActionEvente){ ?if(e.getActionCommand().equals("注冊”)){???if(tools.indes(f1.getText())&&tools.indes(f2.getText())){ ??if(tools.eqes(f1。getText(),f2.getText())){ ? JOptionPane.showMessageDialog(this,"該用戶已被注冊,請重新輸入?。?; ? ? System.exit(0); ? }else{ ?? ?tools。addUser(f1.getText(),f1。getText()); ?? JOptionPane.showMessageDialog(this,”你已經(jīng)成功注冊~");???? System。exit(0);? }?? } ??if(f1.getText()。equals("")||f2。getText()。equals(””)){ ? JOptionPane。showMessageDialog(this,"帳號或密碼長度有誤”,"提示",?? ? JOptionPane.WARNING_MESSAGE); ??} ?}??if(e。getActionCommand().equals(”退出”)){ ??System.exit(0); ?}4.5.6、新注冊管理員(用戶名:qunqun;密碼:qunqun)登入效果如下:圖4.12登錄界面圖4。13登錄成功界面4.5.7、主要代碼:staticbooleaneqes(Stringadmin,Stringpasswd){ booleanbool=true;?try{ InputStreamis=newFileInputStream("1111。txt");??BufferedReaderreader=newBufferedReader(newInputStreamReader(is));? String
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 傳統(tǒng)手工藝的職業(yè)成長設計計劃
- 道德故事在課堂教學中的應用計劃
- 推動智慧辦公提升工作效率計劃
- 中職電子商務企業(yè)管理實踐的案例分享試題及答案
- 獸醫(yī)技術評估與分析試題及答案
- 動物心理行為管理試題及答案
- 基金從業(yè)資格理念剖析試題及答案
- 世界各國教育改革狀況
- 2024年預算員證書考試綜合分析題試題及答案
- 電商創(chuàng)新模式與技術試題及答案
- 二十案例示輪回
- 老年營養(yǎng)示范化病房創(chuàng)建方案
- 設備安全操作培訓
- 西方文化概論(第二版)課件全套 曹順慶 第0-6章 緒論 西方文化的淵源與流變、西方文學 -西方社會生活與習俗
- 某地區(qū)現(xiàn)代有軌電車施工方案
- GB/T 6974.3-2024起重機術語第3部分:塔式起重機
- DB11T 2103.1-2023 社會單位和重點場所消防安全管理規(guī)范 第1部分:通則
- 物業(yè)品質巡查管理制度
- 高中物理-《互感與自感》課件-新人教版選修3
- 養(yǎng)殖林麝合作協(xié)議書模板
- 鋼鐵項目環(huán)評報告 - 2工程分析
評論
0/150
提交評論