学生信息管理系统(完整代码、数据库、图片)

合集下载

学生信息管理系统代码

学生信息管理系统代码

主要代码如下: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 '查询用户表源代码如下:#include <iostream>#include <cstring>using namespace std;struct student{int no;char name[30];int math,computer,english,physics;}stu[100]={0,"0",0,0,0,0};void setup();int lookfor(int m);void edit();void Delete();int main(){loop:cout<<"***************************************\n";cout<<" 请选择服务\n"; cout<<" 1 - 录入学生信息\n"; cout<<" 2 - 查找学生信息\n"; cout<<" 3 - 修改学生信息\n"; cout<<" 4 - 删除学生信息\n"; cout<<" 0 - 退出\n"; cout<<"***************************************\n";int menu,num,tem;cin>>menu;system("cls");switch (menu){case 1:{setup();system("cls");goto loop;break;}case 2:{cout<<"请输入您想查询的学号:";cin>>num;tem=lookfor(num);if (tem!=-1){cout<<"学号姓名计算机成绩数学成绩英语成绩物理成绩\n";cout<<stu[tem].no<<" "<<stu[tem].name<<""<<stu[tem].computer<<" "\<<stu[tem].math<<" "<<stu[tem].english<<""<<stu[tem].physics<<endl;}elsecout<<"对不起,该学号不存在!\n";system("pause");system("cls");goto loop;break;}case 3:{edit();system("cls");goto loop;break;}case 4:{Delete();system("cls");goto loop;break;}case 5:{cout<<"谢谢使用!\n";break;}default:{cout<<"错误的请求!\n";system("cls");goto loop;break;}}return 0;}void setup(){char str;for(int i=0;i<100;i++){cout<<"请输入学生学号、姓名、计算机成绩、数学成绩、英语成绩、物理成绩:\n";cin>>stu[i].no>>stu[i].name>>stu[i].computer>>stu[i].math\>>stu[i].english>>stu[i].physics;cout<<"继续(y/n)\n";cin>>str;if(str=='n')break;}}int lookfor(int m){for(int i=0;i<100;i++){if(m==stu[i].no)return i;}return -1;}void edit(){char ch[30];int s1,s2,s3,s4;int t,m,temp;cout<<"请选择学号:"<<endl;cin>>m;temp=lookfor(m);if(m!=-1){cout<<"******************************\n";cout<<" 请选择: \n"; cout<<" 1 - 修改姓名\n"; cout<<" 2 - 修改计算机成绩\n"; cout<<" 3 - 修改数学成绩\n"; cout<<" 4 - 修改英语成绩\n"; cout<<" 5 - 修改物理成绩\n"; cout<<"******************************\n"; cin>>t;switch (t){case 1:cout<<"请输入学生的名字\n";cin>>ch;strcpy(stu[temp].name,ch);break;case 2:cout<<"请输入学生新的计算机成绩\n"; cin>>s1;stu[temp].computer=s1;break;case 3:cout<<"请输入学生新的数学成绩\n"; cin>>s2;stu[temp].math=s2;break;case 4:cout<<"请输入学生新的英语成绩\n"; cin>>s3;stu[temp].english=s3;break;case 5:cout<<"请输入学生新的物理成绩\n";cin>>s4;stu[temp].physics=s4;break;}}elsecout<<"此学号不存在!\n";}void Delete(){int temp,m;cout<<"请选择学号:"<<endl; cin>>m;temp=lookfor(m);if(m!=-1){stu[temp].no=0;stu[temp].name[0]='0';stu[temp].computer=0;stu[temp].math=0;stu[temp].english=0;stu[temp].physics=0;}elsecout<<"此学号不存在!\n";}。

学生信息管理系统源代码

学生信息管理系统源代码

#include "stdio.h"#include "stdlib.h"#include "string.h"#include "conio.h"jiemian();struct student{char name[50];char sex[5];int age;char num[50];float score1;float score2;float score3;float sum;float ave;}stu[50],del;void gn1(){int i=0;char num1;for(i=0;i<50;i++){printf("请输入要添加的学生资料:\n"); printf("学号:");scanf("%s",stu[i].num);printf("姓名:");scanf("%s",stu[i].name);printf("性别:");scanf("%s",&stu[i].sex);printf("年龄:");scanf("%d",&stu[i].age);printf("请输入学生的三门成绩:\n"); printf("语文:");scanf("%f",&stu[i].score1);printf("数学:");scanf("%f",&stu[i].score2);printf("英语:");scanf("%f",&stu[i].score3);printf("是否继续添加:y/n\n");scanf("%c",&num1);scanf("%c",&num1);if(num1=='N' || num1=='n'){system("cls");jiemian();}}}void gn2(){int i;char num[50];printf("请输入要查找的学生学号:\n");scanf("%s",num);for(i=0;i<50;i++)if(strcmp(stu[i].num,num)==0){stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;stu[i].ave=stu[i].sum/3;printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i ].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].score1,stu[i].score2, stu[i].score3,stu[i].sum,stu[i].ave);break;}if(i==50)printf("查找不到!请重新输入!\n");getch();system("cls");jiemian();}void gn3(){char num1,i=0;printf("请输入要修改的学生学号:\n");scanf("%s",stu[i].num);printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i]. num,stu[i].name,stu[i].sex,stu[i].age,stu[i].score1,stu[i].score2,st u[i].score3,stu[i].sum,stu[i].ave);printf("姓名:");scanf("%s",stu[i].name);printf("性别:");scanf("%s",stu[i].sex);printf("年龄:");scanf("%d",&stu[i].age);printf("请输入学生的三门成绩:\n");printf("语文:");scanf("%f",&stu[i].score1);printf("数学:");scanf("%f",&stu[i].score2);printf("英语:");scanf("%f",&stu[i].score3);printf("是否继续修改:y/n?\n");scanf("%c",&num1);scanf("%c",&num1);if(num1=='N' || num1=='n')system("cls");jiemian();}void gn4(){int i;char num[50];printf("请输入要删除的学生学号:\n");scanf("%s",num);for(i=0;i<50;i++)if(strcmp(num,stu[i].num)==0){printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu [i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].score1,stu[i].score 2,stu[i].score3,stu[i].sum,stu[i].ave);stu[i]=del;printf("信息已删除,按任意键返回..\n");break;}if(i==50)printf("您输入的信息不存在!\n");getch();system("cls");jiemian();}void gn5(){int i=0;stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;stu[i].ave=stu[i].sum/3;printf("学号 \t姓名 \t性别 \t年龄 \t语文 \t数学 \t英语 \t总成绩\t 平均成绩 \n");for(i=0;i<50;i++){if(stu[i].age==0)break;printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i].n um,stu[i].name,stu[i].sex,stu[i].age,stu[i].score1,stu[i].score2,stu [i].score3,stu[i].sum,stu[i].ave);}printf("按任意键返回...");getch();system("cls");jiemian();}void gn6(){FILE *fp;int i;char filename[50];printf("\n");printf("\n");printf("请输入要保存的文件名:");scanf("%s",filename);if((fp=fopen(filename,"wb"))==NULL)printf("文件名为空,不能保存!\n");for(i=0;i<50;i++){if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)printf("文件保存失败!\n");}fclose(fp);printf("文件已保存!\n");printf("按任意键返回...\n");getch();system("cls");jiemian();}void gn7(){FILE *fp;int i=0; //打开文件流char filename[50];printf("请输入文件名:");scanf("%s",filename); //输入要载入的文件名if((fp=fopen(filename,"rb"))==0) //如果当前目录下不存在相对应的文件,输出文件不存在,退出系统。

教你用Python实现简易版学生信息管理系统(含源码)

教你用Python实现简易版学生信息管理系统(含源码)

教你⽤Python实现简易版学⽣信息管理系统(含源码)⼀、项⽬分析1、⾸先定义⼀个存放基础学⽣信息列表格式:list = [{学号:姓名,年龄:num,成绩:num },{……}]student1 = [\{1:"jam",'age':17,'socer':99},{2:'kol','age':18,'socer':89},{3:'avlir','age':19,'socer':100}]2、先搭建框架(主函数main())if __name__ == '__main__':while True:menu()key = input("输⼊选项数字查询/输⼊信息:")if key == '1':lookup() #打印指定学⽣信息elif key == '2':append() #添加新的学⽣信息elif key == '3':delete() #删除指定学⽣信息elif key == '4':allinformation() #打印所有信息elif key == '5':revise() #修改指定学⽣信息elif key == '6':save() #保存信息elif key == '0':print("确定退出?")exit = input("输⼊yes退出:")if exit == 'yes':breakelse:print("输⼊错误,返回 ")3、搭建好框架之后,这时候发现需要⼀个菜单界⾯(menu())#页⾯def menu():print('-'*30)print("欢迎来到学⽣管理系统")print("1.输⼊学号查询成绩")print("2.添加学⽣信息")print("3.删除学⽣信息")print("4.打印所有学⽣信息")print("5.修改学⽣信息")print("6.保存学⽣信息到指定⽂件")print("0.退出系统")print("-"*30)4、接下来就是查询指定学⽣信息(lookup())。

简易学生管理系统代码

简易学生管理系统代码

简易学生信息管理系统代码分享供有兴趣的未来IT精英参考!因本人知识有限!代码有很多漏洞!望大家去粗取精!#include<stdio.h>#include<string.h>#include<stdlib.h>//账号与密码的初始值const char *zhang0="123";const char *mima0 ="123";int ren = 0,flag = 0, flag0 =0; //全局变量//学生信息结构体struct student{char name[12];char phone[12];int id;int age;int score;}stu[100]={0};//登录int pipei(){int i = 3;char zhang[10]={0};char mima[10] ={0};while(i>0){ system("clear");printf("请输入账号与密码\n");scanf("%s",zhang);scanf("%s",mima);if(strcmp(zhang0,zhang)==0 && strcmp(mima0,mima)==0)return 1;printf("登录失败! 慎重输入\n");printf("还有%d次机会输入!\n",--i);}return 0;}int request(struct student *stup,char *name,char *phone,int id,int age,int score){//遍历结构体确保这里输入的ID号唯一的int i=0;system("clear");for(i=0;i<ren;i++){if(stu[i].id == id){printf("该ID已经存在了,注册失败\n");flag0 = 0;return 0;}}//对结构体地址进行初始化,注册该用户strcpy((stu+i)->name,name);strcpy((stu+i)->phone,phone);(stu+i)->id = id;(stu+i)->age = age;(stu+i)->score =score;//printf("login was successful\n");//注册成功后,人数就要+1ren++;flag0 = 1;return ren; //返回当前的用户数}//找学号int check(int id){int i=0 ;//遍历for(i=0;i<ren;i++){if(stu[i].id == id){flag = 1;return i;}else{flag=0;}}}//注销函数int select(int id){ int i,j;system("clear");for(i=0;i<ren;i++){if(stu[i].id==id){flag = 1;memset(&stu[i],0,sizeof(struct student));for(j=i;j<ren-1;j++){stu[j]=stu[j+1];}ren--;}else{flag = 0;}}if(flag==0){printf("该学号不存在!请重新确认再输入!\n"); }}//修改int change(struct student *stup){char newname[12];char newphone[12];int newid;int newage;int newscore;int n=0,i=0;system("clear");if(flag){printf("修改学生的信息为:\n");printf("姓名:%s\n 电话:%s\n 学号:%d\n年龄:%d\n 成绩:%d\n",stup->name,stup->phone,stup->id,stup->age,stup->score);printf("修改项目: 1.姓名\t 2.电话\t 3.学号\t 4.年龄\t 5.成绩\n ");scanf("%d",&n);switch(n){case 1:{printf("请输入新名字:\n");scanf("%s",newname);strcpy(stup->name,newname);}break;case 2:{printf("请输入新电话:\n");scanf("%s",newphone);strcpy(stup->phone,newphone);}break;case 3:{printf("请输入新学号:\n");scanf("%d",&newid);for(i=0;i<ren;i++){if(stu[i].id == newid){printf("该ID已经存在了,修改失败\n");flag = 0;return 0;}elseflag = 1;}if(flag)stup->id=newid;}break;case 4:{printf("请输入新年龄:\n");scanf("%d",&newage);stup->age=newage;}break;case 5:{printf("请输入新成绩:\n");scanf("%d",&newscore);stup->score=newscore;}break;default :{printf("没有此操作!请认真选择!\n");}}}else{printf("该学号不存在!请重新确认再输入!\n");return 0;flag =0;}}//查询int show(struct student *stup){system("clear");if(flag){printf("该学生的信息为:\n");printf("姓名:%s\n 电话:%s\n 学号:%d\n年龄:%d\n 成绩:%d\n",stup->name,stup->phone,stup->id,stup->age,stup->score);}else{printf("该学号不存在!请重新确认再输入!\n");return 0;}}int maindows(){ int n = 0,i=0,j=0;char name[12];char phone[12];int id;int age;int score;system("clear");printf("****************\n");printf("请选择用户功能1.注册 2.注销 3.修改 4. 查询 5.整体信息\n ");scanf("%d",&n);switch(n){case 1:{while(1){struct student stu1;system("clear");printf("请继续注册!\n");printf("请输入名字\n");scanf("%s",name);printf("请输入电话\n");scanf("%s",phone);printf("请输入学号\n");scanf("%d",&id);printf("请输入年龄\n");scanf("%d",&age);printf("请输入成绩\n");scanf("%d",&score);request(&stu1,name,phone,id,age,score);if(flag0){printf("注册成功!\n");printf("姓名:%s\n 电话:%s\n 学号:%d\n年龄:%d\n 成绩:%d\n",stu[i].name,stu[i].phone,stu[i].id,stu[i].age,stu[i].score);flag0 = 0;}printf("当前的有效用户%d\n",ren);printf("非零继续注册,零则退出注册!\n");scanf("%d",&i);system("clear");if(i==0)return maindows();}}case 2 :{while(1){ system("clear");printf("请输入注销学生学号:\n");scanf("%d",&id);select(id);printf("当前的有效用户%d\n",ren);printf("非零继续注销,零则退出注销!\n");scanf("%d",&i);if(i==0)return maindows();}}case 3:{system("clear");printf("请输入修改学生学号:\n");scanf("%d",&id);while(1){change(&stu[check(id)]);if(flag){printf("修改后学生的信息为:\n");printf("姓名:%s\n 电话:%s\n 学号:%d\n年龄:%d\n 成绩:%d\n",stu[i].name,stu[i].phone,stu[i].id,stu[i].age,stu[i].score);}printf("非零继续修改,零则退出修改!\n");scanf("%d",&i);if(i==0)return maindows();}}case 4:{while(1){system("clear");printf("请输入查询学生学号:\n");scanf("%d",&id);show(&stu[check(id)]);printf("非零继续查询,零则退出查询!\n");scanf("%d",&i);if(i==0)return maindows();}}case 5:{system("clear");for(i=0;i<ren;i++){printf("第%d位学生信息为:",i+1);printf("姓名:%s\t 电话:%s\t 学号:%d\t年龄:%d\t 成绩:%d\n",stu[i].name,stu[i].phone,stu[i].id,stu[i].age,stu[i].score);}return maindows();}break;}}int main(){if(pipei()){printf("登陆成功!\n");printf("******欢迎进入学生信息管理系统******\n");maindows();}elsereturn 0;}。

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

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

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

学生信息管理系统系统源代码(总34页)--本页仅作为文档封面,使用时请直接删除即可----内页可以根据需求调整合适字体及大小--系统源代码一、登录界面代码using System;using ;using ;using ;using ;using partial class login : protected void txtid_Click(object sender, EventArgs e){= "";= "";}protected void Button1_Click(object sender, EventArgs e){string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);();DataSet ds=new DataSet () ;SqlDataAdapter da = new SqlDataAdapter("select * from users where userid='" + + "' and userpwd='" + + "'", conn);(ds);if [0].==0){Label3 .Text ="账号或密码错误,请重新输入!";}else{Session ["userid"]=txtid .Text ;Session["userpwd"] = ;Session["username"] = [0].Rows[0]["username"].ToString(); Session["userpower"] = [0].Rows[0]["userpower"].ToString(); if (Session["userpower"].ToString () == "0"){("admin/");}else if (Session["userpower"].ToString() == "1"){("student/");}else{= "对不起,权限验证失败";}}();();}}二、添加课程页面代码using System;using ;using ;using ;using ;using partial class addcourse : SqlCommand mycmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e){"onblur", "checkcourseid()");string strconn = ["connStr"];conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e){if == ""){= "课程号不能为空";}else{string sqlstr = "";sqlstr = "insert intocourse(courseid,coursename,coursetime,fen,type,teacher)values('" + + "','" + + "','" + + "','" + + "','" + + "','" + + "')";();mycmd = new SqlCommand(sqlstr, conn);();try{();("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){("<script>javascript:alert('添加失败!!!');</script>");}finally{();sqlstr = "";}}}protected void Button2_Click(object sender, EventArgs e) {= "";= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e) {("");}}三、添加成绩程序代码using System;using ;using ;using ;using ;using partial class addscore : SqlCommand mycmd; SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);}{if .ToString ()== ""){= "学号不能为空";}else{string sqlstr = "";sqlstr = "insert intoscore(userid,username,courseid,coursename,score,[year])values('" + + "','" + + "','" + + "','" + + "','" + + "','" + + "')";();mycmd = new SqlCommand(sqlstr, conn);();try{();("<script>javascript:alert('添加成功!!!');</script>");}catch (SqlException){("<script>javascript:alert('添加失败!!!');</script>");}finally{();sqlstr = "";}}}{= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e){("");}protected void userid_SelectedIndexChanged(object sender, EventArgs e){string sqlstr = "";sqlstr = "select username from students where userid='" + + "'";();mycmd = new SqlCommand(sqlstr, conn);();SqlDataReader da;da = ();while ()){= da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e){string sqlstr = "";sqlstr = "select coursename from course where courseid='" + + "'";();mycmd = new SqlCommand(sqlstr, conn);();SqlDataReader da;da = ();while ()){= da["coursename"].ToString();}}}四、添加学生程序代码using System;using ;using ;using ;using ;using ;using ;using partial class addstudent : SqlComman d mycmd; protected void Page_Load(object sender, EventArgs e){"onblur", "checkuserid()");string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);}protected void Button1_Click(object sender, EventArgs e) {if == "")return;string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string sqlstr = "";string sql = "";sqlstr = "insert intostudents(userid,username,sex,minzu,birthday,class,comefrom,beizhu,xuey,zhua ny,tel,idc,zhengzmm,zhiw,huoj,weij)values('" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "','" + + "')";();mycmd = new SqlCommand(sqlstr, conn);();string name = 获取上传文件的名称string type = ("\\") + 1);alue = wpath;();oString();string sql = "select courseid from course where courseid='" + nam + "'"; SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);();SqlDataReader dr = ();if ()){("<b class='Error'>该课程号已经存在,请换一个</b>");}else{("<b class='Right'>该课程号可以使用</b>");}();}}六、检查学号唯一性程序代码using System;using ;using ;using ;using ;using partial class checkuser : protected void Page_Load(object sen der, EventArgs e){= 0;string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string nam = ["name"].ToString();string sql = "select userid from students where userid='" + nam + "'";SqlCommand DBHelper;DBHelper = new SqlCommand(sql, conn);();SqlDataReader dr = ();if ()){("<b class='Error'>该学号已经存在,请换一个</b>");}else{("<b class='Right'>该学号可以使用</b>");}();}}七、课程信息程序代码using System;using ;using ;using ;using ;using partial class course : SqlConnection conn;SqlDataReader getdata;protected void Page_Load(object sender, EventArgs e){string strconn = ["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);();getdata = ();= getdata;();();();}protected void Button1_Click(object sender, EventArgs e) {DataSet ds;SqlDataReader da;string strsql = "";SqlCommand cmd;();strsql = "select * from course where courseid='" + + "'or coursename like '" + + "'";cmd = new SqlCommand(strsql, conn);da = ();= da;();();();}}八、编辑、删除学生信息程序代码using System;using ;using ;using ;using ;using partial class images_editstudent : SqlCommand cmd;SqlCommand cmd2;protected void Page_Load(object sender, EventArgs e){if (!{string sql = "";SqlDataReader reader;string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "select * from students where userid='" + uid + "'";SqlCommand cmd;cmd = new SqlCommand(sql, conn);();reader = ();while ()){= reader["userId"].ToString();= reader["username"].ToString();= reader["sex"].ToString();= reader["minzu"].ToString();= reader["birthday"].ToString();= reader["class"].ToString();= reader["comefrom"].ToString();= reader["xuey"].ToString();= reader["zhuany"].ToString();= reader["tel"].ToString();= reader["idc"].ToString();}();sql = "";();}}protected void Button1_Click(object sender, EventArgs e) {string uid="";uid=Page .Request ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql="";sql = "update students set userid='" + + "',username='" + + "',minzu='" + + "',sex='" + + "',birthday='" + + "',class='" + + "',comefrom='" + + "',beizhu='" + + "',xuey='" + + "',zhuany='" + + "',tel='" + + "',idc='" + + "',zhengzmm='" + + "'where userid='" + uid + "'";cmd=new SqlCommand (sql,conn );();try{();["color"] = "blue";= "编辑成功";("<script>javascript:alert('编辑成功!!!');</script>");}catch(SqlException ){= "编辑失败";["color"] = "red";}();();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";string sqlall = "";uid = ["id"];string strconn = ["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);();try{();string sql1 = "";sql1 = "delete from users where userid='" + uid + "'"; SqlCommand cmd1 = new SqlCommand(sql1, conn); ();try{();["color"] = "blue";= "删除成功";("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){= "删除失败";("<script>javascript:alert('删除失败!!!');</script>"); }finally{sql1 = "";}}catch(SqlException ){= "删除失败";["color"] = "red";}();();= "";= "";= "";= "";= "";= "";= "";= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e) {("");}}九、编辑、删除课程信息程序代码using System;using ;using ;using ;using ;using partial class editcourse : SqlCommand cmd;protected void Page_Load(object sender, EventArgs e){if (!{string sql = "";SqlDataReader reader;string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "select * from course where courseid='" + uid + "'"; SqlCommand cmd;cmd = new SqlCommand(sql, conn);();reader = ();while ()){= reader["courseid"].ToString();= reader["coursename"].ToString();= reader["coursetime"].ToString();= reader["fen"].ToString();= reader["type"].ToString();= reader["teacher"].ToString();}();sql = "";();}}protected void Button1_Click(object sender, Even tArgs e){string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string sql = "";sql = "update course set courseid='" + + "',coursename='" + +"',coursetime='" + + "',fen='" + + "',type='" + + "',teacher='" + + "' where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);();try{();= "编辑成功";("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){= "编辑失败";}();();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = ["id"];string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);sql = "delete from course where courseid='" + uid + "'";cmd = new SqlCommand(sql, conn);();try{();= "删除成功";("<script>javascript:alert('删除成功!!!');</script>"); }catch (SqlException){= "删除失败";}();();= "";= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e) {("");}}十、编辑、删除成绩信息程序代码using System;using ;using ;using ;using ;using partial class editscore : SqlCommand cmd;SqlConnection conn;protected void Page_Load(object sender, EventArgs e) {if (!{string sql = "";SqlDataReader reader;string uid = "";uid = ["id"];string strconn = ["connStr"];conn = new SqlConnection(strconn);sql = "select * from score where id='" + uid + "'"; SqlCommand cmd;cmd = new SqlCommand(sql, conn);();reader = ();while ()){= reader["id"].ToString();= reader["userid"].ToString();= reader["username"].ToString();= reader["courseid"].ToString();= reader["coursename"].ToString();= reader["score"].ToString();}();sql = "";();}}protected void Button1_Click(object sender, EventArgs e){string uid = "";uid = ["id"];string sql = "";string strconn = ["connStr"];conn = new SqlConnection(strconn);sql = "update score set userid='" + + "',username='" + + "',courseid='" + + "',coursename='" + + "',score='" + + "',[year]='" + + "'where id='" + uid + "'";cmd = new SqlCommand(sql,conn );();try{();= "编辑成功";("<script>javascript:alert('编辑成功!!!');</script>");}catch (SqlException){= "编辑失败";}();();}protected void Button2_Click(object sender, EventArgs e){string sql = "";string uid = "";uid = ["id"];string strconn = ["connStr"];conn = new SqlConnection(strconn);sql = "delete from score where id='" + uid + "'";cmd = new SqlCommand(sql, conn);();try{();= "删除成功";("<script>javascript:alert('删除成功!!!');</script>");}catch (SqlException){= "删除失败";}();();= "";= "";= "";= "";}protected void Button3_Click(object sender, EventArgs e){("");}protected void userid_SelectedIndexChanged(object sender, EventArgs e) {string strconn = ["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select username from students where userid='" + + "'";cmd = new SqlCommand(sqlstr, conn);();SqlDataReader da;da = ();while ()){= da["username"].ToString();}}protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);string sqlstr = "";sqlstr = "select coursename from course where courseid='" + + "'";();cmd = new SqlCommand(sqlstr, c onn);();SqlDataReader da;da = ();while ()){= da["coursename"].ToString();}}}十一、修改密码程序代码using System;using ;using ;using ;using partial class modify_pwd : Sql Connection conn; protected void Page_Load(object sender, EventArgs e){string strconn = ["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 == ""){= "原密码不能为空";}else if == ""){= "新密码不能为空";}else if !={= "新密码和确认密码不一致";}else if != pwd)= "原密码不正确";}else{sql = "";sql = "update users set userpwd='" + + "'where userid='" + uid + "'"; cmd = new SqlCommand(sql, conn);();try{();= "密码修改成功";}catch (SqlException){= "密码修改失败";}finally{();}}}protected void Button2_Click(object sender, EventArgs e){("");}}十二、学生身份操作主界面程序代码using System;using ;using ;using ;using ;using partial class student : protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];SqlConnection conn = new SqlConnection(strconn);string strsql = "";string a = Session["userid"].ToString();();strsql = "select * from students where userid='"+a+"'";DataSet ds=new DataSet () ;SqlDataAdapter da= new SqlDataAdapter(strsql, conn);(ds);if [0]. == 0){Response .Write ("没有记录");}else{= [0].Rows[0]["userid"].ToString();= [0].Rows[0]["username"].ToString();= [0].Rows[0]["sex"].ToString();= [0].Rows[0]["minzu"].ToString();= DateTime .Parse [0].Rows[0]["birthday"].ToString()).ToShortDateString ();= [0].Rows[0]["class"].ToString();= [0].Rows[0]["comefrom"].ToString();= [0].Rows[0]["beizhu"].ToString();}();}}十三、学生身份成绩信息程序代码using System;using ;using ;using ;using ;using partial class score : SqlConnection conn;protected void Page_Load(object sender, EventArgs e){string strconn = ["connStr"];conn = new SqlConnection(strconn);SqlDataReader getdata;SqlDataAdapter da = new SqlDataAdapter();SqlCommand mycmd;DataSet ds = new DataSet();string Sql;Sql = "select * from score where userid='" + Session["user id"] + "'"; mycmd = new SqlCommand(Sql, conn);= mycmd;(ds, "login");();// getdata = ();// = getdata;= ["login"]; ;();();}protected void Button1_Click(object sender, EventArgs e){= 0;SqlDataReader getdata;SqlDataAdapter da = new SqlDataAdapter();SqlCommand mycmd;DataSet ds = new DataSet();string Sql;Sql = "select * from score where userid='" + + "'or year='" + + "'"; mycmd = new SqlCommand(Sql, conn);= mycmd;(ds, "login");();//getdata = ();// = getdata;= ["login"]; ;();();}protected void datagrid1_PageIndexC hanged(object source, DataGridPageChangedEventArgs e){= ;();}}。

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>总结通过上述的设计和实现,我们成功地创建了一个简单的学生信息管理系统。

全面学生信息管理系统代码.doc

全面学生信息管理系统代码.doc

主要代码如下: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 '查询用户表。

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

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

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

学生信息管理系统c语言版源代码#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 1000typedef struct student {int number;char name[20];int grade;int gaoshu;int yingyu;int jisuanji;int sum;}STUDENT;STUDENT student[N]; int shuliang=0;void menu();void fhzjm(){char biaozhi[20];printf("\n");printf("还需要操作么,如果需要操作请输入:yes,否则请输入:no\n");scanf("%s",biaozhi);if(strcmp(biaozhi,"yes")==0){menu();}else if(strcmp(biaozhi,"no")==0)exit(0);else{printf("请输入正确的字符,谢谢~\n"); fhzjm();}}void DengJi(){int rs;int i,k=1;system("CLS");printf("请输入需要输入几个学生信息:"); scanf("%d",&rs);for(i=shuliang;i<shuliang+rs;i++,k++) {printf("请输入第%d个学生的学号:",k); scanf("%d",&student[i].number);printf("请输入学生的姓名:");scanf("%s",student[i].name);printf("请输入学生3门课的成绩:"); printf("请输入第1门课的成绩:");scanf("%d",&student[i].gaoshu);printf("请输入第2门课的成绩:");scanf("%d",&student[i].yingyu);printf("请输入第3门课的成绩:");scanf("%d",&student[i].jisuanji);}shuliang=shuliang+rs;fhzjm();}void ShanChu(){char shanchuinfo[10];system("CLS");printf("删除全部学生信息请输入\"all\",删除指定学号的学生信息请输入\"one\"\n");scanf("%s",shanchuinfo);if(strcmp(shanchuinfo,"all")==0){int j;printf("你删除的学生信息如下:\n");printf("-----------学号-------------姓名-------------高数--------------英语--------------计算机\t\n");for(j=0;j<shuliang;j++)printf("----%d-------%s-------%d-------%d-------%d\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].jisuanji);shuliang=0;printf("删除成功\n\n");}else if(strcmp(shanchuinfo,"one")==0){struct student *p=NULL;int choice;int i,j,k=0;printf("请输入你要删除的人的学号:");scanf("%d",&choice);for(i=0;i<shuliang;i++){if(choice==student[i].number){k=1;j=i;break;}}if(k){if(shuliang==1){p=&student[0];free(p);shuliang=0;}else{for(i=j;i<shuliang;i++) {student[i]=student[i+1];}shuliang=shuliang-1;}printf("删除成功\n\n");}else{printf("输入数据错误~\n"); }}fhzjm();}void LiuLan(){int i;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");}else{for(i=0;i<shuliang;i++){printf("第%d个学生的学号为:%d\n",i+1,student[i].number);printf("第%d个学生的姓名为:%s\n",i+1,student[i].name);printf("第%d个学生的第一门课的成绩为:%d\n",i+1,student[i].gaoshu);printf("第%d个学生的第二门课的成绩为:%d\n",i+1,student[i].yingyu);printf("第%d个学生的第三门课的成绩为:%d\n",i+1,student[i].jisuanji);student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("第%d个学生的总成绩为:%d\n",i+1,student[i].sum);}}fhzjm();}void ChaZhao(){int xx;char choice,yy[20];int i,j,k=0;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");fhzjm();}printf("三种查找方式:学号,姓名,成绩\n");printf("如果按学号查找请输1,如果按姓名查找请输2,如果按成绩查找请输3\n");printf("请输入您查找的方式:");scanf("%s",&choice);if(choice=='1'){printf("请输入需要查找学生的学号:");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].number){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='2'){printf("请输入需要查找学生的姓名:\n");scanf("%s",yy);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(strcmp(yy,student[i].name)==0){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[j].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='3'){printf("请输入需要查找学生的成绩:\n");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数----英语----计算机----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].grade){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}fhzjm();}void PaiXu(){struct student *p1[N],**p2,*temp;int i,j;system("CLS");p2=p1;for( i=0;i<shuliang;i++){p1[i]=student+i;}for( i=0;i<shuliang;i++){for( j=i+1;j<shuliang;j++){if((*(p2+i))->sum<(*(p2+j))->sum){temp=*(p2+i);*(p2+i)=*(p2+j);*(p2+j)=temp;} }}printf("按照总成绩排序之后的信息为:\n");printf("----学号----姓名----总成绩----\t\n");for( i=0;i<shuliang;i++){student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("----%d-----%s----%d-----\n",(*(p2+i))->number,(*(p2+i))->name,(*(p2+i))->sum);}fhzjm();}void CunChu(){int i;FILE *rs;if((rs=fopen("student.txt","w"))==NULL){printf("not open");exit(0);}for(i=0;i<shuliang;i++){fwrite(&student[i], sizeof(student[i]), 1, rs); }if(ferror(rs)){fclose(rs);perror("写文件失败~\n");return;}printf("存储文件成功~\n");fclose(rs);fhzjm();}void DaoChu(){struct student t;int i=0;FILE* fp = fopen("student.txt", "r");shuliang=0;if(NULL==fp){perror("读取文件打开失败~\n");return;}memset(student,0x0,sizeof(student));while(1){fread(&t,sizeof(t),1,fp);if(ferror(fp)){fclose(fp);perror("读文件过程失败~\n");return;}if(feof(fp)){break;}student[i]=t;i++;}fclose(fp);shuliang=i; printf("导出文件成功~\n"); fhzjm();}void menu(){int n=0;system("CLS");printf(" 学生信息管理系统\n");printf(" 作者:陈椿\n");printf("-------------------MENU-----------------\n"); printf(" 1.登记学生信息\n");printf(" 2.删除学生信息\n");printf(" 3.浏览所有已经登记的学生\n");printf(" 4.查找\n");printf(" 4.1按学号查找\n");printf(" 4.2按姓名查找\n");printf(" 4.3按成绩查找\n");printf(" 5.根据总成绩排序\n");printf(" 6.存储到文件\n");printf(" 7.从文件导出\n");printf(" 8.退出系统\n");a: printf(" 请选择:");scanf("%d",&n);switch (n){case 1:DengJi();break;case 2:ShanChu();break;case 3:LiuLan();break;case 4:ChaZhao();break;case 5:PaiXu();break;case 6:CunChu();break;case 7:DaoChu();break;case 8:exit(0);break;default:{printf("请输入1-8之间的数字,谢谢~\n"); goto a;}}}main() {menu();}。

python学生信息管理系统(完整版)

python学生信息管理系统(完整版)

python学⽣信息管理系统(完整版)本⽂是基于上⼀篇()进⾏了完善,并添加了新的功能。

主要包括有:完善部分:输⼊错误;⽆数据查询等异常错误新的功能:⽂件的操作:⽂件的读写,其中重点是对⽂本字符串的详细解析(关于整个解析拆解和重组详见代码,以及添加了注释)学⽣信息管理系统(完整版)学⽣信息管理项⽬,要求带操作界⾯,并完成每项操作:+----------------------+| 1)添加学⽣信息 || 2)显⽰所有学⽣的信息 || 3)删除学⽣信息 || 4)修改学⽣信息 || 5)按学⽣成绩⾼-低显⽰学⽣信息 || 6)按学⽣成绩低-⾼显⽰学⽣信息 || 7)按学⽣年龄⾼-低显⽰学⽣信息 || 8)按学⽣年龄低-⾼显⽰学⽣信息 ||9)保存学⽣信息到⽂件(students.txt) ||10)从⽂件中读取数据(students.txt) ||退出:其他任意按键<回车>|+----------------------+详细代码如下:# student_info.py# 学⽣信息管理项⽬,要求带操作界⾯,并完成每项操作:# +----------------------+# | 1)添加学⽣信息 |# | 2)显⽰所有学⽣的信息 |# | 3)删除学⽣信息 |# | 4)修改学⽣信息 |# | 5)按学⽣成绩⾼-低显⽰学⽣信息 |# | 6)按学⽣成绩低-⾼显⽰学⽣信息 |# | 7)按学⽣年龄⾼-低显⽰学⽣信息 |# | 8)按学⽣年龄低-⾼显⽰学⽣信息 |# |9)保存学⽣信息到⽂件(students.txt) |# |10)从⽂件中读取数据(students.txt) |# |退出:其他任意按键<回车>|# +----------------------+ |def meun():menu_info = '''+----------------------+|1)添加学⽣信息||2)显⽰所有学⽣的信息||3)删除学⽣信息||4)修改学⽣信息||5)按学⽣成绩⾼-低显⽰学⽣信息||6)按学⽣成绩低-⾼显⽰学⽣信息||7)按学⽣年龄⾼-低显⽰学⽣信息||8)按学⽣年龄低-⾼显⽰学⽣信息||9)保存学⽣信息到⽂件(students.txt) ||10)从⽂件中读取数据(students.txt) ||退出:其他任意按键<回车>|+----------------------+'''print(menu_info)# 以下⼆个函数⽤于sorted排序, key的表达式函数def get_age(*l):for x in l:return x.get("age")def get_score(*l):for x in l:return x.get("score")# 1)添加学⽣信息def add_student_info():L = []while True:n = input("请输⼊名字:")if not n: # 名字为空 跳出循环breaktry:a = int(input("请输⼊年龄:"))s = int(input("请输⼊成绩:"))except:print("输⼊⽆效,不是整形数值....重新录⼊信息")continueinfo = {"name":n,"age":a,"score":s}L.append(info)print("学⽣信息录⼊完毕")return L# 2)显⽰所有学⽣的信息def show_student_info(student_info):if not student_info:print("⽆数据信息.....")returnprint("名字".center(8),"年龄".center(4),"成绩".center(4))for info in student_info:print(info.get("name").center(10),str(info.get("age")).center(4),str(info.get("score")).center(4)) # 3)删除学⽣信息def del_student_info(student_info,del_name = ''):if not del_name:del_name = input("请输⼊删除的学⽣姓名:")for info in student_info:if del_name == info.get("name"):return inforaise IndexError("学⽣信息不匹配,没有找到%s" %del_name)# 4)修改学⽣信息def mod_student_info(student_info):mod_name = input("请输⼊修改的学⽣姓名:")for info in student_info:if mod_name == info.get("name"):a = int(input("请输⼊年龄:"))s = int(input("请输⼊成绩:"))info = {"name":mod_name,"age":a,"score":s}return inforaise IndexError("学⽣信息不匹配,没有找到%s" %mod_name)# 5)按学⽣成绩⾼-低显⽰学⽣信息def score_reduce(student_info):print("按学⽣成绩⾼-低显⽰")mit = sorted(student_info ,key = get_score,reverse = True)show_student_info(mit)# 6)按学⽣成绩低-⾼显⽰学⽣信息def score_rise(student_info):print("按学⽣成绩低-⾼显⽰")mit = sorted(student_info ,key = get_score)show_student_info(mit)# 7)按学⽣年龄⾼-低显⽰学⽣信息def age_reduce(student_info):print("按学⽣年龄⾼-低显⽰:")mit = sorted(student_info ,key = get_age,reverse = True)show_student_info(mit)# 8)按学⽣年龄低-⾼显⽰学⽣信息def age_rise(student_info):print("按学⽣年龄低-⾼显⽰:")mit = sorted(student_info ,key = get_age)show_student_info(mit)# 9)保存学⽣信息到⽂件(students.txt)def save_info(student_info):try:students_txt = open("students.txt","w") # 以写模式打开,并清空⽂件内容except Exception as e:students_txt = open("students.txt", "x") # ⽂件不存在,创建⽂件并打开for info in student_info:students_txt.write(str(info)+"\n") # 按⾏存储,添加换⾏符students_txt.close()# 10)从⽂件中读取数据(students.txt)def read_info():old_info = []try:students_txt = open("students.txt")except:print("暂未保存数据信息") # 打开失败,⽂件不存在说明没有数据保存returnwhile True:info = students_txt.readline()if not info:break# print(info)info = info.rstrip() # 去掉换⾏符# print(info)info = info[1:-1] # 去掉{}# print(info)student_dict = {} # 单个学⽣字典信息for x in info.split(","): # 以,为间隔拆分# print(x)key_value = [] # 开辟空间,key_value[0]存key,key_value[0]存valuefor k in x.split(":"): # 以:为间隔拆分k = k.strip() # 去掉⾸尾空字符# print(k)if k[0] == k[-1] and len(k) > 2: # 判断是字符串还是整数key_value.append(k[1:-1]) # 去掉 ⾸尾的'else:key_value.append(int(k))# print(key_value)student_dict[key_value[0]] = key_value[1] # 学⽣信息添加# print(student_dict)old_info.append(student_dict) # 所有学⽣信息汇总students_txt.close()return old_infodef main():student_info = []while True:# print(student_info)meun()number = input("请输⼊选项:")if number == '1':student_info = add_student_info()elif number == '2':show_student_info(student_info)elif number == '3':try:student_info.remove(del_student_info(student_info))except Exception as e:# 学⽣姓名不匹配print(e)elif number == '4':try:student = mod_student_info(student_info)except Exception as e:# 学⽣姓名不匹配print(e)else:# ⾸先按照根据输⼊信息的名字,从列表中删除该⽣信息,然后重新添加该学⽣最新信息 student_info.remove(del_student_info(student_info,del_name = student.get("name"))) student_info.append(student)elif number == '5':score_reduce(student_info)elif number == '6':score_rise(student_info)elif number == '7':age_reduce(student_info)elif number == '8':age_rise(student_info)elif number == '9':save_info(student_info)elif number == '10':student_info = read_info()else:breakinput("回车显⽰菜单")main()关于管理系统的更多内容请点击进⾏学习以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

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

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

学生信息管理系统(简单版)源代码#include#include#include#include#define NUll 0#define LEN sizeof(struct student)struct student{int number;char name[10];float score;struct student *next;};/*函数说明*/struct student * creat(); /*创建链表*/void print(struct student *head); /*输出学生信息*/struct student *add(struct student *head); /*添加学生信息*/ struct student * sort(struct student *head); /*对学生信息进行排序*/struct student * insert(struct student *head); /*插入学生信息*/struct student * del_num(struct student *head); /*删除学生信息*/void search(struct student *head); /*查找学生信息*/struct student * change(struct student *head); /*修改学生信息*/int n;int main(){int num,x;char a[5];struct student *head0,*head,*head1; head=NUll;A :printf(" 学生信息系统 \n");printf("1.建立链表\n");printf("2.添加学生\n");printf("3.插入学生\n");printf("4.删除学生\n");printf("5.查找学生\n");printf("6.修改学生\n");printf("7.数据浏览\n");printf("0.退出程序\n");printf("请选择操作(输入0—7):"); scanf("%d",&num);switch(num){case 1:head=creat();break;case 2:head=add(head);head=sort(head);print(head);break;case 3:head1=insert(head);head1=sort(head1);print(head1);break;case 4:head1=del_num(head);print(head1);break;case 5:search(head);break;case 6:head1=change(head);print(head1);break;case 7:print(head);break;case 0:return 0;default :printf("输入错误的数字!!请再输一次!\07\n"); }goto A;scanf("%d",&x);return 0;}//创建链表struct student * creat(){struct student *head,*p1,*p2;n=0;head=(struct student*)malloc(LEN); if(head!=NULL){printf("空链表已建立!\n");}else{printf("没有足够的内存空间!\07\n"); }head->number=0;strcpy(head->name,"");head->score=0;return head;}//输出学生信息void print(struct student *head) {struct student *p;if(head==NULL){printf("未建立链表!!\n"); return;}p=head->next;printf("\n所有学生信息的显示为:\n");do{printf("学号:%d\t姓名:%s\t分数:%.2f\n",p->number,p->name,p->score);p=p->next;}while(p!=NUll);}//添加学生信息struct student *add(struct student *head){struct student *p1,*p2;if(head==NULL){printf("未建立链表!!\n");return NULL;}p1=head;while(1){p2=(struct student *)malloc(LEN);if(p2==NULL){printf("没有足够的空间!\07\n");return 0;}printf("学号(输入0结束):");scanf("%d",&p2->number);if(p2->number==0){break;}printf("姓名:");scanf("%s",&p2->name);printf("分数:");scanf("%f",&p2->score);n=n+1;//p2->next=NULL;p1->next=p2;p1=p2;}p1->next=NULL;return head;}//对学生信息进行排序struct student * sort(struct student *head) {int t1;float t2;struct student *p1,*p2;if(head==NULL){printf("未建立链表!!\n");return NULL;}p1=head;p2=head->next;for(int i=1;i<n;i++){p1=head->next;p2=p1->next;do{if((p1->number)<(p2->number)){t1=p1->number;t2=p1->score;p1->number=p2->number;p1->score=p2->score;p2->number=t1;p2->score=t2;}p2=p1;p1=p1->next;}while(p1!=NULL);}printf("自动排序……");return head;}//插入学生信息struct student * insert(struct student *head) {struct student *p1,*p2,*stu;if(head==NULL){printf("未建立链表!!\n"); return NULL;}while(1){p1=head->next;p2=p1;stu=(struct student *)malloc(LEN); if(stu==NULL){printf("没有足够的空间!\07\n"); return 0;}printf("\n学号(输入0结束):"); scanf("%d",&stu->number);if(stu->number==0){break;}printf("姓名:");scanf("%s",&stu->name);printf("分数:");scanf("%f",&stu->score);n=n+1;if(stu->numbernumber){stu->next=p1;head->next=stu;}else{while((stu->number)>(p1->number)&&p1!=NULL) {p2=p1;p1=p1->next;}if((stu->number)<=(p1->number)){p2->next=stu;stu->next=p1;}else{p1=stu;stu->next=NULL;}}}return head;}//删除学生信息struct student * del_num(struct student *head) {struct student *p1,*p2;if(head==NULL){printf("未建立链表!!\n");return NULL;}int num;while(1){printf("学号(输入0结束):"); scanf("%d",&num);if(num==0){break;}p1=head;if(num==head->number){head=p1->next;}else{do{p2=p1;p1=p1->next;if(num==p1->number){printf("\n已找到要删除的学生!\n"); p2->next=p1->next;printf("删除完成!\n");n=n-1;break;}}while(p1->next!=NULL);}}return head;}//查找学生信息void search(struct student *head) {int num;struct student *p1;if(head==NULL){printf("未建立链表!!\n"); return;}p1=head->next;while(1){printf("学号(输入0结束):"); scanf("%d",&num);if(num==0){break;}do{if(num==p1->number){printf("该生信息已找到!\n其学号为:%d,姓名为:%s成绩为:%.2f\</n;i++)n",p1->number,p1->name,p1->score);break;}p1=p1->next;if(p1==NULL){printf("未找到学号为%d的相关信息!!\n",num);}}while(p1!=NULL);}}//修改学生信息struct student * change(struct student *head){int num;float score1;struct student *p1;if(head==NULL){printf("未建立链表!!\n");return NULL;}p1=head;printf("学号(输入0结束):\t");scanf("%d",&num);do{if(num==p1->number){printf("已找到学号为%d的同学。

学生信息管理系统源代码

学生信息管理系统源代码

#include "conio.h"#include <stdio.h>#include<stdlib.h>#define MAX 30/*日期结构体类型*/typedef struct{int year;int month;int day;}DATE;/*学生结构体类型*/typedef struct{int num;char name[10];char sex[10];DATE birthday;int score ;}STU;int read_file(STU students[]){ FILE*fp;int i=0;if((fp=fopen("lab.txt","rt"))==NULL) {printf("\n\n*****库文件不存在!请重建");return 0;}while(feof(fp)!=1){fread(&students[i],sizeof(STU),1,fp);if(students[i].num==0)break;elsei++;}fclose(fp);return i;}void save_file(STU students[],int sum){ FILE *fp;int i;if((fp=fopen("lab.txt","wb"))==NULL) { printf("读文件错误!\n");return;}for(i=0;i<sum;i++)if(fwrite(&students[i],sizeof(STU),1,fp)!=1) printf("写文件错误!\n");fclose(fp);}/*输入模块*/int input(STU students[]){int i=0,sum;system("cls");printf("\n\n 录入学生个数\n\n");scanf("%d",&sum);printf("\n\n 录入学生信息\n",MAX);printf("\n\n ----------------------\n") ;for(i=0;i<sum;i++){ printf("\n第%d个人",i+1) ;printf("\n\n 学号");scanf("%d",&students[i].num) ;printf("\n\n 姓名") ;scanf("%s",&students[i].name);printf("\n\n 性别");scanf("%s",&students[i].sex);printf("\n\n 出生日期") ;printf("\n\n 年");scanf("%d",&students[i].birthday.year);printf("\n\n 月");scanf("%d",&students[i].birthday.month);printf("\n\n 日");scanf("%d",&students[i].birthday.day);printf("\n\n 成绩");scanf("%d",&students[i].score );}printf("\n---%d个学生信息输入完毕---\n",i);printf("---按任意键返回主菜单---") ;return i;}/*输出模块*/void output(STU students[],int sum){system("cls");{ int i=0;for(i=0;i<sum;i++){printf("\n -------学生信息------- \n");printf("学号姓名性别出生日期成绩\n");printf("------------------------------- \n");printf("%4d %10s %8s %15d-%2d-%2d %3d\n",students[i].num,students[i].name,students[i].sex,students[i].birthday.year,students[i].birthday.month,students[i].birthday.day,students[i].score );}}printf("按任意键返回主菜单\n");getch();}/*添加模块*/int append(STU students[],int sum){ system("cls");{int i,j;printf("请输入要添加的学生数量:\n");scanf("%d",&j);for(i=sum;i<sum+j;i++){ printf("---按格式输入提示内容:\n");printf("请输入学号:\n");scanf("%d",&students[i].num);printf("请输入姓名:\n");scanf("%s", &students[i].name );printf("请输入性别:\n");scanf("%s",&students[i].sex);printf("请输入出生日期:\n");scanf("%d-%d-%d",&students[i].birthday.year,&students[i].birthday.month,&students[i].birthday.day);printf("请输入成绩:\n") ;scanf ("%d",students[i].score );}printf("%d本信息输入完毕",i);printf("学号姓名性别出生日期成绩\n");printf("------------------------------- \n");printf("%4d %10s %8s %15d-%2d-%2d %3d\n",students[i].num,students[i].name,students[i].sex,students[i].birthday.year,students[i].birthday.month,students[i].birthday.day,students[i].score );printf("按任意键返回主菜单\n");sum=sum+j;return(sum);}}/*修改模块*/void modify(STU students[],int sum){ int i=0,choice,modify_num,flag;do{system("cls") ;printf("\n输入要修改的学生学号\n") ;scanf("%d",&modify_num);for(i=0;i<sum;i++)if(students[i].num==modify_num){printf("\n -------学生信息------- \n");printf("学号姓名性别出生日期成绩\n");printf("------------------------------- \n");printf("%4d %6s %4s %10d-%2d-%2d %6d\n",students[i].num,students[i].name,students[i].sex,students[i].birthday.year,students[i].birthday.month,students[i].birthday.day,students[i].score );printf(" \n 您要修改那一项\n ");printf(" \n 1 学号\n ");printf(" \n 2 姓名\n ");printf(" \n 3 性别\n ");printf(" \n 4 出生日期\n ");printf(" \n 5 成绩\n ");printf(" \n 请选择(1-4): \n ");scanf ("%d",&choice);switch(choice){case 1:printf("\n 输入修改后的学号:");scanf("%d",&students[i].num); break;case 2:printf("\n 输入修改后的姓名:");scanf("%s",&students[i].name); break;case 3:printf("\n 输入修改后的性别:");scanf("%s",&students[i].sex); break;case 4:printf("\n 输入修改后的出生日期");scanf("%d-%d-%d",&students[i].birthday.year,&students[i].birthday.month,&students[i].birthday.day); break;case 5:printf("\n 输入修改后的成绩:");scanf("%d",&students[i].score); break;}printf("\n -------该学生信息------- \n");printf("学号姓名性别出生日期成绩\n");printf("------------------------------- \n");printf("%4d %6s %4s %10d-%2d-%2d %6d\n",students[i].num,students[i].name,students[i].sex,students[i].birthday.year,students[i].birthday.month,students[i].birthday.day,students[i].score );break;}if(i==sum){printf("\n 该学号不存在" );// bioskey(0);}printf("\n\n 继续修改吗?(Y/N) ");choice=getch();if(choice=='Y'||choice=='y'){flag=1;printf("\n 继续!\n");}else flag=0;}while(flag==1);printf("\n---按任意键返回主菜单---\n");//bioskey(0);}/*删除模块*/void del(STU students[],int sum)int j;int del_num;system("cls") ;printf("\n输入要删除的学生学号\n") ;scanf("%d",&del_num);for(i=0;i<sum;i++)if(students[i].num==del_num) break;for(j=i;j<sum;j++)students[j] =students[j+1];}/*查询模块*/void inquire(STU students[],int sum){ int i=0,choice,inquire_num,flag;do{ system("cls") ;printf("\n输入要查询的学生学号\n") ;scanf("%d",&inquire_num);for(i=0;i<sum;i++)if(students[i].num==inquire_num){ printf("\n -------该学生信息------- \n");printf("学号姓名性别出生日期成绩\n");printf("------------------------------- \n");printf("%4d %6s %4s %10d-%2d-%2d %6d\n",students[i].num,students[i].name,students[i].sex,students[i].birthday.year,students[i].birthday.month,students[i].birthday.day,students[i].score ); break;}if(i==sum){printf("\n 该学号不存在" );//bioskey(0);}printf("\n\n 继续查询吗?(Y/N) ");choice=getch();if(choice=='Y'||choice=='y'){flag=1;printf("\n 继续!\n");else flag=0;}while(flag==1);printf("\n---按任意键返回主菜单---\n");//bioskey(0);}/*排序模块*/void sort(STU students[],int sum){STU t;int i,j,k;system("cls") ;printf("\n------------------库行排名--------------------------\n");printf("\n----------------------------------------------------\n");printf("\n 排名学号姓名性别出生日期\n ") ;for(i=0;i<sum;i++){ k=i;for(j=i+1;j<sum;j++)if (students[i].score>students[j].score) k=j;if (k!=i){t=students[i];students[i]=students[k];students[k]=t;}}output(students, sum);//bioskey(0);}void main(){ STU students[MAX];int choice,sum;sum=read_file(students);if(sum==0){ printf("****并录入基本库存信息!****\n");getch();sum=input(students);}do{system("cls");printf("\n\n\n ****学生管理系统*****\n\n") ; printf(" 1 添加学生信息\n\n") ;printf(" 2 修改学生信息\n\n") ;printf(" 3 删除学生信息\n\n") ;printf(" 4 打印学生信息\n\n") ;printf(" 5 查询学生信息\n\n") ;printf(" 6 排序学生信息\n\n") ;printf(" 0 退出系统\n\n\n") ;printf(" 请选择(0-6):") ;scanf("%d",&choice) ;switch (choice){case 1:sum=append(students,sum); break;case 2:modify(students,sum); break;case 3:del(students,sum); break;case 4:output(students,sum); break;case 5:inquire(students,sum);break;case 6:sort(students,sum); break;case 0: break;}}while(choice!=0);save_file(students,sum);}。

学生信息管理系统(完整代码、数据库、图片)

学生信息管理系统(完整代码、数据库、图片)

《Java应用开发》课程设计报告题目:学生信息管理系统指导老师:***姓名:**专业:计算机科学与技术班级: 10级1班日期:2012年6月目录一、系统总体设计 (3)(一)设计目标及完成功能 (3)(二)系统流程图 (4)二、详细设计 (5)(二)系统设计 (9)(三)源代码及技术 (12)三、使用与测试 (42)四、数据库设计 (43)总结(体会) (44)参考文献 (45)一、系统总体设计(一)设计目标及完成功能1、设计目标学生信息管理系统是学校的一项重要数据资源,因而学生信息管理必然成为学校的一项常规性的重要工作.加强学生信息管理在单纯依靠以手工管理的方法,不仅需要耗用大量的人力、物力、财力,而且由于人工管理存在着大量的不可控因素,造成了信息管理的某些不规范,工作效率低,难以达到预期的目的。

为提高工作效率、保证学校能够及时准确了解各学生的各种信息及学生总体信息,开发学生信息管理系统。

2、完成功能完成学生信息的基本管理.本系统分为管理员和学生管理两部分。

管理员管理项目如下:添加学生信息、修改学生信息、查询学生信息、删除学生信息;学生管理项目如下:添加学生信息、查询学生信息.(二)系统流程图二、详细设计图2-1 登陆界面1图2—2 登陆界面2图2—3 系统主界面图2—4 添加学生信息界面图2—5 修改学生信息界面图2—6 查询学生信息界面图2—7 删除学生信息界面图2-8 系统信息界面图2—9 我的信息界面(二)系统设计1、系统结构图学生信息管理系统学生登陆管理员登陆添加学生信息查询学生信息添加学生信息修改学生信息查询学生信息删除学生信息2、类及功能列表(三) 源代码及技术1、所有代码student.mdf -数据库将以下图片以上图名称存入images文件夹目录下。

要自己将各代码新建为.java格式文件,放在与images文件夹同目录下.并将数据库附加到sqlserver2005,再不需要任何改动方可运行.①登陆界面1import java。

C语言学生信息管理系统(完整版)

C语言学生信息管理系统(完整版)

#define PRINT0 printf("name:%s\nsex:%s\nage:%d\nID_card:%d\naddress:%s\n",st[i].name,st[i].sex,st[i].age,st[i] .ID_card,st[i].addr)#define PRINT1 printf("prefession:%s\nstudent_number:%d\n*****score*****\nwuli:%d\n",st[i].prefession,st[i] .student_number,st[i].score.wuli)#define PRINT2 printf("gaoshu:%d\nyingyu:%d\ntiyu:%d\naverage: %d\n",st[i].score.gaoshu,st[i].score.yingyu,st[i ].score.tiyu,st[i].score.aver)#define print1 printf("________________________________")#define N 2#include "string.h"#include "stdio.h"int sum=0;struct score{int wuli;int gaoshu;int yingyu;int tiyu;int aver;};struct message{ char name[10];int age;char sex[5];int ID_card;char addr[30];char prefession[30];int student_number;struct score score;}st[100];/*************write message*************/write_message(){ int flag;char chioce;do{system("cls");flag=2; sum++;printf("_______________________________");printf("please input student's message:\n");printf("\n");print1;printf("%dth student message:",sum);print1;printf("\nname:");scanf("%s",st[sum].name);printf("\nsex:");scanf("%s",st[sum].sex);printf("\nage:");scanf("%d",&st[sum].age);printf("\nID_card:");scanf("%d",&st[sum].ID_card);printf("\naddress:");scanf("%s",st[sum].addr);printf("\nprefession:");scanf("%s",st[sum].prefession);printf("\nschool number:");scanf("%d",&st[sum].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[sum].score.wuli);printf("\ngaoshu:");scanf("%d",&st[sum].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[sum].score.yingyu);printf("\ntiyu:");scanf("%d",&st[sum].score.tiyu);printf("\naverage:");scanf("%d",&st[sum].score.aver);do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*************save message****************/save_message(){ FILE *fp;int i;if((fp=fopen("student.txt","wb"))==NULL){printf("read error \n");printf("press any key back to menu\n");getch();exit(1);}for(i=0;i<sum;i++)if(fwrite(&st[i],sizeof(struct message),1,fp)!=1){printf("write error\n");fclose(fp);}fclose(fp);printf("\n********___OK!___**********\n___press any key back___");sum=i;bioskey(0);}/***************add message*****************/add_message(){int i,j,flag; char chioce;i=0;j=sum-1;flag=0;do{ system("cls");i++; j++;print1;printf("add %dth student's meaasge\n",i);print1;printf("\nname:");scanf("%s",st[j].name);printf("\nsex:");scanf("%s",st[j].sex);printf("\nage:");scanf("%d",&st[j].age);printf("\nID_card:");scanf("%d",&st[j].ID_card);printf("\naddress:");scanf("%s",st[j].addr);printf("\nprefession:");scanf("%s",st[j].prefession);printf("\nstudent_number:");scanf("%d",&st[j].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[j].score.wuli);printf("\ngaoshu:");scanf("%d",&st[j].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[j].score.yingyu);printf("\ntiyu:");scanf("%d",&st[j].score.tiyu);printf("\naverage:");scanf("%d",&st[j].score.aver);printf("\n\nweather add %dth student's message: \n",i+1);do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;}while(1);}while(flag==1);sum=j+1;save_message();}/**********inqiure message******/inqiure_message(){int chioce;do{system("cls");printf("**********choose 0-3**********\n\n\n");printf(" 1:name inquire\n\n\n");printf(" 2:IDcard inqiure\n\n\n");printf(" 3:student_number\n \n\n");printf(" 0:back menu\n\n\n");scanf("%d",&chioce);switch(chioce){case 1: name_inqiure();break;case 2: ID_card_inqiure();break;case 3: grade_inqiure();break;case 0:break;}}while(chioce!=0);}/**********name inqiure*********/name_inqiure(){char NAME[30];int i; int flag,k;char chioce;do{ system("cls");k=0;printf("please input the message you inqiure");printf("\nname:");scanf("%s",NAME);getchar();printf("\n");for(i=0;i<sum;i++){if(strcmp(st[i].name,NAME)==0){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/**********IDcard inqiure*********/ID_card_inqiure(){int card;int i; int flag,k;char chioce;do{ clrscr(); k=0;printf("please input the message you inqiure");printf("\nIDcard:");scanf("%d",&card);getchar();printf("\n");for(i=0;i<sum;i++){if(st[i].ID_card==card){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/*********grade inqiure***********/grade_inqiure(){int GRADE;int i; int flag,k;char chioce;do{ system("cls");k=0;printf("please input the message you inqiure");printf("\nstudent_number:");scanf("%d",&GRADE);getchar();printf("\n");for(i=0;i<sum;i++){if(st[i].student_number==GRADE){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/*********change message**********/change_message(){char pre[30],chioce;int i,gra,flag,num,s;s=0;do{system("cls");printf("please input message you want to change\n ");printf("student_number:");scanf("%d",&gra); getchar();for(i=0;i<sum;i++){if(st[i].student_number==gra){PRINT0;PRINT1;PRINT2;printf("\n********input message you want to change********\n");printf("0:name***1:sex***2:age***3:ID_card***4:address***\n5:prefession***6:wuli***7:stud ent_number***8\n:gaoshu***9:yingyu***10:tiyu***11:average***________\n");printf("choose 0-11\n");scanf("%d",&num); getchar();switch(num){case 0: printf("input the name changed\n");scanf("%s",st[i].name); getchar(); break;case 1: printf("input the sex changed\n");scanf("%s",st[i].sex); getchar(); break;case 2: printf("input the age changed\n");scanf("%d",&st[i].age); getchar(); break;case 3: printf("input the ID_card changed\n");scanf("%d",&st[i].ID_card); getchar(); break;case 4: printf("input the address changed\n");scanf("%s",st[i].addr); getchar(); break;case 5: printf("input the prefession changed\n");scanf("%s",st[i].prefession); getchar(); break;case 6: printf("input the wuli_score changed\n");scanf("%d",&st[i].score.wuli); getchar(); break;case7: printf("input the student_number changed\n");scanf("%d",&st[i].student_number); getchar(); break;case 8: printf("input the gaoshu_score changed\n");scanf("%d",&st[i].score.gaoshu); getchar(); break;case 9: printf("input the yingyu_score changed\n");scanf("%d",&st[i].score.yingyu); getchar(); break;case 10: printf("input the tiyu_score changed\n");scanf("%d",&st[i].score.tiyu); getchar(); break;case 11: printf("input the average_score changed\n");scanf("%d",&st[i].score.aver); getchar(); break;default: printf("input error\n"); break;}printf("\n*********the changed message*********\n\n");PRINT0;PRINT1;PRINT2;s=1;}}if(s!=1) printf("without message you want to change\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*********delete message**********/delete_message(){ int GRADE;int i,j,flag1,flag;char chioce1,chioce2;flag1=3;flag=3;do{ system("cls");printf("please input student's student_number you want to delete\n");printf("student_number:");scanf("%d",&GRADE); getchar();for(i=0;i<sum;i++)if(st[i].student_number==GRADE){do{PRINT0;PRINT1;PRINT2;printf("\n******************************\n_________________ _________________\n");printf("press y/Y deleted:\npress n/N cancel:\n");scanf("%c",&chioce1);getchar();system("cls");if(chioce1=='y'||chioce1=='Y') flag1=1;else if(chioce1=='n'||chioce1=='N') return;else {printf("***input error***\n___press any ker return___\n"); bioskey(0);}}while(flag1!=1);for(j=i;j<sum;j++){ st[j]=st[j+1];flag=2;printf("message was deleted\n");sum-=1; }}if(flag!=2) printf("without message you want to delete\n");do{printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce2);printf("****************************\n");if(chioce2=='y'||chioce2=='Y') {flag=1; break;}else if(chioce2=='n'||chioce2=='N') {flag=0; break;}else {system("cls");printf("input error\n");}print1;printf("\n");}while(1);}while(flag==1);save_message();}/************insert message*************/insert_message(){ int chioce,flag,i; flag=2;do{system("cls");printf("please input the number of people you insert\n");scanf("%d",&chioce);if(chioce>=sum){printf("xin xi pai zai zui hou ");chioce=sum;}for(i=sum;i>chioce;i--) st[i]=st[i-1];printf("\nplease input message you insert");printf("\nname:");scanf("%s",st[i].name);printf("\nsex:");scanf("%s",st[i].sex);printf("\nage:");scanf("%d",&st[i].age);printf("\nID_card:");scanf("%d",&st[i].ID_card);printf("\naddress:");scanf("%s",st[i].addr);printf("\nprefession:");scanf("%s",st[i].prefession);printf("\ngrade:");scanf("%d",&st[i].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[i].score.wuli);printf("\ngaoshu:");scanf("%d",&st[i].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[i].score.yingyu);printf("\ntiyu:");scanf("%d",&st[i].score.tiyu);printf("\naverage:");scanf("%d",&st[i].score.aver);sum+=1;do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*********school_number_order***********/grade_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].student_number>st[j].student_number){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("grade order from min to max\n");for(i=0;i<sum;i++){ print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);bioskey(0);}/***********wuli score order***************/wuli_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.wuli>st[j].score.wuli){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("wuli score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********gaoshu score order***************/gaoshu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.gaoshu>st[j].score.gaoshu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("gaoshu score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********yingyu score order***************/yingyu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.yingyu>st[j].score.yingyu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("yingyu score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********tiyu score order***************/tiyu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.tiyu>st[j].score.tiyu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("yitu order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********average score order***************/average_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.wuli>st[j].score.wuli){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("average score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/********order message****************/order_message(){int chioce;do{system("cls");printf("**********choose 0-6**********\n\n");printf(" 1:grade order\n\n");printf(" 2:wuli score order\n\n");printf(" 3:gaoshu score order\n \n");printf(" 4:ying yu score order\n\n");printf(" 5:tiyu score order\n\n");printf(" 6:average score order\n\n");printf(" 0:back menu\n\n");scanf("%d",&chioce);switch(chioce){case 1: grade_order();break;case 2: wuli_order();break;case 3: gaoshu_order();break;case 4: yingyu_order();break;case 5: tiyu_order();break;case 6: average_order();break;case 0:break;}}while(chioce!=0);}/**********answer secretory***********/mima_message(){int flag;char answer[10];char secret[10]="abcd";flag=2;do{system("cls");printf("\n______________________mi ma wei 'abcd'________________\n\n");printf("______________________qing shu ru mi ma:");scanf("%s",answer);getchar();if(strcmp(secret,answer)==0){flag=1;printf("\n\n =====throngh=====\n\n\n");printf("____________________press any key into next:\n");bioskey(0);}else{flag=0;printf("______________________input error:\n");printf("______________________press any key to return:\n");bioskey(0);}}while(flag!=1);}/*********read message****************/read_message(){int i;system("cls");if(sum<=0){ printf("without message\n");getch();return;}for(i=0;i<sum;i++){system("cls");print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;printf("\n********press any key -show the next one********\n ");getch();}printf("________________totle num :%d________________\n",sum); printf("_____________press any key return______________\n"); bioskey(0);}/*************************************/main(){int chioce,flag;mima_message();do{system("cls");chioce=9;printf("**********************************************\n");printf("****welcome to system of managing students****\n");printf("**********************************************\n\n");printf("-------------------choose 0-8-----------------\n\n");printf(" 1:write message\n\n");printf(" 2:add message\n\n");printf(" 3:inqiure name\n\n");printf(" 4:change message\n\n");printf(" 5:insert message\n\n");printf(" 6:order message\n\n");printf(" 7:delete message\n\n");printf(" 8:read messaeg\n\n");printf(" 0:***exit***\n\n");scanf("%d",&chioce);getchar();switch(chioce){case 1: write_message();break;case 2: add_message();break;case 3: inqiure_message();break;case 4: change_message();break;case 5: insert_message();break;case 6: order_message();break;case 7: delete_message();break;case 8: read_message();break;case 0: printf("___sure press y/Y:___\n\n___no sure press n/N:___");scanf("%c",&chioce);getchar();if(chioce=='y'||chioce=='Y') flag=0;else flag=1;break;default : printf("\n ___input error___\n\n");printf("***press any key to go on***\n");getch();break;}}while(flag!=0);save_message();system("cls");printf("\n\n___message was saved___\n\n\n*****file name is student.txt*****\n");bioskey(0);}。

学生信息管理系统c语言数据结构

学生信息管理系统c语言数据结构

学生信息管理系统c语言数据结构以下是一个基于C语言的数据结构实现的学生信息管理系统示例:```cinclude <>include <>include <>// 定义学生结构体struct Student {char name[20];int age;int id;};// 定义学生信息管理系统结构体struct StudentSystem {struct Student students[100]; // 学生数组int count; // 学生数量};// 初始化学生信息管理系统void initStudentSystem(struct StudentSystem system) {system->count = 0;}// 添加学生信息void addStudent(struct StudentSystem system, char name, int age, int id) {if (system->count >= 100) {printf("学生数量已达上限!\n");return;}system->students[system->count].name[0] = '\0';strcpy(system->students[system->count].name, name);system->students[system->count].age = age;system->students[system->count].id = id;system->count++;}// 查询学生信息void queryStudent(struct StudentSystem system, int id) {for (int i = 0; i < system->count; i++) {if (system->students[i].id == id) {printf("学生姓名:%s,年龄:%d\n", system->students[i].name, system->students[i].age);return;}}printf("未找到该学生!\n");}// 显示所有学生信息void showAllStudents(struct StudentSystem system) {for (int i = 0; i < system->count; i++) {printf("学生姓名:%s,年龄:%d,学号:%d\n", system->students[i].name, system->students[i].age, system->students[i].id); }}// 测试代码int main() {struct StudentSystem system;initStudentSystem(&system); // 初始化学生信息管理系统 addStudent(&system, "张三", 20, 1001); // 添加学生信息 addStudent(&system, "李四", 21, 1002); // 添加学生信息 showAllStudents(&system); // 显示所有学生信息queryStudent(&system, 1002); // 查询学生信息return 0;}```。

(完整word版)学生信息管理系统(Java)+代码(word文档良心出品)

(完整word版)学生信息管理系统(Java)+代码(word文档良心出品)

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

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

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

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

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

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

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

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

系统总体结构如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

字段名称数据类型描述sno char (10) 学号,关键字sn char (20) 姓名sa int 年龄ss char (10) 性别sd char (10) 院系字段名称数据类型描述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、学生信息管理系统的登录学生信息管理系统可由管理员和学生两种身份的人使用。

学生信息管理系统(Java)+代码

学生信息管理系统(Java)+代码

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

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

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

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

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

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

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

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

系统总体结构如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

具体的结构图如图所示。

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

字段名称数据类型描述sno char (10)学号,关键字sn char (20)姓名sa int年龄ss char (10)性别sd char (10)院系字段名称数据类型描述cno char (10)课程号,关键字cn char (30)课程名pcno char (10)先行课程号字段名称数据类型描述sno char (10)学号,关键字cno char (10)课程号,关键字g int 成绩字段名称数据类型描述un char (10) 用户名,关键字pw char (10) 密码qx int 角色4、界面库设计1、学生信息管理系统的登录学生信息管理系统可由管理员和学生两种身份的人使用。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
①登陆界面1
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class First extends JFrame implements MouseListener{
private JPanel panel=(JPanel)getContentPane();
private JPanel panel2=new JPanel();
JLabel l1;
public First() {
super("学生信息管理系统");
ImageIconbackground= new ImageIcon("images\\Login.jpg");//整个背景图片
JLabel L=new JLabel(background);
处理“登陆”按钮的事件
实现登陆功能
Connctsql()
连接数据库
3
Menu
actionPerformed(actionEvent e)
处理菜单按钮的事件
主界面,实现管理员操作功能
Menu()
构造方法,构造界面及注册事件
4
addForm
Connctsql()
连接数据库
管理员添加学生信息
actionPerformed(ActionEvent e)
getLayeredPane().add(L, new Integer(Integer.MIN_VALUE));
setSize(500,400);
setVisible(true);
setResizable(false);
setLocation(450,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
处理按钮事件
5
modifyForm
Connctsql()
连接数据库
管理员修改学习
actionPerformed(ActionEvent ae)
处理按钮事件
6
Serch
Connctsql()
连接数据库
管理员查询学生信息
actionPerformed(ActionEvent e)
处理按钮事件
7
deleteForm
12
AboutSystem
AboutSystem()
构造方法,构造界面
帮助窗口,关于系统
(三)源代码及技术
1、所有代码
-数据库
将以下图片以上图名称存入images文件夹目录下。
要自己将各代码新建为.java格式文件,放在与images文件夹同目录下。并将数据库附加到sqlserver2005,再不需要任何改动方可运行。
2、完成功能
完成学生信息的基本管理。本系统分为管理员和学生管理两部分。管理员管理项目如下:添加学生信息、修改学生信息、查询学生信息、删除学生信息;学生管理项目如下:添加学生信息、查询学生信息。
(二)系统流程图
二、详细设计
图2-1 登陆界面1
图2-2登陆界面2
图2-3系统主界面
图2-4添加学生信息界面
}
public void mouseClicked(MouseEvent e){
if((JLabel)e.getSource()==l1)
{ this.dispose();
Login d=new Login();}
}
public void mouseExited(Mouse==l1)
学生信息管理系统(完整代码、数据库、图片)
《Java应用开发》
课程设计报告
题目:学生信息管理系统
指导老师:***
姓 名:**
专 业:计算机科学与技术
班级:10级1班
日 期:2012年6月
一、系统总体设计
(一)设计目标及完成功能
1、设计目标
学生信息管理系统是学校的一项重要数据资源,因而学生信息管理必然成为学校的一项常规性的重要工作。加强学生信息管理在单纯依靠以手工管理的方法,不仅需要耗用大量的人力、物力、财力,而且由于人工管理存在着大量的不可控因素,造成了信息管理的某些不规范,工作效率低,难以达到预期的目的。为提高工作效率、保证学校能够及时准确了解各学生的各种信息及学生总体信息,开发学生信息管理系统。
图2-5 修改学生信息界面
图2-6 查询学生信息界面
图2-7 删除学生信息界面
图2-8 系统信息界面
图2-9 我的信息界面
(二) 系统设计
1、系统结构图
2、类及功能列表
序号
类名
方法
类功能说明
方法名
功能
1
First
First()
构造方法,构造界面并注册事件
美观效果
2
Login
actionPerformed(actionEvent e)
panel2.add(l1);
panel.add(panel2);
panel.setLayout(null);
panel.add(L);
panel2.setBounds(118,258,300,100);
//设置监听器
l1.addMouseListener(this);
getLayeredPane().setLayout(null);
Connctsql()
连接数据库
管理员删除学生信息
actionPerformed(ActionEvent ae)
处理按钮事件
8
Menu2
actionPerformed(actionEvent e)
处理菜单按钮的事件
主界面,实现学生操作功能
Menu2()
构造方法,构造界面及注册事件
9
addForm2
Connctsql()
{
l1.setBackground(Color.BLACK);
}
}
public void mouseEntered(MouseEvent e){
L.setBounds(0,0,500,400);//取整张图片
panel.setOpaque(false);
panel2.setOpaque(false);
ImageIcon button= new ImageIcon("images\\T20.jpg");
l1=new JLabel(button);
连接数据库
学生添加学生信息
actionPerformed(ActionEvent e)
处理按钮事件
10
Serch2
Connctsql()
连接数据库
学生查询学生信息
actionPerformed(ActionEvent e)
处理按钮事件
11
Aboutme
Aboutme()
构造方法,构造界面
帮助窗口,关于我
相关文档
最新文档