




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、本人親自做的,不需要做任何修改即可順利運(yùn)行, sql 表也與程序無縫連接,沒有未識(shí)別部 分。Sql 表如下: CREATE TABLE STU( 學(xué)號(hào) varchar(14) PRIMARY KEY, 姓名 varchar(8) NOT NULL, 密碼 varchar(8) NOT NULL, 班級 varchar(14) NOT NULL , 性別 varchar(2), 學(xué)校 varchar(14) NOT NULL);CREATE TABLE TCH( 用戶名 varchar(8) NOT NULL, 密碼 varchar(8) NOT NULL );CREATE TABLE成績表(
2、學(xué)號(hào) varchar(14) PRIMARY KEY, 計(jì)算機(jī)網(wǎng)絡(luò) varchar(8) NOT NULL, 汽車概論 varchar(8) NOT NULL, 初級日語 varchar(8) NOT NULL, 接口技術(shù) varchar(8) NOT NULL, ava 程序設(shè)計(jì) varchar(8) NOT NULL, 數(shù)據(jù)庫 varchar(8) NOT NULL, 大學(xué)物理 varchar(8) NOT NULL);源程序代碼: import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.s
3、ql.*;public class systems extends JFrame implements ActionListener static systems ss;JPanel panel = new JPanel();JLabel label1 = new JLabel( 輸入姓名: ); JTextField name = new JTextField();JLabel label2 = new JLabel( 密碼: );JPasswordField pwd = new JPasswordField(); JButton Enter = new JButton( 登錄 ); JBu
4、tton Exit = new JButton( 退出 );String url = D:Systemstitle.jpg; ButtonGroup bgp = new ButtonGroup();JRadioButton stu = new JRadioButton( 學(xué)生 );JRadioButton tch = new JRadioButton(教師 );public systems()super( 登錄系統(tǒng) ); this.setResizable(false);JLabel img = new JLabel(new ImageIcon(url); img.setBounds(0,0,
5、500,100); panel.add(img);stu.setBounds(165,210,70,20);tch.setBounds(265,210,70,20); bgp.add(stu);bgp.add(tch);panel.add(stu);panel.add(tch);Enter.setBounds(150,250,80,20);Exit.setBounds(270,250,80,20);Enter.addActionListener(this);Exit.addActionListener(this); panel.add(Enter); panel.add(Exit);panel
6、.setLayout(null);this.add(panel); label1.setBounds(135,130,100,25);panel.add(label1);name.setBounds(265,130,100,25);panel.add(name); label2.setBounds(135,165,100,25);panel.add(label2);pwd.setBounds(265,165,100,25);panel.add(pwd); this.setBounds(100,100,500,350); this.setVisible(true);this.setDefault
7、CloseOperation(JFrame.EXIT_ON_CLOSE); public void actionPerformed(ActionEvent e)if(e.getSource()=Enter)String username , password;username = name.getText();password = pwd.getText();tryClass.forName(oracle.jdbc.driver.OracleDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(ss,ce.
8、getMessage(); if(stu.isSelected()tryConnection conDriverManager.getConnection(jdbc:oracle:thin:user29:1521:XE,hr,oracle); Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(select * from STU); while(rs.next()if(rs.getString( 學(xué)).equals(username)&(rs.getString(密碼 ).equals(password
9、)JOptionPane.showMessageDialog(ss, 登陸成功 ); Students stu = new Students();elseJOptionPane.showMessageDialog(ss, 登錄失敗 );rs.close(); stmt.close();catch (SQLException se)JOptionPane.showMessageDialog(ss,se.getMessage();else if(tch.isSelected()tryConnection conDriverManager.getConnection(jdbc:oracle:thin
10、:user29:1521:XE,hr,oracle);Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(select * from TCH);while(rs.next() if(rs.getString( 用 戶 ).equals(username)&(rs.getString(密碼 ).equals(password)JOptionPane.showMessageDialog(ss, 登陸成功 );else JOptionPane.showMessageDialog(ss, 登錄失敗 );catc
11、h (SQLException se) JOptionPane.showMessageDialog(ss,se.getMessage();else System.exit(0);public static void main(String args)systems sys = new systems();import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Students extends JFrame implements ActionListener JMenuBar jmb = new JM
12、enuBar();JMenu Message = new JMenu( 信息 );JMenu Score = new JMenu( 成績 );JMenuItem Item1 = new JMenuItem(插入 );JMenuItem Item2 = new JMenuItem(查詢 );JMenuItem Item3 = new JMenuItem(查詢 );public Students() super( 學(xué)生界面 ); this.setSize(500,400); this.setVisible(true); this.setResizable(false); this.setDefau
13、ltCloseOperation(JFrame.EXIT_ON_CLOSE); this.setJMenuBar(jmb);jmb.add(Message); jmb.add(Score);Message.add(Item1);Message.add(Item2); Score.add(Item3);Item1.addActionListener(this);Item2.addActionListener(this);Item3.addActionListener(this);public void actionPerformed(ActionEvent e) if(e.getSource()
14、=Item1)AddMsg ad = new AddMsg();else if(e.getSource()=Item2)Serch ser = new Serch(); elsepublic static void main(String args)Students stu = new Students();import java.awt.*;import javax.swing.*;import java.awt.event.*; public class Teachers extends JFrame implements ActionListener JMenuBar bar = new
15、 JMenuBar();JMenu menu1 = new JMenu( 信息 );JMenu menu2 = new JMenu( 成績 );JMenuItem item1 = new JMenuItem( 錄入信息 );JMenuItem item2 = new JMenuItem( 錄入成績 ); JPanel jpl = new JPanel();public Teachers() super( 教師界面 ); this.setSize(500,300); this.setResizable(false); this.setVisible(true); this.setDefaultC
16、loseOperation(JFrame.EXIT_ON_CLOSE); this.setJMenuBar(bar);this.add(jpl); jpl.setLayout(null);bar.add(menu1);bar.add(menu2); menu1.add(item1); menu2.add(item2);item1.addActionListener(this); item2.addActionListener(this);public void actionPerformed(ActionEvent e) if(e.getSource()=item1) AddMsg msg =
17、 new AddMsg();elseAddscore as = new Addscore();public static void main(String args)Teachers tch = new Teachers();import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Serch extends JFrame implements ActionListener /* 查詢學(xué)生信息控件 */ static Serch s;JPanel jpl = new
18、 JPanel();JLabel SCH = new JLabel(查詢學(xué)生信息 ,JLabel.CENTER);JLabel label1 = new JLabel( JButton serch = new JButton(JLabel label2 = new JLabel( JLabel label3 = new JLabel(JLabel label4 = new JLabel( JLabel label5 = new JLabel(請輸入學(xué)號(hào): ,JLabel.CENTER); 查詢 );姓名: ,JLabel.CENTER);班級: ,JLabel.CENTER);學(xué)校: ,JLa
19、bel.CENTER); 性別: ,JLabel.CENTER);ButtonGroup bgp = new ButtonGroup();JRadioButton man = new JRadioButton(男 );JRadioButton women = new JRadioButton(女 );JTextField num = new JTextField();JTextField nam = new JTextField();JTextField clas = new JTextField();JTextField scl = new JTextField();JButton rese
20、t = new JButton( 重置 );public Serch()this.setSize(500,400); this.setVisible(true); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl);jpl.setLayout(null);serch.addActionListener(this); reset.addActionListener(this);/* 查詢面板 */ SCH.setBounds(100,20,300,20);jpl.
21、add(SCH); label1.setBounds(100,60,100,20);jpl.add(label1); num.setBounds(220,60,140,20);jpl.add(num);serch.setBounds(120,100,90,20);reset.setBounds(260,100,90,20); jpl.add(serch);jpl.add(reset);label2.setBounds(100,140,70,20);jpl.add(label2);nam.setBounds(190,140,140,20); jpl.add(nam);label5.setBoun
22、ds(100,180,70,20); jpl.add(label5);man.setBounds(205,180,60,20); women.setBounds(285,180,60,20); bgp.add(man);bgp.add(women);jpl.add(man);jpl.add(women);label3.setBounds(100,220,70,20);jpl.add(label3); clas.setBounds(190,220,140,20); jpl.add(clas);label4.setBounds(100,260,70,20);jpl.add(label4);scl.
23、setBounds(190,260,140,20);jpl.add(scl);public void actionPerformed(ActionEvent e)String id = num.getText();if(e.getSource()=serch)tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce) JOptionPane.showMessageDialog(s,ce.getMessage();tryConnection con DriverManager.getConnec
24、tion(jdbc:odbc:sysdb,sa,);Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(select * from STU where ID = + id + );while(rs.next()nam.setText(rs.getString(Name); if(rs.getString(Sex).equals(男 )man.setSelected(true);elsewomen.setSelected(true);clas.setText(rs.getString(Class); sc
25、l.setText(rs.getString(Collage);catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();public static void main(String args)Serch sch = new Serch();import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class AddMsg extends JFrame implements ActionList
26、ener static AddMsg s;/* 添加學(xué)生信息控件 */JPanel jpl = new JPanel();添加基本信息 ,JLabel.CENTER); 學(xué)號(hào): ,JLabel.CENTER); 姓名: ,JLabel.CENTER); 性別: ,JLabel.CENTER);JLabel label1 = new JLabel(JLabel label2 = new JLabel(JLabel label3 = new JLabel( JLabel label4 = new JLabel(JLabel label5 = new JLabel(班級: ,JLabel.CENTE
27、R);JLabel label6 = new JLabel(學(xué)院: ,JLabel.CENTER);JTextField num = new JTextField(2);JTextField nam = new JTextField(4);ButtonGroup bgp = new ButtonGroup(); JRadioButton man = new JRadioButton(男 );JRadioButton women = new JRadioButton(女 );JTextField clas = new JTextField();JTextField scl = new JText
28、Field();JButton reset = new JButton(重置 );JButton addmsg = new JButton( 添加 );public AddMsg()super( 添加學(xué)生信息 );this.setResizable(false);this.setSize(500,400); this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(jpl);jpl.setLayout(null);addmsg.addActionListener(this); rese
29、t.addActionListener(this);/* 插入面板 */ label1.setBounds(100,20,300,20);jpl.add(label1); label2.setBounds(100,50,70,20);jpl.add(label2); num.setBounds(190,50,140,20);jpl.add(num); label3.setBounds(100,90,70,20);jpl.add(label3); nam.setBounds(190,90,140,20);jpl.add(nam); label4.setBounds(100,130,70,20);
30、jpl.add(label4); man.setBounds(190,130,60,20); women.setBounds(270,130,60,20);jpl.add(man); jpl.add(women);bgp.add(man); bgp.add(women);label5.setBounds(100,170,70,20); jpl.add(label5);clas.setBounds(190,170,140,20); jpl.add(clas);label6.setBounds(100,210,70,20);jpl.add(label6); scl.setBounds(190,21
31、0,140,20);jpl.add(scl); reset.setBounds(120,250,90,20);addmsg.setBounds(240,250,90,20);jpl.add(reset); jpl.add(addmsg);public void actionPerformed(ActionEvent e)if(e.getSource()=addmsg)String sex;if(man.isSelected()sex= 男 ;elsesex= 女 ;try Class.forName(oracle.jdbc.driver.OracleDriver);catch (ClassNo
32、tFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage(); tryConnection con = DriverManager.getConnection(jdbc:oracle:thin:user29:1521:XE,hr,oracle);Statement stmt = con.createStatement();int a = stmt.executeUpdate(insert into STU(ID , Pwd , Name, Sex , Class , Collage)values(+num.getText(
33、)+,+12345678,+nam.getText()+,+sex+, +clas.getText()+,+scl.getText()+);if(a=1)JOptionPane.showMessageDialog(s, 已成功添加 );elseJOptionPane.showMessageDialog(s, 添加失敗 );stmt.close();catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();elsenum.setText();nam.setText();clas.setText();scl.set
34、Text();num.requestFocus();public static void main(String args)AddMsg amg = new AddMsg();import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Addscore extends JFrame implements ActionListenerstatic Addscore ss;JLabel label = new JLabel( 學(xué)號(hào):) , new JLabel( 計(jì)算機(jī)網(wǎng)
35、絡(luò): ) , new JLabel( 汽車概論: ) , new JLabel( 初級日語: ) , new JLabel( 接口技術(shù): ) , new JLabel(Java 程序設(shè)計(jì): ) , new JLabel( 數(shù)據(jù)庫: ) , new JLabel( 算法設(shè)計(jì): ) , new JLabel( 大學(xué)物理: );JTextField txt = new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTex
36、tField() ,new JTextField() ,new JTextField() ;JButton add = new JButton(添加 );JButton reset = new JButton(重置 );JPanel jpl = new JPanel();JLabel title = new JLabel(添加學(xué)生成績 , JLabel.CENTER);Font f = new Font(黑體 , Font.BOLD , 16 );int s = 100;public Addscore()super( 添加學(xué)生信息 );this.setResizable(false);this.setSize(500,600); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setVisible(true);this.add(jpl);add.addActionListener(this);reset.addActionListener(this);jpl.setLayout(null);title.setBoun
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 服裝批發(fā)商直播帶貨與網(wǎng)紅營銷考核試卷
- 刨花板行業(yè)綠色生產(chǎn)與可持續(xù)發(fā)展考核試卷
- 彈射玩具銷售季節(jié)性規(guī)律考核試卷
- 樂器配件精密加工技術(shù)考核試卷
- 動(dòng)物用藥品銷售與市場預(yù)測分析考核試卷
- 刺繡藝術(shù)在充電寶的個(gè)性化設(shè)計(jì)考核試卷
- 創(chuàng)業(yè)項(xiàng)目品牌定位與市場推廣考核試卷
- 勞務(wù)合同范本遷戶口
- 學(xué)校鏟車租賃合同范本
- 淘客推廣合同范本
- 《化工設(shè)備機(jī)械基礎(chǔ)(第8版)》完整全套教學(xué)課件
- 代理記賬業(yè)務(wù)內(nèi)部規(guī)范制度-代理記賬業(yè)務(wù)規(guī)范
- 山東虛擬電廠商業(yè)模式介紹
- 2024-2025學(xué)年高中思想政治選擇性必修2 法律與生活統(tǒng)編版(部編版)教學(xué)設(shè)計(jì)合集
- 第09講二元一次方程組中的新定義題型(原卷版+解析)-2021-2022學(xué)年下學(xué)期七年級數(shù)學(xué)下冊期末復(fù)習(xí)高頻考點(diǎn)專題(人教版)
- 全國職業(yè)院校技能大賽高職組(商務(wù)數(shù)據(jù)分析賽項(xiàng))備賽試題庫(含答案)
- 八年級道德與法治下冊 第三單元 人民當(dāng)家作主教案 新人教版
- JGJ153-2016 體育場館照明設(shè)計(jì)及檢測標(biāo)準(zhǔn)
- 【年產(chǎn)100噸植物乳桿菌菌劑生產(chǎn)線設(shè)計(jì)10000字(論文)】
- 《湖南省醫(yī)療保險(xiǎn)“雙通道”管理藥品使用申請表》
- 中醫(yī)內(nèi)科學(xué)歌訣355首 內(nèi)科歌訣完整
評論
0/150
提交評論