《Java程序设计实训》
学生成绩管理系统
设计数据库:
CREATEDATABASE学生成绩管理系统
(1)教师信息表创建:
createtable教师信息表(
教师IDvarchar(8)primarykey,
教师姓名varchar(8)notnullunique,
登录密码varchar(8)notnull,
)
(2)学籍信息表创建:
createtable学籍信息表(
学号varchar(15)primarykey,
姓名varchar(8)notnull,
年龄varchar(10),
出生日期varchar(10),
性别varchar(4),
班级varchar(8)notnull,
专业varchar(5),
民族varchar(10),
登录密码varchar(6)notnull)
(3)成绩信息表创建:
createtable成绩信息表(
学号varchar(15),
计算机网络varchar(8),
计算机专业英语smallint,
计算机信息技术基础smallint,
Java程序设计smallint,
数据库应用实训教程smallint,
高等数学smallint,
Xmlsmallint,)
概要结构分析:
word/media/image1.gif
1.登录界面和主界面
.*;
import;
.*;
import
.*;
classmyConnection{ResultSetre;
publicmyConnection(){}
publicResultSetgetResult(Stringsql){
try{();
Connectionconn=("jdbc:odbc:学生成绩管理系统","ww","123");
Statementstmt=,;
ResultSetre=(sql);
returnre;}
catch(Exceptione){
"getResult------"+());
returnnull;}}
publicbooleanexecuteSql(Stringsql){
try{();
Connectionconn=("jdbc:odbc:学生成绩管理系统","ww","123");
Statementstmt=();
(sql);
();
returntrue;}
catch(Exceptione){
"executeSql----"+());
returnfalse;}}}
classstuMainFrameextendsJFrameimplementsActionListener
{JMenuBarjmb=newJMenuBar();
Message=newJMenu("信息");
JMenuScore=newJMenu("查询");
JMenuItemItem1=newJMenuItem("添加学生信息");
JMenuItemmName=newJMenuItem("学生成绩查询");
JMenuItemmScore=newJMenuItem("按成绩查询");
JMenuItemmNam1=newJMenuItem("查询学生信息");
JLabellabel=newJLabel();
publicstuMainFrame(){ImageIconicon=newImageIcon("src/images/");
(icon);
(0,0,(),());
add(label);
setSize(),());
(jmb);
(Message);
(Score);
(Item1);
(mNam1);
(mName);
(mScore);
(this);
(this);
(this);
(this);}
publicvoidactionPerformed(ActionEvente)
{if()==Item1)
{newaddForm().setVisible(true);}
elseif()==mName)
{dispose();
newScore1().setVisible(true);}
elseif()==mScore)
{newscoreQueryForm().setVisible(true);}
elseif()==mNam1)
{dispose();
newSerch1().setVisible(true);}}}
classmainFrameextendsJFrameimplementsActionListener{
JLabellabel=newJLabel();
JMenuBarmBar=newJMenuBar();
JPanelp=newJPanel();
privateJMenumSystem,mOperate,mQuery,mHelp,myMenuUser;
privateJMenuItemmFile,mNew,mOpen,mExit,mAdd,mDel,mModify,mName,miShow,mScore,mAbout,miUser,mAddSc;
publicmainFrame()
{ (mBar);
ImageIconicon=newImageIcon("src/images/");
(icon);
(0,0,(),());
add(label);
setSize(),());
myMenuUser=newJMenu("用户");
miUser=newJMenuItem("编辑用户");
(miUser);
mSystem=newJMenu("系统");
mOperate=newJMenu("数据操作");
mQuery=newJMenu("查询");
mHelp=newJMenu("帮助");
(mSystem);
(mOperate);
(mQuery);
(mHelp);
(myMenuUser);
mFile=newJMenuItem("文件");
mNew=newJMenuItem("新建");
mOpen=newJMenuItem("打开");
mExit=newJMenuItem("退出");
(mFile);
(mNew);
(mOpen);
();
(mExit);
mAdd=newJMenuItem("添加基本信息");
mAddSc=newJMenuItem("添加成绩信息");
mDel=newJMenuItem("删除");
mModify=newJMenuItem("修改");
(mAdd);
(mAddSc);
(mDel);
(mModify);
mName=newJMenuItem("查询学生信息");
mScore=newJMenuItem("查询学生成绩");
miShow=newJMenuItem("全部显示");
(mName);
(mScore);
();
(miShow);
mAbout=newJMenuItem("软件信息");
(mAbout);
(this);
(this);
(this);
(this);
(this);
(this);
(this);
(this);
(this);
(this);}
publicvoidactionPerformed(ActionEvente){
if()==mExit){
dispose();
newCJ().setVisible(true);}
elseif()==mAbout){
(this,"学生成绩管理系统\n\n电信学院\n\n2012年3月","软件信息",;}
elseif()==mAdd){
dispose();
newaddForm().setVisible(true);}
elseif()==mAddSc){
dispose();
newaddScore().setVisible(true);}
elseif()==mDel){
dispose();
newdeleteForm().setVisible(true);}
elseif()==mName){
dispose();
newSerch().setVisible(true);}
elseif()==mScore){
dispose();
newScore().setVisible(true);}
elseif()==mModify){
newmodifyForm().setVisible(true);}
elseif()==miUser){
newuserFrame().setVisible(true);}
elseif()==miShow){
newfreshTable().setVisible(true);}}}
classCJextendsJFrameimplementsActionListener{
JLabelt1=newJLabel("ID号:");
JLabelt3=newJLabel("密码:");
JLabellabel=newJLabel();
publicStringzh=null;
JTextFieldt2=newJTextField(null,15);
JTextFieldt4=newJPasswordField(null,15);
JRadioButtonb=newJRadioButton("教师");
JRadioButtonb1=newJRadioButton("学生");
JButtonjB1=newJButton("登录");
JButtonjB2=newJButton("取消");
publicCJ(){super("学生生成绩管理系统");
setLayout(null);
(110,170,60,20);
;
add(jB1);
(210,170,60,20);
;
add(jB2);
(90,50,80,35);
add(t1);
(120,50,150,35);
add(t2);
(90,100,80,35);
add(t3);
(120,100,150,35);
add(t4);
(200,20,70,30);
(120,20,70,30);
ButtonGroupbg=newButtonGroup();
(false);
(true);
(false);
add(b);(b);add(b1);(b1);
(false);
(false);
ImageIconicon=newImageIcon("src/images/");
(icon);
(0,0,(),());
add(label);
setSize(),());
setResizable(false);
setVisible(true);
setLocation(300,300);
setDefaultCloseOperation;
(this);
(this);}
publicvoidactionPerformed(ActionEvente){
if()==jB2){
(0);}
elseif()==jB1){
Stringusername,password;
username=();
password=();
if()){
if().equals("")){
(null,"请输入用户名","温馨提示",;
}
elseif().equals("")){
(null,"请输入密码","温馨提示",;
}
else{
myConnectionconn=newmyConnection();
ResultSetrs;
String sql="select*from教师信息表where教师ID='"+()+"'and登录密码='"+()+"'";
try{
rs=(sql);
();
if()==1)
{setVisible(false);
();
while()){
();
sql="select*from学籍信息表";
mainFramemf=newmainFrame();
(null);
(true);
(300,300);
(false);
("学生成绩管理系统:教师登录界面");
;
(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
(0);
}
});
(null,("教师姓名")+"老师!您好!欢迎登录学生成绩管理系统!");}
}
else{
(null,"用户名或密码错误","登录失败",;
}
}
catch(Exceptioner){
}
}
}
if()){
if().equals("")){
(null,"请输入用户名","温馨提示",;
}
elseif().equals("")){
(null,"请输入密码","温馨提示",;
}
else{
myConnectionconn=newmyConnection();
ResultSetrs;
String sql="select*from学籍信息表where学号='"+().toString()+"'and登录密码='"+().toString()+"'";
try{
rs=(sql);
();
if()==1)
{setVisible(false);
();
while()){
();
sql="select*from学籍信息表";
stuMainFramesmf=newstuMainFrame();
(500,400);
(true);
(false); ;
(newWindowAdapter(){
publicvoidwindowClosing(WindowEvente){
(0);
}
});
(null,("学生姓名")+"同学!您好!欢迎登录学生成绩管理系统!");}}
else{
(null,"用户名或密码错误","登录失败",;
}}
catch(Exceptioner){
}}}}}
publicstaticvoidmain(String[]args){
try{
());
}
catch(Exceptione){}
CJframe=newCJ();
newmainFrame();
stuMainFramestu=newstuMainFrame();}}
2.添加学生基本信息
.*;
import;
.*;
import
.*;
publicclassaddFormextendsJFrameimplementsActionListener
{JLabellabel1=newJLabel("添加基本信息",;
JLabellabxuehao=newJLabel("学号:",;
JLabellabyear=newJLabel("年龄:",;
JLabellabName=newJLabel("姓名:",;
JLabellabDate=newJLabel("出生日期:",;
JLabellabclass=newJLabel("班级:",;
JLabellabzy=newJLabel("专业:",;
JLabellabmz=newJLabel("民族:",;
JLabellabsex=newJLabel("性别:",;
JTextFieldtxtName=newJTextField(20);
JTextFieldtxtDate=newJTextField(18);
JTextFieldtxtXueHao=newJTextField(20);
JTextFieldtxtYear=newJTextField(20);
JTextFieldtxtClass=newJTextField(20);
JTextFieldtxtZY=newJTextField(20);
JTextFieldtxtMZ=newJTextField(20);
ButtonGroupbgp=newButtonGroup();
JRadioButtonman=newJRadioButton("男");
JRadioButtonwomen=newJRadioButton("女");
JButtonbtnAdd=newJButton("添加");
JButtonbtnCancel=newJButton("返回");
JButtonbtnReset=newJButton("重置");
JPaneljpl=newJPanel();etVisible(true);}
if()==btnAdd)
{if().toString().equals("")){
(null,"请输入学号","温馨提示",;
}elseif().toString().equals("")){
(null,"请输入姓名","温馨提示",;
}elseif().toString().equals("")){
(null,"请输入年龄","温馨提示",;
}elseif().toString().equals("")){
(null,"出生日期","温馨提示",;
}elseif().toString().equals("")){
(null,"请输入专业","温馨提示",;
}elseif().toString().equals("")){
(null,"请输入民族","温馨提示",;
}elseif().toString().equals("")){
(null,"请输入班级","温馨提示",;}
else{
Stringsex;
if())
{sex="男";}
else
{sex="女";}
try
{();}
catch(ClassNotFoundExceptionce)
{(null,());}
try{
Connectioncon=("jdbc:odbc:学生成绩管理系统","ww","123");
Statementstmt=();
inta=("insertinto学籍信息表(学号,登录密码,姓名,年龄,出生日期,性别,班级,专业,民族)values('"+()+"','"+00000+"','"+()+"','"+()+"','"+()+"','"+sex+"','"+()+"','"+()+"','"+()+"')");
if(a==1)
{(null,"已成功添加","温馨提示",;}
else
{(null,"添加失败","温馨提示",;}
();}
catch(SQLExceptionse)
{(null,());}}}
else{("");
("");
("");
("");
("");
("");
("");
();}}
publicstaticvoidmain(String[]args)
{addFormamg=newaddForm();}}
3.添加学生成绩
.*;
.*;
import
.*;
publicclassaddScoreextendsJFrameimplementsActionListener
{staticaddScoress;
JLabel[]label={newJLabel("学号:"),newJLabel("计算机网络:"),newJLabel("Linux操作系统:"),newJLabel("计算机专业英语:"),newJLabel("计算机信息技术基础:"),newJLabel("Java程序设计:"),newJLabel("数据库应用实训教程:"),newJLabel("高等数学:"),newJLabel("XML:")};
JTextField[]txt={newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField()};
JButtonadd=newJButton("添加");
JButtonreset=newJButton("重置");
JButtonCancel=newJButton("返回");
JPaneljpl=newJPanel();
JLabeltitle=newJLabel("添加学生成绩",;
Fontf=newFont("黑体",,16);
ints=100;
publicaddScore()
{
super("添加学生信息");
(false);
(500,600);
(EXIT_ON_CLOSE);
(true);
(jpl);
(this);
(this);
(this);
(null);
(150,40,200,20);
(f);
;
;
(title);
for(inti=0;i<;i++)
{
label[i].setBounds(100,s,140,20);
(label[i]);
txt[i].setBounds(260,s,140,20);
(txt[i]);
s=s+40;
}
(100,s,80,20);
(200,s,80,20);
(300,s,80,20);
(add);
(reset);
(Cancel);
}
publicvoidactionPerformed(ActionEvente)
{
if()==Cancel){
dispose();
newmainFrame().setVisible(true);
}
elseif()==add)
{try
{();}
catch(ClassNotFoundExceptionce)
{(ss,());}
try{Connectioncon=("jdbc:odbc:学生成绩管理系统","ww","123");
Statementstmt=();
inta=("insertinto成绩信息表(学号,计算机网络,Linux操作系统,计算机专业英语,计算机信息技术基础,Java程序设计,数据库应用实训教程,高等数学,Xml)values('"+txt[0].getText()+"','"+txt[1].getText()+"','"+txt[2].getText()+"','"+txt[3].getText()+"','"+txt[4].getText()+"','"+txt[5].getText()+"','"+txt[6].getText()+"','"+txt[7].getText()+"','"+txt[8].getText()+"')");if(a==1)
{(ss,"添加成功");}
else
{(ss,"添加失败");}}
catch(SQLExceptionse)
{(ss,()); }}
else
{for(inti=0;i<;i++)
{txt[i].setText("");
txt[0].requestFocus(); }}}
publicstaticvoidmain(String[]args)
{addScoreas=newaddScore();}}
4.修改学生信息:
.*;
.*;
import
.*;
publicclassmodifyFormextendsJFrameimplementsActionListener
{
JPaneljpl=newJPanel();
JLabelSCH=newJLabel("修改学生信息",;
Fontf=newFont("楷体",+,30);
JLabellabel1=newJLabel("请输入学号:",;
JButtonbtnQuery=newJButton("查询");
JLabellabel2=newJLabel("姓名:",;
JLabellabyear=newJLabel("年龄:",;
JLabellabDate=newJLabel("出生日期:",;
JLabellabel5=newJLabel("性别:",;
JLabellabel3=newJLabel("班级:",;
JLabellabel4=newJLabel("专业:",;
JLabellabmz=newJLabel("民族:",;
ButtonGroupbgp=newButtonGroup();
JRadioButtonman=newJRadioButton("男");
JRadioButtonwomen=newJRadioButton("女");
JTextFieldtyear=newJTextField();
JTextFieldtDate=newJTextField();
JTextFieldtmz=newJTextField();
JTextFieldnum=newJTextField();
JTextFieldnam=newJTextField();
JTextFieldclas=newJTextField();
JTextFieldscl=newJTextField();
JButtonbtnModify=newJButton("修改");
JButtonbtnCancel=newJButton("取消");
Connectioncon;
Statementsql;
ResultSetrs;
intre;
publicmodifyForm()
{(560,460);
(true);
(false);
;
;
(jpl);
;
;
;
(null);
(this);
(this);
(this);
(100,20,300,20);
(SCH);
(100,60,100,20);
(label1);
(220,60,140,20);
(num);
(120,100,90,20);
(230,100,90,20);
(340,100,90,20);
(btnQuery);
(btnModify);
(btnCancel);
(100,150,70,20);
(label2);
(190,150,140,20);
(nam);
(100,180,70,20);
(labyear);
(190,180,140,20);
(tyear);
(100,210,70,20);
(labDate);
(190,210,140,20);
(tDate);
(100,250,70,20);
(label5);
(205,250,60,20);
(285,250,60,20);
(man);
(women);
(man);
(women);
(100,290,70,20);
(label3);
(190,290,140,20);
(clas);
(100,320,70,20);
(label4);
(190,320,140,20);
(scl);
(100,350,70,20);
(labmz);
(190,350,140,20);
(tmz);
}
publicvoidactionPerformed(ActionEventae){
if()==btnCancel){
dispose();newmainFrame().setVisible(true);}
elseif()==btnQuery){
try{
();}
catch(ClassNotFoundExceptione){}
try{con=("jdbc:odbc:学生成绩管理系统","ww","123");
sql=();
rs=("select*from学籍信息表where学号='"+()+"'");
if()){
("学号"));
("姓名"));
("年龄").toString());
("出生日期"));
if("性别").equals("男"))
{(true);}
else
{(true);}
("班级"));
("专业"));
("民族"));
(true);
(true);
(true);
(true);
(true);
(true);
(true);
}else{
(null,"不存在该记录!","温馨提示",;
(false);
("");
("");
("");
("");
("");
("");
("");
();
(false);
(false);
(false);
(false);
(false);
(false);
}}catch(SQLExceptione){}}
elseif()==btnModify)
{try
{con=("jdbc:odbc:学生成绩管理系统","ww","123");
sql=();
re=("Update学籍信息表set姓名='"+()+"',年龄='"+()+"',出生日期='"+()+"',班级='"+()+"',专业='"+()+"',民族='"+()+"'where学号='"+()+"'");
if(re==1)
{(null,"记录修改完毕!","温馨提示",;}
else
{(null,"记录修改失败!","温馨提示",;
}();}
catch(SQLExceptionse)
{(null,());}}
else{(false);
("");
("");
("");
("");
("");
("");
("");
();
(false);
(false);
(false);
(false);
(false);
(false);}}
publicstaticvoidmain(String[]args){
newmodifyForm();}}
5.删除学生信息
.*;
.*;
import
.*;
publicclassdeleteFormextendsJFrameimplementsActionListener
{JPaneljpl=newJPanel();
JLabelSCH=newJLabel("删除学生信息",;
Fontf=newFont("楷体",+,30);
JLabellabel1=newJLabel("请输入学号:",;
JButtonbtnQuery=newJButton("查询");
JLabellabel2=newJLabel("姓名:",;
JLabellabyear=newJLabel("年龄:",;
JLabellabDate=newJLabel("出生日期:",;
JLabellabel5=newJLabel("性别:",;
JLabellabel3=newJLabel("班级:",;
JLabellabel4=newJLabel("专业:",;
JLabellabmz=newJLabel("民族:",;
ButtonGroupbgp=newButtonGroup();
JRadioButtonman=newJRadioButton("男");
JRadioButtonwomen=newJRadioButton("女");
JTextFieldtyear=newJTextField();
JTextFieldtDate=newJTextField();
JTextFieldtmz=newJTextField();
JTextFieldnum=newJTextField();
JTextFieldnam=newJTextField();
JTextFieldclas=newJTextField();
JTextFieldscl=newJTextField();
JButtonbtnDelete=newJButton("删除");
JButtonbtnCancel=newJButton("取消");
Connectioncon;
Statementsql;
ResultSetrs;
intre;
deleteForm()
{ (560,460);
(true);
(false);
;
;
(jpl);
;
;
;
(null);
(this);
(this);
(this);
(100,20,300,20);
(SCH);
(100,60,100,20);
(label1);
(220,60,140,20);
(num);
(120,100,90,20);
(230,100,90,20);
(340,100,90,20);
(btnQuery);
(btnDelete);
(btnCancel);
(100,150,70,20);
(label2);
(190,150,140,20);
(nam);
(100,180,70,20);
(labyear);
(190,180,140,20);
(tyear);
(100,210,70,20);
(labDate);
(190,210,140,20);
(tDate);
(100,250,70,20);
(label5);
(205,250,60,20);
(285,250,60,20);
(man);
(women);
(man);
(women);
(100,290,70,20);
(label3);
(190,290,140,20);
(clas);
(100,320,70,20);
(label4);
(190,320,140,20);
(scl);
(100,350,70,20);
(labmz);
(190,350,140,20);
(tmz);
(false);etVisible(true);}
elseif()==btnQuery){
try{();}
catch(ClassNotFoundExceptione){}
try{con=("jdbc:odbc:学生成绩管理系统","ww","123");
sql=();
rs=("select*from学籍信息表where学号='"+()+"'");
if()){
("学号"));
("姓名"));
("年龄").toString());
("出生日期"));
if("性别").equals("男"))
{(true);}
else
{(true);}
("班级"));
("专业"));
("民族"));
(true);
(true);
(true);
(true);
(true);
(true);
(true);
}else{(null,"不存在该记录!","温馨提示",;
(false);
("");
("");
("");
("");
("");
("");
("");
();
(false);
(false);
(false);
(false);
(false);
(false);}
}catch(SQLExceptione){}}
elseif()==btnDelete) 生信息查询与成绩查询
.*;
.*;
import
import.*;
.*;
publicclassScoreextendsJFrameimplementsActionListener
{staticScores;
JLabeltitle=newJLabel("查询成绩",;
Fontf=newFont("楷体",+,16);
JPaneljpl=newJPanel();
JLabellabel1=newJLabel("请输入学号:",;
JTextFieldnum=newJTextField();
JButtonserch=newJButton("查询成绩");
JButtonreset=newJButton("重置");
JLabellabel2=newJLabel("计算机网络:",;
JLabellabel3=newJLabel("Linux操作系统:",;
JLabellabel4=newJLabel("计算机专业英语:",;
JLabellabel5=newJLabel("计算机信息技术基础:",;
JLabellabel6=newJLabel("Java程序设计:",;
JLabellabel7=newJLabel("数据库:",;
JLabellabel8=newJLabel("高等数学:",;
JLabellabel9=newJLabel("XML:",;
JButtonCancel=newJButton("返回");
JTextField[]txt={newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField(),newJTextField()};
staticintp=140;
publicScore()
{super("查询分数");
(false);
(500,550);
(true);
;
;
;
(f);
(jpl);
(null);
(100,20,300,20);
(title);
(100,60,90,20);
(label1);
(210,60,140,20);
(num);
(100,100,90,20);
(200,100,90,20);
(300,100,90,20);
(serch);
(reset);
(Cancel);
(this);
(this);
(this);
(100,140,140,20);
(100,180,140,20);
(100,220,140,20);
(100,260,140,20);
(100,300,140,20);
(100,340,140,20);
(100,380,140,20);
(100,420,140,20);
(label2);
(label3);
(label4);
(label5);
(label6);
(label7);
(label8);
(label9);
for(inti=0;i<;i++)
{txt[i].setBounds(260,p,140,20);
(txt[i]);
p=p+40;}}
publicvoidactionPerformed(ActionEvente)
{if()==Cancel){
dispose();
newmainFrame().setVisible(true); }
if()==serch)
{Stringid=();
try{();}
catch(ClassNotFoundExceptionce)
{(s,());}
try{Connectioncon=("jdbc:odbc:学生成绩管理系统","ww","123");
Statementstmt=();
ResultSetrs=("select*from成绩信息表where学号='"+id+"'");
while())
{for(inti=0;i<;i++)
{txt[i].setText(i+2));}}}
catch(SQLExceptionse)
{(s,());}}
else
{for(inti=0;i<;i++)
{txt[i].setText("");}
("");}}
publicstaticvoidmain(String[]args)
{Scores=newScore();}}
.*;
.*;
import
.*;
publicclassSerchextendsJFrameimplementsActionListener
{ staticSerchs;
JPaneljpl=newJPanel();
JLabelSCH=newJLabel("查询学生信息",;
JLabellabel1=newJLabel("请输入学号:",;
JButtonserch=newJButton("查询");
JLabellabel2=newJLabel("姓名:",;
JLabellabyear=newJLabel("年龄:",;
JLabellabDate=newJLabel("出生日期:",;
JLabellabel5=newJLabel("性别:",;
JLabellabel3=newJLabel("班级:",;
JLabellabel4=newJLabel("专业:",;
JLabellabmz=newJLabel("民族:",;
ButtonGroupbgp=newButtonGroup();
JRadioButtonman=newJRadioButton("男");
JRadioButtonwomen=newJRadioButton("女");
JTextFieldtyear=newJTextField();
JTextFieldtDate=newJTextField();
JTextFieldtmz=newJTextField();
JTextFieldnum=newJTextField();
JTextFieldnam=newJTextField();
JTextFieldclas=newJTextField();
JTextFieldscl=newJTextField();
JButtonreset=newJButton("重置");
JButtoncaln=newJButton("取消");
publicSerch()
{(560,460);
(true);
(false);
;
(jpl);
;
;
;
(null);
(this);
(this);
(this);
(100,20,300,20);
(SCH);
(100,60,100,20);
(label1);
(220,60,140,20);
(num);
(120,100,90,20);
(230,100,90,20);
(340,100,90,20);
(serch);
(reset);
(caln);
(100,150,70,20);
(label2);
(190,150,140,20);
(nam);
(100,180,70,20);
(labyear);
(190,180,140,20);
(tyear);
(100,210,70,20);
(labDate);
(190,210,140,20);
(tDate);
(100,250,70,20);
(label5);
(205,250,60,20);
(285,250,60,20);
(man);
(women);
(man);
(women);
(100,290,70,20);
(label3);
(190,290,140,20);
(clas);
(100,320,70,20);
(label4);
(190,320,140,20);
(scl);
(100,350,70,20);
(labmz);
(190,350,140,20);
(tmz);}
publicvoidactionPerformed(ActionEvente)
{if()==caln){
dispose();
newmainFrame().setVisible(true);}
elseif()==serch){
try{();}
catch(ClassNotFoundExceptionse){}
try{Connectioncon=("jdbc:odbc:学生成绩管理系统","ww","123");
Statementstmt=();
ResultSetrs=("select*from学籍信息表where学号='"+()+"'");
if()){("学号"));
("姓名"));
("年龄").toString());
("出生日期"));
if("性别").equals("男"))
{(true);}
else
{(true);}
("班级"));
("专业"));
("民族"));
}else{(null,"不存在该记录!","温馨提示",;
("");
("");
("");
("");
("");
("");
("");
();}
}catch(SQLExceptionse){}}}
publicstaticvoidmain(String[]args)
{Serchsch=newSerch();}}
packageUI;
.*;
.*;
import
classJFrameMainextendsJFrame{
privateJPanelpanelNorth=newJPanel();
privateJButtonbtnUser=newJButton("用户登录");
privateJButtonbtnQuery=newJButton("数据查询");
privateJButtonbtnInsert=newJButton("数据插入");
privateJButtonbtnUpdate=newJButton("数据修改");
privateJButtonbtnDelete=newJButton("数据删除");
privateJTextAreata=newJTextArea(6,10);
publicJFrameMain(Stringtitle){
super(title);
(100,100,300,200);
ContainercontentPane=();
(btnUser);
(btnQuery);
(btnInsert);
(btnUpdate);
(btnDelete);
(panelNorth,;
(ta,;
(newMyActionListener());
(newMyActionListener());
(newMyActionListener());
(newMyActionListener());
(newMyActionListener());
(true);
;
}
privateclassMyActionListenerimplementsActionListener{
publicvoidactionPerformed(ActionEvente){
}
}
}
publicclassMainWnd{
/**
*@paramargs
*/
publicstaticvoidmain(String[]args){
//TODOAuto-generatedmethodstub
newJFrameMain("学生成绩管理系统");
}
}
本文来源:https://www.2haoxitong.net/k/doc/69c7362a900ef12d2af90242a8956bec0875a54b.html
文档为doc格式