学生信息管理系统+代码

合集下载

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(。

学生信息管理系统代码

学生信息管理系统代码

主要代码如下: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 Security Info=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。

学生信息管理系统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");} }。

python学生信息管理系统实现代码

python学生信息管理系统实现代码

python学⽣信息管理系统实现代码1.本⼈第⼀次学python做出来的,当时满满的成就感,当作纪念⾮常简单,复制即可使⽤代码块import json#把字符串类型的数据转换成Python基本数据类型或者将Python基本数据类型转换成字符串类型。

def login_user():while True:register=input('学⽣姓名:')try:with open(register+'.json')as file_object:user_message=json.load(file_object)#json.load(obj) 读取⽂件中的字符串,序列化成Python的基本数据类型except FileNotFoundError:print('该⽤户不存在!')breakelse:print('_'*20)register_password = input('请输⼊学号:')if user_message['id']==register and user_message['password']==register_password:str_print = '姓名:{}\t数学成绩:{}\t语⽂成绩:{}\t英语成绩: {}'grade_list = []while 1:print('''******************************欢迎使⽤【学⽣信息管理系统】请选择你想要进⾏的操作1.新建学⽣信息2.显⽰全部信息3.查询学⽣信息4.删除学⽣信息5.修改学⽣信息0.退出系统******************************''')action = input('请选择你想要的进⾏操作:\n')if action == '1':'''新建学⽣信息'''name = input('请输⼊名字')math = input('请输⼊数学成绩')chinese = input('请输⼊语⽂成绩')english = input('请输⼊英语成绩')total = int(math) + int(chinese) + int(english)grade_list.append([name,math,chinese,english,total])print([name,math,chinese,english,total])print('姓名:{}\t数学成绩:{}\t语⽂成绩:{}\t英语成绩: {}'.format(name,math,chinese,english,total))passelif action == '2':'''显⽰全部信息'''for info in grade_list:print(str_print.format(*info))elif action == '3':'''查询学⽣信息'''name = input('请输⼊你需要查询学⽣的姓名:')for info in grade_list:if name in info:print(str_print.format(*info))breakelse:print('此学⽣不存在')elif action == '4':'''删除学⽣信息'''name = input('请输⼊你需要查询学⽣的姓名:')for info in grade_list:if name in info:info_=grade_list.pop(grade_list.index(info))print('这个学员的信息已经被删除\n',info_)breakelse:print('此学⽣不存在')elif action == '5':'''修改学⽣信息'''name = input('请输⼊你需要查询学⽣的姓名:')for info in grade_list:if name in info:index = grade_list.index(info)breakelse:print('此学⽣不存在')continuemath = input('请输⼊数学成绩:')chinese = input('请输⼊语⽂成绩:')english = input('请输⼊英语成绩:')total = int(math) + int(chinese) + int(english)grade_list[index][0:] = [name,math,chinese,english,total]print('修改后的⼀个成绩',grade_list[index])elif action == '0':'''退出系统'''breakelse:print('输⼊信息有误,请重新输⼊')#print('登陆成功')return register,user_messageelse:print('登陆失败!⽤户名或密码错误')breakdef register_user():new_user=input('增加学⽣姓名:')try:with open(new_user+',.jion','r') as file_object:passexcept FileNotFoundError:new_password_one=input('请确认学号:')new_password_two=input('请再次确认学号:')if new_password_one==new_password_two:user_message={'id':new_user,'password':new_password_one}with open(new_user+'.json','w')as file_object:json.dump(user_message,file_object)#json.dump(obj) 将Python的基本数据类型序列化成字符串并写⼊到⽂件中print('新⽤户已经注册成功!可以登录了。

学生信息管理系统完整源代码+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();}}. ..。

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()。

  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(用户信息表),下面定义每张表的字段名称和数据类型。

s(学生信息表)字段名称数据类型描述sno char (10)学号,关键字sn char (20)姓名sa int年龄ss char (10)性别sd char (10)院系c(课程信息表)字段名称数据类型描述cno char (10)课程号,关键字cn char (30)课程名pcno char (10)先行课程号字段名称数据类型描述sno char (10)学号,关键字cno char (10)课程号,关键字g int成绩unpw(用户信息表)字段名称数据类型描述un char (10)用户名,关键字pw char (10)密码qx int角色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();}} }。

相关文档
最新文档