版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/Student_Management_System.java/JHelpTextPanel.java/ 定义帮助文档类class JHelpTextPanel extends JPanelFont newSmallTitleFont=new Font(" 楷体 ",Font.BOLD,12); JTextArea HelpText=new JTextArea();JHelpTextPanel()setLayout(null);setBackground(Color.orange);HelpText.setBackground(Color.orange);HelpText.
2、setForeground(Color.red);HelpText.setFont(newSmallTitleFont);HelpText.setBounds(0,0,600,600);add(HelpText);/Student_InforPanel .javaclass Student_InforPanel extends JPanel implements ActionListener / 四种常用字体的定义Font newTitleFont=new Font("楷体 ",Font.BOLD,40);Font newSmallTitleFont=new Font(&q
3、uot; 楷体 ",Font.BOLD,25); Font newCommonFont=new Font("宋体 ",Font.BOLD,20);Font newSubMenuFont=new Font(" 宋体 ",Font.BOLD,15);Font NewSubMenuFont=new Font(" 宋体 ",Font.BOLD,10);/ 性别数组定义String os="男 ","女 "/ 定义确认对话框图标ImageIcon thinker=new ImageIcon(&q
4、uot;ICON/thinker.gif");/ 定义学生信息管理系统面板菜单控件JLabel StudentSno_Clue=new JLabel("学号 :");JLabel StudentName_Clue=new JLabel("姓名 :");JLabel StudentSex_Clue=new JLabel("性别 :");JLabel StudentAge_Clue=new JLabel("年龄 :");JLabel StudentClass_Clue=new JLabel("班级
5、:");JLabel StudentDept_Clue=new JLabel("系别 :");JTextField StudentSno_Input=new JTextField();JTextField StudentName_Input=new JTextField();ComboBoxModel Othermode=new OtherAModel(); JComboBox StudentSex_Input=new JComboBox(Othermode); JTextField StudentAge_Input=new JTextField(); JText
6、Field StudentClass_Input=new JTextField();JTextField StudentDept_Input=new JTextField();JTextArea QueryInforShow=new JTextArea();JLabel QueryClue=new JLabel("以下是你要查询的学生信息:");JButton Add_StudentInformation=new JButton("增加学生信息 ");JButton Del_StudentInformation=new JButton("删除学
7、生信息 ");JButton Query_StudentInformation=new JButton("查询学生信息 ");JButton Modify_StudentInformation=new JButton("修改学生信息");/定义变量int ValidAge;String SnoOrigin;Student_InforPanel()setBackground(Color.orange);QueryInforShow.setBackground(Color.orange);setLayout(null);StudentSno_Clu
8、e.setBounds(270,120,80,30);StudentSno_Clue.setFont(newCommonFont);StudentSno_Input.setBounds(350,120,120,30);StudentName_Clue.setBounds(270,170,80,30);StudentName_Clue.setFont(newCommonFont);StudentName_Input.setBounds(350,170,120,30);StudentSex_Clue.setBounds(270,220,80,30);StudentSex_Clue.setFont(
9、newCommonFont);StudentSex_Input.setBounds(350,220,120,30);StudentAge_Clue.setBounds(270,270,80,30);StudentAge_Clue.setFont(newCommonFont);StudentAge_Input.setBounds(350,270,120,30);StudentClass_Clue.setBounds(270,320,80,30);StudentClass_Clue.setFont(newCommonFont);StudentClass_Input.setBounds(350,32
10、0,120,30);StudentDept_Clue.setBounds(270,370,80,30);StudentDept_Clue.setFont(newCommonFont);StudentDept_Input.setBounds(350,370,120,30);Query_StudentInformation.setBounds(80,120,130,30);Query_StudentInformation.setFont(newSubMenuFont);Query_StudentInformation.addActionListener(this);QueryClue.setBou
11、nds(80,180,300,50);QueryClue.setFont(newSubMenuFont);QueryInforShow.setBounds(80,220,530,100);QueryInforShow.setFont(newSubMenuFont);Del_StudentInformation.setBounds(80,120,130,30);Del_StudentInformation.setFont(newSubMenuFont);Del_StudentInformation.addActionListener(this);Add_StudentInformation.se
12、tBounds(80,170,130,30);Add_StudentInformation.setFont(newSubMenuFont);Add_StudentInformation.addActionListener(this);Modify_StudentInformation.setBounds(80,220,130,30);Modify_StudentInformation.setBounds(80,220,130,30);Modify_StudentInformation.setFont(newSubMenuFont);Modify_StudentInformation.addAc
13、tionListener(this);add(StudentSno_Clue);add(StudentSno_Input);add(StudentName_Clue);add(StudentName_Input);add(StudentSex_Clue);add(StudentSex_Input);add(StudentAge_Clue);add(StudentAge_Input);add(StudentClass_Clue);add(StudentClass_Input);add(StudentDept_Clue);add(StudentDept_Input);add(QueryClue);
14、add(QueryInforShow);add(Add_StudentInformation);add(Del_StudentInformation);add(Query_StudentInformation);add(Modify_StudentInformation);public void actionPerformed(ActionEvent e)if(e.getSource()=Add_StudentInformation)if(IsValidAge(StudentAge_Input.getText()tText(),StudentName_Input.getText(),*,Val
15、idAge,StudentClass_Input.getText(),StudentDept_Input.getText();emptyInput();if(e.getSource()=Del_StudentInformation)QueryInforShow.setText("");QueryInforShow.setText(DataBaseControl.temptInformation);int result=JOptionPane.showConfirmDialog(null," 你确定要删除该生信息吗? ","ConfirmMess
16、age",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,think er);if(result=JOptionPane.YES_OPTION)JOptionPane.showMessageDialog(null," 删除操作成功! ","Happy Message",JOptionPane.PLAIN_MESSAGE);elseJOptionPane.showMessageDialog(null," 数据库操作出现异常,删除操作失败! ","Error
17、 Message",JOptionPane.ERROR_MESSAGE);elseQueryInforShow.setText("对不起,没有找到你要删除的学生信息 .");if(e.getSource()=Query_StudentInformation)QueryInforShow.setText("");entSno_Input.getText()QueryInforShow.setText(DataBaseControl.temptInformation);elseQueryInforShow.setText("对不起,没有你
18、想要查询的学生信息 ");if(e.getSource()=Modify_StudentInformation)if(IsValidAge(StudentAge_Input.getText()StudentName_Input.getText(),ValidAge,StudentClass_Input.getText(),StudentDept_Input.getText();public boolean IsValidAge(String StringAge)tryValidAge=Integer.parseInt(StringAge);catch(NumberFormatExce
19、ption e)e.printStackTrace();return false;if(ValidAge<=120&ValidAge>0)return true;elseJOptionPane.showMessageDialog(null," 你输入的年龄不合实际情况 n 请重新输入 !","WARNING MESSAGE",JOptionPane.WARNING_MESSAGE);return false;class OtherAModel extends DefaultComboBoxModelOtherAModel()for(i
20、nt i=0;i<os.length;i+)addElement(osi);public void emptyInput()StudentSno_Input.setText("");StudentAge_Input.setText("");StudentName_Input.setText("");StudentClass_Input.setText("");StudentDept_Input.setText("");public void OnlyShowSno()StudentSno_
21、Clue.setVisible(true);StudentSno_Input.setVisible(true);StudentSno_Input.setText("");QueryClue.setVisible(true);QueryInforShow.setVisible(true);StudentName_Clue.setVisible(false);StudentName_Input.setVisible(false);StudentSex_Clue.setVisible(false);StudentSex_Input.setVisible(false);Studen
22、tAge_Clue.setVisible(false);StudentAge_Input.setVisible(false);StudentClass_Clue.setVisible(false);StudentClass_Input.setVisible(false);StudentDept_Clue.setVisible(false);StudentDept_Input.setVisible(false);/ 显示学生信息的所有面板控件public void ShowWhole()StudentSno_Clue.setVisible(true);StudentSno_Input.setVi
23、sible(true);StudentSno_Input.setText("");QueryClue.setVisible(false);QueryInforShow.setVisible(false);StudentName_Clue.setVisible(true);StudentName_Input.setVisible(true);StudentName_Input.setText("");StudentSex_Clue.setVisible(true);StudentSex_Input.setVisible(true);StudentAge_C
24、lue.setVisible(true);StudentAge_Input.setVisible(true);StudentAge_Input.setText("");StudentClass_Clue.setVisible(true);StudentClass_Input.setVisible(true);StudentClass_Input.setText("");StudentDept_Clue.setVisible(true);StudentDept_Input.setVisible(true);StudentDept_Input.setText
25、("");/Student_ScorePanel.javaclass Student_ScorePanel extends JPanel implements ActionListener / 三种常用字体的定义Font newTitleFont=new Font("楷体 ",Font.BOLD,40);Font newSmallTitleFont=new Font("楷体 ",Font.BOLD,25);Font newCommonFont=new Font("宋体 ",Font.BOLD,20);Font ne
26、wSubMenuFont=new Font(" 宋体 ",Font.BOLD,15);Font NewSubMenuFont=new Font(" 宋体 ",Font.BOLD,10);/ 定义确认对话框图标ImageIcon thinker=new ImageIcon("ICON/thinker.gif");JLabel ScoreSno_Clue=new JLabel(" 学号 :"); JLabel ScoreEnglish_Clue=new JLabel(" 英语 :");JLabel
27、ScoreSeniorMath_Clue=new JLabel(" 高数 :"); JLabel ScoreC_Clue=new JLabel("C:"); JLabel ScoreVC_Clue=new JLabel("VC:");JLabel ScoreJAVA_Clue=new JLabel("JAVA:");JTextField ScoreSno_Input=new JTextField(); JTextField ScoreEnglish_Input=new JTextField(); JTextFiel
28、d ScoreSeniorMath_Input=new JTextField(); JTextField ScoreC_Input=new JTextField(); JTextField ScoreVC_Input=new JTextField(); JTextField ScoreJAVA_Input=new JTextField(); JTextArea ScoreShow=new JTextArea();JLabel ScoreShowClue=new JLabel("你要查询的学生成绩信息为:");JButton Add_ScoreInformation=new
29、JButton("JButton Del_ScoreInformation=new JButton("JButton Query_ScoreInformation=new JButton("增加学生成绩 ");删除学生成绩 ");查询学生成绩");JButton Modify_ScoreInformation=new JButton("修改学生成绩 ");/ 定义变量 int ValidScore; String ScoreSno;Student_ScorePanel()/ 学生成绩管理面板设置控件 setBack
30、ground(Color.orange); ScoreShow.setBackground(Color.orange); setLayout(null);ScoreSno_Clue.setBounds(270,120,80,30);ScoreSno_Clue.setFont(newCommonFont);ScoreSno_Input.setBounds(350,120,120,30);ScoreEnglish_Clue.setBounds(270,170,80,30);ScoreEnglish_Clue.setFont(newCommonFont);ScoreEnglish_Input.set
31、Bounds(350,170,120,30);ScoreSeniorMath_Clue.setBounds(270,220,80,30);ScoreSeniorMath_Clue.setFont(newCommonFont);ScoreSeniorMath_Input.setBounds(350,220,120,30); ScoreC_Clue.setBounds(270,270,80,30); ScoreC_Clue.setFont(newCommonFont); ScoreC_Input.setBounds(350,270,120,30); ScoreVC_Clue.setBounds(2
32、70,320,80,30); ScoreVC_Clue.setFont(newCommonFont); ScoreVC_Input.setBounds(350,320,120,30); ScoreJAVA_Clue.setBounds(270,370,80,30); ScoreJAVA_Clue.setFont(newCommonFont); ScoreJAVA_Input.setBounds(350,370,120,30);Query_ScoreInformation.setBounds(80,120,130,30);Query_ScoreInformation.setFont(newSub
33、MenuFont);Query_ScoreInformation.addActionListener(this);ScoreShowClue.setFont(newSubMenuFont);ScoreShowClue.setBounds(80,180,300,50);ScoreShow.setFont(newSubMenuFont);ScoreShow.setBounds(80,220,530,100);Del_ScoreInformation.setBounds(80,120,130,30);Del_ScoreInformation.setFont(newSubMenuFont);Del_S
34、coreInformation.addActionListener(this);Add_ScoreInformation.setBounds(80,170,130,30);Add_ScoreInformation.setFont(newSubMenuFont);Add_ScoreInformation.addActionListener(this);Modify_ScoreInformation.setBounds(80,220,130,30);Modify_ScoreInformation.setFont(newSubMenuFont); Modify_ScoreInformation.ad
35、dActionListener(this);add(ScoreSno_Clue);add(ScoreSno_Input);add(ScoreEnglish_Clue);add(ScoreEnglish_Input);add(ScoreSeniorMath_Clue);add(ScoreC_Clue);add(ScoreSeniorMath_Input);add(ScoreC_Input);add(ScoreVC_Clue);add(ScoreVC_Input);add(ScoreJAVA_Clue);add(ScoreJAVA_Input);add(ScoreShow);add(ScoreSh
36、owClue);add(Add_ScoreInformation);add(Del_ScoreInformation);add(Query_ScoreInformation);add(Modify_ScoreInformation);public void actionPerformed(ActionEvent e)if(e.getSource()=Query_ScoreInformation)/查询按纽事件触发处理()ScoreShow.setText("");ScoreShow.append(" 学号 tt英语 t高数 tCtVCtJAVAn");D
37、atabase.NowScoreNum);elseScoreShow.setText("");ScoreShow.setText("对不起,没有你想要查找的学生信息!");if(e.getSource()=Add_ScoreInformation)/增加学生成绩信息按纽的时间触发if(IsValidScore(ScoreEnglish_Input.getText()&&IsValidScore(Scor eSeniorMath_Input.getText()&&IsValidScore(ScoreC_Input.getTe
38、xt()&&IsValidScore(ScoreVC_Input.getText()&&IsValidScore(ScoreJAVA_Input.getText()IsValidScore(ScoreEnglish_Input.getText();int englishscore=ValidScore;IsValidScore(ScoreSeniorMath_Input.getText();int seniorscore=ValidScore;IsValidScore(ScoreC_Input.getText();int cscore=ValidScore;Is
39、ValidScore(ScoreVC_Input.getText();int vcscore=ValidScore;IsValidScore(ScoreJAVA_Input.getText();int javascore=ValidScore;emptyInput();if(e.getSource()=Del_ScoreInformation)/删除学生成绩信息事件触发处理()ScoreShow.setText("");ScoreShow.append(" 学号 tt英语 t高数 tCtVCtJAVAn");int result=JOptionPane.
40、showConfirmDialog(null," 你真的要删除该学生的成绩信息吗? ","Confirm Message",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,thinker);if(result=JOptionPane.YES_OPTION);elseScoreShow.setText("");ScoreShow.setText("对不起,你要删除的学生成绩信息不存在!");if(e.getSource()=Modify_ScoreInfo
41、rmation)/修改数据库中学生成绩信息事件的触发if(IsValidScore(ScoreEnglish_Input.getText()&&IsValidScore(Scor eSeniorMath_Input.getText()&&IsValidScore(ScoreC_Input.getText()&&IsValidScore(ScoreVC_Input.getT ext()&&IsValidScore(ScoreJAVA_Input.getText()IsValidScore(ScoreEnglish_Input.get
42、Text();int englishscore=ValidScore;IsValidScore(ScoreSeniorMath_Input.getText();int seniorscore=ValidScore;IsValidScore(ScoreC_Input.getText();int cscore=ValidScore;IsValidScore(ScoreVC_Input.getText();int vcscore=ValidScore;IsValidScore(ScoreJAVA_Input.getText();int javascore=ValidScore;englishscor
43、e,seniorscore, cscore, vcscore, javascore); emptyInput();public boolean IsValidScore(String stringAge)/try判断成绩输入是否合法ValidScore=Integer.parseInt(stringAge);catch(NumberFormatException e)JOptionPane.showMessageDialog(null,"符 !","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE);return fals
44、e;成绩输入中含有非法字if(ValidScore>100|ValidScore<0)JOptionPane.showMessageDialog(null,"分数只能在0100 之间的整数! ","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE);return false;return true;/ 只显示学生成绩面板中学号相关控件public void ScoreShowOnlySno()ScoreSno_Clue.setVisible(true);ScoreSno_Input.setVisible(tru
45、e);ScoreSno_Input.setText("");ScoreShowClue.setVisible(true);ScoreShow.setVisible(true);ScoreEnglish_Clue.setVisible(false);ScoreEnglish_Input.setVisible(false);ScoreEnglish_Input.setText("");ScoreSeniorMath_Clue.setVisible(false);ScoreSeniorMath_Input.setVisible(false);ScoreSeni
46、orMath_Input.setText("");ScoreC_Clue.setVisible(false);ScoreC_Input.setVisible(false);ScoreC_Input.setText("");ScoreVC_Clue.setVisible(false);ScoreVC_Input.setVisible(false);ScoreVC_Input.setText("");ScoreJAVA_Clue.setVisible(false);ScoreJAVA_Input.setVisible(false);Sco
47、reJAVA_Input.setText("");public void emptyInput()/ScoreSno_Input.setText("");ScoreEnglish_Input.setText("");ScoreSeniorMath_Input.setText("");ScoreC_Input.setText("");ScoreVC_Input.setText("");ScoreJAVA_Input.setText("");清空成绩输入控件/
48、 显示学生成绩面板中所有控件 public void ScoreShowWhole()ScoreSno_Clue.setVisible(true); ScoreSno_Input.setVisible(true); ScoreShowClue.setVisible(false); ScoreShow.setVisible(false); ScoreEnglish_Clue.setVisible(true); ScoreEnglish_Input.setVisible(true); ScoreSeniorMath_Clue.setVisible(true); ScoreSeniorMath_In
49、put.setVisible(true); ScoreC_Clue.setVisible(true); ScoreC_Input.setVisible(true); ScoreVC_Clue.setVisible(true); ScoreVC_Input.setVisible(true); ScoreJAVA_Clue.setVisible(true); ScoreJAVA_Input.setVisible(true);/DataBaseControl.java/ 数据库操作class DataBaseControl/private String s=""/ 登录用户信息S
50、tring UserRealName;String UserSex;int UserAge;String UserClass;String UserDept;/ 类中公有变量类型变量String LoginName=""String PW=""int Rank;final int MaxNum=20;String Student_Information=new StringMaxNum; String Student_Score=new StringMaxNum;String Database_Score="学号 "," 英
51、语 "," 高数 ","C","VC","JAVA"String Database_Information="学号 "," 姓名 "," 性别 "," 年龄 "," 班级 "," 系别 "int NowScoreNum;int NowInformationNum;static String temptInformation=""private Connection c
52、on1;private Statement st1;String str;public void init(String UserName,String PassWord,int i)LoginName=UserName;PW=PassWord;Rank=i;public boolean ConnectDataBase()/连接数据源tryreturn false;trycon1=DriverManager.getConnection("jdbc:odbc: 学生管理数据库 "); st1=con1.createStatement();catch(SQLException
53、e)return false;return true;public int QueryUserLogin()/用户身份验证int i=0;if(ConnectDataBase()tryResultSet rs1=st1.executeQuery("select* from UserLogin where 用户名 ='"+LoginName+"'");while(rs1.next()if(rs1.getString(3).equals(PW)&&(rs1.getInt(4)=Rank)JOptionPane.showMessageDialog(null,"登录成功 !n"+rs1.getString(2)+"欢迎你使用学生管理系统","Happy Message",JOptionPane.PLAIN_MESSAGE); if(Rank=1)return 1;elsereturn 2;/end-ifi+;/end-whileif(i=0)JOptionPane.showMessageDialog(null,"该用户不存在!","Error Message"
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 病人就诊管理课程设计
- 2024上海市饲料添加剂买卖合同示范文本
- 担保协议三篇
- 江苏省义务教务课程设计
- 2024房屋按揭买卖合同范本
- 2024签订无效劳动合同怎么办呢
- 班主任的自我提升与培训计划
- 2024合同违约责任的条款
- 2024转租合同协议书范文
- 水库大坝安全监测工程合同三篇
- 交通疏解施工安全交底
- 伽玛莱士说明书
- 8.2《小二黑结婚》课件37张-统编版高中语文选择性必修中册
- 中国传统饮食与养生PPT课件(带内容)
- 世纪末世纪初的保守主义
- 人教版初中化学九年级上册5.1 质量守恒定律 (第一课时)教案(表格式)
- 道路施工临时围挡施工方案
- 高边坡施工危险源辨识及分析
- 转体实施专项施工组织设计及对策
- 运动损伤处理与预防PPT通用课件
- 振动标线设计规范
评论
0/150
提交评论