




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
PAGEII《Java程序設計》結課報告課程名稱JAVA程序設計設計題目同學信息管理系統專業班級信科101班學號09同學姓名XX教師彭潔信息工程系《Java程序設計》結課報告?目錄TOC\o"1-2"\h\uHYPERLINK\l"_Toc355627604"目錄?PAGEREF_Toc355627604\hIIHYPERLINK\l”_Toc355627605"第1章系統簡介 PAGEREF_Toc355627605\h3HYPERLINK\l"_Toc355627606”1.1系統功能 PAGEREF_Toc355627606\h3HYPERLINK\l"_Toc355627607”1.2系統引用例子?PAGEREF_Toc355627607\h3HYPERLINK\l”_Toc355627608”第2章表的設計?PAGEREF_Toc355627608\h4HYPERLINK\l"_Toc355627609"2.1系統數據庫表結構?PAGEREF_Toc355627609\h4HYPERLINK\l"_Toc355627610"第3章連接數據庫的實現?PAGEREF_Toc355627610\h5HYPERLINK\l”_Toc355627611"3.1SQLServer數據庫連接的關鍵代碼?PAGEREF_Toc355627611\h5HYPERLINK\l"_Toc355627612"第4章系統簡略設計?PAGEREF_Toc355627612\h6HYPERLINK\l"_Toc355627613"4。1 系統登錄模塊設計?PAGEREF_Toc355627613\h6HYPERLINK\l”_Toc355627614"4。2系統主界面簡略設計 PAGEREF_Toc355627614\h9HYPERLINK4。3同學信息增刪改模塊設計?PAGEREF_Toc355627615\h10_Toc355627617”4.5注冊子管理員模塊設計?PAGEREF_Toc355627617\h15HYPERLINK第4章系統簡略設計 HYPERLINK\l"_Toc293570566”4。1 系統登錄模塊設計4。1.1、運行效果圖圖4.1登錄主界面效果圖4.1.2、主要代碼publicclassloginextendsJDialog{staticPreparedStatementSQL; privatestaticfinallongserialVersionUID=1L;privateJLabell_Id=newJLabel(”登陸賬戶”,JLabel.CENTER);privateJLabell_pw=newJLabel("登陸密碼",JLabel。CENTER);privateJTextFieldt_Id=newJTextField(10);privateJPasswordFieldt_pw=newJPasswordField(10);privateJButtonbtnLogin;privateJButtonbtnAdd;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("系統登錄”);?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:數據校驗??success=t.eqes(id,password); if(success){//如果數據校驗成功顯示主界面?? 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 系統主界面簡略設計 4。2。1、運行效果圖圖4.2登錄后系統界面效果圖4。2.2、主要代碼publicmainView(){ super();??setTitle("全部同學信息");? setBounds(350,150,700,400); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);? setVisible(true); finalJScrollPanescrollPane=newJScrollPane(); con=db.getconn(); ?VectortableValueV,columnNameV;//存放列名? columnNameV=newVector();??columnNameV.add(”學號"); columnNameV.add("名字");??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.add(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.add(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!=—1)//推斷是否存在被選中行? 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.addActionListener(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())); ?update.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(”依據姓名查詢同學信息”); setLayout(newBorderLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); validate();?setBounds(350,150,650,400);?finalJPanelpane=newJPanel(); jl=newJLabel("輸入姓或者名查詢");?TextField=newJTextField("",5);?jb1=newJButton("查詢");?jb2=newJButton(”返回"); pane。add(jl); pane.add(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.add(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.addWindowListener(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.add(t2); ?Pane.add(t3); ?Pane.add(t4);? Pane。add(t5); Pane.add(f1); ?Pane.add(f2); Pane。add(f3); ?Pane。add(b1);??Pane.add(b2); ?b1。addActionListener(this); b2.addActionListener(this); }4。5。3、當注冊名已經存在時效果如下:圖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,”你已經成功注冊~");???? 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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- Leucomycin-A6-生命科學試劑-MCE
- 2025年中期美股策略觀點:溢價收斂龍頭為先
- 農業農村土地制度改革與土地流轉政策研究報告
- 量子密鑰分發在工業互聯網平臺中的數據加密效率優化報告
- 金融行業數據治理與隱私保護在金融大數據分析中的應用報告
- 文化藝術中心建筑2025年初步設計可持續發展評估報告
- 2025年農業綠色生產模式與新型農業經營主體培育策略研究報告
- 工業互聯網平臺安全多方計算在智能制造領域的應用案例分析報告
- 基于監管視角的美國次貸危機成因分析及其對我國的啟示
- 國立高雄大學東亞語文學系‘近(現)代史’第7堂明治國際關系大正
- 2023年國考真題(附答案)
- 個案工作知識點隋玉杰主編
- 乙狀結腸癌護理查房
- 2022年高考真題及答案解析《歷史、地理、政治》(廣東卷)
- 信息素養通識教程:數字化生存的必修課(中山大學)超星爾雅學習通網課章節測試答案
- 朗文4B 復習提要及朗文4B單詞及句子
- TSGD0012023年壓力管道安全技術監察規程-工業管道(高清晰版)
- 運動控制系統阮毅陳維鈞課后答案清華大學出版社
- 光伏電站項目工程資料清單
- YY/T 0003-1990病床
- SB/T 10977-2013倉儲作業規范
評論
0/150
提交評論