学生信息管理系统系统源代码
学生信息管理系统java课程设计(含源代码)
JAVA 程序设计 课程设计陈述宇文皓月课 题: 学生信息管理系统 姓 名: 学 号: 同组姓名: 专业班级: 指导教师: 设计时间:目 录1、需要实现的功能32、设计目的3 1、功能模块划分32、数据库结构描述43、系统详细设计文档64、各个模块的实现方法描述95、测试数据及期望结果11一、系统描述1、需求实现的功能1.1、录入学生基本信息的功能学生基本信息主要包含:学号、姓名、年龄、出生地、专业、班级总学分,在拔出时,如果数据库已经存在该学号,则不克不及再拔出该学号。
1.2、修改学生基本信息的功能在管理员模式下,只要在表格中选中某个学生,就可以对该学生信息进行修改。
评阅意见:评定成绩:指导老师签名:年 月 日1.3、查询学生基本信息的功能可使用“姓名”对已存有的学生资料进行查询。
1.4、删除学生基本信息的功能在管理员模式下,只要选择表格中的某个学生,就可以删除该学生。
1.5、用户登陆用分歧的登录权限可以进入分歧的后台界面,从而实现权限操纵。
1.6、用户登陆信息设置可以修改用户登陆密码2、设计目的学生信息管理系统是一个教育单位不成缺少的部分。
一个功能齐全、简单易用的信息管理系统不单能有效地减轻学校相关工作人员的工作负担,它的内容对于学校的决策者和管理者来说都至关重要。
所以学生信息管理系统应该能够为用户提供充足的信息和快捷的查询手段。
但一直以来人们使用传统人工的方式管理文件档案、统计和查询数据,这种管理方式存在着许多缺点,如:效率低、保密性差、人工的大量浪费;另外时间一长,将发生大量的文件和数据,这对于查找、更新和维护都带来了很多困难。
随着科学技术的不竭提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。
作为计算机应用的一部分,使用计算机对学校的各类信息进行管理,具有手工管理无法比较的优点。
例如:检索迅速、查询方便、效率高、可靠性好、存储量大、保密性好、寿命长、成本低等。
学生信息管理系统完整源代码+mysql文件
数据库所用的数据自己导入MYSQL5.5,Navicat8就可以用了。
下面是具体的数据资料/*MySQL Data TransferSource Host: localhostSource Database: simsTarget Host: localhostTarget Database: simsDate: 2013-6-25 9:24:26*/SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for manager-- ----------------------------DROP TABLE IF EXISTS `manager`;CREATE TABLE `manager` (`id` varchar(10) NOT NULL,`name` varchar(30) NOT NULL,`Mima` varchar(20) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Table structure for studentinfo-- ----------------------------DROP TABLE IF EXISTS `studentinfo`;CREATE TABLE `studentinfo` (`Sname` varchar(30) NOT NULL,`Ssex` varchar(10) NOTNULL,`Snumber` varchar(10) NOT NULL,`Sprofession` varchar(30) NOT NULL,`Sclass`varchar(20) NOT NULL,`Sdate` varchar(30) character set utf8 collate utf8_unicode_ciNOT NULL,PRIMARY KEY (`Snumber`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDBfree: 4096 kB';-- ------------------------------ Table structure for userinfo-- ----------------------------DROP TABLE IF EXISTS `userinfo`;CREATE TABLE `userinfo` (`id` varchar(10) NOT NULL,`name` varchar(30) NOT NULL,`Mima` varchar(20) character set utf8 collate utf8_unicode_ci NOT NULL, PRIMARY KEY(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Records-- ----------------------------INSERT INTO `manager` VALUES ('1', '1', '2');INSERT INTO `manager` VALUES ('2', '恩恩', '123456');INSERT INTO `manager` VALUES ('3', '大大', '123456');INSERT INTO `manager` VALUES ('4', '啊啊', '123456');INSERT INTO `manager` VALUES ('5', '5', '5');INSERT INTO `manager` VALUES ('6', '孙霞', '123456');INSERT INTO `studentinfo` V ALUES ('张三', '男', '2010303755', '数学', '2', '2010-02- 12');INSERT INTO `studentinfo` V ALUES ('李四', '男', '2010303760', '物理', '1', '1995.9.6'); INSERT INTO `studentinfo` V ALUES ('王二', '女', '2010303761', '应数', '2','1990.9.11');INSERT INTO `studentinfo` V ALUES ('麻子', '女', '2010303762', '信计', '1','1999.9.10');INSERT INTO `userinfo` V ALUES ('1', '1', '1');INSERT INTO `userinfo` V ALUES ('13', '13', '1');INSERT INTO `userinfo` V ALUES ('2', '2', '2');INSERT INTO `userinfo` V ALUES ('3', '3', '3');INSERT INTO `userinfo` V ALUES ('6', '6', '6');INSERT INTO `userinfo` V ALUES ('7', '7', '6');下面是相应的程序:package MS;import java.awt.event.ActionEvent;import java.awt.event.ActionListener; import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Add implements ActionListener {JFrame f1;Container ct;JPanel jp,jp1,jp2,jp3;JButton btn1,btn2;JLabel label;JTextField tf1,tf2,tf3,tf4,tf5,tf6;Add(){f1=new JFrame();ct=f1.getContentPane();//初始化面板jp=new JPanel();jp1=new JPanel(new GridLayout(6,1));jp2=new JPanel(new GridLayout(6,1));jp3=new JPanel();btn1=new JButton("确定");btn2=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>添加学生信息</font>",SwingConstants.CENTER);label.setForeground(Color.gray);tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);tf6.setText("例:2000-02-02");//文本框加入提示语tf6.addFocusListener(new FocusListener(){public void focusGained(FocusEvent e) {tf6.setText("");}public void focusLost(FocusEvent e) {}});jp.add(label);ct.add(jp,"North");jp1.add(new JLabel("姓名",SwingConstants.CENTER));jp2.add(tf1);jp1.add(new JLabel("性别",SwingConstants.CENTER));jp2.add(tf2);jp1.add(new JLabel("学号",SwingConstants.CENTER));jp2.add(tf3);jp1.add(new JLabel("专业",SwingConstants.CENTER));jp2.add(tf4);jp1.add(new JLabel("班级",SwingConstants.CENTER));jp2.add(tf5);jp1.add(new JLabel("入学时间",SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);ct.add(jp1,"West");ct.add(jp2,"East");ct.add(jp3,"South");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f1.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f1.setLocation(xcenter, ycenter);f1.setVisible(true);//f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);}public void insert(){if(tf1.getText().equals("")||tf2.getText().equals("")||tf3.getText().equals("")||tf4.getText().equals("")||tf5.getText().equals("")||tf6.getText().equals("")){JOptionPane.showMessageDialog(f1,"请填写完整信息");return;}try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connectioncon=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String s="insert into studentinfo values('"+tf1.getText()+"','"+tf2.getText()+"','"+tf3.getText()+"','"+tf4.getText()+"','"+tf5.getText()+"','"+tf6.getText()+"');";String query="select * from studentinfo where Snumber='"+tf3.getText().trim()+"'";ResultSet res=st.executeQuery(query);if(res.next()){JOptionPane.showMessageDialog(f1,"学号信息已经存在!");con.close();tf3.setText("");}else if(tf6.getText().length()!=10){JOptionPane.showMessageDialog(f1,"入学时间格式有误!");con.close();tf6.setText("");}int insert=st.executeUpdate(s);if(insert==1){JOptionPane.showMessageDialog(f1,"录入信息成功!");tf1.setText("");tf2.setText("");tf3.setText("");tf4.setText("");tf5.setText("");tf6.setText("");}}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){insert();}else if(cmd.equals("取消")){f1.hide();}}public Container getCt(){return ct;}public void setCt(Container ct){this.ct = ct;}}package MS;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Delete implements ActionListener {JFrame f2;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JTextField text;JTable table;//接收数据库中返回的信息JButton btn1,btn2,btn3;Object columnName[]={"姓名","性别","学号","专业","班级","入学时间"};Object ar[][]=new Object[80][6];Delete(){f2=new JFrame();ct=f2.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();label=new JLabel();text=new JTextField();btn1=new JButton("查询");btn2=new JButton("删除");btn3=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>请输入要删除的学生姓名:</font>",SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar,columnName);JScrollPane scroll=new JScrollPane(table);text=new JTextField(20);jp2.add(btn1);jp2.add(btn2);jp2.add(btn3);jp1.add(label);jp1.add(text);ct.add(jp1,"North");jp3.setLayout(new BorderLayout());jp3.add(new JLabel("学生信息如下"));jp3.add(scroll);ct.add(jp2,"South");ct.add(jp3,"Center");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f2.setSize(450, 400);int xcenter=(x-450)/2;int ycenter=(y-400)/2;f2.setLocation(xcenter, ycenter);f2.setVisible(true);//f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);btn3.addActionListener(this);}int i=0;public void show(String s){while(i>=0){ar[i][0]="";ar[i][1]="";ar[i][2]="";ar[i][3]="";ar[i][4]="";ar[i][5]="";i--;}i=0;try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String sql="select * from studentinfo where Sname='"+s+"'";ResultSet res=st.executeQuery(sql);/*if(!(res.next())){JOptionPane.showMessageDialog(f,"所要查询的信息不存在");} */while(res.next()){String sName=res.getString(1);String sSex=res.getString(2);String sNumber=res.getString(3);String sProfession=res.getString(4);String sClass=res.getString(5);String sDate=res.getString(6);ar[i][0]=sName;ar[i][1]=sSex;ar[i][2]=sNumber;ar[i][3]=sProfession;ar[i][4]=sClass;ar[i][5]=sDate;i++;}f2.repaint();con.close();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}public void delete(int line){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String name=(String)(ar[line][2]);String sql="delete from studentinfo where Snumber ='"+name+"'";int del=st.executeUpdate(sql);if(del==1){ar[line][0]="";ar[line][1]="";ar[line][2]="";ar[line][3]="";ar[line][4]="";ar[line][5]="";JOptionPane.showMessageDialog(null,"删除成功!","信息", JOptionPane.YES_NO_OPTION);}con.close();f2.repaint();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("查询")){String qu=text.getText().trim();show(qu);}if(cmd.equals("删除")){int de=table.getSelectedRow();if(de==-1){JOptionPane.showMessageDialog(null,"请选定要删除的行","错误信息", JOptionPane.YES_NO_OPTION);}else{delete(de);}}if(cmd.equals("取消")){f2.hide();}}}package MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.SwingConstants;public class Liulan implements ActionListener {JFrame f4;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JButton btn1,btn2;JTable table;Object[][] ar=new Object[80][6];Object[] columnName={"姓名","性别","学号","专业","班级","入学时间"};Liulan(){f4=new JFrame();ct=f4.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();btn1=new JButton("点击浏览");btn2=new JButton(" 取消");label=new JLabel("<html><font color=#00FF22 size='4'>学生信息浏览<font>",SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar, columnName);JScrollPane scroll=new JScrollPane(table);jp1.add(label);jp2.add(btn1);jp2.add(btn2);jp3.add(scroll);ct.add(jp1,"North");ct.add(jp3,"Center");ct.add(jp2,"South");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f4.setSize(500,530);int xcen=(x-500)/2;int ycen=(y-530)/2;f4.setLocation(xcen,ycen);f4.setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);}int i=0;public void select(){while(i>=0){ar[i][0]="";ar[i][1]="";ar[i][2]="";ar[i][3]="";ar[i][4]="";ar[i][5]="";i--;}i=0;try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String s="select * from studentinfo";ResultSet res=st.executeQuery(s);while(res.next()){String sName=res.getString(1);String sSex=res.getString(2);String sNumber=res.getString(3);String sProfession=res.getString(4);String sClass=res.getString(5);String sDate=res.getString(6);ar[i][0]=sName;ar[i][1]=sSex;ar[i][2]=sNumber;ar[i][3]=sProfession;ar[i][4]=sClass;ar[i][5]=sDate;i++;}f4.repaint();con.close();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){// TODO Auto-generated method stubString cmd=e.getActionCommand();if(cmd.equals("点击浏览")){select();}else if(cmd.equals(" 取消")){f4.hide();}}}package MS;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.Connection;import java.sql.DriverManager;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.SwingConstants;@SuppressWarnings("serial")public class Login extends JFrame implements ActionListener {Container cp=null;JFrame f=null;JButton button1,button2,button3;JTextField t1;JPasswordField t2;JLabel jlable1,jlable2;JRadioButton rabtn1,rabtn2;Color c;JPanel jp1,jp2,jp3;String table=null;Login(){f=new JFrame("学生信息管理系统");button1=new JButton("确定");button2=new JButton("取消");button3=new JButton("注册");//button3.setOpaque(false);button3.setBorder(null);button3.setBackground(Color.getColor("#292421"));rabtn1=new JRadioButton("普通用户");rabtn1.setBackground(Color.getColor("#292421"));rabtn2=new JRadioButton("管理员");rabtn2.setBackground(Color.getColor("#292421"));ButtonGroup group=new ButtonGroup();group.add(rabtn1);group.add(rabtn2);cp=f.getContentPane();jlable1=new JLabel("输入用户号");jlable2=new JLabel("输入密码");jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();t1=new JTextField(20);t2=new JPasswordField(20);//jp3.add(group);jp1.add(jlable1);jp1.add(t1);jp1.add(jlable2);jp1.add(t2);jp1.add(rabtn1);jp1.add(rabtn2);jp1.add(button3);JLabel JL=new JLabel("<html><font color=#292421 size='7'><i>欢迎登陆" + "</i></font>",SwingConstants.CENTER);cp.add(JL,"North");jp2.add(button1);jp2.add(button2);cp.add(jp1,"Center");cp.add("South",jp2);cp.setBackground(new Color(127, 255, 212 ));jp2.setBackground(new Color(127, 255, 212 ));jp1.setBackground(new Color(127, 255, 212 ));Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f.setSize(250,300);int xcenter=(x-300)/2;int ycenter=(y-300)/2;f.setLocation(xcenter,ycenter);/*显示在窗口中央*/f.setVisible(true);//f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//------------------------------------------------------------///*监听事件*/button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);rabtn1.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e){JRadioButton jop=(JRadioButton) e.getSource();if (jop.isSelected())table="userinfo";}});rabtn2.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e){JRadioButton jop=(JRadioButton) e.getSource();if (jop.isSelected())table="manager";}});f.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});}@SuppressWarnings("deprecation")public void confirm(String tableName){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String id=t1.getText().trim();String Mima=t2.getText().trim();String queryMima="select * from "+tableName+" where id='"+id+"' and mima='"+Mima+"'";ResultSet res=st.executeQuery(queryMima);if(res.next()){if(tableName.equals("manager"))new Mstudent(id);else if(tableName.equals("userinfo"))new Ustudent(id);f.hide();con.close();}else{JOptionPane.showMessageDialog(null,"密码错误请重输!!!","提示!",JOptionPane.YES_NO_OPTION);}t1.setText("");t2.setText("");}catch(SQLException g){System.out.println("错误代码:"+g.getErrorCode());System.out.println("错误内容:"+g.getMessage());}}ItemListener listen=new ItemListener(){public void itemStateChanged(ItemEvent e) {// TODO Auto-generated method stub}};public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){if(table==null){JOptionPane.showMessageDialog(f,"请选择用户类型");}confirm(table);}else if(cmd.equals("取消")){f.dispose();}else if(cmd.equals("注册")){new Regist();}}public static void main(String []arg){new Login();}}package MS;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenuBar;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.SwingConstants;import javax.swing.border.TitledBorder;@SuppressWarnings("serial")public class Mstudent extends JFrame implements ActionListener {JButton Query = new JButton("查询信息");JButton add = new JButton("添加信息");JButton delete = new JButton("删除信息");JButton xiugai = new JButton("浏览全部信息");JButton liulan = new JButton("修改密码");JMenuBar mb = new JMenuBar();// 菜单栏JPanel jp = new JPanel();Container cp = getContentPane();String userName;Mstudent(){}Mstudent(String userName){erName = userName;mb.add(Query);mb.add(add);mb.add(delete);mb.add(xiugai);mb.add(liulan);JPanel j=new JPanel();j.add(mb,"Center");cp.add(j, "North");// 设置边框jp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue, 2), null, TitledBorder.CENTER,TitledBorder.TOP));jp.setLayout(new BorderLayout());JLabel label1 = new JLabel("欢迎使用学生信息管理系统",SwingConstants.CENTER);jp.add(label1);JScrollPane scrollpane = new JScrollPane(jp);cp.add(scrollpane,"Center");setTitle("欢迎登陆" + "--" + "你好:" + userName);Toolkit kit = Toolkit.getDefaultToolkit();Dimension screen = kit.getScreenSize();int x = screen.width; /* 取得显示器窗口的宽度*/int y = screen.height; /* 取得显示器窗口的高度*/setSize(600, 600);int xcenter = (x - 600) / 2;int ycenter = (y - 600) / 2;setLocation(xcenter, ycenter);/* 显示在窗口中央*/setVisible(true);//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 注册临听器Query.addActionListener(this);add.addActionListener(this);delete.addActionListener(this);xiugai.addActionListener(this);liulan.addActionListener(this);}public void actionPerformed(ActionEvent e){String cmd = e.getActionCommand();if (cmd.equals("查询信息")){new QueryWays();}if (cmd.equals("添加信息")){new Add();}if (cmd.equals("删除信息")){new Delete();}if (cmd.equals("浏览全部信息")){new Liulan();}if (cmd.equals("修改密码")){new UpdateCode();}}public static void main(String[] args){new Mstudent("");}}package MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Query implements ActionListener {String sql =null;int a;String info;JFrame f3;// Container cp;JPanel jp1,jp2,jp3,jp4,jp,jpwest;JButton btn1,btn2;//确定,取消JLabel label,label2;//标签,请输入姓名(label)JTextField tf,tf1,tf2,tf3,tf4,tf5,tf6;//文本框Query(int a){this.a=a;f3=new JFrame();Container cp=f3.getContentPane();//初始化面板,按钮,标签,文本框jp=new JPanel();jp1=new JPanel();jp2=new JPanel(new GridLayout(6,1));jp3=new JPanel();jp4=new JPanel(new GridLayout(6,1));jpwest=new JPanel();btn1=new JButton("确定");btn2=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>请输入姓名:" + "</font>",SwingConstants.CENTER);label2=new JLabel("<html><font color=#CC00FF size='4'>请输入学号:" + "</font>",SwingConstants.CENTER);label.setForeground(Color.gray);tf=new JTextField(20);//------------------------------------------------tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);//布局,添加控件if(a==0){jp.add(label);jp.add(tf);}else if(a==1){jp.add(label2);jp.add(tf);}cp.add(jp,"North");jp4.add(new JLabel("姓名",SwingConstants.CENTER));jp2.add(tf1);jp4.add(new JLabel("性别",SwingConstants.CENTER));jp2.add(tf2);jp4.add(new JLabel("学号",SwingConstants.CENTER));jp2.add(tf3);jp4.add(new JLabel("专业",SwingConstants.CENTER));jp2.add(tf4);jp4.add(new JLabel("班级",SwingConstants.CENTER));jp2.add(tf5);jp4.add(new JLabel("入学时间",SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);cp.add(jp4,"West");cp.add(jp2,"East");cp.add(jp3,"South");cp.add(jp1);Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width; //显示窗口宽度int y=screen.height;//窗口高度f3.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f3.setLocation(xcenter,ycenter);f3.setVisible(true);//f3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);/*f3.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});*/。
学生信息管理系统C语言源代码
#include<stdio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define len sizeof(struct student)FILE *fp;struct student{long num;char name[15];int age;char sex[3];char chushen[10];char dizhi[20];char phone[11];char email[20];struct student *next;};void menu(){printf("===========学生信息管理系统==========\n\n");printf(" 1、录入学生信息\n");printf(" 2、浏览学生信息\n");printf(" 3、查询学生信息\n");printf(" 4、删除学生信息\n");printf(" 5、插入学生信息\n");printf(" 6、修改学生信息\n");printf(" 7、排序学生信息\n");printf(" 8、退出管理系统\n");printf("=====================================\n");}struct student *creat() //录入学生信息{int n;struct student *head;struct student *p1,*p2;n=0;p1=p2=(struct student *) malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chushen ,p1->dizhi,p1->phone,p1->email);head=NULL;while(p1->num!=0){n=n+1;if(n==1) head=p1;else p2->next=p1;p2=p1;p1=(struct student *)malloc(len);scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p1->num,&p1->age,p1->name,p1->sex,p1->chu shen,p1->dizhi,p1->phone,p1->email);}p2->next=NULL;return(head);}void insert(struct student *head) //插入学生信息{int search_num;struct student *p,*q,*s;p=head;printf("在哪个学生前插入请输入学号:\n");scanf("%d",&search_num);while((p!=NULL)&&(p->num!=search_num)){q=p;p=p->next;}s=(struct student *)malloc(len);q->next=s;system("cls");printf("请输入学生信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&s->num,&s->age,s->name,s->sex,s->chushen,s->diz hi,s->phone,s->email);s->next=p;}void printList(struct student *head) //浏览全部学生信息{struct student *p;p=head;if(head==NULL)printf("没有学生信息!!\n");else{do{fread(p,len,1,fp);printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);p=p->next;}while(p!=NULL);}}void findList_num(struct student *head,long search_num) //按学号查找{struct student *p;p=head;while((p!=NULL)&&(p->num!=search_num))p=p->next;if(p!=NULL)printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->diz hi,p->phone,p->email);elseprintf("没有该学生信息!!\n");}void findList_name(struct student *head,char *search_name) //按姓名查找{struct student *p;int cmp1=0,cmp=0;p=head;while(p!=NULL)if(strcmp(p->name,search_name)!=0){p=p->next;cmp++;}else{printf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n",p->num,p->age,p->name,p->sex,p->chushen,p->dizhi,p->phone,p->email);p=p->next;cmp1=1;}if(cmp!=0&&cmp1==0)printf("没有该学生信息!!\n");}void xiugai(struct student *p1,long xiu_num) //修改学生信息{struct student *p2;p2=p1;while((p2!=NULL)&&(p2->num!=xiu_num))p2=p2->next;if(p2!=NULL){scanf("%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&p2->num,&p2->age,p2->name,p2->sex,p2->chu shen,p2->dizhi,p2->phone,p2->email);}elseprintf("没有该学生信息!!\n");}struct student *delList(struct student *head,long del_num) // 删除学生信息{struct student *p,*q;p=head;q=head;while(p &&(p->num != del_num)){q=p;p=p->next;}if(p==NULL)printf("无此学号!\n");else{if(p == head){head = p->next;free(p);}else{q->next = p->next;free(p);}}return head;}void paixu(struct student *head) //按学号排序{struct student *p,*f,*t;char ch[100];int i;t=f=p=head;for(p=head;p->next!=NULL;p=p->next){for(t=head,f=t->next;t->next!=NULL;t=t->next,f=f->next){if(t->num>f->num>0){i=t->num;t->num=f->num;f->num=i;i=t->age;t->age=f->age;f->age=i;strcpy(ch,t->name);strcpy(t->name,f->name);strcpy(f->name,ch);strcpy(ch,t->sex);strcpy(t->sex,f->sex);strcpy(f->sex,ch);strcpy(ch,t->chushen);strcpy(t->chushen,f->chushen);strcpy(f->chushen,ch);strcpy(ch,t->dizhi);strcpy(t->dizhi,f->dizhi);strcpy(f->dizhi,ch);strcpy(ch,t->phone);strcpy(t->phone,f->phone);strcpy(f->phone,ch);strcpy(ch,t->email);strcpy(t->email,f->email);strcpy(f->email,ch);}}}// return head;}void save(struct student *head) //保存为磁盘文件{struct student *p;if((fp=fopen("keshe","w"))==NULL){printf("cannot open this file\n");exit(0);}p=head;while(p!=NULL){fprintf(fp,"%d\n",p->num);fprintf(fp,"%d\n",p->age);fprintf(fp,"%s\n",p->name);fprintf(fp,"%s\n",p->sex);fprintf(fp,"%s\n",p->chushen);fprintf(fp,"%s\n",p->dizhi);fprintf(fp,"%s\n",p->phone);fprintf(fp,"%s\n",p->email);p=p->next;}fclose(fp);}struct student *read() //从磁盘读取文件{struct student *head=NULL;struct student *p=NULL;struct student *t=NULL;int a;// fp=fopen("keshe","r");if((fp=fopen("keshe","r"))==NULL){printf("cannot open this file\n");exit(0);}while(1){t=(struct student *)malloc(len);a=fscanf(fp,"%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s",&t->num,&t->age,t->name,t->sex,t->chush en,t->dizhi,t->phone,t->email);if(a==0||a==-1)return head;t->next=NULL;if(p==NULL){p=t;head=t;}else{p->next=t;p=p->next;p->next=NULL;}}fclose(fp);}void main(){int code=0;struct student *pt = NULL;while(code!=8){menu();printf("请输入上述序号进行操作:\n");scanf("%d",&code);system("cls");switch(code){case 1:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=creat();save(pt);system("cls");printf("===========================录入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("************录入学生信息成功***********!!\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 2:{system("cls");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();printList(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 3:{int search=0;system("cls");printf("===========================查询学生信息==============================\n");printf("---------------------------------------------------------------------\n");while(search!=3){printf("1、按学号查询\n2、按姓名查询\n3、退出查询\n");scanf("%d",&search);switch(search){case 1:{long search_num;system("cls");printf("请输入学生学号\n");scanf("%d",&search_num);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 2:{char search_name[15];system("cls");printf("请输入学生姓名\n");scanf("%s",search_name);system("cls");printf("===========================查询结果==================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_name(read(),search_name);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};}}system("cls");};break;case 4:{long del_num;system("cls");printf("===========================删除学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("请输入要删除学生信息的学号:\n");scanf("%d",&del_num);system("cls");pt=delList(read(),del_num);save(pt);printf("===========================删除结果================================\n");printf("-------------------------------------------------------------------\n");printf("学号为%d的学生信息成功删除\n",del_num);printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 5:{system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");insert(pt);save(pt);system("cls");printf("===========================插入学生信息==============================\n");printf("---------------------------------------------------------------------\n");printf("****插入学生信息成功***!!\n\n");printf("按回车键返回主菜单\n");getchar();getchar();system("cls");}break;case 6:{long search_num;system("cls");printf("请输入要修改的学生学号:\n");scanf("%d",&search_num);system("cls");printf("每个学生的信息之间用Tab键分隔\n");printf("===========================修改学生信息==================================\n");printf("-------------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");findList_num(read(),search_num);printf("\n");printf("请输入修改信息:\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();xiugai(pt,search_num);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("****修改学生信息成功***!!\n\n");printf("\n按回车键返回查询菜单\n");getchar();getchar();system("cls");};break;case 7:{system("cls");printf(" 按学号从小到大排序\n\n");printf("===========================学生信息表================================\n");printf("---------------------------------------------------------------------\n");printf("学号\t年龄\t姓名\t性别\t出生\t地址\t电话\te-mail\n");pt=read();paixu(pt);printList(pt);save(pt);printf("================================================================ =====\n");printf("---------------------------------------------------------------------\n");printf("\n按回车键返回主菜单\n");getchar();getchar();system("cls");};break;case 8:read();break;}}}。
php学生信息管理系统源代码
php学生信息管理系统源代码PHP学生信息管理系统源代码是一种基于Web技术的信息管理系统,可以帮助学校或教育机构管理学生信息,包括个人基本信息、课程成绩、考勤记录等。
该系统使用PHP语言编写,采用MySQL 数据库作为数据存储,具有良好的可扩展性和易用性。
该系统的主要功能包括:学生信息管理、课程信息管理、成绩管理、考勤管理、教师管理、班级管理、权限管理等。
下面对这些功能进行详细介绍。
一、学生信息管理学生信息管理是该系统的核心功能之一,它包括对学生基本信息的添加、修改、删除、查询和导出等操作。
管理员可以通过该功能完成对学生信息的全面管理,包括学生的姓名、性别、出生日期、联系方式等基本信息,以及学生的班级、专业、入学时间等详细信息。
同时,管理员还可以为每个学生上传照片,方便识别和管理。
二、课程信息管理课程信息管理是该系统的另一个重要功能,它包括对课程的添加、修改、删除、查询和导出等操作。
管理员可以通过该功能完成对课程信息的管理,包括课程名称、课程编号、授课教师、学分、学时等详细信息。
同时,管理员还可以为每个课程设置课程目标、教学大纲、教学计划等内容,方便学生和教师了解课程的内容和要求。
三、成绩管理成绩管理是该系统的重要功能之一,它包括对学生成绩的录入、修改、查询和导出等操作。
管理员和教师可以通过该功能完成对学生成绩的管理,包括成绩的录入、审核、统计和分析等。
同时,系统还支持成绩的按课程、按学生、按班级等多种方式进行查询和分析,方便学校或教育机构对学生的学习情况进行全面监测和评估。
四、考勤管理考勤管理是该系统的另一个重要功能,它包括对学生考勤记录的添加、修改、查询和导出等操作。
管理员和教师可以通过该功能完成对学生考勤记录的管理,包括考勤的录入、审核、统计和分析等。
同时,系统还支持考勤的按日期、按课程、按学生、按班级等多种方式进行查询和分析,方便学校或教育机构对学生的出勤情况进行全面监测和评估。
五、教师管理教师管理是该系统的重要功能之一,它包括对教师信息的添加、修改、删除、查询和导出等操作。
学生信息管理系统源代码
#include<stdio.h>#include <stdlib.h>#include <string.h>typedef struct{long class_1; //班级long number; //学号char name[20]; //姓名float math; //数学float c_program; //C语言float physics; //大学物理float english; //大学英语float polity; //政治float sport; //体育float summary; //总分float average; //平均分}Student;Student stud[100]; //定义结构体数组变量的大小int i=0; //i用于记录输入的学生的个数int menu() //菜单函数{int a;printf("***********************学生信息管理系统*************************\n");//菜单选择printf("\t\t【1】输入学生信息\n");printf("\t\t【2】显示所有学生的信息\n");printf("\t\t【3】按平均分升降排序\n");printf("\t\t【4】根据学生的学号查找学生的信息\n");printf("\t\t【5】插入学生的信息\n");printf("\t\t【6】删除学生的信息\n");printf("\t\t【7】修改学生的信息\n");printf("\t\t【8】从文件中读入数据\n");printf("\t\t【9】将所有记录写入文件\n");printf("\t\t【0】退出本系统\n");printf("***********************学生信息管理系统*************************\n");printf("请选择你要的操作【0-9】:");scanf("%d",&a); //读入一个数while(a<0 || a>9){printf("输入错误!请重新输入。
学生管理系统程序源代码
学生管理系统程序源代码简介:学生管理系统是一种用于学校或者教育机构管理学生信息的软件系统。
它可以匡助学校管理学生的个人信息、课程信息、成绩信息等。
本文将提供一个标准格式的学生管理系统程序源代码,用于展示如何设计和实现一个简单的学生管理系统。
源代码:```python# 导入所需库import csv# 定义学生类class Student:def __init__(self, id, name, age, grade):self.id = id = nameself.age = ageself.grade = grade# 定义学生管理系统类class StudentManagementSystem:def __init__(self):self.students = []# 添加学生def add_student(self, student):self.students.append(student)# 删除学生def delete_student(self, student):self.students.remove(student)# 根据学生ID查找学生def find_student_by_id(self, id):for student in self.students:if student.id == id:return studentreturn None# 根据学生姓名查找学生def find_student_by_name(self, name):for student in self.students:if == name:return studentreturn None# 导出学生信息到CSV文件def export_to_csv(self, filename):with open(filename, 'w', newline='') as file:writer = csv.writer(file)writer.writerow(["ID", "Name", "Age", "Grade"])for student in self.students:writer.writerow([student.id, , student.age, student.grade]) # 从CSV文件导入学生信息def import_from_csv(self, filename):with open(filename, 'r') as file:reader = csv.reader(file)next(reader) # 跳过标题行for row in reader:id = row[0]name = row[1]age = row[2]grade = row[3]student = Student(id, name, age, grade)self.add_student(student)# 示例用法if __name__ == "__main__":# 创建学生管理系统对象sms = StudentManagementSystem()# 添加学生student1 = Student("001", "Alice", 18, "A")student2 = Student("002", "Bob", 17, "B")sms.add_student(student1)sms.add_student(student2)# 根据ID查找学生found_student = sms.find_student_by_id("001")if found_student:print("Found student:", found_)else:print("Student not found.")# 根据姓名查找学生found_student = sms.find_student_by_name("Bob") if found_student:print("Found student:", found_)else:print("Student not found.")# 导出学生信息到CSV文件sms.export_to_csv("students.csv")# 从CSV文件导入学生信息sms.import_from_csv("students.csv")```以上是一个简单的学生管理系统程序的源代码示例。
[工学]学生信息管理系统完整源码
学生信息管理系统完整源代码注:本系统采用C/S结构,运用Java GUI知识编写,数据库为SQL SERVER 2005,没有采用典型的三级框架结构,所以代码有冗余,仅供参考。
一、数据表及数据源首先创建数据库,包含数据表如下:数据库创建完成后,新建一个名为SIMS的数据源,不会建数据源的同学可以在去搜索创建数据源的详细步骤,这里的数据名称一定要为SIMS,否则在以后程序连接数据库的语句中会出现错误。
二、操作演示三、代码部分创建Java工程,创建名称为SIMS的包,一下Java类均包含在一个包内。
1.登录界面package SIMS;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.text.SimpleDateFormat;import java.util.*;import java.util.Date;public class login extends JFrame implements ActionListener{String userID; //保留用户输入IDString password; //保留用户输入passwordJLabel jlID=new JLabel("用户ID:"); //使用文本创建标签对象 JLabel jlPwd=new JLabel("密码:");JTextField jtID=new JTextField(); //创建ID输入框JPasswordField jpPwd=new JPasswordField(); //创建密码输入框ButtonGroup bg=new ButtonGroup(); //创建ButtonGroup组件对象JPanel jp=new JPanel(); //创建Panel容器JLabel jl=new JLabel();JRadioButton jrb1=new JRadioButton("管理员");JRadioButton jrb2=new JRadioButton("教师");JRadioButton jrb3=new JRadioButton("学生",true);JButton jb1=new JButton("登录");JButton jb2=new JButton("重置");public login(){this.setLayout(null); //设置窗口布局管理器this.setTitle("学生信息管理系统"); //设置窗口标题this.setBounds(200,150,500,300); //设置主窗体位置大小和可见性this.setVisible(true); //设置窗口的可见性this.setResizable(false);jlID.setBounds(150,60,100,20); //设置ID框属性jtID.setBounds(220,60,100,20); //设置ID输入框属性jlPwd.setBounds(150,90,100,20); //设置密码框属性jpPwd.setBounds(220,90,100,20); //设置密码输入框属性jp.setBounds(35,120,400,250); //设置JPanel容器属性jb1.setBounds(160,170,60,20); //设置登录按钮属性jb2.setBounds(250,170,60,20); //设置取消按钮属性jb1.addActionListener(this); //设置登录按钮监听器jb2.addActionListener(this); //设置取消按钮监听器jl.setBounds(340,75,130,20); //设置提示框属性bg.add(jrb1); //将所有空间加入窗体bg.add(jrb2);bg.add(jrb3);this.add(jlID);this.add(jlPwd);this.add(jtID);this.add(jpPwd);this.add(jb1);this.add(jb2);this.add(jl);jp.add(jrb1);jp.add(jrb2);jp.add(jrb3);this.add(jp);centerShell(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(( (screenWidth - shellWidth) / 2),((screenHeight - shellHeight) / 2) );}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(userID);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入IDpassword=jpPwd.getText(); //获取用户输入密码if(e.getSource()==jb1){ //处理登录事件if(userID.equals("") || password.equals("")){jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("请输入用户ID和密码");}else{Connection con=null;try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"","");//获取连接字符串Statement stat=con.createStatement();if(jrb1.isSelected())//如果登录选中的管理员{ResultSet rs=stat.executeQuery("select * from Admin"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectAdmin_Pwd,Admin_Name from Admin where Admin_ID='"+userID+"'");//从表Admin获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new admin(rss.getString(2));//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb2.isSelected()){ResultSet rs=stat.executeQuery("select * from Teacher_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectTea_Pwd,Tea_Names from Teacher_Info where Tea_ID='"+userID+"'");//从表Teacher_Info获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new teacher(rss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb3.isSelected()){ResultSet rs=stat.executeQuery("select * from Student_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rsss=stat.executeQuery("selectStu_Pwd,Stu_Name from Student_Info where Stu_ID='"+userID+"'");//从表Student_Info获取信息while(rsss.next()){String str=rsss.getString(1);if(str.equals(password)){new student(rsss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}}catch(Exception ex){ex.getStackTrace();}finally{try{con.close();}catch(Exception exc){exc.printStackTrace();}}}}else if(e.getSource()==jb2){ //处理登录事件jtID.setText("");jpPwd.setText("");jrb3.setSelected(true);jl.setText("");}}public static void main(String[] args){new login();}}2.添加课程package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_course extends JFrame implements ActionListener{ static add_course ss;String courseID=""; //课程名String coursename=""; //课程名String count=""; //课时JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlcoursename=new JLabel("课程名:");JLabel jlcount=new JLabel("课时:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtcoursename=new JTextField();JTextField jtcount=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_course(){ //添加教师账号信息this.setTitle("添加课程信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(title);this.add(jlcoursename);this.add(jlcount);this.add(jtcourseID);this.add(jtcoursename);this.add(jtcount);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加课程信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlcoursename.setBounds(180,140,100,20);jlcount.setBounds(180,200,100,20);jtcourseID.setBounds(250,80,140,20);jtcoursename.setBounds(250,140,140,20);jtcount.setBounds(250,200,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容coursename=jtcoursename.getText();count=jtcount.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || coursename.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){warning.setText("课程ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!count.equals("")){temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name,Course_Count)values('"+courseID+"','"+coursename+"','"+count+"')");}else{temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name) values('"+courseID+"','"+coursename+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");warning.setText("");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtcourseID.setT ext("");jtcoursename.setText("");jtcount.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}}3.添加学生package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_student extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("学号:"); //创建文本框对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField();JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_student(){this.setTitle("添加学生账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加学生账号信息");title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20);submit.addActionListener(this);reset.addActionListener(this);this.setSize(600,400);centerShell(this);this.setVisible(true);this.setResizable(false); //设置窗体不可变大小this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){ //判断是否已输入必填信息warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否相同warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Stu_ID from Student_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd) values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){ //重置所有控件warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}//public static void main(String args[]){// new add_student();//}}4.添加教师package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_teacher extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("教工号:"); //使用文本框创建标签对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField(); //创建文本框对象JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_teacher(){ //添加教师账号信息this.setTitle("添加教师账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加教师账号信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否一致warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Tea_ID from Teacher_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd)values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}// public static void main(String[] args){// new add_teacher();// }}5.添加授课信息package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_tc extends JFrame implements ActionListener{static add_tc ss;String courseID=""; //课程名String teachername=""; //课程名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlteachername=new JLabel("教师号:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtteachername=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_tc(){ //添加授课信息this.setTitle("添加授课信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(jlteachername);this.add(title);this.add(jtcourseID);this.add(jtteachername);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加授课信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlteachername.setBounds(180,140,100,20);jtcourseID.setBounds(250,80,140,20);jtteachername.setBounds(250,140,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,250,60,20);reset.setBounds(300,250,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容teachername=jtteachername.getText();int temp=0,flag1=0,flag2=0,flag3=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || teachername.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){flag1=1; //判断课程ID存在break;}}ResultSet rss=stat.executeQuery("select Tea_ID fromTeacher_Info");while(rss.next()){if(rss.getString(1).equals(teachername)){flag2=1; //判断教师ID存在break;}}if(flag1!=1){warning.setText("课程ID不存在");}else if(flag2!=1){warning.setText("教师ID不存在");}ResultSet rsss=stat.executeQuery("select Course_ID,T ea_ID from tc");while(rsss.next()){if(rsss.getString(1).equals(courseID) &&rsss.getString(2).equals(teachername)){flag3=1;warning.setText("授课信息重复");。
c语言课程设计报告+学生成绩信息管理系统+源代码
实验报告一、问题陈述及其需求分析(一)问题陈述学生信息管理系统是对学生信息的基本管理,其中包括以下及模块:(1)增加一个学生的信息(需输入要增加学生的所有信息);(2)统计本班学生总人数及男女生人数。
(3)分别按照学号查找学生的信息;若找到则输出该学生全部信息,否则输出查找不到的提示信息。
(4)按学号对所有学生信息排序,并输出结果;(5)删除一个学生的信息(需指定要删除学生的学号);同时显示删除后的结果。
(二)功能需求分析学生信息管理系统设计学生信息包括:学号,姓名,性别,出生年月,电话使之提供以下功能:1、系统以菜单方式工作2、建立链表并显示3、插入新的学生信息4、删除某学号的学生信息5、查找某学号的学生信息6、对学生信息排序7、统计学生人数8、输出学生信息二总体设计(一)模块依据程序的数据结构,描述该程序的层次结构,如下图:1、建立链表并显示voidcreatelist(structstucode**r);2、插入新的学生信息voidinsert(structstucode**r);3、删除某学号的学生信息voiddel(structstucode**r);4、查找某学号的学生信息voidsearch1(structstucode*r);5、对学生信息排序voidsort(structstucode**r);6、统计学生人数voidsearch2(structstucode*r);7、输出学生信息voidout(structstucode*r);(二)程序总体框架模块层次结构,只确定了模块之间的关系和函数原型,不是程序的执行步骤。
程序总体框架是该程序的总体流程图。
改程序不是顺序连续地执行全部功能,而是在某一时刻有选择地执行一种或多种功能。
因此选用菜单方式是较佳的方案,程序总体框架如下图:(三)运行环境(软,硬件环境)硬件:CPU,内存,主板,硬盘,显卡,键盘,显示器等等。
软件:WindowsXPtruboc应用软件。
简单学生管理信息系统源代码
package xsgl;import java.awt。
*;import java.awt。
event。
*;import java。
sql。
*;import java。
util.*;import javax。
swing。
*;import java。
util。
Vector;import javax.swing。
table.*;import java。
awt。
event.*;public class Xsglxt extends JFrame implements ActionListener//继承JFrame 并实现接口ActionListener{JPanel mb1,mb2;JLabel bq1;JTextField wbk1;JButton an1,an2,an3,an4;JTable bg1; //定义表格对象JScrollPane gd1;Xsxx xsxx2;//定义Xsxx类的一个对象xsxx2 public static void main(String[] args){Xsglxt xs=new Xsglxt();}public Xsglxt() //XSGLXT构造方法,用于对象初始化。
{mb1=new JPanel();bq1=new JLabel(”请输入姓名”);wbk1=new JTextField(10);an1=new JButton(”查询”);an1.addActionListener(this); //对按钮1添加监听an1。
setActionCommand(”chaxun”);//设置按钮1的监听信息mb1.add(bq1);mb1.add(wbk1); mb1.add(an1);mb2=new JPanel();an2=new JButton("添加”);an2。
addActionListener(this);an2。
setActionCommand("tianjia”);an3=new JButton(”修改”);an3.addActionListener(this);an3。
学生信息管理系统c语言版源代码
学生信息管理系统c语言版源代码#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 1000typedef struct student {int number;char name[20];int grade;int gaoshu;int yingyu;int jisuanji;int sum;}STUDENT;STUDENT student[N]; int shuliang=0;void menu();void fhzjm(){char biaozhi[20];printf("\n");printf("还需要操作么,如果需要操作请输入:yes,否则请输入:no\n");scanf("%s",biaozhi);if(strcmp(biaozhi,"yes")==0){menu();}else if(strcmp(biaozhi,"no")==0)exit(0);else{printf("请输入正确的字符,谢谢~\n"); fhzjm();}}void DengJi(){int rs;int i,k=1;system("CLS");printf("请输入需要输入几个学生信息:"); scanf("%d",&rs);for(i=shuliang;i<shuliang+rs;i++,k++) {printf("请输入第%d个学生的学号:",k); scanf("%d",&student[i].number);printf("请输入学生的姓名:");scanf("%s",student[i].name);printf("请输入学生3门课的成绩:"); printf("请输入第1门课的成绩:");scanf("%d",&student[i].gaoshu);printf("请输入第2门课的成绩:");scanf("%d",&student[i].yingyu);printf("请输入第3门课的成绩:");scanf("%d",&student[i].jisuanji);}shuliang=shuliang+rs;fhzjm();}void ShanChu(){char shanchuinfo[10];system("CLS");printf("删除全部学生信息请输入\"all\",删除指定学号的学生信息请输入\"one\"\n");scanf("%s",shanchuinfo);if(strcmp(shanchuinfo,"all")==0){int j;printf("你删除的学生信息如下:\n");printf("-----------学号-------------姓名-------------高数--------------英语--------------计算机\t\n");for(j=0;j<shuliang;j++)printf("----%d-------%s-------%d-------%d-------%d\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].jisuanji);shuliang=0;printf("删除成功\n\n");}else if(strcmp(shanchuinfo,"one")==0){struct student *p=NULL;int choice;int i,j,k=0;printf("请输入你要删除的人的学号:");scanf("%d",&choice);for(i=0;i<shuliang;i++){if(choice==student[i].number){k=1;j=i;break;}}if(k){if(shuliang==1){p=&student[0];free(p);shuliang=0;}else{for(i=j;i<shuliang;i++) {student[i]=student[i+1];}shuliang=shuliang-1;}printf("删除成功\n\n");}else{printf("输入数据错误~\n"); }}fhzjm();}void LiuLan(){int i;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");}else{for(i=0;i<shuliang;i++){printf("第%d个学生的学号为:%d\n",i+1,student[i].number);printf("第%d个学生的姓名为:%s\n",i+1,student[i].name);printf("第%d个学生的第一门课的成绩为:%d\n",i+1,student[i].gaoshu);printf("第%d个学生的第二门课的成绩为:%d\n",i+1,student[i].yingyu);printf("第%d个学生的第三门课的成绩为:%d\n",i+1,student[i].jisuanji);student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("第%d个学生的总成绩为:%d\n",i+1,student[i].sum);}}fhzjm();}void ChaZhao(){int xx;char choice,yy[20];int i,j,k=0;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");fhzjm();}printf("三种查找方式:学号,姓名,成绩\n");printf("如果按学号查找请输1,如果按姓名查找请输2,如果按成绩查找请输3\n");printf("请输入您查找的方式:");scanf("%s",&choice);if(choice=='1'){printf("请输入需要查找学生的学号:");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].number){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='2'){printf("请输入需要查找学生的姓名:\n");scanf("%s",yy);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(strcmp(yy,student[i].name)==0){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[j].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='3'){printf("请输入需要查找学生的成绩:\n");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数----英语----计算机----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].grade){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}fhzjm();}void PaiXu(){struct student *p1[N],**p2,*temp;int i,j;system("CLS");p2=p1;for( i=0;i<shuliang;i++){p1[i]=student+i;}for( i=0;i<shuliang;i++){for( j=i+1;j<shuliang;j++){if((*(p2+i))->sum<(*(p2+j))->sum){temp=*(p2+i);*(p2+i)=*(p2+j);*(p2+j)=temp;} }}printf("按照总成绩排序之后的信息为:\n");printf("----学号----姓名----总成绩----\t\n");for( i=0;i<shuliang;i++){student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("----%d-----%s----%d-----\n",(*(p2+i))->number,(*(p2+i))->name,(*(p2+i))->sum);}fhzjm();}void CunChu(){int i;FILE *rs;if((rs=fopen("student.txt","w"))==NULL){printf("not open");exit(0);}for(i=0;i<shuliang;i++){fwrite(&student[i], sizeof(student[i]), 1, rs); }if(ferror(rs)){fclose(rs);perror("写文件失败~\n");return;}printf("存储文件成功~\n");fclose(rs);fhzjm();}void DaoChu(){struct student t;int i=0;FILE* fp = fopen("student.txt", "r");shuliang=0;if(NULL==fp){perror("读取文件打开失败~\n");return;}memset(student,0x0,sizeof(student));while(1){fread(&t,sizeof(t),1,fp);if(ferror(fp)){fclose(fp);perror("读文件过程失败~\n");return;}if(feof(fp)){break;}student[i]=t;i++;}fclose(fp);shuliang=i; printf("导出文件成功~\n"); fhzjm();}void menu(){int n=0;system("CLS");printf(" 学生信息管理系统\n");printf(" 作者:陈椿\n");printf("-------------------MENU-----------------\n"); printf(" 1.登记学生信息\n");printf(" 2.删除学生信息\n");printf(" 3.浏览所有已经登记的学生\n");printf(" 4.查找\n");printf(" 4.1按学号查找\n");printf(" 4.2按姓名查找\n");printf(" 4.3按成绩查找\n");printf(" 5.根据总成绩排序\n");printf(" 6.存储到文件\n");printf(" 7.从文件导出\n");printf(" 8.退出系统\n");a: printf(" 请选择:");scanf("%d",&n);switch (n){case 1:DengJi();break;case 2:ShanChu();break;case 3:LiuLan();break;case 4:ChaZhao();break;case 5:PaiXu();break;case 6:CunChu();break;case 7:DaoChu();break;case 8:exit(0);break;default:{printf("请输入1-8之间的数字,谢谢~\n"); goto a;}}}main() {menu();}。
基于ASP+ACCESS的学生信息管理系统(源代码及全套资料)
摘要随着科学技术的发展,计算机领域不断取得新的研究成果。
并不断地代替和延伸脑力劳动方面发挥越来越重要的作用,无论是工业还是日常生活都越来越离不开计算机,尤其是在学校里,随着不同高校的的不断扩大和招生人数的不断增加,要处理大量的学生数据信息显得尤为的重要。
学生的信息管理是学校工作中一项重要的内容。
本系统论文主要是管理学生的资料。
重点介绍其功能:信息添加、信息修改、信息的删除及信息查询。
使用进行静态页面设计 ,应用A S P 程序进行后台管理操作,并用A ccess 进行后台数据库的连接设计。
主要是以四大功能进行系统的设计和实现。
关键词: Dreamw eaver M X 2004 系统站点设计 A S P A ccess 数据库1 .1 开发工具的介绍1 . 1 . 1 AS PASP ( Ac t i ve Se ve r Pa g e s 动态网页)是微软公司推出的一种用以取代CGI ( Common Ga t e wa y I nt e r f a c e ) 技术。
目前, I nt e r ne t 上的许多基于W i ndows 平台的W e b 站点已开始应用 ASP 来替换 CGI 。
ASP 是在服务器端脚本编译环境,使用它可以创建和运行动态、交互的 W e b 服务器应用程序。
ASP 可以与 HT ML 页、脚本命令和 Ac t i ve X 组件组合创建交互的 W e b 页和基于 W e b 的功能强大的应用程序。
ASP 应用程序很容易开发和修改。
ASP 是一个位于服务器端的脚本运行环境。
通过这种环境,用户可以创建和运行动态的交互式W e b 服务器应用程序,如交互式动态网页,包括使用H T M L表单收集和处理信息、上传与下载等。
通常情况下,用户通过浏览器看到的网页大多是静态的,目前I nt e r ne t 上的许多站点,仍然提供“静态”( s t a t i c )的主页内容。
学生信息系统源代码
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<conio.h>#define MY1 printf("\t学号\t姓名\t性别\t年龄\t出生年月\t地址\t电话\t")#define MY2 printf("\n%d\t%6s\t%4s\t%2d\t%4d%2d%2d\t%4s\t%6s\t\n",s[i].num,s[i].name,s[i].sex,s[i].age,s[ i].a.year,s[i].a.month,s[i].a.day,s[i].address,s[i].tel)#define MAX 20int i;int sum;/*时间结构体类型*/struct date{int year;int month;int day;}a;struct s_message{int num;char name[20];char sex[5];int age;struct date a;char address[50];char tel[11];char email[20];}s[MAX];/*保存学生信息模块*/void save_message(int sum){int i;FILE *fp;if((fp=fopen("D:\\s.txt","wb"))==NULL){printf("reading file is wrong!\n");return;}for (i=0;i<sum;i++){if(fwrite(&s[i],sizeof(struct s_message),1,fp)!=1)printf("writing file is wrong!\n");}fclose(fp);}/*读取学生信息模块*/int read_message(){FILE *fp;int i=0;if((fp=fopen("D:\\s.txt","rb"))==NULL){printf("\n\n***********暂时无任何库存信息,按回车键进入主菜单选择基本信息的录入!***********\n");return 0;}while(feof(fp)==0) /*feof(fp)有两个返回值:如果遇到文件结束,函数feof(fp)的值为1,否则为0。
学生管理系统(1:添加学生信息界面)
学⽣管理系统(1:添加学⽣信息界⾯)源码上传⾄:添加学⽣信息界⾯:添加学⽣实现代码:需求:1、点击确定按钮时,能够获取当前界⾯的所有控件的输⼊信息,在⼀个新的确认信息界⾯进⾏显式,等待确认。
2、在确认界⾯中,确认ok,点击确定按钮能够将学⽣信息写⼊到⽂件中保存起来,同时,将添加学⽣信息的界⾯恢复到初始值状态。
1/*********addstudents.h********/2 #ifndef ADDSTUDENTS_H3#define ADDSTUDENTS_H45 #include <QDialog>6 #include <QButtonGroup>78namespace Ui {9class AddStudents;10 }1112class AddStudents : public QDialog13 {14 Q_OBJECT1516public:17explicit AddStudents(QWidget *parent = nullptr);18 ~AddStudents();19void clear_on_addstudent_ok(); //确认界⾯点击确定之后,恢复添加学⽣信息界⾯的初始值20void write_to_file(QString src); //写⽂件2122private slots:23void my_add_students_info_ok_slots(); //添加学⽣信息界⾯的确定按钮槽函数24void my_add_students_info_cancel_slots();//添加学⽣信息界⾯的取消按钮槽函数25private:26 QButtonGroup *sexGroup; //存放性别单选按钮27 QButtonGroup *habbitGroup; //存放爱好多选按钮28 Ui::AddStudents *ui; //添加学⽣信息界⾯的UI29 };3031#endif// ADDSTUDENTS_H在addstudents.cpp中:1、⾸先看构造函数:1>需要绑定当前界⾯的按钮与槽函数,需要点击发送信号的有两个按钮:确定按钮+取消按钮2>对于性别⼀栏,两个单选按钮,是互斥的,只能选择其中⼀个,当⼀个被选中,那么另外⼀个⼀定是未选中状态。
学生成绩管理系统(数据结构C语言版源代码)
学生成绩管理系统(数据结构C语言版源代码)-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII#include<stdio.h>#include<string.h>#include<stdlib.h>struct students{char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *next; /*用与构建连表指向下一结点*/};FILE *fp; /*定义全局变量fp*/void Revisemenu();/*修改菜单*/void Sortmenu();/*排序菜单*/void menu();/*主菜单*/void secret();/*安全验证*/struct students * Input();/*新建学生信息*/void fprint(struct students *head);/*将信息导入文件可追加*/void fprint_(struct students *head);/*将信息导入文件并覆盖*/void Browse(struct students *head);/*浏览全部学生信息*/struct students * create(struct students *head,int *n);/*从tushu_list中读取数据构建链表*/void FindofNum(struct students *head);/*按学号查询学生信息*/void FindofNname(struct students *head);/*按姓名查询学生信息*/void SortEnglish(struct students * head);/*按英语成绩排序*/void SortJava(struct students * head);/*按Java成绩排序*/void SortSjjg(struct students * head);/*按数据结构成绩排序*/void SortSzdl(struct students * head);/*按数字逻辑电路成绩排序*/void SortJsj(struct students * head);/*按计算机组成原理成绩排序*/struct students * Delete(struct students * head,char m[15]);/*按学号删除学生成绩信息*/struct students * Revise();/*修改学生信息(按编号修改)*//*主菜单*/void menu(){printf("\n\n");printf("***************************************************\n");printf(" 学生成绩管理系统 \n");printf("---------------------------------------------------\n");printf(" 1-添加新同学 2-浏览学生信息 \n");printf(" 3-按学号查询 4-按姓名查询 \n");printf(" 5-按成绩排序 6-修改学生信息 \n");printf(" 7-删除学生信息 0-退出系统 \n");printf("---------------------------------------------------\n");printf("___________________________________________________\n");}/*排序菜单*/void Sortmenu(){printf("\n\n");printf("***************************************************\n");printf(" 按成绩排序 \n");printf(" 1-大学英语 2-JAVA编程 \n");printf(" 3-数据结构 4-数字逻辑电路 \n");printf(" 5-计算机组成原理 0-返回上级菜单 \n");printf("***************************************************\n");}/*修改菜单*/void Revisemenu(){printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf(" 1--修改学生姓名 2--修改学生学号 \n");printf(" 3--修改学生性别 4--修改英语成绩 \n");printf(" 5--修改JAVA成绩 6--修改数据结构 \n");printf(" 7--修改数字电路 8--修改计算计 \n");printf(" 0--返回上级菜单 \n");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");}/*安全验证*/void secret(){char a[20];printf("**欢迎来到学生信息管理系统,进入系统前请先进行密码验证---");printf(" ");do{gets(a); /*输入密码*/system("cls"); /*调用库函数清屏*/printf("对不起!您输入的密码有误,请重新输入---");}while(strcmp(a,"0605")!=0); /*单一密码"0605"*/system("cls");}/*新建学生信息*/struct students * Input(){struct students *p1,*p2,*head; /*建立辅助结点及头结点*/char Name;int n=0,x;printf("\n请按对应项输入学生信息以#结束:\n");printf("姓名学号性别英语 Java 数据结构数字电路计算机组成原理\n");p1=(struct students *)malloc(sizeof(struct students));head=p2=p1;do{ /*使用do while语句输入学生信息*/scanf("%s",&p1->Name);if(strcmp(p1->Name,"#")==0)break; /*判断结束符*/elsescanf("%s%s%lf%lf%lf%lf%lf",p1->Num,p1->Sex,&p1->English,&p1->Java,&p1->Sjjg,&p1->Szdl,&p1->Jsj);Name='#';p1=(struct students *)malloc(sizeof(struct students));p2->next=p1;p2=p1;n++;}while(1);p1->next=NULL;printf("学生信息输入结束!\n");getchar();printf("是否保存学生信息(1.是/2.否):");scanf("%d",&x);if(x==1)fprint(head); /*调用函数保存至文件*/elseprintf("\n文件没有被保存!\n");return head; /*返回头指针*/}/*将信息导入文件可追加*/void fprint(struct students *head){struct students *p1;if((fp=fopen("students_list.txt","a"))==NULL){printf("File open error!\n");exit(0);}for(p1=head;p1->next!=NULL;p1=p1->next) /*遍历*/fprintf(fp,"%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n", p1->Name,p1->Num,p1->Sex,p1->English,p1->Java,p1->Sjjg,p1->Szdl,p1->Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/printf("\n学生信息已成功保存到文件 students_list.txt 中!\n");getchar();}/*将信息导入文件并覆盖*/void fprint_(struct students *head){struct students *p1;if((fp=fopen("students_list.txt","w"))==NULL){printf("File open error!\n");exit(0);}for(p1=head;p1!=NULL;p1=p1->next) /*遍历*/fprintf(fp,"%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n", p1->Name,p1->Num,p1->Sex,p1->English,p1->Java,p1->Sjjg,p1->Szdl,p1->Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/;getchar();}/*浏览全部学生信息*/void Browse(struct students *head){char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/if((fp=fopen("students_list.txt","a+"))==NULL){printf("File open error!\n");exit(0);}printf("-------------------------------------------------------------\n");printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(!feof(fp))/*读取并输出*/{fscanf(fp,"%s%s%s%lf%lf%lf%lf%lf",Name,Num,Sex,&English,&Java,&Sjjg,&Sz dl,&Jsj);printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",Name,Num,Sex,English,Java,Sjjg,Szdl,Jsj);};if(fclose(fp)){printf("Can not close the file!\n");exit(0);}}/*从tushu_list中读取数据构建链表*/struct students * create(struct students * head,int *n){FILE *fp;struct students*p,*p1,*p2;if((fp=fopen("students_list.txt","a+"))==NULL){printf("File open error!\n");exit(0);}while(!feof(fp)){(*n)++;p=(struct students *)malloc(sizeof(struct students));fscanf(fp,"%s%s%s%lf%lf%lf%lf%lf",p->Name,p->Num,p->Sex,&p->English,&p->Java,&p->Sjjg,&p->Szdl,&p->Jsj);if(head==NULL){head=p;p1=p;}else{p1->next=p;p2=p1;p1=p;}}p2->next=NULL;free(p);(*n)--;fclose(fp);return head;}/*按姓名查询学生信息*/void FindofName(struct students *head){int i=0,n=0;char b[20];struct students *p;head=create(head,&n);p=head;printf("\n请输入要查询的学生姓名:");scanf("%s",b);while(p!=NULL){if(strcmp(p->Name,b)==0){printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);i++;}p=p->next;}if(i==0)printf("\n对不起!没有找到名为“%s”的学生信息!\n",b);}/*按学号查询学生信息*/void FindofNum(struct students *head){int i=0,n;char b[20];struct students *p;head=create(head,&n);p=head;printf("\n请输入要查询的学生学号:");scanf("%s",b);while(p!=NULL){if(strcmp(p->Num,b)==0){printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);i++;}p=p->next;}if(i==0)printf("\n对不起!没有找到学号为“%s”学生信息!\n",b);}/*按英语成绩排序*/void SortEnglish(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double English;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;English=p->English; /*将链表中第一个成绩赋给English*/while(p!=NULL){if((p->English)>English)/*比较*/English=p->English;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->English==English){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->English==English){ /*分数相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按英语成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按JAVA成绩排序*/void SortJava(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Java;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Java=p->Java; /*将链表中第一个成绩赋给Java*/while(p!=NULL){if((p->Java)>Java)/*比较*/Java=p->Java;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Java==Java){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Java==Java){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按Java成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按数据结构排序*/void SortSjjg(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Sjjg;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Sjjg=p->Sjjg; /*将链表中第一个成绩赋给Sjjg*/while(p!=NULL){if((p->Sjjg)>Sjjg)/*比较*/Sjjg=p->Sjjg;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Sjjg==Sjjg){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Sjjg==Sjjg){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按数据结构成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按数字电路排序*/void SortSzdl(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Szdl;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Szdl=p->Szdl; /*将链表中第一个成绩赋给Szdl*/while(p!=NULL){if((p->Szdl)>Szdl)/*比较*/Szdl=p->Szdl;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Szdl==Szdl){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Szdl==Szdl){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按数字电路成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按计算机组成原理排序*/void SortJsj(struct students * head){struct students *p,*tail; /*定义中间变量*/int n;double Jsj;p=(struct students *)malloc(sizeof(struct students));head=create(head,&n);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");while(head->next!=NULL) /*利用选择法排序*/{tail=NULL;p=head;Jsj=p->Jsj; /*将链表中第一个成绩赋给Jsj*/while(p!=NULL){if((p->Jsj)>Jsj)/*比较*/Jsj=p->Jsj;tail=p;p=p->next;}tail=NULL;p=head;while(p->next!=NULL){if(p->Jsj==Jsj){printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);if(p==head)head=head->next;elsetail->next=p->next;}tail=p;p=p->next;}if(p->Jsj==Jsj){ /*成绩相同时无需比较*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);tail->next=NULL;}}p=head; /*将链表赋给结构体指针*/printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);/*浏览排序后的信息*/printf("按计算机组成原理成绩排序后输出如上(注:此过程不保存至文件):\n");return;}/*按学号删除学生成绩信息*/struct students * Delete(struct students * head,char m[15]){struct students *ptr1,*ptr2;int n;printf("\n所有学生信息如下:\n");Browse(head);printf("\n请输入想要删除的学生学号:");scanf("%s",m);head=create(head,&n);if(head==NULL){printf("无学生信息!\n");return head;}if((strcmp(head->Num,m)==0)&&head!=NULL){ptr2=head;head=head->next;free(ptr2);}if(strcmp(head->Num,m)!=0){ptr1=head;ptr2=head->next;while(ptr2!=NULL){if(strcmp(ptr2->Num,m)==0){ptr1->next=ptr2->next;free(ptr2);}elseptr1=ptr2;ptr2=ptr1->next;}}fprint_(head);printf("\n学号为' %s '学生信息已被删除,并保存至文件!\n",m);return head;}/*修改学生信息(按编号修改)*/struct students * Revise(){int n=0,t;char num[10];char Num[10]; /*字符型学生学号*/char Name[20]; /*字符型学生姓名*/char Sex[3]; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *head=NULL;struct students *p;printf("\n所有学生信息如下:\n");Browse(head);head=create(head,&n);printf("\n输入需要修改的学生的学号:");scanf("%s",num);p=head;while(head!=NULL){if(strcmp(p->Num,num)==0){system("cls");Revisemenu();printf("编号为%s的学生信息如下:\n",num);printf("姓名学号性别英语 Java 数据结构数字电路计算机\n");printf("%s\t%s\t%s\t%.1lf\t%.1lf\t%.1lf\t%.1lf\t%.1lf\n",p->Name,p->Num,p->Sex,p->English,p->Java,p->Sjjg,p->Szdl,p->Jsj);while(1){printf("请选择需要修改的信息:");scanf("%d",&t);switch(t){case 1:printf("请输入新姓名:");scanf("%s",Name);strcpy(p->Name,Name);break;case 2:printf("请输入新学号:");scanf("%s",&Num);strcpy(p->Num,Num);break;case 3:printf("请输入新性别:");scanf("%s",Sex);strcpy(p->Sex,Sex);break;case 4:printf("请输入新英语成绩:");scanf("%lf",&English);p->English=English;break;case 5:printf("请输入新Java成绩:");scanf("%lf",&Java);p->Java=Java;break;case 6:printf("请输入新数据结构成绩:");scanf("%lf",&Sjjg);p->Sjjg=Sjjg;break;case 7:printf("请输入新数字电路成绩:");scanf("%lf",&Szdl);p->Szdl=Szdl;break;case 8:printf("请输入新计算机组成原理成绩:");scanf("%lf",&Jsj);p->Jsj=Jsj;break;case 0:system("cls");menu();goto lab;break;default:printf("对不起,输入有误!");break;}}}elsep=p->next;}lab:fprint_(head);printf("修改完成,并储存至文件!\n");return head;}/*主函数*/void main(){int choice,ch;char m[15];struct students *head=NULL;secret();menu();while(1){printf("请输入选项:");scanf("%d",&choice);switch(choice){case 1:Input();break;case 2:system("cls");menu();Browse(head);break;case 3:system("cls");menu();FindofNum(head);break;case 4:system("cls");menu();FindofName(head);break;case 5:system("cls");Sortmenu();do{printf("请输入您的选择:");scanf("%d",&ch);switch(ch){case 1:system("cls");Sortmenu();SortEnglish(head);break;case 2:system("cls");Sortmenu();SortJava(head);break;case 3:system("cls");Sortmenu();SortSjjg(head);break;case 4:system("cls");Sortmenu();SortSzdl(head);break;case 5:system("cls");Sortmenu();SortJsj(head);break;}}while(ch!=0);system("cls");menu();break;case 6:system("cls");menu();Revise();break;case 7:system("cls");menu();head=Delete(head,m);break;case 0:system("cls");printf("\t\t欢迎下次再来!");exit(0);default:printf("对不起,输入有误!");break;}}return ;}。
学生成绩信息管理系统源代码
p2=p1;p1=p1->next;
}
if(number==p1->number)
{
if(p1==head)
head=p1->next;
else
p2->next=p1->next;
printf("删除:%d\n",number);n=n-1;
scanf("%s",&p1->name);
printf("请输入语文成绩(0~100):");
scanf("%f",&p1->yuwen);
while(p1->yuwen<0||p1->yuwen>100)
{getchar();
printf("输入错误,请重新输入语文成绩");
printf("现在的学生数为:%d个!\n",n);
return(head);
}
struct student *insert(struct student *head, struct student *stud)//插入函数
{struct student *p0,*p1,*p2;
printf("请输入语文成绩(0~100):");
scanf("%f",&p1->yuwen);
while(p1->yuwen<0||p1->yuwen>100)
{getchar();
printf("输入错误,请重新输入语文成绩");
scanf("%f",&p1->yuwen);}
NetBeans实现学生信息管理系统源码
PROJECT ION StudentInformationManagementSystemStudent Management System SoftwareNIITAcknowledgementI would like to thank our Faculty Mr. Shahnawaz and Chinese associate Faculty Ms. Li Fanfan for all their guidance and support during the entire phase of this project development without which the project would not have been completed.System AnalysisNetBeans实现学生信息管理系统源码System Summary:It is convenient for the users to manage student information.for example :add, delete,update and overview student information. Business Rules:1,create database ,tables and constraints.2,interface design3,implement the source code4,debug and testData Query:create database SIMSuse SIMScreate table useinfo(uid int primary key identity(101,1),uname nchar(20)not null,upassword nchar(10)default'00000',urealname nchar(20),umobil nchar(15))create table studentinfor(sid int primary key identity(10001,1),sname nchar(20)not null,sgender char(4),sbirthday nchar(15),smobil nchar(15),semil nchar(20),sacademy nchar(20),smajor nchar(20),)alter table useinfoadd constraint uniq unique(uname)alter table studentinforadd constraint un unique(sname)alter table studentinforalter column smobil char(11)alter table useinfodrop constraint DF__useinfo__upasswo__108B795B//How to Use Update、Insert、Select、delete in Code1)stat=con.prepareStatement("update studentinfor setsgender=?,sbirthday=?,smobil=?,semil=?,sacademy=?,smajor=? wheresid=?");2)stat=con.prepareStatement("insert into useinfo values(?,?,?,?)");3)ResultSet rs = stmt.executeQuery("SELECT * FROM useinfo");4)stat=con.prepareStatement("delete from studentinfor where sid=?");ConfigurationHardware: Intel (R) Pentium(R) Dual E2180 2.1G Hz1.20G Hz 3.00GB RAM250GB 7200 RPM Hard Disk10/100NICOptical MouseKeyboard17"Color MonitorOperating System: Microsoft Windows 07 Software: Netbeans IDE 7.2.1、Microsoft SQL Server 2008Individual Project ScheduleSource Code//login GUI and the main function//StudentMain.javapackage studentinformationmanagementsystem;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;import javax.swing.UIManager;public class StudentMain extends JFrame implements ActionListener{JLabel Ltitle,Lname,Lpassword;JButton Blogin,Bexit,Lregister;JTextField TFname;JPasswordField TFpassword;GridBagLayout gbl;GridBagConstraints gbc;GridLayout gl;Font f1,f2,f3;JPanel p1,p2;Connection con;PreparedStatement stat;Statement stmt;ResultSet rs;public String name;public StudentMain(boolean flag){//boolean f=fsuper("StudentInformationManagementSystem");this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);f1=new Font("宋体",1,25);f2=new Font("宋体",1,20);f3=new Font("宋体",1,18);Ltitle=new JLabel("Student Information Management System",JLabel.CENTER);Ltitle.setVerticalAlignment(JLabel.CENTER);Ltitle.setForeground(Color.red);Lname=new JLabel("UserName",JLabel.CENTER);Lpassword=new JLabel("UserPassword",JLabel.CENTER);Lregister=new JButton("Register");Ltitle.setFont(f1);Lname.setFont(f2);Lpassword.setFont(f2);Lregister.setFont(f2);TFname=new JTextField(15);//TFname.setBounds(0,0,150,40);TFname.setFont(f2);TFpassword=new JPasswordField(15);TFpassword.setFont(f2);TFpassword.setEchoChar('*');Blogin=new JButton("Login");Blogin.setFont(f2);Bexit=new JButton("Exit");Bexit.setFont(f2);p1=new JPanel();p2=new JPanel();gbl=new GridBagLayout();gbc=new GridBagConstraints();gl=new GridLayout(3,1);p1.setLayout(gbl);gbc.fill=GridBagConstraints.NONE;gbc.insets=new Insets(0,0,11,10);gbc.anchor=GridBagConstraints.CENTER;gbc.gridwidth=1;gbl.setConstraints(Lname, gbc);p1.add(Lname);gbc.gridwidth = GridBagConstraints.REMAINDER;gbc.anchor=GridBagConstraints.LINE_START;gbl.setConstraints(TFname, gbc);p1.add(TFname);gbc.gridwidth=1;gbc.anchor=GridBagConstraints.CENTER;gbl.setConstraints(Lpassword, gbc);p1.add(Lpassword);gbc.gridwidth = GridBagConstraints.REMAINDER;gbc.anchor=GridBagConstraints.CENTER;gbl.setConstraints(TFpassword, gbc);p1.add(TFpassword);p2.setLayout(new FlowLayout(FlowLayout.CENTER,20,0)); p2.add(Blogin);p2.add(Bexit);p2.add(Lregister);this.setLayout(gl);this.add(Ltitle);this.add(p1);this.add(p2);Blogin.addActionListener(this);Bexit.addActionListener(this);Lregister.addActionListener(this);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds((screenSize.width-365)/2, (screenSize.height-449)/2, 550, 350);this.setVisible(flag);}public void actionPerformed(ActionEvent ae){if(ae.getActionCommand()=="Exit")System.exit(0);if(ae.getActionCommand()=="Login"){name=TFname.getText();String password=TFpassword.getText();if(name.equals("")||password.equals(""))JOptionPane.showMessageDialog(null,"UserName,UserPassword is not null");else{try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");con=DriverManager.getConnection("jdbc:odbc:DataSource","","");Statement stmt=con.createStatement();ResultSet rs = stmt.executeQuery("SELECT * FROM useinfo");boolean isfind=false;while(rs.next()){if(name.equals(rs.getString(2))){isfind=true;if(password.equals( rs.getString(3))){this.dispose();new Function(name);TFname.setText("");TFpassword.setText("");}else{JOptionPane.showMessageDialog(null,"Password is worng!");}break;}}if( isfind==false){JOptionPane.showMessageDialog(null,"Not Exsit the User,Please Register!");}con.close();}catch(Exception e){System.out.println("Error "+e.getMessage());}}}if(ae.getActionCommand()=="Register"){new AddUser();}}public static void main(String[] args) {// TODO code application logic heretry{UIManager.setLookAndFeel(newcom.sun.java.swing.plaf.windows.WindowsLookAndFeel());}catch(Exception e){}new StudentMain(true);}}//Function GUI//Function.javapackage studentinformationmanagementsystem;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.table.*;import java.util.*;public class Function extends JFrame implements ActionListener{JMenu funmenu1,funmenu2,funmenu3;JMenuItem menuitempwd,menulogout,menuexit,menuoverview;JPanel funpl1,funpl2,funpl3,funpl4,funpl5,funpl6;JLabel funlb1,funlb2;JButton funjbadd,funjbdelete,funjbupdate,funjboverview,funjbok,funjbcancel;JMenuBar funmenubar;JComboBox funjcb1;JTextField funjtf1,funjtf2;Font funf1;JScrollPane jsp;JTable funjtb;JScrollPane funjsp;Connection con;Statement stmt;PreparedStatement stat;ResultSet rs;ResultSetMetaData rsmd;public String ss;Function(String str){super("StudentManagementSystem");this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);ss=str;setLayout(null);funjsp=new JScrollPane();funf1=new Font("Arial",Font.BOLD|Font.ITALIC,20);funjcb1=new JComboBox();funjcb1.addItem("select by ID");funjcb1.addItem("select by name");funjcb1.addActionListener(this);funpl2=new JPanel();funpl2.setLayout(new FlowLayout(FlowLayout.CENTER,0,3));funpl3=new JPanel();funpl3.setLayout(new FlowLayout(FlowLayout.LEFT,20,3));funpl4=new JPanel();funpl4.setLayout(new FlowLayout(FlowLayout.CENTER,20,3));funpl5=new JPanel();funpl5.setLayout(new GridLayout(4,1));funpl6=new JPanel();funpl6.setLayout(new FlowLayout());funmenubar=new JMenuBar();funmenubar.setBounds(0,0,490,30);funlb1=new JLabel("Welcome To The System! ",JLabel.CENTER);funlb1.setFont(funf1);Object tablesize[][]=new Object[20][8];for(int i=0;i<20;i++){for(int j=0;j<8;j++){tablesize[i][j]=null;}}Stringcolumn[]={"sid","sname","sgender","sbirth","smobil","semil","sacademy","smajor"};funjtb=new JTable(tablesize,column);funjtb.setShowGrid(true);funjtf1=new JTextField(25);funjtf1.addActionListener(this);funjbadd=new JButton("Add");funjbadd.addActionListener(this);funjbdelete=new JButton("Delete");funjbdelete.addActionListener(this);funjboverview=new JButton("Overview");funjboverview.addActionListener(this);funjbupdate=new JButton("Update");funjbupdate.addActionListener(this);funjbok=new JButton("OK");funjbok.addActionListener(this);funjbcancel=new JButton("Cancel");funjbcancel.addActionListener(this);funmenu1=new JMenu("user management");funmenu2=new JMenu(" overview");funmenu3=new JMenu(" help");menuoverview=new JMenuItem("check my infomation",JMenuItem.CENTER);menuoverview.addActionListener(this);menuitempwd=new JMenuItem("password management",JMenuItem.CENTER);menuitempwd.addActionListener(this);funmenu1.add(menuoverview);funmenu1.add(menuitempwd);menulogout=new JMenuItem("Log Out",JMenuItem.CENTER);menulogout.addActionListener(this);funmenu1.add(menulogout);menuexit=new JMenuItem("Exit",JMenuItem.CENTER);menuexit.addActionListener(this);funmenu1.add(menuexit);funmenubar.add(funmenu1);funmenubar.add(funmenu2);funmenubar.add(funmenu3);funpl2.add(funlb1);funpl3.add(funjcb1);funpl3.add(funjtf1);funpl3.add(funjbok);funpl3.add(funjbcancel);funpl4.add(funjboverview);funpl4.add(funjbadd);funpl4.add(funjbdelete);funpl4.add(funjbupdate);funpl5.add(funpl2);funpl5.add(funpl3);funpl5.add(funpl4);funpl5.setBounds(0,50,475,120);funpl6.add(new JScrollPane(funjtb));funpl6.setBounds(10,165,455,500);add(funmenubar);add(funpl5);add(funpl6);this.setVisible(true);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds((screenSize.width-450)/2, (screenSize.height-550)/2,490,580);}public void actionPerformed(ActionEvent ae){//update passwordString s=ae.getActionCommand();TableModel mdl=funjtb.getModel();if(ae.getSource().equals(menuitempwd)){try{UpdatePassword up=new UpdatePassword();up.TFuname.setText(ss);}catch(Exception e){System.out.println("Error: "+e);}}else if(ae.getSource().equals(funjboverview)){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor");String rows[]={"","","","","","","",""};while(rs.next()){for(int i=0;i<8;i++){rows[i]=rs.getString(i+1);mdl.setValueAt(rows[i], rs.getRow()-1, i);}}con.close();funjtb.repaint();}catch(Exception e){System.out.println("Error:"+e);}}else if(ae.getSource().equals(menuoverview)){try{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select uid,uname,urealname,umobil from useinfo whereuname='"+ss+"'");rs.next();String id=Integer.toString(rs.getInt(1));String name=rs.getString(2);String realname=rs.getString(3);String mobil=rs.getString(4);UserInformation ui=new UserInformation(true);ui.TFuid.setText(id);ui.TFuname.setText(name);ui.TFurealname.setText(realname);ui.TFumobil.setText(mobil);con.close();}catch(Exception e){System.out.println("Error: "+e);}}else if(ae.getSource().equals(menulogout)){this.dispose();new StudentMain(true);}else if(ae.getSource().equals(menuexit)){System.exit(1);}else if(ae.getSource() == funjbok){if(funjtf1.getText().equals("")){JOptionPane.showMessageDialog(null, "Please Input The StudentID or StudentName");}else if (funjcb1.getSelectedItem().equals("select by ID")){int sid=Integer.parseInt(funjtf1.getText());try{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sid="+sid);String rows[]={"","","","","","","",""};if(rs.next()){int id=rs.getInt(1);String ID=Integer.toString(id);String name=rs.getString(2);String gender=rs.getString(3);String birth=rs.getString(4);String mobil=rs.getString(5);String email=rs.getString(6);String academy=rs.getString(7);String major=rs.getString(8);StudentInformation si=new StudentInformation();si.TFid.setText(ID);si.TFname.setText(name);si.TFsex.setText(gender);si.TFbirthday.setText(birth);si.TFmobil.setText(mobil);si.TFemail.setText(email);si.TFacademy.setText(academy);si.TFmajor.setText(major);}else{JOptionPane.showMessageDialog(null, "Check The ID Again!");}con.close();}catch(Exception e){System.out.println("Error:"+e);}}else if (funjcb1.getSelectedItem().equals("select by name")){try{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sname='"+funjtf1.getText()+"'");String rows[]={"","","","","","","",""};rsmd=rs.getMetaData();if(rs.next()){int id=rs.getInt(1);String ID=Integer.toString(id);String name=rs.getString(2);String gender=rs.getString(3);String birth=rs.getString(4);String mobil=rs.getString(5);String email=rs.getString(6);String academy=rs.getString(7);String major=rs.getString(8);StudentInformation si=new StudentInformation();si.TFid.setText(ID);si.TFname.setText(name);si.TFsex.setText(gender);si.TFbirthday.setText(birth);si.TFmobil.setText(mobil);si.TFemail.setText(email);si.TFacademy.setText(academy);si.TFmajor.setText(major);}else{JOptionPane.showMessageDialog(null, "Check The Name Again!");}con.close();funjtb.repaint();funjtb.updateUI();}catch(Exception e){System.out.println("Error:"+e);}}}else if (ae.getSource().equals(funjbcancel)){funjtf1.setText(null);}else if(ae.getActionCommand()=="Add"){new AddInformation();}else if(ae.getActionCommand()=="Delete"){try{if(funjcb1.getSelectedItem().equals("select by ID")){if(funjtf1.getText().equals("")){JOptionPane.showMessageDialog(null,"Please Input StudentID!");}else{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sid="+Integer.parseInt(funjtf1.getText()));if(rs.next()){con.close();con=DriverManager.getConnection("jdbc:odbc:DataSource");stat=con.prepareStatement("delete from studentinfor where sid=?");String s1=funjtf1.getText();int n=Integer.parseInt(s1);stat.setInt(1, n);stat.executeUpdate();JOptionPane.showMessageDialog(null,"Student has been Deleted!");con.close();}else{JOptionPane.showMessageDialog(null,"The Stufdent not Exist!");}}}else if(funjcb1.getSelectedItem().equals("select by name")){if(funjtf1.getText().equals("")){JOptionPane.showMessageDialog(null,"Please Input StudentName!");}else{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sname='"+funjtf1.getText()+"'");if(rs.next()){con.close();con=DriverManager.getConnection("jdbc:odbc:DataSource");stat=con.prepareStatement("delete from studentinfor where sname=?");String s1=funjtf1.getText();stat.setString(1, s1);stat.executeUpdate();JOptionPane.showMessageDialog(null,"Student has been Deleted!");con.close();}else{JOptionPane.showMessageDialog(null,"The Stufdent not Exist!");}}}}catch(Exception e){System.out.println("Error: "+e);}}else if(ae.getSource().equals(funjbupdate)){try{if(funjcb1.getSelectedItem().equals("select by ID")){if(funjtf1.getText().equals("")){JOptionPane.showMessageDialog(null,"Please Input StudentID!");}else{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sid="+Integer.parseInt(funjtf1.getText()));if(rs.next()){int sd=Integer.parseInt(sss);UpdateInformation ui=new UpdateInformation();con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sid="+sd);rs.next();String sr=rs.getString(1);String sr1=rs.getString(2);ui.TFid.setText(sr);ui.TFname.setText(sr1);con.close();}else{JOptionPane.showMessageDialog(null,"The Stufdent not Exist!");}}}if(funjcb1.getSelectedItem().equals("select by name")){if(funjtf1.getText().equals("")){JOptionPane.showMessageDialog(null,"Please Input StudentName!");}else{con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sname='"+funjtf1.getText()+"'");if(rs.next()){String ss=funjtf1.getText();UpdateInformation ui=new UpdateInformation();con=DriverManager.getConnection("jdbc:odbc:DataSource");stmt=con.createStatement();rs=stmt.executeQuery("select * from studentinfor where sname='"+ss+"'");rs.next();String sr=rs.getString(1);ui.TFid.setText(sr);ui.TFname.setText(sr1);con.close();}else{JOptionPane.showMessageDialog(null,"The Stufdent not Exist!");}}}}catch(Exception e){System.out.println("Error:"+e);}}}}//Add User GUI//AddUser.javapackage studentinformationmanagementsystem;import java.awt.*;import java.sql.*;import javax.swing.*;import java.awt.event.*;public class AddUser extends JFrame implements ActionListener{JLabel lname,lpassword,lrealname,lmobil;JTextField fname,frealname,fmobil;JButton ok,quit;JPasswordField fpassword;Connection con;PreparedStatement stat;Statement stmt;ResultSet rs;AddUser(){super("AddUserInformation");this.setLayout(null);lname=new JLabel("Name");lname.setBounds(20,20,50,25);fname=new JTextField();fname.setEditable(true);fname.setBounds(90,20,120,25);lpassword=new JLabel("Password");lpassword.setBounds(20,55,50,25);fpassword=new JPasswordField();fpassword.setEchoChar('*');fpassword.setEditable(true);fpassword.setBounds(90,55,120,25);lrealname=new JLabel("RealName");lrealname.setBounds(20,90,50,25);frealname=new JTextField();frealname.setEditable(true);frealname.setBounds(90,90,120,25);lmobil=new JLabel("Mobil");lmobil.setBounds(20,125,50,25);fmobil=new JTextField();fmobil.setEditable(true);fmobil.setBounds(90,125,120,25);ok=new JButton("OK");ok.setBounds(40,180,50,25);quit=new JButton("Quit");quit.setBounds(120,180,60,25);this.add(lname);this.add(fname);this.add(lpassword);this.add(fpassword);this.add(lrealname);this.add(frealname);this.add(lmobil);this.add(fmobil);this.add(ok);this.add(quit);ok.addActionListener(this);quit.addActionListener(this);this.setVisible(true);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds((screenSize.width-350)/2, (screenSize.height-450)/2, 260, 280); }public void actionPerformed(ActionEvent ae){if(ae.getActionCommand()=="Quit")this.dispose();if(ae.getActionCommand()=="OK"){String name=fname.getText();String password=fpassword.getText();String realname=frealname.getText();String mobil=fmobil.getText();if(name.equals("")||password.equals("")||realname.equals("")||mobil.equals(""))JOptionPane.showMessageDialog(null,"Please Input All Information!");else{if((password.length()==6)&&(fmobil.getText().length()==11)){try{con=DriverManager.getConnection("jdbc:odbc:DataSource","","");stat=con.prepareStatement("insert into useinfo values(?,?,?,?)");stat.setString(1, name);stat.setString(2, password);stat.setString(3, realname);stat.setString(4, mobil);stat.executeUpdate();JOptionPane.showMessageDialog(null,"User Information has been Inserted!");fname.setText("");fpassword.setText("");frealname.setText("");fmobil.setText("");con.close();stmt.close();rs.close();}catch(Exception e){System.out.println("Error: "+e);}}else{JOptionPane.showMessageDialog(null,"Please Input 6 Lengh Number Password And Input 11 Mobile Number!");}}}}}//AddInformation GUI//AddInformation.javapackage studentinformationmanagementsystem;import javax.swing.JFrame;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;import java.util.Calendar;public class AddInformation extends JFrame implements ActionListener{ JLabelLid,Lname,Lsex,Lmale,Lfemale,Lsub1,Lsub2,Lbirthday,Lacademy,Lmajor,Lmobil,Lemail;JTextField TFid,TFname,TFacademy,TFmajor,TFmobil,TFemail;JButton Bquit,Bok;ButtonGroup bp;JComboBox year,month,day;Calendar calendar;JRadioButton male,female;Connection con;PreparedStatement stat;Statement stmt;ResultSet rs;public AddInformation(){super("AddStudentInformation");this.setLayout(null);Lid=new JLabel();Lname=new JLabel();Lsex=new JLabel();male=new JRadioButton();female=new JRadioButton();year=new JComboBox();month=new JComboBox();day=new JComboBox();calendar=Calendar.getInstance();Lsub1=new JLabel();Lsub2=new JLabel();Lbirthday=new JLabel();Lacademy=new JLabel();Lmajor=new JLabel();Lmobil=new JLabel();Lemail=new JLabel();TFid=new JTextField();TFname=new JTextField();TFacademy=new JTextField();TFmajor=new JTextField();TFmobil=new JTextField();TFemail=new JTextField();Bok=new JButton();Bquit=new JButton();bp=new ButtonGroup();bp.add(male);bp.add(female);Lid.setText("ID: ");Lid.setBounds(10, 10, 50, 25);Lname.setText("Name: ");Lname.setBounds(180,10,50,25);TFid.setEditable(false);TFid.setBounds(10,40,140,25);TFname.setEditable(true);TFname.setBounds(180,40,140,25);Lsex.setText("Genger: ");Lsex.setBounds(10,70,60,25);Lbirthday.setText("Birthday: ");Lbirthday.setBounds(180,70,60,25);male.setSelected(true);male.setText("M");male.setBounds(10,100,40,25);female.setText("F");female.setBounds(50,100,40,25);for(int i=1970;i<=2020;i++){year.addItem(new Integer(i));}year.setSelectedItem(calendar.get(Calendar.YEAR)); year.addActionListener(this);for(int i=1;i<=12;i++){month.addItem(new Integer(i));}month.setSelectedIndex(calendar.get(Calendar.MONTH)); month.addActionListener(this);calendar.set(Calendar.MONTH,month.getSelectedIndex());int maxd=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); for(int i=1;i<=maxd;i++){day.addItem(new Integer(i));}year.setBounds(180, 100, 50, 25);month.setBounds(240, 100, 40, 25);day.setBounds(290,100,40,25);Lsub1.setText("-");Lsub1.setBounds(232,100,10,25);Lsub2.setText("-");Lsub2.setBounds(282, 100,10, 25);Lacademy.setText("Academy: ");Lacademy.setBounds(10,130,60,25);Lmajor.setText("Major: ");Lmajor.setBounds(180,130,60,25);TFacademy.setEditable(true);TFacademy.setBounds(10,160,140,25);TFmajor.setEditable(true);TFmajor.setBounds(180,160,140,25);Lmobil.setText("Mobil: ");Lmobil.setBounds(10,190,60,25);Lemail.setText("Email: ");Lemail.setBounds(180,190,60,25);TFmobil.setEditable(true);TFmobil.setBounds(10,220,140,25);TFemail.setEditable(true);TFemail.setBounds(180,220,140,25);Bok.setText("OK");Bok.setBounds(150,280,50,25);Bquit.setText("Quit");Bquit.setBounds(230,280,60,25);this.add(Lid);this.add(Lname);this.add(TFid);this.add(TFname);this.add(Lsex);this.add(Lbirthday);this.add(month);this.add(Lsub1);this.add(Lsub2);this.add(year);this.add(day);this.add(male);this.add(female);this.add(Lacademy);this.add(Lmajor);this.add(TFacademy);this.add(TFmajor);this.add(Lmobil);this.add(Lemail);this.add(TFmobil);this.add(TFemail);this.add(Bok);this.add(Bquit);Bok.addActionListener(this);Bquit.addActionListener(this);year.addActionListener(this);month.addActionListener(this);this.setVisible(true);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds((screenSize.width-365)/2, (screenSize.height-449)/2, 350, 360);}public void actionPerformed(ActionEvent ae){String name=TFname.getText();String sex=male.isSelected()?"Male":"Female";String m=month.getSelectedItem().toString();String y=year.getSelectedItem().toString();String d=day.getSelectedItem().toString();String birth=y+"-"+m+"-"+d;String academy=TFacademy.getText();String major=TFmajor.getText();String mobil=TFmobil.getText();String email=TFemail.getText();if(ae.getSource()==year){calendar.set(Calendar.YEAR, ((Integer) year.getSelectedItem()).intValue());int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);for(int i=1;i<=maxDay;i++){day.addItem(new Integer(i));}}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
系统源代码一、登录界面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class login : System.Web.UI.Page{protected void txtid_Click(object sender, EventArgs e){txtid.Text = "";txtpassword.Text = "";}protected void Button1_Click(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);conn.Open();DataSet ds=new DataSet () ;SqlDataAdapter da = new SqlDataAdapter("select * from users whereuserid='" + txtid.Text + "' and userpwd='" + txtpassword.Text + "'", conn); da.Fill(ds);if (ds.Tables[0].Rows.Count==0){Label3 .Text ="账号或密码错误,请重新输入!";}else{Session ["userid"]=txtid .Text ;Session["userpwd"] = txtpassword.Text;Session["username"] =ds.Tables[0].Rows[0]["username"].ToString();Session["userpower"] =ds.Tables[0].Rows[0]["userpower"].ToString();if (Session["userpower"].ToString () == "0"){Response.Redirect("admin/index.aspx");}else if (Session["userpower"].ToString() == "1"){Response.Redirect("student/index.aspx");}else{Label3.Text = "对不起,权限验证失败";}}conn.Close();ds.Clear ();}}二、添加课程页面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addcourse : System.Web.UI.Page{SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){courseid.Attributes.Add("onblur", "checkcourseid()");string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if (courseid.Text.ToString() == ""){Label7.Text = "课程号不能为空";}else{string sqlstr = "";sqlstr = "insert intocourse(courseid,coursename,coursetime,fen,type,teacher)values('" + courseid.Text + "','" + coursename.Text + "','" + coursetime.Text + "','" + fen.Text + "','" + type.Text + "','" + teacher.Text + "')";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();try{mycmd.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{conn.Close();sqlstr = "";}}}protected void Button2_Click(object sender, EventArgs e) {courseid.Text = "";coursename.Text = "";coursetime.Text = "";fen.Text = "";type.Text = "";}protected void Button3_Click(object sender, EventArgs e) {Response.Redirect("course.aspx");}}三、添加成绩程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addscore : System.Web.UI.Page{SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if (userid.SelectedValue .ToString ()== ""){Label11.Text = "学号不能为空";}else{string sqlstr = "";sqlstr = "insert intoscore(userid,username,courseid,coursename,score,[year])values('" +userid.SelectedValue + "','" + username.Text + "','" +txtcourseid.SelectedValue + "','" + coursename.Text + "','" + score.Text + "','" + txtyear.SelectedValue + "')";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();try{mycmd.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{conn.Close();sqlstr = "";}}}protected void Button2_Click(object sender, EventArgs e){username.Text = "";coursename.Text = "";score.Text = "";txtyear.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("score.aspx");}protected void userid_SelectedIndexChanged(object sender, EventArgs e) {string sqlstr = "";sqlstr = "select username from students where userid='" +userid.SelectedValue + "'";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();SqlDataReader da;da = mycmd.ExecuteReader();while (da.Read()){username.Text = da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e){string sqlstr = "";sqlstr = "select coursename from course where courseid='" + txtcourseid.SelectedValue + "'";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();SqlDataReader da;da = mycmd.ExecuteReader();while (da.Read()){coursename.Text = da["coursename"].ToString();}}}四、添加学生程序代码using System;using System.IO;using System.Text;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addstudent : System.Web.UI.Page{SqlCommand mycmd;protected void Page_Load(object sender, EventArgs e){userid.Attributes.Add("onblur", "checkuserid()");string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if (userid.Text.ToString() == "")return;string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sqlstr = "";string sql = "";sqlstr = "insert intostudents(userid,username,sex,minzu,birthday,class,comefrom,beizhu,xuey,zhu any,tel,idc,zhengzmm,zhiw,huoj,weij)values('" + userid.Text + "','" +txtusername.Text + "','" + txtsex.SelectedItem.Value + "','" + txtminzu.Text + "','" + txtbirthday.Text + "','" + txtclass.Text + "','" + txtcomefrom.Text + "','" + txtbeizhu.Text + "','" + txtxuey.SelectedValue + "','" + txtzhuany.SelectedValue + "','" + txttel.Text + "','" + txtidc.Text + "','" + txtzzmm.SelectedValue + "','" + txtzhiw.Text + "','" + txthuoj.Text + "','" + txtweij.Text + "')";conn.Open();mycmd = new SqlCommand(sqlstr, conn);mycmd.Dispose();string name = this.FileUpload1.FileName;//获取上传文件的名称string type = name.Substring(stIndexOf("\\") + 1);//获取上传文件的后缀string ipath = Server.MapPath("images/") +DateTime.Now.ToString("yyyyMMddhhmmss") + name;string wpath = "images\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + name;string query1 = "insert into images(userid,path) values('" + userid.Text + "',@path)";FileUpload1.SaveAs(ipath); //服务器保存路径SqlCommand cm = new SqlCommand(query1);cm.Connection = conn;cm.Parameters.Add("@path", SqlDbType.VarChar, 50);cm.Parameters["@path"].Value = wpath;cm.ExecuteNonQuery();// this.lb_info.Text = "上传成功!";try{mycmd.ExecuteNonQuery();string sqlstr1 = "";sqlstr1 = "insert into users(userid,username)values('" +userid.Text + "','" + txtusername.Text + "') ";SqlCommand mycmd1 = new SqlCommand(sqlstr1, conn); mycmd1.Dispose();try{mycmd1.ExecuteNonQuery();Response.Write("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{sqlstr1 = "";}}catch (SqlException){Response.Write("<script>javascript:alert('添加失败!!!');</script>");}finally{conn.Close();sqlstr = "";}}protected void Button2_Click(object sender, EventArgs e) {userid.Text = "";txtusername.Text = "";txtminzu.Text = "";txtbirthday.Text = "";txtclass.Text = "";txtcomefrom.Text = "";txtbeizhu.Text = "";}protected void Button3_Click(object sender, EventArgs e) {Response.Redirect("student.aspx");}}五、检查课程号唯一性程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class checkcourseid : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){Response.Expires = 0;string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string nam = Request.QueryString["name"].ToString();string sql = "select courseid from course where courseid='" + nam + "'";SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);conn.Open();SqlDataReader dr = DBHelper.ExecuteReader();if (dr.Read()){Response.Write("<b class='Error'>该课程号已经存在,请换一个</b>");}else{Response.Write("<b class='Right'>该课程号可以使用</b>"); }dr.Close();}}六、检查学号唯一性程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class checkuser : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){Response.Expires = 0;string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string nam = Request.QueryString["name"].ToString();string sql = "select userid from students where userid='" + nam + "'";SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);conn.Open();SqlDataReader dr = DBHelper.ExecuteReader();if (dr.Read()){Response.Write("<b class='Error'>该学号已经存在,请换一个</b>");}else{Response.Write("<b class='Right'>该学号可以使用</b>");}dr.Close();}}七、课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class course : System.Web.UI.Page{SqlConnection conn;SqlDataReader getdata;protected void Page_Load(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);SqlDataReader getdata;SqlCommand mycmd;DataSet ds = new DataSet();string sql = "";sql = "select * from course order by courseid";mycmd = new SqlCommand(sql, conn);conn.Open();getdata = mycmd.ExecuteReader();grdMain.DataSource = getdata;grdMain.DataBind();mycmd.Connection.Close();conn.Close();mycmd.Dispose();}protected void Button1_Click(object sender, EventArgs e){DataSet ds;SqlDataReader da;string strsql = "";SqlCommand cmd;conn.Open();strsql = "select * from course where courseid='" + courseid.Text + "'or coursename like '" + coursename.Text + "'";cmd = new SqlCommand(strsql, conn);da = cmd.ExecuteReader();Datagrid1.DataSource = da;Datagrid1.DataBind();conn.Close();cmd.Dispose();cmd.Connection.Close();}}八、编辑、删除学生信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class images_editstudent : System.Web.UI.Page{SqlCommand cmd;SqlCommand cmd2;protected void Page_Load(object sender, EventArgs e){if (!this.IsPostBack){string sql = "";SqlDataReader reader;string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; SqlConnection conn = new SqlConnection(strconn);sql = "select * from students where userid='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()){userid.Text = reader["userId"].ToString();txtusername.Text = reader["username"].ToString();txtsex.SelectedValue = reader["sex"].ToString();txtminzu.Text = reader["minzu"].ToString();txtbirthday.Text = reader["birthday"].ToString();txtclass.Text = reader["class"].ToString();txtcomefrom.Text = reader["comefrom"].ToString();txtxuey.Text = reader["xuey"].ToString();txtzhuany.Text = reader["zhuany"].ToString();txttel.Text = reader["tel"].ToString();txtidc.Text = reader["idc"].ToString();}cmd.Dispose();sql = "";conn.Close();}}protected void Button1_Click(object sender, EventArgs e){string uid="";uid=Page .Request ["id"];string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql="";sql = "update students set userid='" + userid.Text + "',username='" + txtusername.Text + "',minzu='" + txtminzu.Text + "',sex='" +txtsex.SelectedItem.Value + "',birthday='" + txtbirthday.Text + "',class='"+ txtclass.Text + "',comefrom='" + txtcomefrom.Text + "',beizhu='" + txtbeizhu.Text + "',xuey='" + txtxuey.Text + "',zhuany='" + txtzhuany.Text + "',tel='" + txttel.Text + "',idc='" + txtidc.Text + "',zhengzmm='" + txtzzmm.SelectedValue + "'where userid='" + uid + "'";cmd=new SqlCommand (sql,conn );conn.Open();try{cmd.ExecuteNonQuery();Label11.Style["color"] = "blue";Label11.Text = "编辑成功";Response.Write("<script>javascript:alert('编辑成功!!!');</script>");}catch(SqlException ){Label11.Text = "编辑失败";Label11.Style["color"] = "red";}cmd.Dispose();conn.Close();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";string sqlall = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "delete from students where userid='" + uid + "'"; sqlall = "delete from images where userid='" + uid + "'";cmd = new SqlCommand(sql, conn);cmd2 = new SqlCommand(sqlall,conn);conn.Open();try{cmd.ExecuteNonQuery();string sql1 = "";sql1 = "delete from users where userid='" + uid + "'"; SqlCommand cmd1 = new SqlCommand(sql1, conn);cmd1.Dispose();try{cmd1.ExecuteNonQuery();Label11.Style["color"] = "blue";Label11.Text = "删除成功";Response.Write("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){Label11.Text = "删除失败";Response.Write("<script>javascript:alert('删除失败!!!');</script>");}finally{sql1 = "";}}catch(SqlException ){Label11.Text = "删除失败";Label11.Style["color"] = "red";}cmd.Dispose();conn.Close();userid.Text = "";txtusername.Text = "";txtminzu.Text = "";txtbirthday.Text = "";txtclass.Text = "";txtcomefrom.Text = "";txtbeizhu.Text = "";txtxuey.Text = "";txtzhuany.Text = "";txttel.Text = "";txtidc.Text = "";}protected void Button3_Click(object sender, EventArgs e) {Response.Redirect("student.aspx");}}九、编辑、删除课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class editcourse : System.Web.UI.Page{SqlCommand cmd;protected void Page_Load(object sender, EventArgs e){if (!this.IsPostBack){string sql = "";SqlDataReader reader;string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; SqlConnection conn = new SqlConnection(strconn);sql = "select * from course where courseid='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()){courseid.Text = reader["courseid"].ToString();coursename.Text = reader["coursename"].ToString();coursetime.Text = reader["coursetime"].ToString();fen.Text = reader["fen"].ToString();type.Text = reader["type"].ToString();type.Text = reader["teacher"].ToString();}cmd.Dispose();sql = "";conn.Close();}}protected void Button1_Click(object sender, EventArgs e){string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql = "";sql = "update course set courseid='" + courseid.Text + "',coursename='" + coursename.Text + "',coursetime='" + coursetime.Text + "',fen='" + fen.Text + "',type='" + type.Text + "',teacher='" + teacher.Text + "' where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);conn.Open();try{cmd.ExecuteNonQuery();Label7.Text = "编辑成功";Response.Write("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){Label7.Text = "编辑失败";}cmd.Dispose();conn.Close();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; SqlConnection conn = new SqlConnection(strconn);sql = "delete from course where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);conn.Open();try{cmd.ExecuteNonQuery();Label7.Text = "删除成功";Response.Write("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){Label7.Text = "删除失败";}cmd.Dispose();conn.Close();courseid.Text = "";coursename.Text = "";coursetime.Text = "";fen.Text = "";type.Text = "";}protected void Button3_Click(object sender, EventArgs e) {Response.Redirect("course.aspx");}}十、编辑、删除成绩信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class editscore : System.Web.UI.Page{SqlCommand cmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){if (!this.IsPostBack){string sql = "";SqlDataReader reader;string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);sql = "select * from score where id='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);conn.Open();reader = cmd.ExecuteReader();while (reader.Read()){id.Text = reader["id"].ToString();userid.Text = reader["userid"].ToString();username.Text = reader["username"].ToString();txtcourseid.Text = reader["courseid"].ToString();coursename.Text = reader["coursename"].ToString();score.Text = reader["score"].ToString();}cmd.Dispose();sql = "";conn.Close();}}protected void Button1_Click(object sender, EventArgs e){string uid = "";uid = Page.Request["id"];string sql = "";string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);sql = "update score set userid='" + userid.SelectedValue +"',username='" + username.Text + "',courseid='" + txtcourseid.SelectedValue + "',coursename='" + coursename.Text + "',score='" + score.Text + "',[year]='" + txtyear.SelectedValue + "'where id='" + uid + "'";cmd = new SqlCommand(sql,conn );conn.Open();try{cmd.ExecuteNonQuery();Label11.Text = "编辑成功";Response.Write("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){Label11.Text = "编辑失败";}cmd.Dispose();conn.Close();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = Page.Request["id"];string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);sql = "delete from score where id='" + uid + "'";cmd = new SqlCommand(sql, conn);conn.Open();try{cmd.ExecuteNonQuery();Label11.Text = "删除成功";Response.Write("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){Label11.Text = "删除失败";}cmd.Dispose();conn.Close();id.Text = "";username.Text = "";coursename.Text = "";score.Text = "";}protected void Button3_Click(object sender, EventArgs e){Response.Redirect("score.aspx");}protected void userid_SelectedIndexChanged(object sender, EventArgs e) {string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select username from students where userid='" +userid.SelectedValue + "'";conn.Open();cmd = new SqlCommand(sqlstr, conn);cmd.Dispose();SqlDataReader da;da = cmd.ExecuteReader();while (da.Read()){username.Text = da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventA rgs e){string strconn = ConfigurationManager.AppSettings["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select coursename from course where courseid='" + txtcourseid.SelectedValue + "'";conn.Open();cmd = new SqlCommand(sqlstr, conn);cmd.Dispose();SqlDataReader da;da = cmd.ExecuteReader();while (da.Read()){coursename.Text = da["coursename"].ToString();}}}十一、修改密码程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class modify_pwd : System.Web.UI.Page{SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ConfigurationManager.AppSettings["connStr"]; conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){。