您好,登錄后才能下訂單哦!
一、前言
本學(xué)期學(xué)習(xí)了JAVA語(yǔ)言,在學(xué)期的結(jié)束,寫(xiě)一個(gè)有操作界面,與數(shù)據(jù)庫(kù)關(guān)聯(lián)的管理系統(tǒng),用來(lái)鞏固自己本學(xué)習(xí)所學(xué)的知識(shí)。
用到的知識(shí):JAVA基礎(chǔ),JAVA界面設(shè)計(jì)(GUI),Oracle數(shù)據(jù)庫(kù)(需要掌握數(shù)據(jù)庫(kù)的基本操作語(yǔ)句),鏈接數(shù)據(jù)庫(kù)。
使用的開(kāi)發(fā)工具:MyEclipse Professional 2014
二、設(shè)計(jì)
我們管理的屬性有:項(xiàng)目編號(hào),項(xiàng)目名稱(chēng),參與人員,負(fù)責(zé)人,項(xiàng)目開(kāi)始時(shí)間,結(jié)束時(shí)間。科研項(xiàng)目系統(tǒng)主要有四個(gè)功能,對(duì)科研項(xiàng)目的增加、刪除、修改、查詢(xún)。以及為增加系統(tǒng)安全性所設(shè)計(jì)的登陸模式。
2.1 增加:向數(shù)據(jù)庫(kù)的表中增加科研項(xiàng)目的所有信息
添加后在控制臺(tái)使用SQL語(yǔ)句查找,驗(yàn)證是否已添加至數(shù)據(jù)庫(kù)中。
2.2 查詢(xún):通過(guò)具有唯一性的項(xiàng)目編號(hào)查找該項(xiàng)目的所有信息
2.3 修改:根據(jù)項(xiàng)目編號(hào)選中要修改的項(xiàng)目,并重新輸入項(xiàng)目信息進(jìn)行修改
2.4 刪除:通過(guò)具有唯一性的項(xiàng)目編號(hào)刪除對(duì)應(yīng)項(xiàng)目的所有信息
三、窗體源碼
3.1 登錄界面
package 科研信息管理系統(tǒng); import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LoginWindows extends Frame implements WindowListener,ActionListener { public Label lgLabel; //用戶(hù)名標(biāo)簽 public Label pwdLabel; //密碼標(biāo)簽 public TextField lgText; //用戶(hù)名文本框 public TextField pwdText; //密碼文本框 public Button lgBt; //登錄按鈕 public Button quitBt; //退出按鈕 public LoginWindows() { super(); this.setSize(400, 300); this.setTitle("科研信息管理系統(tǒng)"); this.setLayout(null); lgLabel=new Label(); lgLabel.setText("登錄賬號(hào):"); lgLabel.setSize(60, 30); lgLabel.setLocation(70,70); pwdLabel=new Label(); pwdLabel.setText("密 碼:"); pwdLabel.setSize(60,30); pwdLabel.setLocation(70, 150); lgText=new TextField(); lgText.setSize(180, 30); lgText.setLocation(140, 70); pwdText=new TextField(); pwdText.setSize(180,30); pwdText.setLocation(140, 150); lgBt=new Button(); lgBt.setLabel("登錄"); lgBt.setSize(60,30); lgBt.setLocation(120, 220); quitBt=new Button(); quitBt.setLabel("退出"); quitBt.setSize(60,30); quitBt.setLocation(220,220); quitBt.addActionListener(this); lgBt.addActionListener(this); this.addWindowListener(this); this.add(lgLabel); this.add(pwdLabel); this.add(lgText); this.add(pwdText); this.add(lgBt); this.add(quitBt); this.setVisible(true); } public static void main(String args[]) { LoginWindows main=new LoginWindows(); } @Override public void actionPerformed(ActionEvent e) { Button bt=(Button) e.getSource(); if(bt.getLabel().equals("退出")) { System.exit(0); } else { if ((lgText.getText().equals(""))||(pwdText.getText().equals(""))) { JOptionPane.showMessageDialog(this,"賬號(hào)或密碼為空"); } else { if ((lgText.getText().equals("admin"))&&(pwdText.getText().equals("111"))) //if((lgText.getText().equals(""))||(pwdText.getText().equals(""))) { this.setVisible(false); // Sqlwindow sql=new Sqlwindow(); WindowsView w=new WindowsView(); w.SciencePro(); } else { JOptionPane.showMessageDialog(this, "沒(méi)有權(quán)限"); } }}} @Override public void windowOpened(WindowEvent e) { // TODO Auto-generated method busb } @Override public void windowClosing(WindowEvent e) { // TODO Auto-generated method busb System.exit(0); } @Override public void windowClosed(WindowEvent e) { // TODO Auto-generated method busb } @Override public void windowIconified(WindowEvent e) { // TODO Auto-generated method busb } @Override public void windowDeiconified(WindowEvent e) { // TODO Auto-generated method busb } @Override public void windowActivated(WindowEvent e) { // TODO Auto-generated method busb } @Override public void windowDeactivated(WindowEvent e) { // TODO Auto-generated method busb } }
3.2主窗體源碼
package 科研信息管理系統(tǒng); import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import javax.swing.tree.*; public class WindowsView implements TreeSelectionListener,ActionListener //窗口類(lèi) { JFrame main; JPanel leftPa; JPanel upPa; JPanel downPa; ///查詢(xún)用控件 JLabel numLa; //通過(guò)項(xiàng)目編號(hào)查詢(xún) JTextField numTxt; JButton numBt; JTextField nameTxt; //顯示項(xiàng)目名稱(chēng)的文本框 JTextField peopleTxt; //顯示參與人員 JTextField principalTxt; //顯示主要負(fù)責(zé)人 JTextField timeStartTxt; //顯示開(kāi)始時(shí)間的文本框 JTextField timeEndTxt; //顯示預(yù)期結(jié)束時(shí)間的文本框 //增加用控件 JLabel anumLa; JLabel anameLa; JLabel apeopleLa; JLabel aprincipalLa; JLabel atimeStartLa; JLabel atimeEndLa; JTextField anumTxt; JTextField anameTxt; JTextField apeopleTxt; JTextField aprincipalTxt; JTextField atimeStartTxt; JTextField atimeEndTxt; JButton addBt; JTable showTable; //刪除用控件 JLabel dnumLa; JButton dnumBt; JTextField dnumTxt; //修改用控件 JLabel alnumLa; JTextField allnumTxt; JButton alseBt; JButton alBt; JLabel allnumLa; JLabel alnameLa; JLabel alpeopleLa; JLabel alprincipalLa; JLabel altimeStartLa; JLabel altimeEndLa; JTextField alnumTxt; JTextField alnameTxt; JTextField alpeopleTxt; JTextField alprincipalTxt; JTextField altimeStartTxt; JTextField altimeEndTxt; public void SciencePro() { main=new JFrame(); main.setSize(800,800); main.setTitle("科研信息管理"); main.setLayout(null); leftPa=new JPanel(); leftPa.setSize(150, 600); leftPa.setLocation(0, 0); leftPa.setBackground(Color.white); initLeftPanel(); main.add(leftPa); upPa=new JPanel(); upPa.setSize(650, 400); upPa.setLocation(150, 0); upPa.setBackground(Color.gray); main.add(upPa); downPa=new JPanel(); downPa.setSize(650, 400); downPa.setLocation(150, 400); downPa.setBackground(Color.orange); main.add(downPa); main.setVisible(true); } private void initLeftPanel() { String[] strs={"查詢(xún)","增加","刪除","修改"}; JTree tree=new JTree(strs); tree.addTreeSelectionListener(this); leftPa.add(tree); } public void valueChanged(TreeSelectionEvent e) { JTree tree=(JTree)e.getSource(); DefaultMutableTreeNode selectionNode =(DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); String str=selectionNode.toString(); if(str.equals("查詢(xún)")) { initUpDownPaWhenSearch(); } if(str.equals("增加")) { initUpDownPaWhenAdd(); } if(str.equals("刪除")) { initUpDownPaWhenDelete(); } if(str.equals("修改")) { initUpDownPaWhenAlert(); } } private void initUpDownPaWhenSearch() { //清空上下面板上的控件 upPa.removeAll(); downPa.removeAll(); //動(dòng)態(tài)的加載上面板的控件 upPa.setLayout(null); numLa=new JLabel(); numLa.setText("請(qǐng)輸入項(xiàng)目編號(hào)"); numLa.setLocation(40, 60); numLa.setSize(100, 40); numTxt=new JTextField(); numTxt.setLocation(180, 60); numTxt.setSize(200, 30); numBt=new JButton(); numBt.setText("查詢(xún)"); numBt.addActionListener(this); numBt.setLocation(250, 160); numBt.setSize(60, 30); upPa.add(numLa); upPa.add(numTxt); upPa.add(numBt); upPa.validate(); upPa.repaint(); numBt.addActionListener(this); //動(dòng)態(tài)的加載下面板的控件 nameTxt=new JTextField(); nameTxt.setLocation(80, 50); nameTxt.setSize(300, 30); peopleTxt=new JTextField(); peopleTxt.setLocation(80, 100); peopleTxt.setSize(300, 30); principalTxt=new JTextField(); principalTxt.setLocation(80, 150); principalTxt.setSize(300, 30); timeStartTxt=new JTextField(); timeStartTxt.setLocation(80, 200); timeStartTxt.setSize(300, 30); timeEndTxt=new JTextField(); timeEndTxt.setLocation(80,250); timeEndTxt.setSize(300, 30); downPa.setLayout(null); downPa.add(nameTxt); downPa.add(peopleTxt); downPa.add(principalTxt); downPa.add(timeStartTxt); downPa.add(timeEndTxt); downPa.validate(); downPa.repaint(); } public void actionPerformed(ActionEvent e) { JButton bt=(JButton)e.getSource(); //bt.addActionListener(this); if(bt.getText().equals("查詢(xún)")) { if(numTxt.getText().equals("")) { JOptionPane.showMessageDialog(null, "請(qǐng)輸入項(xiàng)目編號(hào)"); } else { DealSearch deal=new DealSearch(); String inf=deal.findProByNum(Integer.parseInt(numTxt.getText().trim())); if((inf!=null)&&(!inf.equals(""))) { String[] strs=inf.split(","); nameTxt.setText(strs[1]); peopleTxt.setText(strs[2]); principalTxt.setText(strs[3]); timeStartTxt.setText(strs[4]); timeEndTxt.setText(strs[5]); } } } if(bt.getText().equals("新增")) { if (anumTxt.getText().equals("")||anameTxt.getText().equals("")||apeopleTxt.getText().equals("")||aprincipalTxt.getText().equals("")||atimeStartTxt.getText().equals("")||atimeEndTxt.getText().equals("")) { JOptionPane.showMessageDialog(null, "輸入中不能有空值!!"); } else { ScienceProject s=new ScienceProject(); s.SetNum(Integer.parseInt(anumTxt.getText())); s.SetName(anameTxt.getText()); s.SetPeople(apeopleTxt.getText()); s.SetLeader(aprincipalTxt.getText()); s.SetTimeStart(atimeStartTxt.getText()); s.SetTimeFinish(atimeEndTxt.getText()); DealAdd deal=new DealAdd(); deal.add(s); } } if(bt.getText().equals("刪除")) { if(Integer.parseInt(dnumTxt.getText())==0) { JOptionPane.showMessageDialog(null, "不能刪除空的項(xiàng)目編號(hào)??!"); } else { DealDelete deal=new DealDelete(); deal.delete(Integer.parseInt(dnumTxt.getText().trim())); } } if(bt.getText().equals("提交")) { if(Integer.parseInt(allnumTxt.getText())==0) { JOptionPane.showMessageDialog(null, "不能修改空的項(xiàng)目編號(hào)??!"); } else { DealSub deal=new DealSub(); deal.submit(Integer.parseInt(allnumTxt.getText())); } } if(bt.getText().equals("修改")) { if (alnameTxt.getText().equals("")||alpeopleTxt.getText().equals("")||alprincipalTxt.getText().equals("")||altimeStartTxt.getText().equals("")||altimeEndTxt.getText().equals("")) { JOptionPane.showMessageDialog(null, "輸入中不能有空值??!"); } else { ScienceProject s=new ScienceProject(); s.SetNum(Integer.parseInt(allnumTxt.getText())); s.SetName(alnameTxt.getText()); s.SetPeople(alpeopleTxt.getText()); s.SetLeader(alprincipalTxt.getText()); s.SetTimeStart(altimeStartTxt.getText()); s.SetTimeFinish(altimeEndTxt.getText()); DealAlter deal=new DealAlter(); deal.alter(s); } } } private void initUpDownPaWhenAdd() { //清空上下面板上的控件 upPa.removeAll(); downPa.removeAll(); //動(dòng)態(tài)的加載上面板的控件 upPa.setLayout(null); anumLa=new JLabel(); anumLa.setText("請(qǐng)輸入要增加的項(xiàng)目編號(hào)"); anumLa.setLocation(30, 50); anumLa.setSize(150, 40); anumTxt=new JTextField(); anumTxt.setLocation(200, 50); anumTxt.setSize(250, 30); anameLa=new JLabel(); anameLa.setText("請(qǐng)輸入要增加的項(xiàng)目名稱(chēng)"); anameLa.setLocation(30, 100); anameLa.setSize(150, 40); anameTxt=new JTextField(); anameTxt.setLocation(200, 100); anameTxt.setSize(250, 30); apeopleLa=new JLabel(); apeopleLa.setText("請(qǐng)輸入項(xiàng)目參與人員"); apeopleLa.setLocation(30, 150); apeopleLa.setSize(150, 40); apeopleTxt=new JTextField(); apeopleTxt.setLocation(200, 150); apeopleTxt.setSize(250, 30); aprincipalLa=new JLabel(); aprincipalLa.setText("請(qǐng)輸入項(xiàng)目負(fù)責(zé)人"); aprincipalLa.setLocation(30, 200); aprincipalLa.setSize(150, 40); aprincipalTxt=new JTextField(); aprincipalTxt.setLocation(200, 200); aprincipalTxt.setSize(250, 30); atimeStartLa=new JLabel(); atimeStartLa.setText("請(qǐng)輸入項(xiàng)目開(kāi)始時(shí)間"); atimeStartLa.setLocation(30, 250); atimeStartLa.setSize(150, 40); atimeStartTxt=new JTextField(); atimeStartTxt.setLocation(200, 250); atimeStartTxt.setSize(250, 30); atimeEndLa=new JLabel(); atimeEndLa.setText("請(qǐng)輸入項(xiàng)目結(jié)束時(shí)間"); atimeEndLa.setLocation(30, 300); atimeEndLa.setSize(150, 40); atimeEndTxt=new JTextField(); atimeEndTxt.setLocation(200, 300); atimeEndTxt.setSize(250, 30); addBt=new JButton(); addBt.setText("新增"); addBt.addActionListener(this); //addBt.addMouseListener(this); addBt.setLocation(250, 340); addBt.setSize(60, 30); upPa.add(addBt); upPa.add(anumLa); upPa.add(anameLa); upPa.add(apeopleLa); upPa.add(aprincipalLa); upPa.add(atimeStartLa); upPa.add(atimeEndLa); upPa.add(anameTxt); upPa.add(anumTxt); upPa.add(apeopleTxt); upPa.add(aprincipalTxt); upPa.add(atimeStartTxt); upPa.add(atimeEndTxt); upPa.validate(); upPa.repaint(); downPa.validate(); downPa.repaint(); } private void initUpDownPaWhenDelete() { //清空上下面板上的控件 upPa.removeAll(); downPa.removeAll(); //動(dòng)態(tài)的加載上面板的控件 upPa.setLayout(null); numLa=new JLabel(); numLa.setText("請(qǐng)輸入要?jiǎng)h除的項(xiàng)目編號(hào)"); numLa.setLocation(40, 60); numLa.setSize(150, 40); dnumTxt=new JTextField(); dnumTxt.setLocation(200, 60); dnumTxt.setSize(250, 30); dnumBt=new JButton(); dnumBt.setText("刪除"); dnumBt.addActionListener(this); dnumBt.setLocation(270, 170); dnumBt.setSize(60, 30); upPa.add(numLa); upPa.add(dnumTxt); upPa.add(dnumBt); upPa.validate(); upPa.repaint(); downPa.validate(); downPa.repaint(); } private void initUpDownPaWhenAlert() { //清空上下面板上的控件 upPa.removeAll(); downPa.removeAll(); //動(dòng)態(tài)的加載上面板的控件 upPa.setLayout(null); alnumLa=new JLabel(); alnumLa.setText("請(qǐng)輸入要修改的項(xiàng)目編號(hào)"); alnumLa.setLocation(40, 60); alnumLa.setSize(150, 40); alseBt=new JButton(); alseBt.setText("提交"); alseBt.addActionListener(this); alseBt.setLocation(270, 170); alseBt.setSize(60, 30); allnumTxt=new JTextField(); allnumTxt.setLocation(200, 60); allnumTxt.setSize(200, 30); upPa.add(alnumLa); upPa.add(alseBt); upPa.add(allnumTxt); upPa.validate(); upPa.repaint(); alBt=new JButton(); alBt.setText("修改"); alBt.addActionListener(this); alBt.setLocation(450, 170); alBt.setSize(60, 30); /* allnumLa=new JLabel(); allnumLa.setText("請(qǐng)輸入修改后的項(xiàng)目編號(hào)"); allnumLa.setLocation(30, 00); allnumLa.setSize(150, 40); alnumTxt=new JTextField(); alnumTxt.setLocation(180, 00); alnumTxt.setSize(250, 30);*/ alnameLa=new JLabel(); alnameLa.setText("請(qǐng)輸入修改后項(xiàng)目名稱(chēng)"); alnameLa.setLocation(30, 50); alnameLa.setSize(150, 40); alnameTxt=new JTextField(); alnameTxt.setLocation(180, 50); alnameTxt.setSize(250, 30); alpeopleLa=new JLabel(); alpeopleLa.setText("請(qǐng)重設(shè)參與人員"); alpeopleLa.setLocation(30, 100); alpeopleLa.setSize(150, 40); alpeopleTxt=new JTextField(); alpeopleTxt.setLocation(180, 100); alpeopleTxt.setSize(250, 30); alprincipalLa=new JLabel(); alprincipalLa.setText("請(qǐng)重設(shè)項(xiàng)目負(fù)責(zé)人"); alprincipalLa.setLocation(30, 150); alprincipalLa.setSize(150, 40); alprincipalTxt=new JTextField(); alprincipalTxt.setLocation(180, 150); alprincipalTxt.setSize(250, 30); altimeStartLa=new JLabel(); altimeStartLa.setText("請(qǐng)重設(shè)項(xiàng)目開(kāi)始時(shí)間"); altimeStartLa.setLocation(30, 200); altimeStartLa.setSize(150, 40); altimeStartTxt=new JTextField(); altimeStartTxt.setLocation(180, 200); altimeStartTxt.setSize(250, 30); altimeEndLa=new JLabel(); altimeEndLa.setText("請(qǐng)重設(shè)項(xiàng)目結(jié)束時(shí)間"); altimeEndLa.setLocation(30, 250); altimeEndLa.setSize(150, 40); altimeEndTxt=new JTextField(); altimeEndTxt.setLocation(180, 250); altimeEndTxt.setSize(250, 30); downPa.add(alBt); //downPa.add(allnumLa); downPa.add(alnameLa); downPa.add(alpeopleLa); downPa.add(alprincipalLa); downPa.add(altimeStartLa); downPa.add(altimeEndLa); downPa.add(alnameTxt); //downPa.add(alnumTxt); downPa.add(alpeopleTxt); downPa.add(alprincipalTxt); downPa.add(altimeStartTxt); downPa.add(altimeEndTxt); downPa.setLayout(null); downPa.validate(); downPa.repaint(); } }
3.3 組織SQL語(yǔ)句,鏈接數(shù)據(jù)庫(kù)部分
package 科研信息管理系統(tǒng); import java.sql.*; import java.util.Scanner; public class Sql { public void AddScienceProject(ScienceProject scienceProject) { try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String conStr="jdbc:oracle:thin:@localhost:1521:XE"; Connection con=DriverManager.getConnection(conStr,"system","1"); StringBuffer sql=new StringBuffer("insert into science values("+scienceProject.GetNum()+",'"+scienceProject.GetName()+"','"+scienceProject.GetPeople()+"','"+scienceProject.GetLeader()+"','"+scienceProject.GetTimeStart()+"','"+scienceProject.GetTimeFinish()+"')"); Statement st=con.createStatement(); st.execute(sql.toString()); st.close(); con.close(); } catch (Exception e) { // TODO: handle exception System.out.println(e.toString()); } } public void DelScienceProject(ScienceProject scienceProject) { try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String conStr="jdbc:oracle:thin:@localhost:1521:XE"; Connection con=DriverManager.getConnection(conStr,"system","1"); StringBuffer sql=new StringBuffer("delete from science where num="+scienceProject.GetNum()+""); Statement st=con.createStatement(); st.execute(sql.toString()); st.close(); con.close(); } catch (Exception e) { // TODO: handle exception System.out.println(e.toString()); } } public void UpdScienceProject(ScienceProject scienceProject) { try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String conStr="jdbc:oracle:thin:@localhost:1521:XE"; Connection con=DriverManager.getConnection(conStr,"system","1"); StringBuffer sql =new StringBuffer("update science set name='"+scienceProject.GetName()+"',workpeople='"+scienceProject.GetPeople()+"',manager='"+scienceProject.GetLeader()+"',timestart='"+scienceProject.GetTimeStart()+"',timeend='"+scienceProject.GetTimeFinish()+"' where num="+scienceProject.GetNum()+""); Statement st=con.createStatement(); st.execute(sql.toString()); st.close(); con.close(); } catch (Exception e) { // TODO: handle exception System.out.println("修改異常"); System.out.println(e.toString()); } } public ScienceProject Findbynum(int num) { ScienceProject scienceProject=new ScienceProject(); try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String conStr="jdbc:oracle:thin:@localhost:1521:XE"; Connection con=DriverManager.getConnection(conStr,"system","1"); StringBuffer sql=new StringBuffer("select * from science where num="+num+""); Statement st=con.createStatement(); ResultSet rs=st.executeQuery(sql.toString()); while(rs.next()) { scienceProject.SetNum(rs.getInt(1)); scienceProject.SetName(rs.getString(2)); scienceProject.SetPeople(rs.getString(3)); scienceProject.SetLeader(rs.getString(4)); scienceProject.SetTimeStart(rs.getString(5)); scienceProject.SetTimeFinish(rs.getString(6)); } st.close(); con.close(); } catch (Exception e) { // TODO: handle exception System.out.println(e.toString()); } return scienceProject; } public ScienceProject Look() { ScienceProject scienceProject=new ScienceProject(); try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String conStr="jdbc:oracle:thin:@localhost:1521:XE"; Connection con=DriverManager.getConnection(conStr,"system","1"); StringBuffer sql=new StringBuffer("select *from science"); Statement st=con.createStatement(); ResultSet rs=st.executeQuery(sql.toString()); while(rs.next()) { scienceProject.SetNum(rs.getInt(1)); scienceProject.SetName(rs.getString(2)); scienceProject.SetPeople(rs.getString(3)); scienceProject.SetLeader(rs.getString(4)); scienceProject.SetTimeStart(rs.getString(5)); scienceProject.SetTimeFinish(rs.getString(6)); } st.close(); con.close(); } catch (Exception ex) { // TODO: handle exception System.out.println(ex.toString()); } return scienceProject; } public static void main(String args[]) { } }
3.4 增刪查改對(duì)應(yīng)處理的源碼
//處理增加 package 科研信息管理系統(tǒng); import javax.swing.JOptionPane; public class DealAdd { public DealAdd() {} public void add(ScienceProject s) { Sql sql=new Sql(); if(sql.Findbynum(s.GetNum()).GetNum()!=0) { JOptionPane.showMessageDialog(null, "該項(xiàng)目已存在,請(qǐng)重新輸入!"); } else { sql.AddScienceProject(s); JOptionPane.showMessageDialog(null,"增加成功"); } } }
由設(shè)計(jì)部分可以看到,刪除時(shí)需要先提交項(xiàng)目編號(hào),所以,需要處理提交事件
//處理提交 package 科研信息管理系統(tǒng); import javax.swing.JOptionPane; public class DealSub { DealSub() {} public void submit(int num) { Sql sql =new Sql(); if(sql.Findbynum(num).GetNum()==0) { JOptionPane.showMessageDialog(null, "不存在該項(xiàng)目"); } else { JOptionPane.showMessageDialog(null, "請(qǐng)?jiān)谙路教顚?xiě)修改后的項(xiàng)目信息"); } } } //處理刪除 package 科研信息管理系統(tǒng); import javax.swing.JOptionPane; public class DealDelete { public DealDelete() {} public void delete(int num) { ScienceProject s=new ScienceProject(); Sql sql=new Sql(); if(sql.Findbynum(num).GetNum()==0) { JOptionPane.showMessageDialog(null, "不存在該項(xiàng)目~"); } else { s=sql.Findbynum(num); sql.DelScienceProject(s); JOptionPane.showMessageDialog(null, "刪除成功~"); } } } //處理修改 package 科研信息管理系統(tǒng); import javax.swing.JOptionPane; public class DealAlter { public DealAlter() {} public void alter(ScienceProject s) { Sql sql=new Sql(); sql.UpdScienceProject(s); JOptionPane.showMessageDialog(null,"修改成功"); } } //處理查詢(xún) package 科研信息管理系統(tǒng); public class DealSearch //處理查詢(xún)事件 { public DealSearch() {} public String findProByNum(int num)//通過(guò)項(xiàng)目編號(hào)查詢(xún) { String result=""; ScienceProject s=new ScienceProject(); Sql sql=new Sql(); s=sql.Findbynum(num); result=s.GetNum()+","+s.GetName()+","+s.GetPeople()+","+s.GetLeader()+","+s.GetTimeStart()+","+s.GetTimeFinish(); return result; } }
3.5 主函數(shù)調(diào)用登錄窗口
package 科研信息管理系統(tǒng); public class Test { public static void main(String[] args) { LoginWindows v=new LoginWindows(); } }
四、總結(jié)
還是有一些的缺陷存在的,由于對(duì)科研項(xiàng)目的不熟悉,有些屬性設(shè)計(jì)得不合理,還有很多沒(méi)有考慮到的地方,另外對(duì)GUI的不熟悉也限制了我們?cè)诖翱谏系脑O(shè)計(jì)。還需要在項(xiàng)目屬性及窗口等方面進(jìn)行修改。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。