学生信息管理系统+代码

合集下载

c语言学生管理系统代码

c语言学生管理系统代码

C语言学生管理系统代码
简介
学生管理系统是一个用于管理学生信息的简单程序,它可以实现添加学生信息、显示学生信息、修改学生信息和删除学生信息等功能。

通过这个系统,学校或机构可以更方便地管理和维护学生的相关数据。

功能
1.添加学生信息:通过输入学生的姓名、学号、年龄和性别等信息,将
学生信息存储在系统中。

每个学生信息包括学号、姓名、年龄和性别等关键信息。

2.显示学生信息:可以显示系统中所有学生的信息,包括学号、姓名、
年龄和性别。

3.修改学生信息:通过输入学生的学号,可以修改该学生的姓名、年龄
和性别等信息。

4.删除学生信息:通过输入学生的学号,可以删除该学生的信息。

实现
下面是一个简单的C语言学生管理系统代码示例:
```c #include <stdio.h> #include <string.h>
#define MAX_STUDENTS 100
// 定义学生结构体 struct Student { int id; char name[100]; int age; char
gender[10]; };
// 定义全局变量,用于存储学生信息和统计学生数量 struct Student
students[MAX_STUDENTS]; int num_students = 0;
// 添加学生 void addStudent() { if (num_students >= MAX_STUDENTS) { printf(。

学生信息管理系统c语言代码

学生信息管理系统c语言代码

#include<stdio.h>#include<stdlib.h>#include<string.h>#define LEN 15#define N 100struct record //定义结构体{char code[LEN];char name[LEN];int age;char sex[3];char time[LEN];char add[30];char tel[LEN];char mail[30];}stu[N];int k=1,n,m; //引用void readfile();void seek();void modify();void insert();void del();void display();void save();void menu();int main(){while(k)menu();system("pause");return 0;}void help(){printf("\n0.欢迎使用系统帮助!\n");printf("\n1.进入系统后,先刷新学生信息,再查询;\n");printf("\n2.按照菜单提示键入数字代号;\n");printf("\n3.增加学生信息后,切记保存按;\n");printf("\n4.谢谢您的使用!\n");}void readfile()//建立信息{char *p="student.txt";FILE *fp;int i=0;if ((fp=fopen("C:\\Users\\86139\\Desktop\\student.txt","r+"))==NULL){printf("Open file %s error! Strike any key to exit!",p);system("pause");//暂停的意思,等待用户信号exit(0);}while(fscanf(fp,"%s %s %d %s %s %s %s %s",stu[i].code,stu[i].name,&stu[i].age,stu[i].sex,stu[i].time,s tu[i].add,stu[i].tel,stu[i].mail)==8){i++;i=i;}fclose(fp);n=i;printf("录入完毕!\n");}void seek() //查找信息{int i,item,flag;char s1[21];printf("------------------\n");printf("-----1.按学号查询-----\n");printf("-----2.按姓名查询-----\n");printf("-----3.退出本菜单-----\n");printf("------------------\n");while(1){printf("请选择子菜单编号:");scanf("%d",&item);flag=0;switch(item){case 1:printf("请输入要查询的学生的学号:\n");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0)//{flag=1;printf("学生学号学生姓名年龄性别出生年月地址电话E-mail\n");printf("--------------------------------------------------------------------\n");printf("%6s %7s %6d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age,stu[i].sex,st u[i].time,stu[i].add,stu[i].tel,stu[i].mail);if(flag==0){printf("该学号不存在!\n");}}break;case 2:printf("请输入要查询的学生的姓名:\n");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].name,s1)==0){flag=1;printf("学生学号学生姓名年龄性别出生年月地址电话E-mail\n");printf("--------------------------------------------------------------------\n");printf("%6s %7s %6d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age,stu[i].sex,st u[i].time,stu[i].add,stu[i].tel,stu[i].mail);}if(flag==0)printf("该姓名不存在!\n"); break;case 3:return;default:printf("请在1-3之间选择\n");}}}void modify() //修改信息{int i,item,num;char sex1[3],s1[LEN],s2[LEN];printf("请输入要要修改的学生的学号:\n");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0){num=i;printf("------------------\n");printf("1.修改姓名\n");printf("2.修改年龄\n");printf("3.修改性别\n");printf("4.修改出生年月\n");printf("5.修改地址\n");printf("6.修改电话号码\n");printf("7.修改E-mail地址\n");printf("8.退出本菜单\n");printf("------------------\n");}while(1){printf("请选择子菜单编号:");scanf("%d",&item);switch(item){case 1:printf("请输入新的姓名:\n");scanf("%s",s2);strcpy(stu[num].name,s2); break;case 2:printf("请输入新的年龄:\n");scanf("%d",&stu[num].age);break;case 3:printf("请输入新的性别:\n");scanf("%s",sex1);strcpy(stu[num].sex,sex1); break;case 4:printf("请输入新的出生年月:\n");scanf("%s",s2);strcpy(stu[num].time,s2); break;case 5:printf("请输入新的地址:\n");scanf("%s",s2);strcpy(stu[num].add,s2); break;case 6:printf("请输入新的电话号码:\n");scanf("%s",s2);strcpy(stu[num].tel,s2); break;case 7:printf("请输入新的E-mail地址:\n");scanf("%s",s2);strcpy(stu[num].mail,s2); break;case 8:return;default:printf("请在1-8之间选择\n");}}}void sort()//排序{int i,j,*p,*q,s;char temp[10];for(i=0;i<n-1;i++){for(j=n-1;j>i;j--)if(strcmp(stu[j-1].code,stu[j].code)>0)//比较学号的大小{strcpy(temp,stu[j-1].code); //交换学号以及以下的信息(冒泡排序)strcpy(stu[j-1].code,stu[j].code);strcpy(stu[j].code,temp);strcpy(temp,stu[j-1].name);strcpy(stu[j-1].name,stu[j].name);strcpy(stu[j].name,temp);strcpy(temp,stu[j-1].sex);strcpy(stu[j-1].sex,stu[j].sex);strcpy(stu[j].sex,temp);strcpy(temp,stu[j-1].time);strcpy(stu[j-1].time,stu[j].time);strcpy(stu[j].time,temp);strcpy(temp,stu[j-1].add);strcpy(stu[j-1].add,stu[j].add);strcpy(stu[j].add,temp);strcpy(temp,stu[j-1].tel);strcpy(stu[j-1].tel,stu[j].tel);strcpy(stu[j].tel,temp);strcpy(temp,stu[j-1].mail);strcpy(stu[j-1].mail,stu[j].mail);strcpy(stu[j].mail,temp);p=&stu[j-1].age;q=&stu[j].age;s=*q;*q=*p;*p=s;}}}void insert()//插入函数{int i=n,j,flag;printf("请输入待增加的学生数:\n");scanf("%d",&m);do{flag=1;while(flag){flag=0;printf("请输入第%d 个学生的学号:\n",i+1);scanf("%s",stu[i].code);for(j=0;j<i;j++)if(strcmp(stu[i].code,stu[j].code)==0){printf("已有该学号,请检查后重新录入!\n");flag=1;break;}}printf("请输入第%d 个学生的姓名:\n",i+1);scanf("%s",stu[i].name);printf("请输入第%d 个学生的年龄:\n",i+1);scanf("%d",&stu[i].age);printf("请输入第%d 个学生的性别:\n",i+1);scanf("%s",stu[i].sex);printf("请输入第%d 个学生的出生年月:(格式:年.月)\n",i+1);scanf("%s",stu[i].time);printf("请输入第%d 个学生的地址:\n",i+1);scanf("%s",stu[i].add);printf("请输入第%d 个学生的电话:\n",i+1);scanf("%s",stu[i].tel);printf("请输入第%d 个学生的E-mail:\n",i+1);scanf("%s",stu[i].mail);if(flag==0){i=i;i++;}}while(i<n+m);n+=m;printf("录入完毕!\n\n");sort();}void del()//删除信息{int i,j,flag=0;char s1[LEN+1];printf("请输入要删除学生的学号:\n");scanf("%s",s1);for(i=0;i<n;i++)if(strcmp(stu[i].code,s1)==0){flag=1;for(j=i;j<n-1;j++)stu[j]=stu[j+1];}if(flag==0)printf("该学号不存在!\n");if(flag==1){printf("删除成功,显示结果请选择菜单\n");n--;}}void display() //浏览信息{int i;printf("所有学生的信息为:\n");printf("学生学号学生姓名年龄性别出生年月地址电话E-mail\n");printf("--------------------------------------------------------------------\n");for(i=0;i<n;i++){printf("%6s %7s %5d %5s %9s %8s %10s %14s\n",stu[i].code,stu[i].name,stu[i].age,stu[i].sex,stu[i].ti me,stu[i].add,stu[i].tel,stu[i].mail);}}void save() // 保存{int i;FILE *fp;fp=fopen("C:\\Users\\86139\\Desktop\\student.txt","a");for(i=0;i<n;i++){fprintf(fp,"%s %s %d %s %s %s %s %s\n",stu[i].code,stu[i].name,stu[i].age,stu[i].sex,stu[i].time,stu[i]. add,stu[i].tel,stu[i].mail);}fclose(fp);}void menu()//菜单{int num;printf(" \n\n 学生信息管理系统\n\n");printf("*********************系统功能菜单************************ \n");printf("友情提示:查询前请先刷新系统!\n");printf(" ---------------------- ---------------------- \n");printf(" ********************************************* \n");printf(" * 0.系统帮助及说明* * 1.刷新学生信息* \n");printf(" ********************************************* \n");printf(" * 2.查询学生信息* * 3.修改学生信息* \n");printf(" ********************************************* \n");printf(" * 4.增加学生信息* * 5.按学号删除信息* \n");printf(" ********************************************* \n");printf(" * 6.显示当前信息* * 7.保存当前学生信息* \n");printf(" ********************** ********************** \n");printf(" * 8.退出系统* \n");printf(" ********************** \n");printf(" ---------------------- ---------------------- \n");printf("请选择菜单编号:");scanf("%d",&num);switch(num){case 0:help();break;case 1:readfile();break;case 2:seek();break;case 3:modify();break;case 4:insert();break;case 5:del();break;case 6:display();break;case 7:save();break;case 8:k=0;break;default:printf("请在0-8之间选择\n");} }。

学生信息管理系统完整源代码+mysql文件

学生信息管理系统完整源代码+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语言简单版

学生管理系统c语言简单版

学生管理系统c语言简单版学生管理系统c语言简单版介绍:学生管理系统是一种用于管理学生信息的软件,它可以方便地对学生的基本信息、课程成绩等进行录入、查询、修改和删除等操作。

本文将介绍如何使用C语言编写一个简单的学生管理系统。

功能:1. 添加学生信息2. 查询学生信息3. 修改学生信息4. 删除学生信息5. 显示所有学生信息实现方法:1. 添加学生信息添加学生信息需要输入以下内容:姓名、性别、年龄、班级和电话号码。

我们可以定义一个结构体来存储这些信息,代码如下:```struct Student {char name[20];char sex[10];int age;char class[20];char phone[20];};```然后定义一个数组来存储多个学生的信息:```struct Student students[100];int count = 0; // 学生数量```接下来,我们可以编写一个函数来添加新的学生信息:```void addStudent() {struct Student student;printf("请输入姓名:");scanf("%s", );printf("请输入性别:");scanf("%s", student.sex);printf("请输入年龄:");scanf("%d", &student.age);printf("请输入班级:");scanf("%s", student.class);printf("请输入电话号码:");scanf("%s", student.phone);students[count++] = student; // 将新的学生信息存储到数组中 printf("添加成功!\n");}```2. 查询学生信息查询学生信息可以按照姓名或电话号码进行查询。

学生信息管理系统源代码

学生信息管理系统源代码

学生信息管理系统源代码import java.io.*;class StuInfo {public String name;public int number;public String sex;public String age;public String bir;public String email;public String addr;public String tel;public String getName() {return name;}public void setName(String name) { = name;}public int getNumber() {return number;}public void setNumber(int number) {this.number = number;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public String getAge() {return age;}public void setAge(String age) {this.age = age;}public String getBir() {return bir;}public void setBir(String bir) {this.bir = bir;}public String getEmail() {return email;}public void setEmail(String email ) { this.email = email;}public String getAddr() {return addr;}public void setAddr(String addr) {this.addr = addr;}public String getTel() {return tel;}public void setTel(String tel) {this.tel = tel;}}public class Student {private static PrintStream out = System.out;private static String filename = "Stu.txt";private static int total = 0;private static int rt = 0;//recyle lengthprivate StuInfo[] stuInfos;private StuInfo[] recycle;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));//创建缓冲流public Student(){stuInfos = new StuInfo[11];}public void 信息录入(){BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));try{System.out.print("\n请输入学生信息(以0结束)\n");System.out.print("学号:\n");StuInfo stu = new StuInfo();stu.setNumber(Integer.parseInt(buf.readLine()));while(stu.getNumber()!=0) {System.out.print("姓名:\n\n");stu.setName(buf.readLine());System.out.print("性别:\n\n");stu.setSex(buf.readLine());System.out.print("年龄:\n\n");stu.setAge (buf.readLine());System.out.print("生日:\n\n");stu.setBir(buf.readLine());System.out.print("邮箱:\n\n");stu.setEmail(buf.readLine());System.out.print("地址:\n\n");stu.setAddr(buf.readLine());System.out.print("电话:\n\n");stu.setTel(buf.readLine());//添加其他输入信息stuInfos[total]=stu;total++;stu = new StuInfo();System.out.print("\n请输入下一个学生信息(以0结束)\n");System.out.print("姓名:\n");stu.setName(buf.readLine());}}catch(Exception e){out.print(e);}}public void 保存数据(){try{FileWriter fwr=new FileWriter(filename);BufferedWriter fw = new BufferedWriter(fwr);fw.write(total+"\r\n");for(int k=0;k<total;k++){//保存学生信息fw.write(stuInfos[k].getNumber()+"\r\n");fw.write(stuInfos[k].getName()+"\r\n");fw.write(stuInfos[k].getSex()+"\r\n");fw.write(stuInfos[k].getAge()+"\r\n");fw.write(stuInfos[k].getBir()+"\r\n");fw.write(stuInfos[k].getEmail()+"\r\n");fw.write(stuInfos[k].getAddr()+"\r\n");fw.write(stuInfos[k].getTel()+"\r\n");}fw.write(rt+"\r\n");for(int k=0;k<rt;k++){//保存回收站信息fw.write(recycle[k].getNumber()+"\r\n");fw.write(recycle[k].getName()+"\r\n");fw.write(recycle[k].getSex()+"\r\n");fw.write(recycle[k].getAge()+"\r\n");fw.write(recycle[k].getBir()+"\r\n");fw.write(recycle[k].getEmail()+"\r\n");fw.write(recycle[k].getAddr()+"\r\n");fw.write(recycle[k].getTel()+"\r\n");}fw.flush();fw.close();fwr.close();System.out.println("\n已保存数据!");}catch(Exception e){out.print(e);}}public void 读取数据(){try{FileReader fr = new FileReader(filename);BufferedReader bfr = new BufferedReader(fr); String buff = bfr.readLine();if(buff != null) {total = Integer.parseInt(buff);}else{total = 0;}StuInfo stu;for(int i=0; i<total;i++) {stu = new StuInfo();stu.setNumber(Integer.parseInt(bfr.readLine())); stu.setName(bfr.readLine());stu.setSex(bfr.readLine());stu.setAge(bfr.readLine());stu.setBir(bfr.readLine());stu.setEmail(bfr.readLine());stu.setAddr(bfr.readLine());stu.setTel(bfr.readLine());stuInfos[i]=stu;}buff = bfr.readLine();if(buff!= null) {rt = Integer.parseInt(buff);}else{rt = 0;}for(int i=0; i<rt;i++) {stu = new StuInfo();stu.setNumber(Integer.parseInt(bfr.readLine()));stu.setName(bfr.readLine());stu.setSex(bfr.readLine());stu.setAge(bfr.readLine());stu.setBir(bfr.readLine());stu.setEmail(bfr.readLine());stu.setAddr(bfr.readLine());stu.setTel(bfr.readLine());//补全recycle[i]=stu;}// bfr.flush();bfr.close();fr.close();System.out.println("读取成功");}catch(Exception e){out.print(e);}}public void 显示学生(StuInfo[] stus,int length){ try{out.println("----------");for(int i=0;i<length;i++){out.println("学号:"+stus[i].getNumber());out.println("姓名:"+stus[i].getName());out.println("性别:"+stus[i].getSex());out.println("年龄:"+stus[i].getAge());out.println("生日:"+stus[i].getBir());out.println("邮箱:"+stus[i].getEmail());out.println("地址:"+stus[i].getAddr());out.println("电话:"+stus[i].getTel());//输出其他内容.....out.println("----------");}System.out.println("请按任意键继续");buf.read();//}catch(Exception e){out.print(e);}}public void 姓名查询(String name){StuInfo[] result = new StuInfo[11];int r = 0;for(int i=0;i<total;i++){if(stuInfos[i].getName().equals(name)){result[r]=stuInfos[i];r++;}}if(r==0){System.out.print("查找不到该学生!");//提示找不到学生return;}else{显示学生(result, r);}}public void 学号查询(String number ){StuInfo[] result = new StuInfo[11];int r = 0;for(int i=0;i<total;i++){if(Integer.toString(stuInfos[i].getNumber()).equals(number)){result[r]=stuInfos[i];r++;//补全}}if(r==0){System.out.print("查找不到该学生!");//提示找不到学生}else{显示学生(result, r);}}public void 查找菜单(){//全字匹配int choice;try{do{System.out.println("查找界面");//System.out.println("1:按姓名查询");System.out.println("2:按学号查询");System.out.println("0:返回上级");BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));choice = Integer.parseInt(buf.readLine());switch(choice){case 1:System.out.println("请输入姓名");//获得输入的姓名String name = buf.readLine();姓名查询(name);break;case 2:System.out.println("请输入学号");String number = buf.readLine();学号查询(number);//获得输入的学号break;default:System.out.println("对不起,出现异常!");//异常:7}}while(choice!=0);}catch(Exception e){out.print(e);}}public boolean 修改学生(int number) {boolean flag = false;try{for(int i=0;i<total;i++){if(stuInfos[i].getNumber()==number) {BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));StuInfo stu = new StuInfo();System.out.print("\n请输入学生信息\n");System.out.print("姓名:\n\n");stu.setName(buf.readLine());System.out.print("性别:\n\n");stu.setSex(buf.readLine());System.out.print("年龄:\n\n");stu.setAge (buf.readLine());System.out.print("生日:\n\n");stu.setBir(buf.readLine());System.out.print("邮箱:\n\n");stu.setEmail(buf.readLine());System.out.print("地址:\n\n");stu.setAddr(buf.readLine());System.out.print("电话:\n\n");stu.setTel(buf.readLine());stu.setNumber(number);stuInfos[i]=stu;System.out.print("修改完成啦!");//提示修改完成break;}}}catch(Exception e){out.print(e);}return flag;}public boolean 删除学生(int number){boolean flag = false;for(int i=0;i<total;i++){if(stuInfos[i].getNumber()==number){if(rt==0){recycle = new StuInfo[101];}recycle[rt]=stuInfos[i];for(;i<total-1;i++){stuInfos[i]=stuInfos[i+1];}total--;flag=true;break;}}return flag;}public void 删除页面(){System.out.print("删除页面");//请输入要删除的学号try{int choice;BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));System.out.println("1:学生信息修改");System.out.println("2:学生信息删除");System.out.println("请输入您的选择(1--2)");//...choice = Integer.parseInt(buf.readLine());switch(choice){case 1:System.out.println("请输入要修改的学号:");choice = Integer.parseInt(buf.readLine());修改学生(choice);break;case 2:System.out.println("请输入要删除的学号:");choice = Integer.parseInt(buf.readLine());删除学生(choice);break;//补充}/*if(删除学生(choice)){System.out.print("删除成功!");//删除成功}else{System.out.print("删除失败!");//删除失败}*/}catch(Exception e){out.print(e);}}public void showMenu() {try{int choice;do{System.out.println("学生管理系统主菜单界面");System.out.println("1:学生信息录入");System.out.println("2:学生信息浏览");System.out.println("3:学生信息查询");System.out.println("4:学生修改与删除");System.out.println("5:学生信息保存");System.out.println("6:学生信息读取");System.out.println("0:退出系统");System.out.println("请输入您的选择(0--6)");BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));choice = Integer.parseInt(buf.readLine());switch(choice){case 1:信息录入();//break;case 2://补全方法调用显示学生(stuInfos, total);break;case 3:查找菜单();break;case 4:删除页面();break;case 5:保存数据();break;case 6:读取数据();break;default:System.out.print("出现异常!"); //异常:7}}while(choice!=0);}catch(Exception e){System.out.println(e);}// TODO 自动生成的方法存根}public static void main(String[] args) {Student student = new Student();student.showMenu();}}. ..。

学生信息管理系统系统源代码

学生信息管理系统系统源代码

学生信息管理系统系统源代码-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII系统源代码一、登录界面代码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 where userid='" + 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 sende r, 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 = ConfigurationManage r.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,zhuany, 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.AppSe ttings["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql = "";sql = "update course set courseid='" + courseid.Text + "',coursename='" + coursename.Text + "',coursetime='" + coursetime.Text + "',fen='" + fen.Te xt + "',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 sen der, 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.U I.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();trycmd.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, EventArgs 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){string sql="";SqlCommand cmd;string uid;string pwd;uid = Session["userid"].ToString ();pwd = Session["userpwd"].ToString();if (txtpassword.Text == ""){Label4.Text = "原密码不能为空";}else if (password.Text == ""){Label4.Text = "新密码不能为空";}else if (password.Text != password1.Text){Label4.Text = "新密码和确认密码不一致";}else if (txtpassword.Text != pwd){Label4.Text = "原密码不正确";}。

Python编写的学生信息管理系统

Python编写的学生信息管理系统

import timedef addStu(): #添加学生信息print('请输入学生信息')xinxi=['编号:','姓名:','性别:','年龄:','电话:'] stu=[]for i in xinxi:x=input(i)stu.append(x)fa.seek(0,2)fa.write(','.join(stu)+'\n')print('添加学生\'{}\'的信息成功'.format(stu[1]))def readStu(): #显示学生信息fa.seek(0)stu=[]print('编号\t姓名\t性别\t年龄\t电话')for line in fa:stu.append(line.strip('\n').split(','))for i in stu:for j in i:print('{:<4}'.format(j),end='\t')print('')def updateStu(): #修改学生信息num=input('请输入学生编号:')stuOld=[]stu=[]stuNew=[]fa.seek(0)jishu=0for line in fa:stuOld=line.strip('\n').split(',')if stuOld[0]==num:jishu=1print('编号\t姓名\t性别\t年龄\t电话')for row in stuOld:print(row,end='\t')print()while True:print('''请选择要修改的信息1.姓名2.性别3.年龄4.电话0.返回上层菜单''')s=input("请输入你的选择:")if s=='1':xm=input("请输入姓名:")stuOld[1]=xmprint('修改成功')breakelif s=='2':xb=input("请输入性别:")stuOld[2]=xbprint('修改成功')breakelif s=='3':nl=input("请输入年龄:")stuOld[3]=nlprint('修改成功')breakelif s=='4':dh=input("请输入电话:")stuOld[4]=dlprint('修改成功')breakelif s=='0':jishu=2print("12345")breakelse:print("请重新选择")stu.append(stuOld)stuNew=stuOldelse:stu.append(stuOld)fa.close()if jishu==1:fb=open('学生信息表.csv','w')stu.sort()for row in stu:fb.write(','.join(row)+'\n')print('编号\t姓名\t性别\t年龄\t电话')for i in stuNew:print(i,end='\t')print('\n')fb.close()elif jishu==2:passelse:print("没有找到学生信息")def findStu(): #查找学生信息num=input('请输入学生编号:')fa.seek(0)jishu=0for line in fa:stu=line.strip('\n').split(',')if stu[0]==num:jishu+=1print('编号\t姓名\t性别\t年龄\t电话')for i in stu:print(i,end='\t')print()if jishu==0:print("没有找到学生信息,请重新输入")time.sleep(1)findStu()def delStu(): #删除学生信息num=input('请输入学生编号:')stuNew=[]stuOld=[]fa.seek(0)for line in fa:stuOld=line.strip('\n').split(',')if stuOld[0]!=num:stuNew.append(line.strip('\n').split(','))else:print('编号\t姓名\t性别\t年龄\t电话')for i in stuOld:print(i,end='\t')x=input("\n确定要删除这个学生信息吗?(是/否)")if x=='是':print('删除成功!')continueelse:print('未进行任何操作!')stuNew.append(line.strip('\n').split(',')) fb=open('学生信息表.csv','w')for row in stuNew:fb.write(','.join(row)+'\n')fb.close()def sortStu(): #排序fa.seek(0)stu=[]x=1for line in fa:stu.append(line.strip('\n').split(','))stu.sort()fb=open('学生信息表.csv','w')for row in stu:fb.write(','.join(row)+'\n')fb.close()print('排序完成!')def controlStu(): #控制x=input()if x=='1':addStu()elif x=='2':findStu()elif x=='3':updateStu()elif x=='4':delStu()elif x=='5':readStu()elif x=='6':sortStu()elif x=='0':quit()else:print("输入错误,请重新选择")while True:try:fa=open('学生信息表.txt','r+')print('''------欢迎登录学生信息管理系统------ ------------------------------------请选择你要执行的功能:1.添加学生信息2.查找学生信息3.更新学生信息4.删除学生信息5.显示学生信息6.排序学生信息0.退出系统''')controlStu() finally:fa.close()。

Jsp学生信息管理系统登录验证全代码

Jsp学生信息管理系统登录验证全代码

1.jsp登录界面 Login.jspNo.:00000000000000587 <%@page language="java"contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><html><head><meta http-equiv="Content-Type"content="text/html;charset=UTF-8"><title>用户登录界面</title></head><form action="LoginServlet"method="post"><body bgcolor="blue"><marquee direction="right"onmouseover="stop()"onmouseout="start()"style="font-family: 楷体_GB2312"><p><font size="10px"color="red">学生信息信息管理系统</font></p></marquee><table align=center width="237"><tr><td><table width=100%><tr><td colspan=6><font size=2><div id="b2bContent"style="FILTER: revealTrans(Duration = 1, Transition =</font></td></tr><tr><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt0"onclick="javascript:showPage(0);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">1</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt1"onclick="javascript:showPage(1);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">2</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt2"onclick="javascript:showPage(2);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">3</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt3"onclick="javascript:showPage(3);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">4</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt4"onclick="javascript:showPage(4);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">5</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt5"onclick="javascript:showPage(5);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">6</div></font></td></tr></table><script language="javascript">b2bStr = new Array();b2bStr[0]= "<div style='float:left; width:100%;overflow:hidden;'><a href=1.gif target=_blank><img src=1.gif width=214px height=145px border=0></a><br><a target=_blank title=太阳岛公园一角 href=1.gif>太阳岛公园一角</a></div>";width:100%;overflow:hidden;'><a href=2.gif target=_blank><img src=2.gif width=214px height=145px border=0></a><br><a target=_blank title=太阳岛公园湖光山色 href=2.gif>太阳岛公园湖光山色</a></div>";b2bStr[2] = "<div style='float:left; width:100%;overflow:hidden;'><a href=3.gif target=_blank><img src=3.gif width=214px height=145px border=0></a><br><a target=_blank title=哈尔滨雪雕 href=3.gif>哈尔滨雪雕</a></div>";b2bStr[3] = "<div style='float:left; width:100%;overflow:hidden;'><a href=4.gif target=_blank><img src=4.gif width=214px height=145px border=0></a><br><a target=_blank title=镜泊湖 href=4.gif>镜泊湖</a></div>";b2bStr[4] = "<div style='float:left; width:100%;overflow:hidden;'><a href=5.gif target=_blank><img src=5.gif width=214px height=145px border=0></a><br><a target=_blank title=太阳岛公园瀑布 href=5.gif>太阳岛公园瀑布</a></div>";b2bStr[5] = "<div style='float:left; width:100%;overflow:hidden;'><a href=6.gif target=_blank><img src=6.gif width=214px height=145px border=0></a><br><a target=_blank title=镜泊湖夜色 href=6.gif>镜泊湖夜色</a></div>";var page=0;var speed=3000;function showPage(id){setTransition();b2bContent.innerHTML=b2bStr[id];b2bContent.filters.revealTrans.play();}function turnPage(){showPage(page);theTimer=setTimeout("turnPage()", speed);checkBt();page++;if(page>=6) page=0;}function checkBt(){for(var i=0;i<6;i++){btObj=eval('bt'+i);if(page==i){btObj.style.color='#FFFFFF';btObj.style.backgroundCol or='#FF781C';}else{btObj.style.color='#000000';btObj.style.backgroundColor='#F7 F7F7';}}}function setTransition(){b2bContent.filters.revealTrans.Transition=Math.round(Math.random( )*23);b2bContent.filters.revealTrans.apply();}turnPage();</script></TD></TR></table><hr color="green"width="540"><table align="center"><tr><td>用户名:<input type="text"name="username"size="8" maxlength="6"></td></tr><tr><td>密&nbsp;&nbsp;&nbsp;&nbsp;码:<input type="password" name="password"size="10"maxlength="6"></td></tr><tr><td><input type="submit"value="登录">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"value="取消"></td></table></form></body></html>2.java代码(1)User.Java 定义的属性和数据库中的字段相对应package com.softeem.dt;public class User {private int id;private String username;private String password;private String xh;private String college;public int getId(){return id;}public void setId(int id){this.id = id;}public String getUsername() {return username;}ername = username;}public String getPassword() {return password;}public void setPassword(String password) { this.password = password;}public String getXh() {return xh;}public void setXh(String xh) {this.xh = xh;}public String getCollege() {return college;}public void setCollege(String college) { this.college = college;}}(2)UserDAO.java 操作数据库tb_user,验证用户登录package com.softeem.dao;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import com.softeem.db.DBManager;import er;public class UserDAO {/***验证用户登录*@return*/public boolean checkDenglu(User user) {boolean flag = false;// 获得数据库连接Connection conn = DBManager.getConnection();// 用select * from查询数据库中的所有字段String sql = "select count(*) from tb_user where username=? and password=?";try {PreparedStatement pst = conn.prepareStatement(sql);pst.setString(1, user.getUsername());pst.setString(2, user.getPassword());ResultSet rs = pst.executeQuery();while (rs.next()) {int count = rs.getInt(1);//用count和0比较,若大于0表示该用户存在,否则不存在if(count > 0){flag = true;}}} catch (SQLException e) {e.printStackTrace();}return flag;}}3.LoginServlet,点击登录跳转到服务器端package com.softeem.servlet;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import er;/*** Servlet implementation class LoginServlet*/public class LoginServlet extends HttpServlet {private static final long serialVersionUID = 1L;/*** @see HttpServlet#HttpServlet()*/public LoginServlet() {super();}/*** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.doGet(request, response);}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //获取表单数据//处理乱码request.setCharacterEncoding("utf-8");String username = request.getParameter("username");String password = request.getParameter("password");//封装到user对象中User user = new User();user.setUsername(username);user.setPassword(password);//调用dao的checkLogin方法UserDAO dao = new UserDAO();boolean flag = dao.checkLogin(user);String message = null;String path = null;if(flag){message = "登录成功";path="success.jsp";request.getSession().setAttribute("user", user);}else{message ="对不起密码错误,请重新输入!";path="fail.jsp";}//response返回messageresponse.setCharacterEncoding("utf-8");response.getWriter().write(message);*///属于服务器跳转,浏览器地址栏没有发生改变request.getRequestDispatcher(path).forward(request,response);}}青年人首先要树雄心,立大志,其次就要决心作一个有用的人才。

HTML学生信息管理系统+代码

HTML学生信息管理系统+代码

HTML学生信息管理系统+代码系统设计表单表单包含了一系列输入字段,用于添加或编辑学生信息。

以下是表单的字段:- 姓名- 年龄- 性别- 学号- 专业学生信息展示区域学生信息展示区域用于展示添加或编辑后的学生信息。

该区域通过一个表格来展示学生列表。

CSS 样式系统的CSS 样式用于美化界面,使其更加易于使用和吸引人。

JavaScript 代码系统的 JavaScript 代码用于处理用户的输入,并根据用户操作来更新学生信息展示区域。

以下是系统的主要 JavaScript 函数:- `addStudentInfo()`: 用于添加新的学生信息到学生列表中;- `editStudentInfo()`: 用于编辑学生信息;- `deleteStudentInfo()`: 用于删除学生信息;- `displayStudentInfo()`: 用于展示学生信息;系统实现系统的实现步骤如下:2. 使用 CSS 样式美化界面;3. 在 JavaScript 中定义相应的函数,并使用 DOM 操作来处理用户的输入;5. 运行网页,测试系统的功能。

代码示例以下是一个代码示例,展示如何实现系统的功能。

<head><title>学生信息管理系统</title><style>/* CSS 样式 *//* ... */</style><script>// JavaScript 代码function addStudentInfo() {// 实现添加学生信息的逻辑}function editStudentInfo() {// 实现编辑学生信息的逻辑}function deleteStudentInfo() {// 实现删除学生信息的逻辑}function displayStudentInfo() {// 实现展示学生信息的逻辑}</script></head><body><h1>学生信息管理系统</h1><form><!-- 表单字段 --><!-- ... --><button onclick="addStudentInfo()">添加</button><button onclick="editStudentInfo()">编辑</button><button onclick="deleteStudentInfo()">删除</button></form><div id="studentList"><!-- 学生信息展示区域 --><!-- ... --></div></body>总结通过上述的设计和实现,我们成功地创建了一个简单的学生信息管理系统。

c语言--学生信息管理系统代码

c语言--学生信息管理系统代码

#include <stdio.h>#include <stdlib.h>#include <string.h>#define FUNC_NEW 1 /* 建立新的班级学生数据*/#define FUNC_SA VE 2 /*把数据写入文件并保存*/#define FUNC_OPEN 3 /*打开文件并从里读入数据*/#define FUNC_INSERT 4 /*插入一个学生的信息*/#define FUNC_SEARCH 5 /*查找学生的信息*/#define FUNC_CHANGE 6 /*修改学生的信息*/#define FUNC_DELETE 7 /*删除学生的信息*/#define FUNC_DISPLAY 8 /*展示学生的信息*/#define FUNC_CENSUS 9 /*分段统计学生总分人数并打印*/ #define FUNG_EXIT 10/*结束程序*/#define FUNC_CLOSE 10#define MAX_NUM 45#define MAX_NAME_STRLEN 30void DoSave();void DoOpen();void DoNew();void DoInsert();void DoDisplay();void DoDelete();void DoSearch();void DoChange();void Docensus();void DoExit();//用户定义的类型声明struct _student{int id;char name[MAX_NAME_STRLEN];int Math;int English;int Chinese;int Physics;int Chemistry;float averScore;int sum;};typedef struct _student STUD;struct _studTb{STUD stud[MAX_NUM];int length;};//全局变量的定义struct _studTb si;char strClassId[15];int main(){int iUserSelect;int MainMenu();system("color 20");for(;;){iUserSelect = MainMenu();if(FUNC_CLOSE == iUserSelect)break;switch(iUserSelect){case FUNC_NEW:DoNew();break;case FUNC_OPEN:DoSave();break;case FUNC_SA VE:DoOpen();break;case FUNC_INSERT:DoInsert();break;case FUNC_SEARCH:DoSearch();break;case FUNC_CHANGE:DoChange();break;case FUNC_DELETE:DoDelete();break;case FUNC_DISPLAY:DoDisplay();break;case FUNC_CENSUS:Docensus();break;case FUNC_CLOSE :DoExit();break;default:break;}}}int MainMenu(){int iUserSelect;system("cls");printf(" --------------------------------------------------------------------- \n");printf(" | ***********欢迎来到学生管理系统********** |\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(" | ****** 9> 分段统计学生信息****** | \n");printf(" | ****** 10> 退出学生系统****** | \n");printf(" | *****Please select a function id(1..9) to execute:***** | \n");printf(" --------------------------------------------------------------------- \n");scanf("%d",&iUserSelect);if(iUserSelect<1&&iUserSelect>9)printf("请正确输入指令\n");elsereturn iUserSelect;}void DoNew(){int number,i;system("cls");printf("\t\tFUNCION: 新建一个班级:\n");printf("\t\t请输入班级序号(string):");scanf("%s",strClassId);printf("\t\t请输入这个班有多少人:");scanf("%d",&number);for (i = 0; i < number; i++){printf("\t\t请输入学生学号:");scanf("%d",&si.stud[i].id);printf("\t\t请输入学生姓名:");scanf("%s",si.stud[i].name);printf("\t\t请输入学生成绩:\n");printf("\t\tMath English Chinese Physics Chemistry\n");scanf("%4d %4d %4d %4d %4d",\& si.stud[i].Math,& si.stud[i].English,& si.stud[i].Chinese,& si.stud[i].Physics,& si.stud[i].Chemistry);}si.length = number;}//保存学生信息void DoSave(){FILE *fp;int i;system("cls");if((fp=fopen("stu-list.txt","wb"))==NULL){printf("打开文件失败\n");return;}for(i=0;i<si.length;i++){if(fwrite(&si.stud[i],sizeof(si),1,fp)==1)printf("保存成功\n");}fclose(fp);}//开文件读取学生信息void DoOpen(){FILE *fp;int i=0;system("cls");if((fp=fopen("stu-list.txt","ab+"))==NULL){printf("打开文件失败\n");return;}while(!feof(fp)){if(fread(&si.stud[i],sizeof(si),1,fp)==1)i++;}fclose(fp);for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 数学:%d 英语:%d 语文:%d 物理:%d 化学:%d\n",si.stud[i].id,si.stud[i].name,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}//插入学生信息void DoInsert(){FILE *fp;int j,INid,sid;int m=0,i=0,k=0;system("cls");if((fp=fopen("stu-list.txt","ab+"))==NULL){ printf("\t文件打开失败!");getchar();return;}while(!feof(fp)){if(fread(&si.stud[i],sizeof(si),1,fp)==1)m++;i++;}/*if(m==0){printf("没有学生记录!");fclose(fp);return;}*/printf("\t请输入要插入信息在那个学号之后:\n");scanf("%d",&INid);for(i=0;i<m;i++)if(INid==si.stud[i].id)break;for(j=m-1;j>i;j--)si.stud[j+1]=si.stud[j];stare1:printf("\t请输入要插入的学生的信息:\n");printf("\t请输入要插入的学号");scanf("%d",&sid);while(k<m){if(si.stud[k].id==sid){printf("\t 该学号已经存在,不允许重复插入!\n");goto stare1;}k++;}si.stud[i+1].id=sid;printf("\t请输入你想输入的姓名");scanf("%s",si.stud[i+1].name);printf(" Math English Chinese Physics Chemistry\n");scanf("%d %d %d %d %d",& si.stud[i+1].Math,& si.stud[i+1].English,& si.stud[i+1].Chinese,& si.stud[i+1].Physics,& si.stud[i+1].Chemistry);si.length=si.length+1;DoSave();}//在文件中查找学生信息,支持姓名学号查找void DoSearch(){int i=0,choice,Sid;char sname[MAX_NAME_STRLEN];int flag=0;system("cls");DoOpen();printf("\n1按姓名查找:\n2按学号查找:");scanf("%d",&choice);switch(choice){case 1: printf("请你输入要查找的姓名");scanf("%s",sname);while(i<si.length){if(strcmp(si.stud[i].name,sname)==0){flag=1;printf("学号:%d 姓名:%s 数学成绩:%d 英语成绩:%d 语文成绩:%d 物理成绩:%d 化学成绩:%d\n",si.stud[i].id,si.stud[i].name ,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}i++;}if(flag==0)printf("你输入的姓名不存在,请确认后再输入");break;case 2: printf("请你输入要查找的学号");scanf("%d",&Sid);while(i<si.length){if(Sid==si.stud[i].id){flag=1;printf("学号:%d 姓名:%s 数学成绩:%d 英语成绩:%d 语文成绩:%d 物理成绩:%d 化学成绩:%d\n",si.stud[i].id,si.stud[i].name ,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}i++;}if(flag==0)printf("你输入的学号不存在,请确认后再输入");break;}printf(" Please input a number to continue!");scanf("%d",&i);return;}//对学生信息进行修改void DoChange(){int choice1;int i=0;int onum;char choice2;system("cls");DoOpen();printf("你想对那个学生进行操作,请输入学号\n");scanf("%d",&onum);while(onum!=si.stud[i].id)i++;if(onum==si.stud[i].id){printf("\n你要修改哪一项");printf("1学号\n2姓名\n3数学成绩\n4英语成绩\n5语文成绩\n6物理成绩\n7化学成绩");printf("请选择");scanf("%d",&choice1);switch(choice1){case 1: printf("\n请输入修改后的学号");scanf("%d",&si.stud[i].id);break;case 2: printf("\n输入你要修改的姓名");scanf("%s",&si.stud[i].name);break;case 3: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Math);break;case 4: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].English);break;case 5: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Chinese);break;case 6: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Physics);break;case 7: printf("\n请输入要修改的成绩");scanf("%d",&si.stud[i].Chemistry);break; }}elseprintf("没有该同学信息");printf(" Please input a number(0..9) to continue!");scanf("%d",&i);}//删除学生信息void DoDelete(){int i,id;char fname[MAX_NAME_STRLEN];system("cls");DoOpen();printf("请输入学生学号");scanf("%d",&id);i=0;while(si.stud[i].id!=id)i++;if(si.stud[i].id==id){while(i<si.length-1){si.stud[i]=si.stud[i+1];i++;}si.length=si.length-1;for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 数学:%d 英语:%d 语文:%d 物理:%d 化学:%d \n",si.stud[i].id,si.stud[i].name,si.stud[i].Math,si.stud[i].English,si.stud[i].Chinese,si.stud[i].Physics,si.stud[i].Chemistry);}elseprintf("没有该同学信息");printf(" Please input a number(0..9) to continue!");scanf("%d",&i);}//展示学生信息void DoDisplay(){struct _studTb m;int i,j,n;system("cls");DoOpen();printf("请选择\n1.数学排名2.英语排名3.语文排名 4.物理排名 5.化学排名 6.学生总分并排序7.学生平均分并排序\n");scanf("%d",&n);if(n==1){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j-1;i++)if(si.stud[i].Math<si.stud[i+1].Math){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 数学成绩排名:%d\n", si.stud[i].id, si.stud[i].name ,si.stud[i].Math);}else if(n==2){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].English<si.stud[i+1].English){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 英语成绩排名:%d\n", si.stud[i].id, si.stud[i].name ,si.stud[i].English);}else if(n==3){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].Chinese<si.stud[i+1].Chinese){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 语文成绩排名:%d\n", si.stud[i].id, si.stud[i].name, si.stud[i].Chinese);}else if(n==4){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].Physics<si.stud[i+1].Physics){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s OS成绩排名:%d\n", si.stud[i].id, si.stud[i].name, si.stud[i].Physics);}else if(n==5){for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].Chemistry<si.stud[i+1].Chemistry){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s C语言成绩排名:%d\n", si.stud[i].id, si.stud[i].name,si.stud[i].Chemistry);}else if(n==6){for(i=0;i<si.length;i++)si.stud[i].sum=si.stud[i].Math+si.stud[i].English+si.stud[i].Chinese+si.stud[i].Physics+si.stud [i].Chemistry;for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].sum<si.stud[i+1].sum){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 总分成绩排名:%f\n", si.stud[i].id, si.stud[i].name, si.stud[i].sum);}else if(n==7){for(i=0;i<si.length;i++){si.stud[i].sum=si.stud[i].Math+si.stud[i].English+si.stud[i].Chinese+si.stud[i].Physics+si.stud [i].Chemistry;si.stud[i].averScore=(float)si.stud[i].sum/si.length;}for(j=0;j<si.length-1;j++){for(i=0;i<si.length-j;i++)if(si.stud[i].averScore<si.stud[i+1].averScore){m.stud[1]=si.stud[i];si.stud[i]=si.stud[i+1];si.stud[i+1]=m.stud[1];}}for(i=0;i<si.length;i++)printf("学号:%d 姓名:%s 平均成绩排名:%f\n", si.stud[i].id, si.stud[i].name, si.stud[i].averScore);}printf(" Please input a number(0..9) to continue!");scanf("%d",&i);}//统计学生信息void Docensus(){struct _studTb sen;int mark;int sum=0;int i=0;system("cls");DoOpen();printf("请输入要统计多少分以上的学生信息");scanf("%d",&mark);while(i<si.length){ if(si.stud[i].Math>mark){sen.stud[sum]=si.stud[i];sum++;}i++;}printf("一共有:%d人\n",sum);for(i=0;i<sum;i++)printf("他的学号%4d姓名%s数学成绩%4d英语成绩%4d 语文成绩%4d 物理成绩%4d 化学成绩%4d\n ",sen.stud[i].id,sen.stud[i].name,sen.stud[i].Math,sen.stud[i].English,sen.stud[i].Chinese,sen.stud[i].Physics,sen.stud[i].Chemistry);printf(" Please input a number(0..9) to continue:");scanf("%d",&i);}void DoExit(){printf("\t\t 谢谢使用!\n");printf("\t\t");system("pause");exit(0);}。

学生信息管理系统源代码

学生信息管理系统源代码

#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("输入错误!请重新输入。

[工学]学生信息管理系统完整源码

[工学]学生信息管理系统完整源码

学生信息管理系统完整源代码注:本系统采用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语言编写学生管理系统的代码

C语言编写学生管理系统的代码

#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>#include<conio.h>struct student{char number[21];char name[21];int age;char sex[3];char birthday[8];}studentArray[100];typedef struct student student;student studentArray[100];char putout[5][12]={"学号","姓名","年龄","性别","出生年月"}; //为格式化输出做准备int count=0;//函数声明部分void explain();void readfile();void searchStudent();void modifyStudent();void addStudent();void delStudent();void printAllstudent();void save();void quit();void initial();void initial(){FILE *fp;char choice='y';int i=0;fp=fopen("e:\\students.txt","r");if(!fp){printf("创建文件失败,即将返回\n");return ;}for(;fread(&studentArray[i],sizeof(struct student),1,fp)!=0;i++);count=i;}//0、说明模块void explain(){printf("\n 很高兴能为您服务\n");printf("\n1.进入本系统,请先刷新学生信息,再查训\n");printf("\n2.您可以根据自己需要的信息键入菜单上的编号\n");printf("\n3.修改学生信息后记得退出前保存信息,以免信息流失\n");printf("\n4.在各个子菜单里按提示操作\n");printf("\n5.谢谢您的使用及支持\n");}//1、刷新模块void readfile(){char *p="students.txt";FILE *fp;int i=0;if((fp=fopen("students.txt","r"))==NULL){printf("打开文件%s出错!请按按任意键返回",p);system("pause");{i++;i=i;}fclose(fp);printf("刷新完毕。

简单学生管理信息系统源代码

简单学生管理信息系统源代码

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。

学籍信息管理系统完整代码

学籍信息管理系统完整代码
string no = Console.ReadLine().Trim();
for (int i = 0; i < lstStudent.Count; i++)
{
if (lstStudent.Count == 0)
{
Console.WriteLine("系统还未添加任何学生信息");
Console.WriteLine("删除成功");
break;
}
if (lstStudent[i].stuNo == no)
{
lstStudent.Remove(lstStudent[i]);
string no = Console.ReadLine().Trim();
for (int i = 0; i < lstStudent.Count; i++)
{
Console.WriteLine("添加成功");
break;
}
case ConsoleKey.D:
lstStudent[i] = item;
Consபைடு நூலகம்le.WriteLine("修改成功!");
break;
Console.Write("学号:");
stu.stuNo = Console.ReadLine().Trim();
Console.Write("姓名:");
{
if (lstStudent.Count == 0)
{
Console.WriteLine("系统还未添加任何学生信息");

学生管理系统 C语言代码

学生管理系统 C语言代码

#include"stdio.h"#include"stdlib.h"#include"string.h"struct stu_info1{char num[13];//学号char name[10];//姓名char sex[5];//性别char cls[20];//班级}stu1[6];struct stu_info2{char counum[6];//课程号char counam[20];//课程名称int credit;//学分}stu2[6];struct stu_info3{char num[13];//学号char counum[6];//课程号float results;//分数}stu3[12];struct stu_info4{char num[13];//学号char counum[6];//课程号float results;//分数}stu4[12];int n=11;void main(){void gengxin();void input1();void input2();void input3();void output();void xianshi();void chaxun();void printf1();void printf2();input1();input2();output();int i;loop: ;printf("*************欢迎使用分数查询系统*************\n");printf("** 请选择**\n");printf("** 1.录入2.删除无用信息(管理员功能) **\n");printf("** 3.显示4.查询(学生功能) **\n");printf("** 5.显示学生信息6.显示课程信息**\n");printf("** 7.退出**\n");printf("**********************************************\n");scanf("%d",&i);switch(i){case 1: input3();break;case 2:gengxin();break;case 3:xianshi();goto loop;case 4: chaxun();goto loop;case 5: printf1();goto loop;case 6: printf2();goto loop;case 7:break;default:printf("error");break;}}void input1()//录入结构体stu1[]{int i;FILE *fp;if((fp=fopen("A.txt","r"))==NULL){printf("can not open file\n");exit(0);}/* printf(" 学号姓名性别班级\n");*/for(i=0;i<=5;i++){fscanf(fp,"%s%s%s%s",&stu1[i].num,&stu1[i].name,&stu1[i].sex,&stu1[i].cls);/*printf("%-13s %-10s %-5s %-20s\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i] .cls);*/}fclose(fp);}void input2()//录入结构体stu2[]{int i;FILE *fp;if((fp=fopen("B.txt","r"))==NULL){printf("can not open file\n");exit(0);}for(i=0;i<=5;i++){fscanf(fp,"%s%s%d",&stu2[i].counum,&stu2[i].counam,&stu2[i].credit);}fclose(fp);}void input3()//录入成绩{FILE *fp;fp=fopen("C.txt","w");int a,i,j,k;float cetss;char number[13],cnum[6],mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){printf("请输入要录入学生成绩的个数\n");scanf("%d",&a);for(i=1;i<=a;i++){printf("请输入要录入的第%d同学的学号:",i);scanf("%s",number);printf("请输入要录入的第%d同学的课程号:",i);scanf("%s",cnum);for(j=0;j<=5;j++)//学号{if((strcmp(number,stu1[j].num)==0))break;}if(j<=5){for(k=0;k<=5;k++)//课程号{if(strcmp(cnum,stu2[k].counum)==0){printf("请输入要录入同学的成绩:");scanf("%f",&cetss);fprintf(fp,"%s %s %f\n",number,cnum,cetss);break;}}}if(j>5||k>5){printf("Error,please input again");i=i-1;}printf("录入成功\n");}}else{printf("密码错误\n");}}void output()// 录入结构体stu3[]{int i;FILE *fp=fopen("C.txt","r");for(i=0;i<n;i++){fscanf(fp,"%s%s%f",&stu3[i].num,&stu3[i].counum,&stu3[i].results);/*printf("%s%s%f\n",stu3[i].num,stu3[i].counum,stu3[i].results);*/ }fclose(fp);}void xianshi()// 显示成绩{int i,j;for(i=0;i<n;i++){for(j=0;j<6;j++){if((strcmp(stu3[i].num,stu1[j].num))==0)printf("%s\t",stu1[j].name);}for(j=0;j<6;j++){if(strcmp(stu3[i].counum,stu2[j].counum)==0)printf("%s\t",stu2[j].counam);}printf("%3.1f\n",stu3[i].results);}}void chaxun()//查询功能{char number[13],c;int i,j,k,a,b,d;while((c=getchar())!='Q'){a=0,b=0;//a记录学分b记录学科printf("请输入要查询同学的学号\n");scanf("%s",number);for(i=0;i<n;i++){if(strcmp(number,stu3[i].num)==0){printf("学号:%s\t",stu3[i].num);for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){printf("姓名:%s\n",stu1[j].name);}}break;}}d=i;for(i=0;i<n;i++)if(strcmp(number,stu3[i].num)==0){b=b+1;for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<6;k++){if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;}break;}}if(stu3[i].results>=60){a=a+stu2[k].credit;printf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,stu2[k].credit);}elseprintf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,0);}if(d<n){printf("共修%d科\t\t实得总学分:%d\n",b,a);}else{printf("学号输入错误\n");}getchar();printf("退出请按Q+回车,继续查询请按回车键");}}void gengxin()//更新信息,删除C.txt中无用信息{FILE *fp;int i,j,k;char mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){fp=fopen("C.txt","w");for(i=0;i<n;i++){for(j=0;j<6;j++)if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<=5;k++)if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;if(k<=5){fprintf(fp,"%s %s %f\n",stu3[i].num,stu3[i].counum,stu3[i].results);}}}printf("更新C.txt成功\n");fclose(fp);}else{printf("密码错误\n");}}void printf1()//显示学生信息{int i;printf(" 学号姓名性别班级\n");for(i=0;i<=5;i++){printf("%-13s%-10s%-5s %-20s\n\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i].cls);}}void printf2()//显示课程信息{int i;printf(" 课程编号课程名称学分\n");for(i=0;i<=5;i++){printf("%-6s%-20s %-4d\n\n",stu2[i].counum,stu2[i].counam,stu2[i].credit);}}。

学生信息管理系统java课程设计代码

学生信息管理系统java课程设计代码

学生信息管理系统java课程设计代码学生信息管理系统Java课程设计代码一、引言学生信息管理系统是一种方便、高效的信息管理工具,可以帮助学校或教育机构管理学生的个人信息、学籍信息等。

本文将介绍一个基于Java语言的学生信息管理系统的设计代码。

二、系统设计1. 需求分析学生信息管理系统需要满足以下需求:- 学生信息的录入、修改和删除- 学生信息的查询和显示- 学生成绩的录入、修改和查询- 学生课表的查询和显示- 学生考勤情况的记录和查询2. 数据库设计系统需要设计学生信息、学生成绩、课程表和考勤情况等相关数据库表。

每个表需要定义相应的字段,如学生姓名、学号、性别、年龄等。

3. 界面设计系统需要设计用户友好的界面,方便用户进行操作。

可以使用JavaSwing等图形界面库进行开发,界面要清晰、美观,并提供相应的按钮和输入框供用户使用。

4. 功能实现系统的功能实现需要编写相应的Java代码。

可以使用面向对象的编程思想,将学生、成绩、课程表和考勤等信息封装成对象,通过调用对象的方法来完成相应的操作。

5. 数据库连接系统需要与数据库进行连接,使用Java JDBC等技术来实现数据库的增删改查操作。

可以使用MySQL等关系型数据库管理系统。

6. 用户权限管理系统可以设计管理员和普通用户两种角色,管理员具有录入、修改和删除学生信息的权限,普通用户只能查询和显示学生信息。

三、代码实现以下是一个简单的学生信息管理系统的Java代码示例:```javaimport java.sql.*;import javax.swing.*;public class StudentManagementSystem {// 数据库连接信息private static final String URL = "jdbc:mysql://localhost:3306/student_db";private static final String USERNAME = "root";private static final String PASSWORD = "123456";public static void main(String[] args) {// 连接数据库Connection conn = null;try {conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);} catch (SQLException e) {e.printStackTrace();JOptionPane.showMessageDialog(null, "数据库连接失败!");System.exit(0);}// 界面初始化JFrame frame = new JFrame("学生信息管理系统");frame.setSize(800, 600);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 添加组件JPanel panel = new JPanel();JLabel label = new JLabel("学生信息管理系统");panel.add(label);frame.add(panel);// 显示界面frame.setVisible(true);}}```四、总结通过以上的代码示例,我们可以看到一个简单的学生信息管理系统的实现框架。

学生信息管理系统c语言代码

学生信息管理系统c语言代码

学生信息管理系统c语言代码以下是一个简单的学生信息管理系统的 C 语言代码示例,包含了学生信息的添加、查询、修改和删除功能。

由于代码超过了 400 字,我将提供一个简化的版本,你可以根据需要进行扩展和改进。

```c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_STUDENTS 100// 学生结构体struct Student {char id[10];char name[50];int age;};// 学生信息列表struct Student students[MAX_STUDENTS];// 学生数量int studentCount = 0;// 添加学生信息void addStudent() {if (studentCount >= MAX_STUDENTS) {printf("学生数量已满,无法添加更多学生。

\n");return;}printf("请输入学生 ID: ");scanf("%s", students[studentCount].id);printf("请输入学生姓名: ");scanf("%s", students[studentCount].name);printf("请输入学生年龄: ");scanf("%d", &students[studentCount].age);studentCount++;printf("学生信息添加成功。

\n");}// 查询学生信息void queryStudent() {if (studentCount == 0) {printf("没有学生信息可供查询。

pythontkinter学生信息管理系统

pythontkinter学生信息管理系统

pythontkinter学⽣信息管理系统使⽤tkinter模块,python3.6,主要功能有添加,查询,删除,修改学⽣信息使⽤模版:1from tkinter import *2import tkinter.font as tkFont3import tkinter as tk4from tkinter import ttk最主要也是最难做的是,实现不同功能的界⾯在同⼀TK窗⼝内容的转换,通过把每个界⾯做成⼀个Frame框架,⽤for循环转换界⾯,来解决这个问题1 LARGE_FONT= ("Verdana", 20)23class Application():4def__init__(self):56 super().__init__()78 self.wm_title("学⽣信息管理系统")910 container = tk.Frame(self)11 container.pack(side="top", fill="both", expand = True)12 container.grid_rowconfigure(0, weight=1)13 container.grid_columnconfigure(0, weight=1)1415 self.frames = {}16#循环功能界⾯17for F in (StartPage, PageOne, PageTwo, PageThree,PageFour):18 frame = F(container, self)19 self.frames[F] = frame20 frame.grid(row=0, column=0, sticky="nsew") # 四个页⾯的位置都是 grid(row=0, column=0), 位置重叠,只有最上⾯的可见!!2122 self.show_frame(StartPage)232425def show_frame(self, cont):26 frame = self.frames[cont]27 raise() # 切换,提升当前 tk.Frame z轴顺序(使可见)!!此语句是本程序的点睛之处下⾯贴出的是主界⾯,这是主页⾯部分代码:1#主页⾯2class StartPage(tk.Frame):3'''主页'''4def__init__(self, parent, root):5 super().__init__(parent)6 label = bel(self, text="学⽣信息管理系统", font=LARGE_FONT)7 label.pack(pady=100)8 ft2=tkFont.Font(size=16)9 Button(self, text="添加学⽣信息",font=ft2,command=lambda: root.show_frame(PageOne),width=30,height=2,fg='white',bg='gray',activebackground='black',activeforeground='white').pack()10 Button(self, text="删除学⽣信息",font=ft2,command=lambda: root.show_frame(PageTwo),width=30,height=2).pack()11 Button(self, text="修改学⽣信息",font=ft2,command=lambda: root.show_frame(PageThree),width=30,height=2,fg='white',bg='gray',activebackground='black',activeforeground='white').pack()12 Button(self, text="查询学⽣信息",font=ft2,command=lambda: root.show_frame(PageFour),width=30,height=2).pack()13 Button(self,text='退出系统',height=2,font=ft2,width=30,command=root.destroy,fg='white',bg='gray',activebackground='black',activeforeground='white').pack()添加学⽣信息页⾯:第⼆功能页⾯添加学⽣信息,,1#添加学⽣信息2class PageOne(tk.Frame):3def__init__(self, parent, root):4 super().__init__(parent)5 label = bel(self, text="添加学⽣信息", font=LARGE_FONT)6 label.pack(pady=100)78 ft3=tkFont.Font(size=14)9 ft4=tkFont.Font(size=12)10 Label(self,text='学⽣学号:',font=ft3).pack(side=TOP)11global e112 e1=StringVar()13 Entry(self,width=30,textvariable=e1,font=ft3,bg='Ivory').pack(side=TOP)14 Label(self,text='学⽣姓名:',font=ft3).pack(side=TOP)15global e216 e2=StringVar()17 Entry(self,width=30,textvariable=e2,font=ft3,bg='Ivory').pack(side=TOP)18 Label(self,text='学⽣成绩:',font=ft3).pack(side=TOP)19global e320 e3=StringVar()21 Entry(self,width=30,textvariable=e3,font=ft3,bg='Ivory').pack(side=TOP)22 Button(self, text="返回⾸页",width=8,font=ft4,command=lambda: root.show_frame(StartPage)).pack(pady=20)23 Button(self, text="确定保存",width=8,font=ft4,command=self.save).pack(side=TOP)2425def save(self):26 with open('student_infor.txt','a+') as student_infor:27 num=str(e1.get())28 name=str(e2.get())29 score=str(e3.get())30 student_infor.write(num+''+name+''+score+'\n')删除学⽣信息1#删除学⽣信息2class PageTwo(tk.Frame):3def__init__(self, parent, root):4 super().__init__(parent)5 label = bel(self, text="删除学⽣信息", font=LARGE_FONT)6 label.pack(pady=100)78 ft3=tkFont.Font(size=14)9 ft4=tkFont.Font(size=12)10 Label(self,text='请输⼊你要删除的学⽣学号:',font=ft3).pack(side=TOP)11global e412 e4=StringVar()13 Entry(self,width=30,textvariable=e4,font=ft3,bg='Ivory').pack(side=TOP)14 Button(self, text="确定删除",width=8,font=ft4,command=self.del1).pack(pady=20)15 Button(self, text="返回⾸页",width=8,font=ft4,command=lambda: root.show_frame(StartPage)).pack() 16#button1 = ttk.Button(self, text="回到⾸页", command=lambda: root.show_frame(StartPage)).pack() 17#button2 = ttk.Button(self, text="去到第⼀页", command=lambda: root.show_frame(PageOne)).pack() 18def del1(self):19 num2=str(e4.get())20 with open('student_infor.txt','r') as f:21 lines=f.readlines()22 with open('student_infor.txt','w') as f_w:23for line in lines:24if num2 in line:25continue26 f_w.write(line)修改学⽣信息:1#修改学⽣信息2class PageThree(tk.Frame):3def__init__(self, parent, root):4 super().__init__(parent)5 bel(self, text="修改学⽣信息", font=LARGE_FONT).pack(pady=100)67 ft3=tkFont.Font(size=14)8 ft4=tkFont.Font(size=12)9 Label(self,text='请输⼊你要修改的学⽣学号:',font=ft3).pack(side=TOP)10 self.e5=StringVar()11 Entry(self,width=30,textvariable=self.e5,font=ft3,bg='Ivory').pack(side=TOP)12 Label(self,text='学⽣姓名:',font=ft3).pack(side=TOP)13 self.e6=StringVar()14 Entry(self,width=30,textvariable=self.e6,font=ft3,bg='Ivory').pack(side=TOP)15 Label(self,text='学⽣成绩:',font=ft3).pack(side=TOP)16 self.e7=StringVar()17 Entry(self,width=30,textvariable=self.e7,font=ft3,bg='Ivory').pack(side=TOP)18 Button(self, text="确定修改",width=8,font=ft4,command=self.modify).pack(pady=20)19 Button(self, text="返回⾸页",width=8,font=ft4,command=lambda: root.show_frame(StartPage)).pack() 20def modify(self):21 num3=str(self.e5.get())22 name3=str(self.e6.get())23 score3=str(self.e7.get())24 with open('student_infor.txt','r') as r_w:25 lines1=r_w.readlines()26 with open('student_infor.txt','w') as rr_w:27for line1 in lines1:28if num3 in line1:29 rr_w.write(num3+''+name3+''+score3+'\n')30continue31 rr_w.write(line1)modify code通过学⽣成绩⾼低查询学⽣信息:1#查询学⽣成绩2class PageFour(tk.Frame):3def__init__(self, parent, root):4 super().__init__(parent)5 label = bel(self, text="查询学⽣成绩", font=LARGE_FONT)6 label.pack(pady=100)7 tree_data=ttk.Treeview()8 ft4=tkFont.Font(size=12)9#滚动条1011 scro=Scrollbar(self)1213 scro.pack(side=RIGHT,fill=Y)14 lista=Listbox(self,yscrollcommand=scro.set,width=50)1516 f=open('student_infor.txt','r')17 text=(" %-16s%-16s%-16s"%("学号","姓名","成绩"))1819 li=[]20for i in f.readlines():21 j=i.split('')22 j[2]=j[2].replace('\n','')23 li.append(j)24 li.sort(key=lambda x:x[2],reverse=False)25for i in li:26 text1=(" %-16s%-16s%-16s"%(i[0],i[1],i[2]))27 lista.insert(0,text1)28 f.close()29 lista.insert(0,text)30 lista.pack()31 Button(self, text="返回⾸页",width=8,font=ft4,command=lambda: root.show_frame(StartPage)).pack(pady=40) View Search Code最后,必不可少的1if__name__ == '__main__':2# 实例化Application3 app = Application()45# 主消息循环:6 app.mainloop()没了,新⼿⼀枚,请多多指教。

学生信息管理系统代码

学生信息管理系统代码

主要代码如下:1、登录界面代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.RecordsetStatic i%cn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from 用户表 where 用户名='" & usna & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "用户名不存在!"cn.CloseText1.Text = ""Text2.Text = ""Text1.SetFocusElseIf Trim(rst("密码")) = Trim(Text2.Text) Then管理界面.ShowElsei = i + 1If i < 3 ThenMsgBox "用户名或密码错误!", vbOKOnly + vbExclamation, "警告"cn.CloseText2.Text = ""Text1.Text = ""Text1.SetFocusElseMsgBox "该用户已被锁定!", vbOKOnly + vbExclamation, "警告"End IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click() Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub2、管理界面代码:Private Sub Sinsert_Click() 添加学生信息.ShowEnd SubPrivate Sub Sselect_Click() 查询学生信息.ShowEnd SubPrivate Sub sustu_Click()查询更新学生信息.ShowEnd SubPrivate Sub xgmm_Click()修改密码.ShowEnd SubPrivate Sub yhzc_Click()用户注册.ShowEnd Sub3、查询学生信息代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.OpenIf Combo1.Text <> "" Thenmysql = "select * from 学生信息表 where 系别='" & Trim(Combo1.Text) & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "没有学生!", vbOKOnly + vbExclamation, "警告"Combo1.Text = ""ElseWith MSFlexGrid1.TextMatrix(0, 1) = "学号".TextMatrix(0, 2) = "姓名".TextMatrix(0, 3) = "性别".TextMatrix(0, 4) = "年龄".TextMatrix(0, 5) = "系别".TextMatrix(0, 6) = "班级"MSFlexGrid1.Rows = 1 '每次查询自动定位到第一行Do While Not rst.EOF.Rows = .Rows + 1.CellAlignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("学号").TextMatrix(.Rows - 1, 2) = rst.Fields("姓名").TextMatrix(.Rows - 1, 3) = rst.Fields("性别").TextMatrix(.Rows - 1, 4) = rst.Fields("年龄").TextMatrix(.Rows - 1, 5) = rst.Fields("系别").TextMatrix(.Rows - 1, 6) = rst.Fields("班级")rst.MoveNextLoopEnd WithEnd IfElseIf Combo2.Text <> "" Thenmysql = "select * from 学生信息表 where 班级='" & Trim(Combo2.Text) & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "没有学生!", vbOKOnly + vbExclamation, "警告" Combo1.Text = ""ElseWith MSFlexGrid1.TextMatrix(0, 1) = "学号".TextMatrix(0, 2) = "姓名".TextMatrix(0, 3) = "性别".TextMatrix(0, 4) = "年龄".TextMatrix(0, 5) = "系别".TextMatrix(0, 6) = "班级"MSFlexGrid1.Rows = 1 '每次查询自动定位到第一行Do While Not rst.EOF.Rows = .Rows + 1.CellAlignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("学号").TextMatrix(.Rows - 1, 2) = rst.Fields("姓名").TextMatrix(.Rows - 1, 3) = rst.Fields("性别").TextMatrix(.Rows - 1, 4) = rst.Fields("年龄").TextMatrix(.Rows - 1, 5) = rst.Fields("系别").TextMatrix(.Rows - 1, 6) = rst.Fields("班级")rst.MoveNextLoopEnd WithEnd IfElseIf Text1.Text <> "" Thenmysql = "select * from 学生信息表 where 学号='" & Trim(Text1.Text) & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "没有学生!", vbOKOnly + vbExclamation, "警告"Combo1.Text = ""ElseWith MSFlexGrid1.TextMatrix(0, 1) = "学号".TextMatrix(0, 2) = "姓名".TextMatrix(0, 3) = "性别".TextMatrix(0, 4) = "年龄".TextMatrix(0, 5) = "系别".TextMatrix(0, 6) = "班级"MSFlexGrid1.Rows = 1 '每次查询自动定位到第一行 Do While Not rst.EOF.Rows = .Rows + 1.CellAlignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("学号") .TextMatrix(.Rows - 1, 2) = rst.Fields("姓名") .TextMatrix(.Rows - 1, 3) = rst.Fields("性别") .TextMatrix(.Rows - 1, 4) = rst.Fields("年龄") .TextMatrix(.Rows - 1, 5) = rst.Fields("系别") .TextMatrix(.Rows - 1, 6) = rst.Fields("班级") rst.MoveNextLoopEnd WithEnd IfElseMsgBox "请输入查询条件!", vbOKOnly + vbExclamation, "警告" End IfEnd SubPrivate Sub Command2_Click()Combo1.Text = ""Combo2.Text = ""Text1.Text = ""End SubPrivate Sub Command3_Click()修改学生信息.ShowEnd Sub '修改学生信息Private Sub Command4_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openmysql = "delete from 学生信息表 where 学号='" & Text1.Text & "'"rst.Open mysql, cnMsgBox "删除成功!", vbOKOnly + vbExclamation, "警告"End SubPrivate Sub Form_Load()Combo1.AddItem "信息服务学院"Combo1.AddItem "电子信息工程系" Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem "40721P"End Sub4、添加学生信息代码Dim cn As New ADODB.Connection Dim rst As New ADODB.RecordsetPrivate Sub Form_Load()Combo1.AddItem "信息服务学院" Combo1.AddItem "电子信息工程系" Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem "40721P"End SubPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.OpenDim sex As Stringusna = Trim(Text1.Text)mysql = "select * from 学生信息表 where 学号='" & usna & "'"rst.Open mysql, cnIf rst.EOF Thenrst.CloseElserst.CloseMsgBox "该学生信息已存在!", vbOKOnly + vbExclamation, "警告"Text1.Text = ""Text2.Text = ""Text3.Text = ""Combo1.Text = ""Combo2.Text = ""Option1.Value = FalseText1.SetFocusEnd IfIf Text1.Text = "" ThenMsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告" Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告" Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请输入年龄!", vbOKOnly + vbExclamation, "警告" Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = "男"Elsesex = "女"End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Combo1.Text)bj = Trim(Combo2.Text)mysql = "insert into 学生信息表(学号,姓名,性别,年龄,系别,班级) values ('" & xh & "','" & xm & "','" & xb & "','" & nl & "','" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息添加成功!")Text1.Text = ""Text2.Text = ""Text3.Text = ""Combo1.Text = ""Combo2.Text = ""Option1.Value = FalseEnd Sub5、修改密码:Dim rst As New ADODB.RecordsetDim cn As New ADODB.ConnectionPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.OpenIf Text1.Text = "" ThenMsgBox "请输入密码!", vbOKOnly + vbExclamation, "警告"Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请输入新密码!", vbOKOnly + vbExclamation, "警告"Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请确认输入的新密码!", vbOKOnly + vbExclamation, "警告"Text3.SetFocusExit SubEnd IfIf Text2.Text = Text3.Text Thenxmm = Trim(Text2.Text)mysql = "update 用户表 set 密码 = '" & xmm & "' where 用户名 = '" & 登陆.Text1.Text & "'"rst.Open mysql, cnMsgBox ("密修改成功!")End IfEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub6、修改学生信息代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB.RecordsetPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from 学生信息表 where 学号='" & usna & "'"rst.Open mysql, cnrst.Closemysql = "delete from 学生信息表 where 学号='" & Text1.Text & "'"rst.Open mysql, cnIf Text1.Text = "" ThenMsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告" Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请输入年龄!", vbOKOnly + vbExclamation, "警告" Text3.SetFocusExit SubEnd IfIf Option1.Value Thensex = "男"Elsesex = "女"End Ifxh = Trim(Text1.Text)xm = Trim(Text2.Text)xb = sexnl = Trim(Text3.Text)xofy = Trim(Combo1.Text)bj = Trim(Combo2.Text)mysql = "insert into 学生信息表(学号,姓名,性别,年龄,系别,班级) values ('" & xh & "','" & xm & "','" & xb & "','" & nl & "','" & xofy & "','" & bj & "')"rst.Open mysql, cnMsgBox ("信息修改成功!")Text1.Text = ""Text2.Text = ""Text3.Text = ""Combo1.Text = ""Combo2.Text = ""Option1.Value = FalseEnd SubPrivate Sub Form_Load()Combo1.AddItem "信息服务学院"Combo1.AddItem "电子信息工程系"Combo2.AddItem "40821P"Combo2.AddItem "40811P"Combo2.AddItem "40822P"Combo2.AddItem "40721P"End Sub7、用户注册代码:Dim rst As New ADODB.RecordsetDim cn As New ADODB.ConnectionPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.OpenIf Text1.Text = "" ThenMsgBox "请输入用户名!", vbOKOnly + vbExclamation, "警告"Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请输入密码!", vbOKOnly + vbExclamation, "警告"Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请再次输入密码!", vbOKOnly + vbExclamation, "警告"Text3.SetFocusExit SubEnd Ifsryhm = Trim(Text1.Text)srmm = Trim(Text2.Text)mysql = "insert into 用户表(用户名,密码) values ('" & sryhm & "','" & srmm & "')"rst.Open mysql, cnMsgBox ("用户添加成功!")Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub '添加用户Private Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End Sub '重置按钮Private Sub Command3_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from 用户表 where 用户名='" & usna & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "用户名可用!"ElseMsgBox "用户名已存在!", vbOKOnly + vbExclamation, "警告"Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusExit SubEnd IfEnd Sub '检查用户名Private Sub Command4_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openusna = Trim(Text1.Text)mysql = "select * from 用户表 where 用户名='" & usna & "'"rst.Open mysql, cnIf rst.EOF ThenMsgBox "无此用户名,删除不成功!", vbOKOnly + vbExclamation, "警告"Elserst.Closeusna = Trim(Text1.Text)mysql = "delete from 用户表 where 用户名='" & usna & "'"rst.Open mysql, cnMsgBox "删除成功!", vbOKOnly + vbExclamation, "警告"Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusEnd IfEnd Sub '删除用户Private Sub Command5_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB.Recordsetcn.ConnectionString = "Provider=SQLOLEDB.1;Persist SecurityInfo=False;User ID=sa;Initial Catalog=students info;Data Source=C1847"cn.Openmysql = "select * from 用户表 "rst.Open mysql, cnIf rst.EOF ThenMsgBox "出错!", vbOKOnly + vbExclamation, "警告"End IfWith MSFlexGrid1.TextMatrix(0, 1) = "用户名".TextMatrix(0, 2) = "密码"MSFlexGrid1.Rows = 1 '每次查询自动定位到第一行Do While Not rst.EOF.Rows = .Rows + 1.CellAlignment = 8.TextMatrix(.Rows - 1, 1) = rst.Fields("用户名") .TextMatrix(.Rows - 1, 2) = rst.Fields("密码") rst.MoveNextLoopEnd Withrst.CloseEnd Sub '查询用户表-----精心整理,希望对您有所帮助!。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

学生信息管理系统设计1、系统简介本系统提供了学生信息管理中常见的基本功能,主要包括管理员和学生两大模块。

管理员的主要功能有对学生信息和课程信息进行增加、删除、修改、查找等操作,对选课信息进行管理,对成绩信息和用户信息进行修改、查找等操作。

学生的主要功能有对学生信息和成绩信息进行查看,对个人的密码信息进行修改等。

2、功能设计需求分析本系统需要实现的功能:(1)、管理员对学生信息和课程信息进行增加、删除、修改、查找等操作,对选课信息进行管理,对成绩信息和用户信息进行修改、查找等操作。

(2)、学生对学生信息和成绩信息进行查看,对个人的密码信息进行修改等。

总体设计学生信息管理系统主要包括管理员和学生两大模块。

管理员模块包括:学生信息管理、课程信息管理、选课信息管理、成绩信息管理、用户信息管理等。

用户模块包括:学生信息查看、成绩信息查看、个人信息管理等。

系统总体结构如图所示。

总体结构图模块详细设计1、学生信息管理模块学生信息管理模块包括增加、删除、修改、查询、显示全部等。

具体的结构图如图所示。

学生信息管理模块结构图2、课程信息管理模块课程信息管理模块包括增加、删除、修改、查询、显示全部等。

具体的结构图如图所示。

课程信息管理模块结构图3、选课信息管理模块选课信息管理模块包括查询、显示全部等。

具体的结构图如图所示。

选课信息管理模块结构图4、成绩信息管理模块成绩信息管理模块包括修改成绩、查询、显示全部等。

具体的结构图如图所示。

成绩信息管理模块结构图5、用户信息管理模块用户信息管理模块包括修改、查询、显示全部等。

具体的结构图如图所示。

用户信息管理模块结构图3、数据库设计在数据库student中共有4张数据表:s(学生信息表)、c(课程信息表)、sc(选课信息表)、unpw(用户信息表),下面定义每张表的字段名称和数据类型。

sc(选课信息表)4、界面库设计1、学生信息管理系统的登录学生信息管理系统可由管理员和学生两种身份的人使用。

管理员和学生身份登录所能操作的功能有很大的区别。

系统初始化一个系统管理员,登录名:admin 密码:admin 学生登录系统的登录名为学号,密码也为学号(如:10001),登录后可以修改密码。

登录界面管理员登录系统后的界面学生登录系统后的界面2、实现管理员和学生操作功能的界面管理员的登录系统后可以进行学生信息管理、课程信息管理、选课信息管理、成绩信息管理、用户信息管理等功能操作,其具体界面设计如下图所示。

学生信息管理功能的界面课程信息管理功能的界面选课信息管理功能的界面成绩信息管理功能的界面用户信息管理功能的界面学生的登录系统后可以进行学生信息查看、成绩信息查看、个人信息管理等功能操作,其具体界面设计如下图所示。

学生信息查看功能的界面成绩信息查看功能的界面个人信息管理功能的界面5、程序类的设计SimpleStudentManager 主函数类DLFrame 登陆界面类ManagerFrane 管理员界面类StudentFrame 学生界面类SM 学生信息管理的类SAdd 用于学生信息管理中增加或修改某条记录的界面的类SSelect 用于学生基本信息管理中查询时输入学号的界面的类CM 课程信息管理的类CAdd 用于课程信息管理中增加或修改某条记录的界面的类CSelect 用于课程信息管理中查询时输入课程号的界面的类SCM 选课信息管理的类SCSelect 用于选课信息管理中查询时输入学号的界面的类GM 成绩信息管理的类GAdd 用于成绩信息管理中修改成绩的界面的类GSelect 用于成绩信息管理中查询时输入学号的界面的类PM 用户信息管理的类UAdd 用于用户信息管理中修改密码的界面的类PSelect 用于用户信息管理中查询时输入用户名的界面的类StudentS 用于学生信息查看时输入学号的界面的类StudentSelect 用于成绩信息查看时输入学号的界面的类PPM 个人信息管理的类PPSelect 用于个人信息管理查询时输入用户名的界面的类程序类的具体代码实现见工程文件夹中的代码及注释6、系统的使用说明及环境配置学生信息管理系统提供了管理员和学生这两个角色登录系统,管理员通过用户名:admin 密码:admin 登录系统后可以进行相应的操作。

学生通过以自己的学号(如10001)作为用户名和密码登录系统后进行相应的学生权限范围内的操作。

数据库:SQL Server 2005连接数据库的登录名:sa 密码:123代码:import .*;import .*;import .*;class CAdd extends JFrame implements ActionListener{isplay();}isNewsm = true;}if () == "取消") {(false);new CM("课程信息管理").display();}}}import .*;import .*;import .*;import CM extends JFrame implements ActionListener {isplay();} catch (SQLException e) {();}} else {try {int rs1 = ("delete from c where cno='"+ mkch + "'");isplay();} catch (SQLException e) {();}}}}public void update() {isplay();} else {sTable = new JTable(playerInfo, columnNames);isplay();}}}import .*;public class CSelect extends JFrame implements ActionListener {elect();}}}import .*;import .*;import .*;class DLFrame extends JFrame implements ActionListener, ItemListener {quals("") || ().equals("")) {rim();pw = ("pw").trim();if ().equals(un)) {if ().equals(pw)) {actionCode = OK;(false);if (qxian == 0) {new ManagerFrane();;import .*;import .*;class GAdd extends JFrame implements ActionListener {isplay();();}isNewsm = true;}if () == "取消") {(false);new GM("成绩信息管理").display();}}}import .*;import .*;import .*;import GM extends JFrame implements ActionListener {xecuteQuery("select * from sc,c where =");} else {rs = stmt.executeQuery("select * from sc,c where = and sno='"+ mxh + "'");}while () && j1 <= row) {kch = ("sno");kcm = ("cn");xxkch = ("g");j1++;}} catch (SQLException e) {();}GAdd gadd = new GAdd();("修改成绩");();}}public void select() {xecuteQuery("select * from sc,c where = and sno='"+ mxh + "'");while ()) {playerInfo[j][0] = ("sno");playerInfo[j][1] = ("cn");playerInfo[j][2] = ("g");j++;}} catch (SQLException e) {();}if (playerInfo[0][1] == null) {();(null, "学号不存在!");new GM("成绩信息管理").display();} else {sTable = new JTable(playerInfo, columnNames);(sTable);scroll = new JScrollPane(sTable);(scroll);}}public void actionPerformed(ActionEvent e) {if () == "修改成绩") {();}if () == "查询") {gst = new GSelect();();}if () == "显示") {();new GM("成绩信息管理").display();}}}import .*;public class GSelect extends JFrame implements ActionListener {xecuteQuery("select * from sc,c where = and sno='"+ gxh + "'");while ()) {("sno"));("cn"));("g"));i++;elect();}}}import .*;import .*;class ManagerFrane extends JFrame implements ActionListener {isplay();if () == "课程信息管理") {new CM("课程信息管理").display();}if () == "选课信息管理") {new SCM("选课信息管理").display();}if () == "成绩信息管理") {new GM("成绩信息管理").display();}if () == "用户信息管理") {new PM("用户信息管理").display();}if () == "退出管理系统") {(0);}}}import .*;import .*;import .*;import PM extends JFrame implements ActionListener {xecuteQuery("select * from unpw where qx=1 and un='"+ myh + "'");}while () && j1 <= row) {yh = ("un");mm = ("pw");j1++;}} catch (SQLException e) {();}UAdd uadd = new UAdd();("修改");();}}public void select() {isplay();} else {sTable = new JTable(playerInfo, columnNames);(sTable);scroll = new JScrollPane(sTable);(scroll);}}public void actionPerformed(ActionEvent e) {if () == "修改") {();}if () == "查询") {pst = new PSelect();();}if () == "显示") {();new PM("用户信息管理").display();}}}import .*;import .*;import .*;import PPM extends JFrame implements ActionListener {xecuteQuery("select * from unpw where qx=1 and un='"+ myh + "'");}while () && j1 <= row) {yh = ("un");mm = ("pw");j1++;}} catch (SQLException e) {();}UAdd uadd = new UAdd();("修改密码");();}}public void select() {elect();} else {sTable = new JTable(playerInfo, columnNames);(sTable);scroll = new JScrollPane(sTable);(scroll);}}public void actionPerformed(ActionEvent e) {();}}import .*;public class PPSelect extends JFrame implements ActionListener {elect();}}}import .*;public class PSelect extends JFrame implements ActionListener {elect();}}}import .*;import .*;import .*;class SAdd extends JFrame implements ActionListener, ItemListener {quals("男")) {("男");("女");} else {("女");("男");}if ().equals("计科系")) {("计科系");("物理系");("数学系");("外语系");}if ().equals("物理系")) {("物理系");("计科系");("数学系");("外语系");}if ().equals("外语系")) {("外语系");("计科系");("物理系");("数学系");}if ().equals("数学系")) {("数学系");("计科系");("物理系");("外语系");}(new FlowLayout);(lsno);(tsno);(lsname);(tsname);(lsage);(tsage);(lssex);(cbssex);(lsdept);(cbsdept);(btnOK);(btnCancel);(p);;(this);(this);(this);(this);();}public void connDB() { isplay();}isNewsm = true;}if () == " 取消 ") {(false);new SM().display();}}public void itemStateChanged(ItemEvent e) { ;import .*;import .*;import SCM extends JFrame implements ActionListener {xecuteQuery("select * from sc where sno='" + mscxh + "'");while ()) {playerInfo[j][0] = ("sno");playerInfo[j][1] = ("cno");playerInfo[j][2] = ("g");j++;}} catch (SQLException e) {();}if (playerInfo[0][1] == null) {();(null, "课程号不存在!");new SCM("选课信息管理").display();} else {sTable = new JTable(playerInfo, columnNames);(sTable);scroll = new JScrollPane(sTable);(scroll);}}public void actionPerformed(ActionEvent e) {if () == "查询") {scst = new SCSelect();();}if () == "显示") {();new SCM("选课信息管理").display();}}}import .*;public class SCSelect extends JFrame implements ActionListener {elect();}}}public class SimpleStudentManager {public static void main(String[] args) {new DLFrame();}}import .*;import .*;import .*;import SM extends JFrame implements ActionListener {isplay();} catch (SQLException e) {();}} else {try {int rs1 = ("delete from s where sno='"+ mxh + "'");("delete from unpw where un='" + mxh+ "'");(null, "记录删除成功!");();new SM().display();} catch (SQLException e) {();}}}}public void update() {isplay();} else {sTable = new JTable(playerInfo, columnNames);isplay();}}}import .*;public class SSelect extends JFrame implements ActionListener {elect();}}}import .*;import .*;class StudentFrame extends JFrame implements ActionListener { JPanel p1 = new JPanel();JPanel p2 = new JPanel();JButton btns = new JButton("学生信息查看");JButton btng = new JButton("成绩信息查看");JButton btnu = new JButton("个人信息管理");JButton btnClose = new JButton("退出管理系统");JLabel l = new JLabel("学生");StudentFrame() {super("学生信息管理系统");setSize(350, 200);add("North", p1);add("Center", p2);(l);(btns);(btng);(btnu);(btnClose);(this);(this);(this);(this);(false);;show();}public void actionPerformed(ActionEvent e) {if () == "学生信息查看"){new StudentS();}if () == "成绩信息查看") {new StudentSelect();}if () == "个人信息管理") {PPSelect ppst= new PPSelect();}if () == "退出管理系统") {(0);}}}import .*;public class StudentS extends JFrame implements ActionListener {etConnection("jdbc:; DatabaseName=student","sa", "123");stmt = ();} catch (SQLException e) {();}}public void closeDB() elect();}}}import .*;public class StudentSelect extends JFrame implements ActionListener {etConnection("jdbc:; DatabaseName=student","sa", "123");stmt = ();} catch (SQLException e) {();}}public void closeDB() elect();}}import .*;import .*;import .*;class UAdd extends JFrame implements ActionListener {isplay();}isNewsm = true;}if () == "取消") {(false);new PM("用户信息管理").display();}}}。

相关文档
最新文档