学生学籍管理系统含java源代码1文档格式.docx

上传人:b****5 文档编号:19649730 上传时间:2023-01-08 格式:DOCX 页数:32 大小:91.98KB
下载 相关 举报
学生学籍管理系统含java源代码1文档格式.docx_第1页
第1页 / 共32页
学生学籍管理系统含java源代码1文档格式.docx_第2页
第2页 / 共32页
学生学籍管理系统含java源代码1文档格式.docx_第3页
第3页 / 共32页
学生学籍管理系统含java源代码1文档格式.docx_第4页
第4页 / 共32页
学生学籍管理系统含java源代码1文档格式.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

学生学籍管理系统含java源代码1文档格式.docx

《学生学籍管理系统含java源代码1文档格式.docx》由会员分享,可在线阅读,更多相关《学生学籍管理系统含java源代码1文档格式.docx(32页珍藏版)》请在冰豆网上搜索。

学生学籍管理系统含java源代码1文档格式.docx

cx.java;

G.删除信息窗口程序:

sc.java;

H.程序数据连接:

DatabaseConn.java;

(2)程序代码及分析说明

A.程序源代码(已提交)

B.Student.java是程序的入口。

使登录窗口位于窗口中间,并且不可改变窗口大小。

C.mainframe.java是程序的登陆窗体。

输入用户名和密码(用户名和密码在数据库的password表中)点击“进入系统”,然后登陆界面消失;

出现要操作的界面(屏幕左上角)。

D.tj.java是添加信息界面。

添加基本信息后,点击“添加信息”按钮,将信息加入xinxi表中。

E.xg.java是修改信息界面。

输入要修改的学号或姓名(两者数其一或全部输入),并输入所有信息,点击“修改信息”按钮(如果数据库中不存在此学号,则弹出对话框“无此学生信息”),若有则修改。

F.sc.java是删除信息界面。

输入要删除的学生的学号,点击“删除信息”按钮,弹出确认删除对话框,即可删除该生信息。

G.cx.java是查询信息界面。

输入要查询的学生学号,点击“信息查询”按钮,在相应的文本区里显示查询的信息。

H:

源代码

//student.java:

程序的入口。

初始化界面,使主界面位于屏幕中间,且用户不能改变大小

//功能:

完成程序的执行顺序

importjavax.swing.UIManager;

importjava.awt.*;

importjava.sql.*;

//importscreen

publicclassstudent

{

booleanpackFrame=false;

//JFrameframe=newJFrame();

publicstudent()

{

mainframeframe=newmainframe();

if(packFrame)

{

frame.pack();

}

else

{

frame.validate();

}

DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();

DimensionframeSize=frame.getSize();

if(frameSize.height>

screenSize.height)

{

frameSize.height=screenSize.height;

if(frameSize.width>

screenSize.width)

{

frameSize.width=screenSize.width;

}

frame.setLocation((screenSize.width-frameSize.width)/2,(screenSize.height-frameSize.height)/2);

frame.setVisible(true);

}

publicstaticvoidmain(String[]args)

try{

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

catch(Exceptione)

e.printStackTrace();

newstudent();

}

//数据库连接

//packagesql.database;

publicclassDatabaseConn

privatestaticStringuser="

"

;

privatestaticStringpassword="

privateConnectionconn=null;

privateStatementstmt=null;

privateResultSetrs=null;

static

try{Class.forName("

sun.jdbc.odbc.JdbcOdbcDriver"

);

//加载驱动

catch(ClassNotFoundExceptione){}

//创建数据库连接对象

publicConnectiongetConnection()

conn=DriverManager.getConnection("

jdbc:

odbc:

stu"

user,password);

returnconn;

}catch(SQLExceptione)

returnnull;

publicStatementcreateStat()

try{

conn=getConnection();

stmt=conn.createStatement();

returnstmt;

}catch(SQLExceptione)

{returnnull;

}

publicResultSetgetRs(Stringsql)

try{

conn=getConnection();

//...

stmt=createStat();

rs=stmt.executeQuery(sql);

returnrs;

}catch(SQLExceptione)

{

returnnull;

publicvoidclose()

{

try{

if(rs!

=null)

rs.close();

if(stmt!

stmt.close();

if(conn!

conn.close();

}catch(SQLExceptionex)

ex.printStackTrace();

}

//mainframe.java

importjava.awt.event.*;

importjavax.swing.*;

publicclassmainframeextendsJFrameimplementsActionListener

staticmainframes;

staticJPanelpan=newJPanel();

staticJLabellabel1=newJLabel("

用户"

staticJLabellabel2=newJLabel("

密码"

staticJTextFieldtextField1=newJTextField();

staticJPasswordFieldpassword=newJPasswordField();

staticJButtonbutton1=newJButton("

进入系统"

staticJRadioButtonradioButton1=newJRadioButton("

管理员"

true);

//“管理员”初始状态被选中

staticJRadioButtonradioButton2=newJRadioButton("

学生"

staticJRadioButtonradioButton3=newJRadioButton("

教师"

ButtonGroupbuttonGroup=newButtonGroup();

publicmainframe()

JLabellabel=newJLabel(newImageIcon("

图片44.jpg"

));

label.setSize(400,400);

pan.add(label);

pan.setLayout(null);

pan.setSize(400,400);

this.setTitle("

学籍管理系统"

this.setSize(400,400);

this.setLayout(null);

label1.setBounds(100,25,49,20);

textField1.setBounds(155,24,120,20);

label2.setBounds(100,62,49,20);

password.setBounds(155,61,120,20);

button1.setBounds(150,200,101,22);

radioButton1.setBounds(105,120,80,20);

radioButton2.setBounds(180,120,60,20);

radioButton3.setBounds(240,120,60,20);

button1.addActionListener(this);

buttonGroup.add(radioButton1);

buttonGroup.add(radioButton2);

buttonGroup.add(radioButton3);

this.add(radioButton1);

this.add(radioButton2);

this.add(radioButton3);

this.add(label1);

this.add(label2);

this.add(textField1);

this.add(password);

this.add(button1);

this.add(pan);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

newmainframe();

publicvoidactionPerformed(ActionEvente)

{

if(radioButton1.isSelected())//管理员

if(textField1.getText().equals("

syc"

)&

&

password.getText().equals("

123"

)){

interfacb=newinterfac();

this.dispose();

//JOptionPane.showMessageDialog(null,"

登陆成功"

}elseif("

.equals(textField1.getText())||"

.equals(password.getText())){

JOptionPane.showMessageDialog(null,"

用户名或密码不能为空"

}else{

JOptionPane.showMessageDialog(null,"

用户名或密码输入有误"

if(radioButton2.isSelected())//学生

Class.forName("

catch(ClassNotFoundExceptionce)

JOptionPane.showMessageDialog(s,ce.getMessage());

try

Connectioncon=DriverManager.getConnection("

"

sa"

Statementstmt=con.createStatement();

ResultSetrs=stmt.executeQuery("

select*frompasswordwhere用户名='

+textField1.getText()+"

'

and密码='

+password.getText()+"

if(textField1.getText().equals("

)||password.getText().equals("

))

JOptionPane.showMessageDialog(this,"

用户名或密码不可为空!

elseif(rs.next())

{newinterfac();

}

else

{JOptionPane.showMessageDialog(this,"

您的输入有误"

//stmt.close();

catch(SQLExceptionse)

JOptionPane.showMessageDialog(s,se.getMessage());

//interface.java

publicclassinterfacextendsJFrameimplementsActionListener

staticJMenuBarjMenuBar=newJMenuBar();

//菜单条

staticJMenujMenuFile=newJMenu("

文件"

//菜单项

staticJMenujMenuExit=newJMenu("

退出"

staticJMenuItemjMenuItem1=newJMenuItem("

添加信息"

//菜单子项

staticJMenuItemjMenuItem2=newJMenuItem("

修改信息"

staticJMenuItemjMenuItem3=newJMenuItem("

信息查询"

staticJMenuItemjMenuItem4=newJMenuItem("

删除信息"

staticJLabellabel3=newJLabel("

请选择操作项"

staticJLabellabel4=newJLabel("

staticJButtonbutton2=newJButton("

staticJButtonbutton3=newJButton("

staticJButtonbutton4=newJButton("

staticJButtonbutton5=newJButton("

publicinterfac()

label3.setBounds(158,92,98,33);

label3.setFont(newFont("

Dialog"

Font.PLAIN,15));

label4.setFont(newFont("

Font.BOLD,20));

label4.setBounds(157,37,280,40);

button2.setBounds(74,136,97,33);

button3.setBounds(226,136,97,33);

button4.setBounds(74,185,97,33);

button5.setBounds(226,185,97,33);

this.add(button2);

this.add(button3);

this.add(button4);

this.add(button5);

this.add(label3);

this.add(label4);

setJMenuBar(jMenuBar);

jMenuFile.add(jMenuItem1);

//”文件“菜单项中加入子菜单

jMenuFile.add(jMenuItem2);

jMenuFile.add(jMenuItem3);

jMenuFile.add(jMenuItem4);

jMenuBar.add(jMenuFile);

//将菜单项加入菜单条

jMenuBar.add(jMenuExit);

button2.addActionListener(this);

//本窗口向按钮事件源注册

button3.addActionListener(this);

button4.addActionListener(this);

button5.addActionListener(this);

jMenuItem1.addActionListener(this);

//本窗口菜单子项注册

jMenuItem2.addActionListener(this);

jMenuItem3.addActionListener(this);

jMenuItem4.addActionListener(this);

jMenuExit.addActionListener(this);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

interfaca=newinterfac();

publicvoidactionPerformed(ActionEvente)//按钮事件的处理

if(e.getSource()==jMenuExit)

System.exit(0);

elseif(e.getSource()==jMenuItem1||e.getSource()==button2)

{

try{

tja=newtj();

catch(Exceptionee){}

elseif(e.getSource()==jMenuItem2||e.getSource()==button3)

try{

xga=newxg();

}catch(Exceptioned){}

elseif(e.getSource()==jMenuItem3||e.getSource()==button4)

cxa=newcx();

catch(Exceptionec){}

elseif(e.getSource()==jMenuItem4||e.getSource()==button5)

sca=newsc();

}catch(Exceptiones){}

//tj.java添加界面

publicclasstjextendsJFrameimplementsActionListener

statictjs;

学号:

staticJTextFieldtextField1=newJTextField("

姓名:

staticJTextFieldtextField2=newJTextField("

性别:

staticJTextFieldtextField7=newJTextField("

出生日期:

staticJTextFieldtextField3=newJTextField("

staticJLabellabel5=newJLabel("

政治面貌:

staticJTextFieldtextField8=newJTextField("

staticJLabellabel6=newJLabel("

籍贯"

staticJTextFieldtextField4=newJTextField("

staticJLabellabel7=newJLabel("

系别:

st

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 艺术

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1