JAVA學生信息管理系統(tǒng)源碼
《JAVA學生信息管理系統(tǒng)源碼》由會員分享,可在線閱讀,更多相關《JAVA學生信息管理系統(tǒng)源碼(14頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、精選優(yōu)質文檔-傾情為你奉上/ AddStuInfo.javapackage com.main;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;import javax.swin
2、g.JOptionPane;import com.bean.Student;import com.dao.StudentDao;import com.db.DB;import com.main.DelteStudent.delAction;public class AddStuInfo extends JFrame StudentDao studao = new StudentDao();DB db = new DB();Connection conn = db.getConnection();JTextField snoText = null;JTextField snameText = n
3、ull;JComboBox sexcom = null;JTextField ageText = null;JComboBox classcom = null;JComboBox departcom = null;public void init() / 窗體設計this.setLayout(null);this.setTitle(學生信息管理系統(tǒng));this.setSize(500, 400);JLabel title = new JLabel(學生信息維護模塊-錄入數(shù)據(jù));title.setBounds(180, 20, 200, 30);this.add(title);JLabel sn
4、oLabel = new JLabel(學號);snoText = new JTextField();snoLabel.setBounds(20, 60, 40, 25);snoText.setBounds(60, 60, 120, 25);this.add(snoLabel);this.add(snoText);JLabel snameLabel = new JLabel(姓名);snameText = new JTextField();snameLabel.setBounds(220, 60, 40, 25);snameText.setBounds(260, 60, 120, 25);th
5、is.add(snameLabel);this.add(snameText);JLabel sexlabel = new JLabel(性別);String sex = 男, 女 ;sexcom = new JComboBox(sex);sexlabel.setBounds(20, 90, 40, 25);sexcom.setBounds(60, 90, 120, 25);this.add(sexlabel);this.add(sexcom);JLabel ageLabel = new JLabel(年齡);ageText = new JTextField();ageLabel.setBoun
6、ds(220, 90, 40, 25);ageText.setBounds(260, 90, 120, 25);this.add(ageLabel);this.add(ageText);JLabel classlabel = new JLabel(班級);String classes = 信息081, 信息082, 物流081 ;classcom = new JComboBox(classes);classlabel.setBounds(20, 120, 40, 25);classcom.setBounds(60, 120, 120, 25);this.add(classlabel);this
7、.add(classcom);JLabel departlabel = new JLabel(學院);String depart = 造紙, 理學院, 機電學院 ;departcom = new JComboBox(depart);departlabel.setBounds(220, 120, 40, 25);departcom.setBounds(260, 120, 120, 25);this.add(departlabel);this.add(departcom);/ 錄入數(shù)據(jù)JButton addbtn = new JButton(錄入);addbtn.setBounds(150, 18
8、0, 60, 30);addbtn.addActionListener(new addAction();this.add(addbtn);/ 返回JButton backbtn = new JButton(返回);backbtn.setBounds(230, 180, 60, 30);backbtn.addActionListener(new BackAction ();this.add(backbtn);this.setLocationRelativeTo(null); / 使窗體居中this.setResizable(false);/ 固定窗體大小this.setVisible(true)
9、; / 設置窗體可見/this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); / 窗體關閉時,程序結束/ 獲取文本框或選擇框的值public Student getStudent() Student stu = new Student();String sno = snoText.getText(); / 獲取輸入的學號String sname = snameText.getText(); / 獲取姓名String sex = (String) sexcom.getSelectedItem();/ 獲取性別int age = Integer.p
10、arseInt(ageText.getText().trim(); / 獲取年齡String className = (String) classcom.getSelectedItem(); / 獲取班級String depart = (String) departcom.getSelectedItem(); / 獲取學院/ 封裝信息stu.setSno(sno);stu.setName(sname);stu.setSex(sex);stu.setAge(age);stu.setClassName(className);stu.setDepart(depart);return stu;publ
11、ic static void main(String args) AddStudent addstu = new AddStudent();addstu.init();/ 錄入的監(jiān)聽器class addAction implements ActionListener public void actionPerformed(ActionEvent e) Student stu = getStudent();boolean b = studao.save(stu, conn);if (b) JOptionPane.showMessageDialog(null, 數(shù)據(jù)錄入成功!); else JOp
12、tionPane.showMessageDialog(null, 學號已存在,數(shù)據(jù)錄入失敗!);class BackAction implements ActionListenerpublic void actionPerformed(ActionEvent e) MainFrame m=new MainFrame (); m.init();/DelStuInfo.javapackage com.main;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connecti
13、on;import java.sql.SQLException;import java.util.Vector;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import com.bean.Student;import com.dao.StudentDao;import com.db.DB;import com.main.AddStudent.BackAction;
14、/刪除學生信息public class DelStuInfo extends JFrame StudentDao studao = new StudentDao();DB db = new DB();Connection conn = db.getConnection();JComboBox snocom = null;public void init() / 窗體設計this.setLayout(null);this.setTitle(學生信息管理系統(tǒng));this.setSize(500, 400);JLabel title = new JLabel(學生信息維護模塊-刪除數(shù)據(jù));title
15、.setBounds(180, 20, 200, 30);this.add(title);/ 選擇學號JLabel snoLabel = new JLabel(請選擇要刪除學生信息的學號);snoLabel.setBounds(20, 60, 200,25);this.add(snoLabel);try Vector vec = studao.getSno();snocom = new JComboBox(vec); / 將數(shù)據(jù)庫里的學號信息裝入下拉框中snocom.setBounds(30, 90, 150, 25); catch (SQLException e) e.printStackT
16、race();this.add(snocom);/ 刪除數(shù)據(jù)JButton delbtn = new JButton(刪除);delbtn.setBounds(100, 180, 60, 30);delbtn.addActionListener(new delAction();this.add(delbtn);/ 返回JButton backbtn = new JButton(返回);backbtn.setBounds(180, 180, 60, 30);backbtn.addActionListener(new BackAction ();this.add(backbtn);this.set
17、LocationRelativeTo(null); / 使窗體居中this.setResizable(false);/ 固定窗體大小this.setVisible(true); / 設置窗體可見/this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); / 窗體關閉時,程序結束public static void main(String args) DelteStudent delstu = new DelteStudent();delstu.init();/ 刪除的監(jiān)聽器class delAction implements ActionList
18、ener public void actionPerformed(ActionEvent e) String delsno = (String) snocom.getSelectedItem();boolean b = studao.delete(delsno, conn);if (b) JOptionPane.showMessageDialog(null, 刪除錄入成功!); else JOptionPane.showMessageDialog(null, 刪除錄入失敗!);class BackAction implements ActionListenerpublic void actio
19、nPerformed(ActionEvent e) MainFrame m=new MainFrame (); m.init();package com.main;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.SQLException;import java.util.Vector;import javax.swing.JButton;import javax.swing.JComboBox;import java
20、x.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;import javax.swing.JOptionPane;import com.bean.Student;import com.dao.StudentDao;import com.db.DB;import com.main.AddStudent.BackAction;import com.main.DelteStudent.delAction;public class EditFrame extends JFrame StudentDao studa
21、o = new StudentDao();DB db = new DB();Connection conn = db.getConnection();JTextField snameText = null;JComboBox sexcom = null;JTextField ageText = null;JComboBox classcom = null;JComboBox departcom = null;JComboBox snocom = null;public void init() / 窗體設計this.setLayout(null);this.setTitle(學生信息管理系統(tǒng));
22、this.setSize(500, 400);JLabel title = new JLabel(學生信息維護模塊-修改數(shù)據(jù));title.setBounds(180, 20, 200, 30);this.add(title);JLabel snoLabel = new JLabel(學號);snoLabel.setBounds(20, 60, 40, 25);this.add(snoLabel);try Vector vec = studao.getSno();snocom = new JComboBox(vec); / 將數(shù)據(jù)庫里的學號信息裝入下拉框中snocom.setBounds(60
23、, 60, 120, 25); catch (SQLException e) e.printStackTrace();this.add(snocom);JLabel snameLabel = new JLabel(姓名);snameText = new JTextField();snameLabel.setBounds(220, 60, 40, 25);snameText.setBounds(260, 60, 120, 25);this.add(snameLabel);this.add(snameText);JLabel sexlabel = new JLabel(性別);String sex
24、 = 男, 女 ;sexcom = new JComboBox(sex);sexlabel.setBounds(20, 90, 40, 25);sexcom.setBounds(60, 90, 120, 25);this.add(sexlabel);this.add(sexcom);JLabel ageLabel = new JLabel(年齡);ageText = new JTextField();ageLabel.setBounds(220, 90, 40, 25);ageText.setBounds(260, 90, 120, 25);this.add(ageLabel);this.ad
25、d(ageText);JLabel classlabel = new JLabel(班級);String classes = 信息081, 信息082, 物流081 ;classcom = new JComboBox(classes);classlabel.setBounds(20, 120, 40, 25);classcom.setBounds(60, 120, 120, 25);this.add(classlabel);this.add(classcom);JLabel departlabel = new JLabel(學院);String depart = 造紙, 理學院, 機電學院 ;
26、departcom = new JComboBox(depart);departlabel.setBounds(220, 120, 40, 25);departcom.setBounds(260, 120, 120, 25);this.add(departlabel);this.add(departcom);/ 修改JButton editbtn = new JButton(修改);editbtn.setBounds(150, 180, 60, 30);editbtn.addActionListener(new editAction();this.add(editbtn);/ 返回JButto
27、n backbtn = new JButton(返回);backbtn.setBounds(220, 180, 60, 30);backbtn.addActionListener(new BackAction ();this.add(backbtn);this.setLocationRelativeTo(null); / 使窗體居中this.setResizable(false);/ 固定窗體大小this.setVisible(true); / 設置窗體可見/ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); / 窗體關閉時,程序結束/
28、獲取文本框或選擇框的值public Student getStudent() Student stu = new Student();String sno = (String) snocom.getSelectedItem(); / 獲取輸入的學號String sname = snameText.getText(); / 獲取姓名String sex = (String) sexcom.getSelectedItem();/ 獲取性別int age = Integer.parseInt(ageText.getText().trim(); / 獲取年齡String className = (St
29、ring) classcom.getSelectedItem(); / 獲取班級String depart = (String) departcom.getSelectedItem(); / 獲取學院/ 封裝信息stu.setSno(sno);stu.setName(sname);stu.setSex(sex);stu.setAge(age);stu.setClassName(className);stu.setDepart(depart);return stu;public static void main(String args) EditFrame editstu = new EditF
30、rame();editstu.init();/ 修改監(jiān)聽器class editAction implements ActionListener public void actionPerformed(ActionEvent e) Student stu = getStudent();boolean b = studao.edit(stu.getSno(), stu.getName(), stu.getSex(),stu.getAge(), stu.getClassName(), stu.getDepart(), conn);if (b) JOptionPane.showMessageDialog(null, 數(shù)據(jù)修改成功!); else JOptionPane.showMessageDialog(null, 數(shù)據(jù)修改失??!);class BackAction implements ActionListenerpublic void actionPerformed(ActionEvent e) MainFrame m=new MainFrame (); m.init();專心-專注-專業(yè)
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。