java课程设计学生管理系统源代码.docx
《java课程设计学生管理系统源代码.docx》由会员分享,可在线阅读,更多相关《java课程设计学生管理系统源代码.docx(93页珍藏版)》请在冰点文库上搜索。
java课程设计学生管理系统源代码
1.MIS_frame类
packageMIS_Login;
importjava.awt.Container;
importjava.awt.Cursor;
importjava.awt.Dimension;
importjava.awt.FlowLayout;
importjava.awt.GridLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.event.MouseAdapter;
importjava.awt.event.MouseEvent;
importjavax.swing.ButtonGroup;
importjavax.swing.ImageIcon;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JPasswordField;
importjavax.swing.JRadioButton;
importjavax.swing.JTextField;
/*
*
*总目标:
*1.一个用户名输入框,一个密码输入框
*2.就一个登陆的按钮
*3.加一组JRadioButton,一个是管理员,一个是学生用户
*4.两个超链接,一个是忘记密码,一个是用户注册
*
*用户注册:
*1.。
。
。
只面向的是学生用户,不对管理员开放
*2.注册的时候只有接受协议的时候,才能跳到下一步详细信息的填写。
*3.包括的信息:
学号,姓名,用户名,邮箱名,密码,确认密码,(5)个基本信息,两个按钮,确认与取消
*4.学号必须是系统存在的。
两次的密码必须是一致的。
符合的话,给出注册成功的信息,否则给出提示信息
*5.dispose(),返回到登陆界面
*
*忘记密码:
*1.一个窗体,必须先填写用户名,先匹配数据库,给出提示,
*2.如果存在用户名,提示信息,“已向***(邮箱),发送验证码”,释放原先的窗体,弹出一个新的窗体,
*包含的内容有:
用户名(不可修改),验证码,新的密码,确认密码。
*3.验证码正确,提示,否则,提示。
。
*
*
**/
importStudent.SubFrame.all.AllFrame_stu;
importAdmin.SubFrame.all.Allframe_admin;
publicclassMIS_frameimplementsActionListener{
publicJButtonb_login;
publicJLabellab_username,lab_pwd;
publicJTextFieldtxt_login;
publicJPasswordFieldtxt_pwd;
publicJLabellab_forget,lab_register;
publicJRadioButtonb_admin_login,b_stu_login;
publicJPanelMIS_p1,MIS_p2,MIS_p3,MIS_p4,MIS_p5;
publicJFramemis_frame;
publicvoidMIS_display(){
MIS_p1=newJPanel();
lab_username=newJLabel("用户名:
");
txt_login=newJTextField(15);
MIS_p1.add(lab_username);
MIS_p1.add(txt_login);
MIS_p1.setLayout(newFlowLayout(FlowLayout.CENTER,0,40));
MIS_p2=newJPanel();
lab_pwd=newJLabel("密码:
");
txt_pwd=newJPasswordField(15);
MIS_p2.add(lab_pwd);
MIS_p2.add(txt_pwd);
MIS_p2.setLayout(newFlowLayout(FlowLayout.CENTER,0,15));
MIS_p3=newJPanel();
b_login=newJButton("登陆");
MIS_p3.add(b_login);
MIS_p3.setLayout(newFlowLayout(FlowLayout.CENTER,0,15));
MIS_p4=newJPanel();
b_admin_login=newJRadioButton("管理员",true);
b_stu_login=newJRadioButton("学生用户");
ButtonGroupbg_login_button=newButtonGroup();
bg_login_button.add(b_admin_login);
bg_login_button.add(b_stu_login);
MIS_p4.add(b_admin_login);
MIS_p4.add(b_stu_login);
MIS_p4.setLayout(newFlowLayout(FlowLayout.CENTER,10,15));
MIS_p5=newJPanel();
lab_forget=newJLabel("忘记密码"+"");
lab_register=newJLabel("注册");
MIS_p5.add(lab_forget);
MIS_p5.add(lab_register);
MIS_p5.setLayout(newFlowLayout(FlowLayout.CENTER));
lab_forget.setCursor(newCursor(Cursor.HAND_CURSOR));
lab_register.setCursor(newCursor(Cursor.HAND_CURSOR));
//ImageIconimg=newImageIcon("D:
\\2013-2014课程表.png");
//JLabelimgLabel=newJLabel(img);//将背景图放在标签里。
////jf.getLayeredPane().add(imgLabel,newInteger(Integer.MIN_VALUE));
//imgLabel.setBounds(0,0,img.getIconWidth(),img.getIconHeight());
//
mis_frame=newJFrame();
Containermis_container=mis_frame.getContentPane();
mis_container.add(MIS_p1);
mis_container.add(MIS_p2);
mis_container.add(MIS_p4);
mis_container.add(MIS_p3);
mis_container.add(MIS_p5);
mis_frame.setLayout(newGridLayout(5,1));
mis_frame.setLocation(600,200);
mis_frame.setPreferredSize(newDimension(500,350));
mis_frame.pack();
mis_frame.setVisible(true);
//忘记密码鼠标监听
lab_forget.addMouseListener(newMouseAdapter(){
publicvoidmouseClicked(MouseEvente){
newForget_pwd_frame().forget_button_function();
}
});
//注册鼠标监听
lab_register.addMouseListener(newMouseAdapter(){
publicvoidmouseClicked(MouseEvente){
System.out.println("注册!
");
newRegister_frame().statement_useragr_frame();
}
});
//登陆按钮监听
b_login.addActionListener(this);
}
//管理员登陆事件
publicvoidaction_admin_login(){
Stringsql_admin_login="select*fromLogin_admin_infowhereA_no=?
";
intadmin_login_flag=0;
admin_login_flag=Search_sno_DB.serch_sno_from_stuDB(sql_admin_login,txt_login.getText());
if(admin_login_flag==1){
newAllframe_admin().buttonFunction();
//mis_frame.dispose();
txt_login.setText(null);
txt_pwd.setText(null);
}
else{
JOptionPane.showMessageDialog(null,"登录失败,请检查用户名密码","提示",0);
}
}
//学生用户登陆
publicvoidaction_stu_login(){
Stringsql_admin_login="select*fromLogin_stu_infowhereSno=?
";
intstu_login_flag=0;
stu_login_flag=Search_sno_DB.serch_sno_from_stuDB(sql_admin_login,txt_login.getText());
if(stu_login_flag==1){
newAllFrame_stu().all_stu_function();
txt_login.setText(null);
txt_pwd.setText(null);
}
else{
JOptionPane.showMessageDialog(null,"登录失败,请检查用户名密码","提示",0);
}
}
//监听登陆按钮
publicvoidactionPerformed(ActionEvente){
if(e.getSource().equals(b_login)){
//管理员登陆
if(b_admin_login.isSelected()){
action_admin_login();
}
//学生用户登陆
elseif(b_stu_login.isSelected()){
action_stu_login();
}
}
}
publicstaticvoidmain(String[]args){
newMIS_frame().MIS_display();
}
}
2.Info_user_reg_class
packageMIS_Login;
importjava.awt.BorderLayout;
importjava.awt.Container;
importjava.awt.Dimension;
importjava.awt.FlowLayout;
importjava.awt.GridLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.PreparedStatement;
importjava.sql.SQLException;
importjavax.swing.*;
importStudentDB.Interactive.StudentDB;
publicclassInfo_user_reg_classextendsVerification_Test{
publicJFrameinfo_user_reg;
publicJLabellab_reg_sno,lab_reg_name,lab_reg_email,lab_reg_pwd,lab_reg_pwd_c;
publicJTextFieldtxt_reg_sno,txt_reg_name,txt_reg_email;
publicJPasswordFieldtxt_reg_pwd,txt_reg_pwd_c;
publicJButtonreg_confirm,reg_cancel;
publicintreg_stu_info_flag=0;//注册信息标示符。
在student_info表的学号
publicintreg_login_info_flag=1;//登录表里的学号
publicStringsql_search_sno_DB="select*fromStudent_infowhereSno=?
";
publicStringsql_search_sno_Login="select*fromLogin_stu_infowheresno=?
";
publicStringsql_login_info_save="insertintoLogin_stu_infovalues(?
?
?
?
)";
publicvoidinfo_user_frame(){
info_user_reg=newJFrame("注册信息");
lab_reg_sno=newJLabel("学号:
");
lab_reg_name=newJLabel("用户名:
");
lab_reg_email=newJLabel("邮箱:
");
lab_reg_pwd=newJLabel("密码:
");
lab_reg_pwd_c=newJLabel("确认密码:
");
txt_reg_sno=newJTextField(10);
txt_reg_name=newJTextField(10);
txt_reg_email=newJTextField(10);
txt_reg_pwd=newJPasswordField(10);
txt_reg_pwd_c=newJPasswordField(10);
JPanelinfo_reg_pb=newJPanel();
reg_confirm=newJButton("确认");
reg_cancel=newJButton("取消");
info_reg_pb.add(reg_confirm);
info_reg_pb.add(reg_cancel);
JPanelinfo_reg_p1=newJPanel(newFlowLayout(FlowLayout.CENTER,15,0));
info_reg_p1.add(lab_reg_sno);
info_reg_p1.add(txt_reg_sno);
JPanelinfo_reg_p2=newJPanel(newFlowLayout(FlowLayout.CENTER,15,0));
info_reg_p2.add(lab_reg_name);
info_reg_p2.add(txt_reg_name);
JPanelinfo_reg_p3=newJPanel(newFlowLayout(FlowLayout.CENTER,15,0));
info_reg_p3.add(lab_reg_email);
info_reg_p3.add(txt_reg_email);
JPanelinfo_reg_p4=newJPanel(newFlowLayout(FlowLayout.CENTER,15,0));
info_reg_p4.add(lab_reg_pwd);
info_reg_p4.add(txt_reg_pwd);
JPanelinfo_reg_p5=newJPanel(newFlowLayout(FlowLayout.CENTER,15,0));
info_reg_p5.add(lab_reg_pwd_c);
info_reg_p5.add(txt_reg_pwd_c);
JPanelinfo_reg_pall=newJPanel(newGridLayout(5,1));
info_reg_pall.add(info_reg_p1);
info_reg_pall.add(info_reg_p2);
info_reg_pall.add(info_reg_p3);
info_reg_pall.add(info_reg_p4);
info_reg_pall.add(info_reg_p5);
info_reg_pall.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(),"用户信息"));
Containerinfo_reg_container=info_user_reg.getContentPane();
info_reg_container.setLayout(newBorderLayout());
info_reg_container.add(info_reg_pall,BorderLayout.CENTER);
info_reg_container.add(info_reg_pb,BorderLayout.SOUTH);
info_user_reg.setLocation(600,200);
info_user_reg.setPreferredSize(newDimension(500,350));
info_user_reg.pack();
info_user_reg.setVisible(true);
//info_user_reg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//监听按钮
reg_confirm.addActionListener(newActionListener(){
@SuppressWarnings("deprecation")
publicvoidactionPerformed(ActionEvente){
if(!
txt_reg_name.getText().isEmpty()){
/*两种情况:
*第一种是:
两次的密码必须要一致
*第二中是:
返回的res_flag要为1.即代表注册成功
*/
if(txt_reg_pwd.getText().equals(txt_reg_pwd_c.getText())){
//寻找在学生管理系统中是否存在学号
reg_stu_info_flag=Search_sno_DB.serch_sno_from_stuDB(sql_search_sno_DB,txt_reg_sno.getText());
//寻找注册用户中是否有存在注册过的学号
reg_login_info_flag=Search_sno_DB.serch_sno_from_stuDB(sql_search_sno_Login,txt_reg_sno.getText());
if(reg_stu_info_flag==1){
if(reg_login_info_flag==0){
//发送邮件
sendVerification(txt_reg_email.getText());
//发送邮件验证码确认信息---参数是学号,传递给下一个窗体
confirm_verification(txt_reg_sno.getText());
}
else{
JOptionPane.showMessageDialog