导航:首页 > 源码编译 > 信息管理网站源码

信息管理网站源码

发布时间:2025-02-04 03:13:32

1. 学生基本信息管理系统C++源代码

#include<iostream>
#include<iomanip>
#include<string>

usingnamespacestd;

typedefstructstudent{
unsignedm_id;
stringm_name;
unsignedm_age;
stringm_sex;
stringm_address;
stringm_contact;
stringm_dormitory;
structstudent*m_next;
}student;

classCStudent{
private:
student*head;
public:
CStudent(){
head=newstudent;
head->m_id=0;
head->m_name="noname";
head->m_next=NULL;
}
~CStudent(){
student*p=head,*q;
while(p){
q=p;
p=q->m_next;
deleteq;
}
}
studentreaddata(intmodel);//model=1:不读取学号,2:不读取姓名,其他,读取所有信息
voidentering();
boolinsert(conststudent&astu);
student*findid(unsignedid)const;
student*findname(conststring&name)const;
student*findsex(conststring&sex)const;
student*finddormitory(conststring&dormitory)const;
unsignedboys()const;
unsignedgirls()const;
unsignedheadcount()const;
booleraseid();
boolerasename();
boolmodifyid();
boolmodifyname();
voidShow()const;
voidquery()const;
voidfriendstatistics(constCStudent&aclss);
voidfrienderase(CStudent&aclss);
voidfriendmodify(CStudent&aclss);
};

stringreadstring(){
stringstr;
while(cin.get()!=' ');
cin>>str;
returnstr;
}

studentCStudent::readdata(intmodel){
studenttmp;
if(model!=1){cout<<"学号:";cin>>tmp.m_id;}
if(model!=2){cout<<"姓名:";tmp.m_name=readstring();}
cin>>tmp.m_age;
cout<<"性别:";
tmp.m_sex=readstring();
cout<<"住址:";
tmp.m_address=readstring();
cout<<"联系方式:";
tmp.m_contact=readstring();
cout<<"寝室:";
tmp.m_dormitory=readstring();
returntmp;
}

voidCStudent::entering(){
studenttmp;
cout<<"学号(0toreturn):";
cin>>tmp.m_id;
while(tmp.m_id){
if(findid(tmp.m_id)==NULL){
cout<<"姓名:";
tmp.m_name=readstring();
cout<<"年龄:";
cin>>tmp.m_age;
cout<<"性别:";
tmp.m_sex=readstring();
cout<<"住址:";
tmp.m_address=readstring();
cout<<"联系方式:";
tmp.m_contact=readstring();
cout<<"寝室:";
tmp.m_dormitory=readstring();
insert(tmp);
}
elsecout<<"重复的学号:"<<tmp.m_id<<endl;
cout<<"学号(0toreturn):";
cin>>tmp.m_id;
}
}

student*CStudent::findid(unsignedid)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_id==id)returnp;
returnNULL;
}

student*CStudent::findname(conststring&name)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_name==name)returnp;
returnNULL;
}


student*CStudent::findsex(conststring&sex)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_sex==sex)returnp;
returnNULL;
}

student*CStudent::finddormitory(conststring&dormitory)const{
student*p;
for(p=head;p->m_next;p=p->m_next)
if(p->m_next->m_dormitory==dormitory)returnp;
returnNULL;
}

boolCStudent::insert(conststudent&astu){
student*newnode,*p=head;
if(p->m_next==NULL){
p->m_next=newstudent(astu);
p->m_next->m_next=NULL;
returntrue;
}
while(p->m_next){
if(p->m_next->m_id==astu.m_id){
cout<<"重复的学号,插入失败! ";
returnfalse;
}
if(p->m_next->m_id>astu.m_id){
newnode=newstudent(astu);
newnode->m_next=p->m_next;
p->m_next=newnode;
returntrue;
}
p=p->m_next;
}
p->m_next=newstudent(astu);
p->m_next->m_next=NULL;
returntrue;
}

unsignedCStudent::boys()const{
unsignedcnt=0;
student*p;
for(p=head->m_next;p;p=p->m_next)
if(p->m_sex=="男")++cnt;
returncnt;
}

unsignedCStudent::girls()const{
unsignedcnt=0;
student*p;
for(p=head->m_next;p;p=p->m_next)
if(p->m_sex=="女")++cnt;
returncnt;
}

unsignedCStudent::headcount()const{
unsignedcnt=0;
student*p;
for(p=head->m_next;p;p=p->m_next,++cnt);
returncnt;
}

boolCStudent::eraseid(){
student*q,*p;
unsignedid;
cout<<"输入要删除的学号:";
cin>>id;
p=findid(id);
if(p==NULL){
cout<<"没有找到学号是""<<id<<""的学生,删除失败! ";
returnfalse;
}
q=p->m_next;
p->m_next=q->m_next;
deleteq;
returntrue;
}
boolCStudent::erasename(){
student*q,*p;
stringname;
cout<<"输入要删除人的姓名:";
name=readstring();
p=findname(name);
if(p==NULL){
cout<<"没有找到姓名是""<<name<<""的学生,删除失败! ";
returnfalse;
}
q=p->m_next;
p->m_next=q->m_next;
deleteq;
returntrue;
}

boolCStudent::modifyid(){
studenttmp,*p;
unsignedid;
cout<<"输入要修改的学号:";
cin>>id;
p=findid(id);
if(p==NULL){
cout<<"没有找到学号是""<<id<<""的学生,修改失败! ";
returnfalse;
}
tmp=readdata(1);
tmp.m_id=id;
*p=tmp;
returntrue;
}

boolCStudent::modifyname(){
student*p,tmp;
stringname;
cout<<"输入要修改人的姓名:";
name=readstring();
p=findname(name);
if(p==NULL){
cout<<"没有找到姓名是""<<name<<""的学生,修改失败! ";
returnfalse;
}
tmp=readdata(2);
tmp.m_name=name;
*p=tmp;
returntrue;
}

intmenu(){
intchoice;
do{
system("cls");
cout<<" **************************** ";
cout<<" *学生基本信息管理系统* ";
cout<<" *==========================* ";
cout<<" *1、录入学生信息* ";
cout<<" *2、显示学生信息* ";
cout<<" *3、查询学生信息* ";
cout<<" *4、添加学生信息* ";
cout<<" *5、统计学生信息* ";
cout<<" *6、删除学生信息* ";
cout<<" *7、修改学生信息* ";
cout<<" *0、退出管理系统* ";
cout<<" **************************** ";
cout<<" 请选择:";
cin>>choice;
}while(choice<0||choice>7);
returnchoice;
}

voidshow(student*p){
cout<<p->m_id<<""<<p->m_name<<""<<p->m_age<<"";
cout<<p->m_sex<<""<<p->m_address<<"";
cout<<p->m_contact<<""<<p->m_dormitory<<endl;
}

voidCStudent::Show()const{
student*p;
cout<<"---------------------------------------------------------- ";
for(p=head->m_next;p;p=p->m_next)show(p);
cout<<"---------------------------------------------------------- ";
system("pause");
}

voidCStudent::query()const{
intselect;
unsignedid;
stringname;
student*p;
cout<<"1、按学号查询 2、按姓名查询 0、返回 ";
cin>>select;
switch(select){
case1:cout<<"请输入学号:";cin>>id;
if(p=findid(id))show(p->m_next);
break;
case2:cout<<"请输入姓名:";name=readstring();
if(p=findname(name))show(p->m_next);
break;
case0:return;
default:cout<<"选择错误。 ";
}
system("pause");
}

voidstatistics(constCStudent&a){
unsignedtotal=a.headcount();
unsignedboys=a.boys();
unsignedgirls=a.girls();
cout<<"学生总数:"<<total<<"人。 ";
cout<<"其中,男生:"<<boys<<"名。";
cout<<"女生:"<<girls<<"名。 ";
system("pause");
}

voiderase(CStudent&a){
intselect;
unsignedid;
stringname;
student*p,*q;
cout<<"1、按学号删除 2、按姓名删除 0、返回 ";
cin>>select;
switch(select){
case1:cout<<"请输入学号:";cin>>id;
if(p=a.findid(id)){
q=p->m_next;
p->m_next=q->m_next;
deleteq;
cout<<"成功删除"<<id<<"的信息。 ";
}
break;
case2:cout<<"请输入姓名:";name=readstring();
if(p=a.findname(name)){
q=p->m_next;
p->m_next=q->m_next;
deleteq;
cout<<"成功删除"<<name<<"的信息。 ";
}
break;
case0:return;
default:cout<<"选择错误。 ";
}
system("pause");
}

voidmodify(CStudent&a){
intselect;
cout<<"1、按学号修改 2、按姓名修改 0、返回 ";
cin>>select;
switch(select){
case1:if(a.modifyid())cout<<"修改成功。 ";break;
case2:if(a.modifyname())cout<<"修改成功。 ";break;
case0:return;
default:cout<<"选择错误。 ";
}
system("pause");
}

intmain(){
CStudenta;
intan;
do{
an=menu();
switch(an){
case1:a.entering();break;
case2:a.Show();break;
case3:a.query();break;
case4:a.entering();break;
case5:statistics(a);break;
case6:erase(a);break;
case7:modify(a);break;
case0:break;
default:cout<<"选择错误。 ";break;
}
}while(an);
return0;
}

2. 学生信息管理系统最简单源代码。

方法一:

1、创建一个c语言项目。然后右键头文件,创建一个Stu的头文件。

3. 学生信息管理系统C++源代码

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
#define INIT_SIZE 10
#define INCRE_SIZE 10
#define SUBJECT_NUM 3
#define LEN 3

void show_Start();

void show_Table();

void addRecord();

void Info_delete();
void deleteRecord();
void delete_Num(int);
void delete_Name(char tarName[]);

void Info_modify();
void modifyRecord();
void modify_Num(int);
void modify_Name(char[]);

void Info_query();
void queryRecord();
void query_Num(int);
void query_Name(char[]);

void display();

void quit();

void menu_CMD();

char *subject[SUBJECT_NUM] = {"高代","数分","C语言"};

struct STUDENT
{
int num;
char name[20];
char sex;
float score[SUBJECT_NUM];
};

//struct STUDENT stu[LEN + 1];

//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

int static stuNum = 0;
//先暂时定义三个学生吧...

STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);;

int main()
{
//record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);
//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

/*
record[1].num = 1001;
strcpy(record[1].name,"Jason");
record[1].sex = 'M';
record[1].score[0] = 85.0;
record[1].score[1] = 90.0;
record[1].score[2] = 95.0;

record[2].num = 1002;
strcpy(record[2].name,"Jerry");
record[2].sex = 'M';
record[2].score[0] = 85.0;
record[2].score[1] = 90.0;
record[2].score[2] = 95.0;

record[3].num = 1003;
strcpy(record[3].name,"Jessie");
record[3].sex = 'F';
record[3].score[0] = 85.0;
record[3].score[1] = 90.0;
record[3].score[2] = 95.0;
*/

/*
Info_modify();
int key;
cout<<"请输入您的选择 : ";
cin>>key;

if(key == 1)
{
int targetNum;
cout<<"请输入您欲修改的学生的学号 : ";
cin>>targetNum;

modify_Num(targetNum);
cout<<endl;

display();
}

if(key == 2)
{
char targetName[20];
cout<<"请输入您欲修改学生的姓名 : ";
cin>>targetName;

modify_Name(targetName);
cout<<endl;

display();
}

if(key == 3)
{
exit(0);
}
*/

show_Start();

menu_CMD();

return 0;

}

//修改完后还应该显示
void show_Start()
{
//cout<<endl;
cout<<" **************************************** "<<endl;
cout<<" 这是一个 "<<endl;
cout<<" 学生成绩管理系统 "<<endl;
cout<<" 可以对学生成绩进行管理 "<<endl;
cout<<" 欢迎大家使用 "<<endl;
cout<<" Made by Jason "<<endl;
cout<<" **************************************** "<<endl;
}

// 显示表头信息,即是 : 学号,姓名,性别,高代,数分,C语言.
void show_Table()
{
cout<<"学号"<<"\t"<<"姓名"<<"\t"<<"性别";
cout<<"\t"<<subject[0]<<"\t"<<subject[1]<<"\t"<<subject[2];
cout<<endl;
}

void menu_CMD()
{
int key;
while(1)
{
cout<<"1. 增加学生信息"<<endl;
cout<<"2. 删除学生信息"<<endl;
cout<<"3. 修改学生信息"<<endl;
cout<<"4. 查询学生信息"<<endl;
cout<<"5. 显示学生信息"<<endl;
cout<<"6. 退出"<<endl;
cout<<"请输入您的选择 : ";
cin>>key;
while(1)
{
if((key < 1)||(key > 6))
{
int key;
cout<<"您的输入有误,请重新输入!"<<endl;
cout<<"请选(1 - 5) : ";
cin>>key;
}
else
{
break;
}
}
switch(key)
{
case 1:
addRecord();
break;
case 2:
deleteRecord();
break;
case 3:
modifyRecord();
break;
case 4:
queryRecord();
break;
case 5:
display();
break;
case 6:
quit();
break;
}

}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//增加学生信息
void addRecord()
{

if(stuNum == 0)
{
cout<<"原来没有记录,现在建立新表!"<<endl;
stuNum++;
}
else
{
cout<<"现在在当前表的末尾添加新的信息!"<<endl;
stuNum++;
}

//如果数组空间不够,重新申请空间
if(stuNum > INIT_SIZE)
{
cout<<"内存空间不够,现在重新申请新的内存空间!"<<endl;
record = (STUDENT*)realloc(record,(INIT_SIZE + INCRE_SIZE)*sizeof(STUDENT));
cout<<"空间申请完成!"<<endl;
}

cout<<"您现在要添加一组新的信息,您确定吗?"<<endl;
cout<<"请输入您的选择(Y/N) : ";
char choi;
cin>>choi;
if((choi == 'Y')||(choi == 'y'))
{
cout<<"请输入学号 : ";
cin>>record[stuNum].num;
cout<<"请输入姓名 : ";
cin>>record[stuNum].name;
cout<<"请输入性别(M为男,F为女) : ";
cin>>record[stuNum].sex;

int i;
for(i = 0;i < SUBJECT_NUM;i++)
{
cout<<"请输入"<<subject[i]<<"的成绩 : ";
cin>>record[stuNum].score[i];
}
}

if((choi == 'N')||(choi == 'n'))
{
cout<<"退出添加新学生信息!"<<endl;
cout<<endl;
}

cout<<"现在已经有"<<stuNum<<"条学生的信息了!"<<endl;
cout<<endl;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//删除信息 晚上完成...

//显示deleteRecord的表头信息
void Info_delete()
{
cout<<"请输入删除方式 : "<<endl;
cout<<"1. 按学号删除"<<endl;
cout<<"2. 按姓名删除"<<endl;
cout<<"3. 退出删除"<<endl;
}

//删除学生的信息,包含两个子函数
void deleteRecord()
{
int key;
cout<<endl;
Info_delete();
cout<<"请输入您的选择 : ";
cin>>key;

if(key == 1)
{
int targetNum;
cout<<"请输入您欲删除学生的学号 : ";
cin>>targetNum;

//按学号删除
delete_Num(targetNum);
cout<<endl;
}

if(key == 2)
{
char targetName[20];
cout<<"请输入您欲删除学生的姓名 : ";
cin>>targetName;

//按姓名删除
delete_Name(targetName);
cout<<endl;
}

if(key == 3)
{
while(1)
{
menu_CMD();

}
}
}

//按学号删除学生信息
//只用完成删除操作,而不必输出. 输出的操作可以在主菜单中进行

void delete_Num(int tarNum)
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(record[i].num == tarNum)
{
//删除还要分两种情况讨论
//1. 欲删除的学生信息是最后一位
//2. 欲删除的学生信息不是最后一位

//第一种情况,欲删除的学生是最后一位
if(i = stuNum)
{
cout<<"您所要删除的学生信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;

cout<<endl<<"删除后学生信息表为 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum - 1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
//显示信息应该放在后面
/*
stuNum--;
cout<<"现在还剩下"<<stuNum<<"条学生的信息";
cout<<endl;
*/
}

//2.第二种情况,欲删除的学生不是最后一位
if(i != stuNum)
{

cout<<"您所要删除的学生信信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];

for(int j = i+1;j <= stuNum;j++)
{
record[j-1] = record[j];
}

//接着完成输出

cout<<endl;
cout<<"删除后学生信息表为 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
/*
stuNum--;
cout<<"现在还剩下"<<stuNum<<"条学生的信息";
cout<<endl;
*/
}

stuNum--;
cout<<"现在还是剩下"<<stuNum<<"条学生的信息";
cout<<endl;
}
}
}

/*

//方法同上
void delete_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(strcmp(record[i].name,tarName) == 0)
{
//删除还要分两种情况讨论
//1. 欲删除的学生信息是最后一位
//2. 欲删除的学生信息不是最后一位

//第一种情况 : 欲删除学生是最后一位
if(i = stuNum)
{
cout<<"您所要删除的学生信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;

cout<<endl<<"删除后学生信息表为 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum - 1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
}

//第二种情况 : 欲删除学生不是最后一位
if(i != stuNum)
{

cout<<"您所要删除的学生信信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];

//整体往前 前移一位
for(int j = i+1;j <= stuNum;j++)
{
record[j-1] = record[j];
}
cout<<endl;

//接着完成输出
cout<<"删除后学生信息表为 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}

cout<<endl;
}
}

}

}

*/

void delete_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{

//删除还要分两种情况讨论
//1. 欲删除的学生信息是最后一位
//2. 欲删除的学生信息不是最后一位

//当欲删除的学生是最后一位,直接输出前面LEN-1位学生的信息

if(strcmp(record[i].name,tarName) == 0)
{
if(i == stuNum)
{
cout<<"您所要删除的学生信息是 : "<<endl;
show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t"
<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];

cout<<endl;

cout<<"删除后学生信息表为 : "<<endl;
show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
/*
stuNum--;
cout<<"现在还剩下"<<stuNum<<"条学生的信息";
cout<<endl;
*/
}

//当欲删的学生不是最后一位,整体往前前移一位
if(i != stuNum)
{
cout<<"您所要删除的学生信息是 : "<<endl;

show_Table();
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex<<"\t";
cout<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;

//整体往前前移一位
for(int j = i+1;j <= stuNum;j++)
{
record[j-1] = record[j];
}

//然后输出
cout<<endl;
cout<<"删除后学生信息表为 : "<<endl;

show_Table();
for(int i = 1;i <= stuNum-1;i++)
{
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(int j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
/*
stuNum--;
cout<<"现在还剩下"<<stuNum<<"条学生的信息";
cout<<endl;
*/
}

stuNum--;
cout<<"现在还剩下"<<stuNum<<"条学生的信息";
cout<<endl;
}
}
}

/*****************************************************************************
******************************************************************************/

//显示modifyRecord的表头信息
void Info_modify()
{
cout<<"请输入修改方式 : "<<endl;
cout<<"1. 按学号修改"<<endl;
cout<<"2. 按姓名修改"<<endl;
cout<<"3. 退出修改"<<endl;
}

//查询学生的成绩,当然里面包括两个子函数
void modifyRecord()
{
int key;
cout<<endl;
Info_modify();
cout<<"请输入您的选择 : ";
cin>>key;

//按学号修改
if(key == 1)
{
int targetNum;
cout<<"请输入您欲修改的学生的学号 : ";
cin>>targetNum;

modify_Num(targetNum);
cout<<endl;

//display();
}

//按姓名修改
if(key == 2)
{
char targetName[20];
cout<<"请输入您欲修改学生的姓名 : ";
cin>>targetName;

modify_Name(targetName);
cout<<endl;

//display();
}

//退出修改
if(key == 3)
{
while(1)
{
menu_CMD();
}
}
}

//按学号修改
void modify_Num(int tarNum)
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(record[i].num == tarNum)
{
cout<<endl<<"请修改该学生的信息"<<endl;
cout<<"请输入该学生的学号 : ";
cin>>record[i].num;
cout<<"请输入该学生的姓名 : ";
cin>>record[i].name;
cout<<"请输入该学生的性别 : ";
cin>>record[i].sex;
cout<<"请输入"<<subject[0]<<"的成绩 : ";
cin>>record[i].score[0];
cout<<"请输入"<<subject[1]<<"的成绩 : ";
cin>>record[i].score[1];
cout<<"请输入"<<subject[2]<<"的成绩 : ";
cin>>record[i].score[2];
}
}
}

//按姓名修改
void modify_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(strcmp(record[i].name,tarName) == 0)
{
cout<<endl<<"请修改该学生的信息 : "<<endl;
cout<<"请输入该学生的学号 : ";
cin>>record[i].num;
cout<<"请输入该学生的姓名 : ";
cin>>record[i].name;
cout<<"请输入该学生的性别 : ";
cin>>record[i].sex;
cout<<"请输入"<<subject[0]<<"的成绩 : ";
cin>>record[i].score[0];
cout<<"请输入"<<subject[1]<<"的成绩 : ";
cin>>record[i].score[1];
cout<<"请输入"<<subject[2]<<"的成绩 : ";
cin>>record[i].score[2];
}
}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//显示queryRecord的表头信息
void Info_query()
{
cout<<"请输入查询方式 : "<<endl;
cout<<"1. 按学号查询"<<endl;
cout<<"2. 按姓名查询"<<endl;
cout<<"3. 退出查询"<<endl;
}

//查询学生信息queryRecord
void queryRecord()
{
int key;
cout<<endl;
Info_query();
cout<<"请输入您的选择 : ";
cin>>key;

if(key == 1)
{
int targetNum;
cout<<"请输入您欲查询学生的学号 : ";
cin>>targetNum;

query_Num(targetNum);
cout<<endl;
}

if(key == 2)
{
char targetName[20];
cout<<"请输入您欲查询学生的学号 : ";
cin>>targetName;

query_Name(targetName);
cout<<endl;
}

//退出查询,退回到主菜单吧...
if(key == 3)
{
while(1)
{
menu_CMD();
}
}
}

//按学号查询
void query_Num(int tarNum)
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(record[i].num == tarNum)
{
//如果表中有该学生信息的话,仅用输出该学生的信息即可.
//输出该学生的信息
cout<<"该学生的信息如下 : "<<endl;

//显示表头信息
show_Table();

//显示该学生具体的信息
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;
}
}
}

//按姓名查询
void query_Name(char tarName[])
{
int i;
for(i = 1;i <= stuNum;i++)
{
if(strcmp(record[i].name,tarName) == 0)
{
cout<<"该学生的信息如下 : "<<endl;

show_Table();

cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
cout<<"\t"<<record[i].score[0]<<"\t"<<record[i].score[1]<<"\t"<<record[i].score[2];
cout<<endl;
}
}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//先显示所有学生的信息吧
//显示record里所有学生的成绩
void display()
{
show_Table();
int i,j;
for(i = 1;i <= stuNum;i++)
{
//cout<<"学号"<<"\t"<<"姓名"<<"\t"<<"性别";
cout<<record[i].num<<"\t"<<record[i].name<<"\t"<<record[i].sex;
for(j = 0;j < SUBJECT_NUM;j++)
{
cout<<"\t"<<record[i].score[j];
}
cout<<endl;
}
cout<<endl;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//退出
void quit()
{
char choi;
cout<<"您确定要退出吗?"<<endl;
cout<<"请输入您的选择(Y/N) : ";
cin>>choi;
if((choi == 'Y')||(choi == 'y'))
{
cout<<"现在退出学生信息管理系统"<<endl;
exit(0);
}
//如果不是退出,则接着退回到主界面
else
{
cout<<endl;
menu_CMD();
}

}

这个是原创的... 在C-Free 4.0里跑过,可以正常运行
你可以试着跑一下,如果有什么问题可以和我联系

4. 学生信息管理系统C++,使用Visual C++ 6.0编写。源代码参考

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedefstructlist{
structlist*next;
intnum;//学号
charname[30];//姓名
intage;//年龄
charsex;//性别
charaddr[50];//地址
charmobile[11];//号码
intdepartment;//寝室号
}user;

voidinsert(user*h);
voidedit(user*h);
voiddel(user*h);
voidS_byName(user*h);
voidS_byNum(user*h);
voiddisplay(user*h);

intmain()
{
intflag;
user*head=(user*)malloc(sizeof(user));
head->next=NULL;
while(1)
{
printf("1、添加新用户信息 ");
printf("2、修改用户信息 ");
printf("3、删除已有用户信息 ");
printf("4、根据用户名查询信息 ");
printf("5、根据学号查询信息 ");
printf("6、显示全部用户信息 "源咐兄);
printf("7、清屏 ");
printf("8、退出 ");
printf("请选择:");
scanf("%d",&flag);
if(flag==1)
雹袭insert(head);
elseif(flag==2)
edit(head);
elseif(flag==3)
del(head);
elseif(flag==4)
S_byName(head);
elseif(flag==5)
S_byNum(head);
elseif(flag==6)
display(head);
elseif(flag==7)
system("clear");
elseif(flag==8)
return0;
else
printf("输入有误,请重新选择! ");
}
}
voidinsert(user*h)
{
user*p=(user*)malloc(sizeof(user));
p->next=h->next;
h->next=p;
printf("请输入新增用户学号:"简键);
scanf("%d",&p->num);
printf("请输入新增用户名称(最多30个字):");
scanf("%s",p->name);
printf("请输入新增用户年龄:");
scanf("%d",&p->age);
printf("请输入新增用户性别:");
scanf("%c",&p->sex);
printf("请输入新增用户的家庭住址(最多50字):");
scanf("%s",p->addr);
printf("请输入新增用户的电话号码(11位数):");
scanf("%s",p->mobile);
printf("请输入新增用户寝室号:");
scanf("%d",&p->department);
printf("新用户记录成功添加:%d%s%d%c%s%s%d ",p->num,p->name,p->age,p->sex,p->addr,p->mobile,p->department);
}
voidedit(user*h)
{
intnum;
intflag=0;
user*lh=h->next;
printf("输入要修改用户的学号:");
scanf("%d",&num);
while(lh)
{
if(num==lh->num)
{
flag=1;
printf("请输入新增用户学号:");
scanf("%d",&lh->num);
printf("请输入新增用户名称(最多30个字):");
scanf("%s",lh->name);
printf("请输入新增用户年龄:");
scanf("%d",&lh->age);
printf("请输入新增用户性别:");
scanf("%c",&lh->sex);
printf("请输入新增用户的家庭住址(最多50字):");
scanf("%s",lh->addr);
printf("请输入新增用户的电话号码(11位数):");
scanf("%s",lh->mobile);
printf("请输入新增用户寝室号:");
scanf("%d",&lh->department);
printf("新用户记录成功添加:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
break;
}
lh=lh->next;
}
if(!flag)
printf("不存在这样的用户 ");
}
voidS_byName(user*h)
{
charname[30];
intflag=0;
user*lh=h->next;
printf("输入要查找的用户名称:");
scanf("%s",name);
while(lh)
{
if(strcmp(name,lh->name)==0)
{
flag=1;
printf("用户信息为:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
break;
}
lh=lh->next;
}
if(!flag)
printf("用户名不存在 ");
}
voidS_byNum(user*h)
{
intnum;
intflag=0;
user*lh=h->next;
printf("输入要查找的学号:");
scanf("%d",&num);
while(lh)
{
if(num==lh->num)
{
flag=1;
printf("用户信息:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
break;
}
lh=lh->next;
}
if(!flag)
printf("找不到匹配的号码 ");
}
voiddisplay(user*h)
{
user*lh=h->next;
inti=1;
while(lh)
{
printf("第%d条用户信息:%d%s%d%c%s%s%d ",i,lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
lh=lh->next;
i++;
}
printf(" ");
}
voiddel(user*h)
{
intnum;
intflag=0;
user*lh=h;
printf("输入要删除的用户学号:");
scanf("%d",&num);
while(lh->next)
{
if(num==lh->next->num)
{
flag=1;
printf("删除用户成功:%d%s%d%c%s%s%d ",lh->num,lh->name,lh->age,lh->sex,lh->addr,lh->mobile,lh->department);
lh->next=lh->next->next;
break;
}
lh=lh->next;
}
if(!flag)
printf("用户名不存在 ");
}

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

void Sort(student *&head, char type,char maxOrMin)
{
/*参数说明:
type=='1' 按 语文 排列
type=='2' 按 数学 排列
type=='3' 按 英语 排列
type=='4' 按 总分 排列
type=='5' 按 平均分 排列
type=='6' 按 座号 排列
*/
student *pHead,*pH;
pHead=pH=head;
int len=GetLength(head);
float *array=new float[len];
int i;
int x=0;

float num=0;

while(head)
{
Count(head);
if(type=='1')
{
num=head->chinaNum;
}
else if(type=='2')
{
num=head->mathNum;
}
else if(type=='3')
{
num=head->englishNum;
}
else if(type=='4')
{
num=head->result;
}
else if(type=='5')
{

num=head->average;
}
else if(type=='6')
{
num=head->num;
}
array[x]=num;
x++;
head=head->next;
}

head=pHead;
if(maxOrMin=='1')
{
for( i=1; i<len; i++)
{
for(int j=0; j<len-i; j++)
{
if(array[j]<array[j+1])
{
float num;
num=array[j];
array[j]=array[j+1];
array[j+1]=num;
}
}
}
}
else
{
for( i=1; i<len; i++)
{
for(int j=0; j<len-i; j++)
{
if(array[j]>array[j+1])
{
float num;
num=array[j];
array[j]=array[j+1];
array[j+1]=num;
}
}
}
}

int pos=1;

for(i=0; i<len; i++)
{
head=pHead;
while(head)
{
if(type=='1')
{
num=head->chinaNum;
}
else if(type=='2')
{
num=head->mathNum;
}
else if(type=='3')
{
num=head->englishNum;
}
else if(type=='4')
{
num=int(head->result);
}
else if(type=='5')
{
num=int(head->average);
}
else if(type=='6')
{
num=int(head->num);
}

int n=0;
if(int(array[i])==int(num))
{

if(int(array[i])!=int(array[i+1]))
{
if(n==0)
{
n=pos;
}
head->pos=pos;
pos++;
}
else
{

head->pos=n;
}
}
head=head->next;
}
}
head=pH;
delete []array;
}

void Count(student *&head)
{
head->result=head->chinaNum+head->englishNum+head->mathNum;
head->average=head->result/3;
}

void DeleteAll(student* &head)
{
student *cp,*np;

cp=head;
while(cp)
{
np=cp->next;
delete cp;
cp=np;
}
head=NULL;
}

void ChaXun(string str,student *head)
{
Sort(head,'4','1');
cout<<"欢迎使用查询功能"<<endl<<endl;
cout<<"请输入你要按什么查询 1->一般查询 2->查找最多 3->查找最少"<<endl;
string s;
cin>>s;
while(s[0]!='1'&&s[0]!='2'&&s[0]!='3')
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>s;
}

if(s[0]=='1')
{
cout<<"按什么查询?"<<endl;
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 "
<<"5->英语成绩 6->总分 7->平均分 8->排名"<<endl;
cin>>str;

while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' && str[0]!='6' &&
str[0]!='7' && str[0]!='8' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
char findStr[30];
cout<<"请输入要查找的关键字或关键数:"<<endl;
cin>>findStr;
switch(str[0])
{

case '1':
Find(head,findStr,'1');
break;
case '2':
Find(head,findStr,'2');
break;
case '3':
Find(head,findStr,'3');
break;
case '4':
Find(head,findStr,'4');
break;
case '5':
Find(head,findStr,'5');
break;
case '6':
Find(head,findStr,'6');
break;
case '7':
Find(head,findStr,'7');
break;
case '8':
Find(head,findStr,'8');
break;
}
}
else if(s[0]=='2')
{
cout<<"请输入要按什么查询?"<<endl;
cout<<"1->语文成绩 2->数学成绩 "
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;
string s;
cin>>s;
switch(s[0])
{
case '1':
FindMaxOrMin(head,'1','1');
break;
case '2':
FindMaxOrMin(head,'2','1');
break;
case '3':
FindMaxOrMin(head,'3','1');
break;
case '6':
FindMaxOrMin(head,'6','1');
break;
case '5':
FindMaxOrMin(head,'5','1');
break;
default:
FindMaxOrMin(head,'4','1');
break;
}
}
else if(s[0]=='3')
{
cout<<"请输入要按什么查询?"<<endl;
cout<<"1->语文成绩 2->数学成绩 "
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;
string s;
cin>>s;
switch(s[0])
{
case '1':
FindMaxOrMin(head,'1','2');
break;
case '2':
FindMaxOrMin(head,'2','2');
break;
case '3':
FindMaxOrMin(head,'3','2');
break;
case '6':
FindMaxOrMin(head,'6','2');
break;
case '5':
FindMaxOrMin(head,'5','2');
break;
default:
FindMaxOrMin(head,'4','2');
break;
}
}
}

void ZengJia(string str, student* &head)
{
student *pNew=new student;
cout<<"欢迎使用增加功能"<<endl<<endl;
cout<<"请输入新学生的名字 :"<<endl;
cin>>pNew->name;
cout<<"请输入新学生的座号 :"<<endl;
cin>>pNew->num;
cout<<"请输入他的语文分数 :"<<endl;
cin>>pNew->chinaNum;
cout<<"请输入他的数学分数"<<endl;
cin>>pNew->mathNum;
cout<<"请输入他的英语分数"<<endl;
cin>>pNew->englishNum;

cout<<"插入记录的 (1->最前面 2->最后面)"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2')
{
cout<<"你输入错误,请重新输入."<<endl;
cout<<"插入记录的 (1->最前面 2->最后面)"<<endl;
cin>>str;
}
if(str[0]=='1')
{
InsertFront(head,pNew);
}
else if(str[0]=='2')
{
InsertRear(head,pNew);
}
cout<<"新学生增加成功."<<endl;

}

void ShanChu(string str, student *&head)
{
char delStr[30];
cout<<"欢迎使用删除功能"<<endl<<endl;
cout<<"1->查询删除 2->全部删除"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2')
{
cout<<"输入错误,请重新输入."<<endl;
cin>>str;
}
if(str[0]=='1')
{
cout<<"请输入要删除的关键字"<<endl;
cin>>delStr;
cout<<"1->删除第一条找到的记录 2->删除所有找到的记录"<<endl;
cin>>str;
while(str[0]!='1'&&str[0]!='2')
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
cout<<"你真的要删除吗? 1->删除 2->取消"<<endl;
string s;
cin>>s;
if(str[0]=='1')
{
if(str[0]=='1')
{
Delete(head,delStr,1);

}
else
{
Delete(head,delStr,2);
}
}
else
{
cout<<"你已经取消删除了."<<endl;
}
}
else
{
cout<<"你真的要删除全部数据吗?这样会使你的数据全部丢失哦."<<endl;
cout<<"1->全部删除 2->取消删除"<<endl;
cin>>str;
if(str[0]=='1')
{
DeleteAll(head);
}
else
{
cout<<"你已经取消删除了."<<endl;
}
}

}

void PaiMing(string str, student* head)
{
string s;
cout<<"欢迎使用排名功能"<<endl<<endl;
cout<<"排名选择: 1->升序 2->降序"<<endl;
cin>>s;
cout<<"请输入要按什么排名?"<<endl;
cout<<"1->语文成绩 2->数学成绩 3->英语成绩 "
<<"4->总分 5->平均分 6->座号"<<endl;

cin>>str;

while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' && str[0]!='6' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
cout<<"姓名:"<<setw(8)<<"座号:"<<setw(10)
<<"语文分数:"<<setw(10) <<"数学分数:"
<<setw(10)<<"英语分数:"<<setw(8)<<"总分数:"
<<setw(8)<<"平均分:"<<setw(6)<<"名次:"<<endl<<endl;
if(s[0]=='2')
{
switch(str[0])
{

case '1':
Sort(head,'1','1');
break;
case '2':
Sort(head,'2','1');
break;
case '3':
Sort(head,'3','1');
break;
case '4':
Sort(head,'4','1');
break;
case '5':
Sort(head,'5','1');
break;
case '6':
Sort(head,'6','1');
break;
}
}
else
{

switch(str[0])
{

case '1':
Sort(head,'1','2');
break;
case '2':
Sort(head,'2','2');
break;
case '3':
Sort(head,'3','2');
break;
case '4':
Sort(head,'4','2');
break;
case '5':
Sort(head,'5','2');
break;
case '6':
Sort(head,'6','2');
break;
}

}
ShowList(head);
return ;
}

void XianShi(string str, student *head)
{
Sort(head,'4','1');

string s;
cout<<"欢迎使用显示功能"<<endl;
cout<<"1->显示全部记录 2->显示记录数目"<<endl;
cin>>s;
if(s[0]=='2')
{
cout<<"记录的数目是:"<<GetLength(head)<<endl;
}
else
{
ShowList(head);
}
}

void XuiGai(string str, student *&head)
{
string s;
student *std;
cout<<"欢迎使用修改功能"<<endl;

cout<<"请输入你要按什么查询"<<endl;
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 "
<<"5->英语成绩 "<<endl;
cin>>str;

while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
char findStr[30];
cout<<"请输入要查找的关键字或关键数:"<<endl;
cin>>findStr;
switch(str[0])
{

case '1':
std=Find(head,findStr,'1');
Reword(std);
break;
case '2':
std=Find(head,findStr,'2');
Reword(std);
break;
case '3':
std=Find(head,findStr,'3');
Reword(std);
break;
case '4':
std=Find(head,findStr,'4');
Reword(std);
break;
case '5':
std=Find(head,findStr,'5');
Reword(std);
break;
}
Write(head);
if(std!=NULL)
{
cout<<"修改成功."<<endl;
}
}

int Run()
{

bool isLoad=false;
student* head=NULL;
student *pNew=new student;
head=Read();
SetTitle(false);
if(head!=NULL)
{ Sort(head,'5','1');
Count(head);

}
string str;
SetTitle(false);

cout<<" 欢迎使用学生管理系统 "<<endl<<endl;

cout<<" 1->用户登陆 2->退出程序 "<<endl;
cin>>str;
if(str[0]=='2')
{
AboutMe();
return 0;
}
else
{
isLoad=Enter('1');
system("cls");

if(isLoad==true)
{
SetTitle(true);
cout<<" 恭喜,您输入的密码正确.可以对本系统的进行任何操作."<<endl;
}
else
{
cout<<" Sorry,您输入的密码错误.你不能修改本系统的任何内容."<<endl;
}
}
begin:
cout<<endl<<endl;
cout<<" 欢迎使用学生管理系统 "<<endl<<endl;
cout<<" 1->增加功能 2-查询功能"<<endl;
cout<<" 3->删除功能 4-排名功能"<<endl;
cout<<" 5->显示功能 6-修改功能"<<endl;
cout<<" 7->用户设置 8-退出程序"<<endl;
cout<<"请输入您的选择: "<<endl;
cin>>str;

while(str[0]!='8')
{
if(isLoad==true && head!=NULL)
{
cout<<endl<<endl;
if(str[0]=='1')
{
ZengJia(str, head);
Sort(head,'4','1');
Write(head);
}
else if(str[0]=='2')
{
ChaXun(str,head);
}
else if(str[0]=='3')
{
ShanChu(str,head);
Sort(head,'4','1');
Write(head);
}
else if(str[0]=='4')
{
PaiMing(str,head);
}
else if(str[0]=='5')
{
XianShi(str,head);
}
else if(str[0]=='6')
{
XuiGai(str,head);
Write(head);
}
else if(str[0]=='7')
{
cout<<"欢迎使用用户修改功能"<<endl;
isLoad=Enter('2');
}
else if(str[0]=='8')
{
AboutMe();
return 0;
}
else
{
cout<<"你输入错误,请重新输入."<<endl;
goto begin;
}
}
else if(isLoad==false && head!=NULL)
{
if(str[0]=='2')
{
ChaXun(str,head);
}
else if(str[0]=='4')
{
PaiMing(str,head);
}
else if(str[0]=='5')
{
XianShi(str,head);
}

else
{
cout<<"你不是管理员,不能进行此项功能."<<endl;
cout<<"你只能进行 查询功能 显示功能 排名功能"<<endl;

}
}
else if( head==NULL && isLoad==true)
{
cout<<"系统检查到你没有任何记录,不能进行任何操作,只能增加记录."<<endl;
ZengJia(str, head);
Write(head);
head=Read();

}
else if( head==NULL && isLoad==false)
{
cout<<"因为你没有登陆,系统又检查到你没有任何记录,你不能进行任何操作."<<endl;
}

cout<<endl<<endl;
cout<<"按任何键继续进行操作."<<endl;
getchar();
getchar();
system("cls");
goto begin;
}

AboutMe();

return 0;
}

void SetTitle(bool isLoad)
{

HWND hwnd=GetForegroundWindow();

if(isLoad==false)
{
SetWindowText(hwnd," 学生管理系统(没有登陆)");

}
else
{
SetWindowText(hwnd," 学生管理系统(已经登陆)");
}

system("color a");
}

void AboutMe()
{

char*pStr= " ┃ \n"
" ┃ \n"
" ┏━━━━┻━━━━┓ \n"
" ┃ 关于作者 ┃ \n"
" ┏━━━━┻━━━━━━━━━┻━━━━┓\n"
" ┃ ┃\n"
" ┃ Aauthor:********** ┃\n"
" ┃ QQ: ********* ┃\n"
" ┃ E-mail:********@**.com ┃\n"
" ┃ ┃\n"
" ┗━━━━━━━━━━━━━━━━━━━┛\n";
system("cls");

srand(time(0));
for(int i=0; i<strlen(pStr); i++)
{
if(pStr[i]!=' ')
{
Sleep(20);
}
cout<<pStr[i];
}
cout<<"Good-bye ."<<endl;
cout<<endl<<endl<<endl<<endl;
}
int main()
{
Run();
return 0;
}

6. 急求java学生信息管理系统源代码,带有连接数据库的,万分感谢

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
public class MainFrame extends JFrame implements ActionListener{
InsertPanel ip = null;
SelectPanel sp = null;
JPanel pframe;
JButton jb1,jb2,jb3;
JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42;
CardLayout clayout;
public MainFrame(String s){
super(s);
JMenuBar mb = new JMenuBar();
this.setJMenuBar(mb);
JMenu m1 = new JMenu("系统");
JMenu m2 = new JMenu("基本信息");
JMenu m3 = new JMenu("成绩");
JMenu m4 = new JMenu("奖惩");
mb.add(m1);
mb.add(m2);
mb.add(m3);
mb.add(m4);
jm11 = new JMenuItem("退出系统");
jm21 = new JMenuItem("输入");
jm22 = new JMenuItem("查询");
jm23 = new JMenuItem("更改");
jm31 = new JMenuItem("输入成绩");
jm32 = new JMenuItem("查询成绩");
jm41 = new JMenuItem("奖励");
jm42 = new JMenuItem("处分");
m1.add(jm11);
m2.add(jm21);
m2.add(jm22);
m2.add(jm23);
m3.add(jm31);
m3.add(jm32);
m4.add(jm41);
m4.add(jm42);
Icon i1 = new ImageIcon();
Icon i2 = new ImageIcon();
Icon i3 = new ImageIcon();
jb1 = new JButton(i1);
jb1.setToolTipText("输入");
jb2 = new JButton(i2);
jb2.setToolTipText("查询");
jb3 = new JButton(i3);
jb3.setToolTipText("退出");
JToolBar tb = new JToolBar("系统工具");
tb.add(jb1);
tb.add(jb2);
tb.add(jb3);
add(tb,BorderLayout.NORTH);
jm11.addActionListener(this);
jm21.addActionListener(this);
jm22.addActionListener(this);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
clayout = new CardLayout();
pframe = new JPanel(clayout);
add(pframe);
JPanel mainp = new JPanel(new BorderLayout());
JLabel mainl = new JLabel("学生信息管理平台",SwingConstants.CENTER);
mainl.setFont(new Font("serif",Font.BOLD,30));
mainp.add(mainl);
pframe.add(mainp,"main");
clayout.show(pframe, "main");
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jm21 || e.getSource() == jb1){
if(ip == null){
ip= new InsertPanel();
pframe.add(ip,"insert");
}
clayout.show(pframe, "insert");
this.setTitle("输入学生信息");
}
else if(e.getSource() == jm22 || e.getSource() == jb2){
if(sp == null){
sp= new SelectPanel();
pframe.add(sp,"select");
}
clayout.show(pframe, "select");
this.setTitle("查询学生信息");
}
else if(e.getSource() == jm11 || e.getSource() == jb3){
System.exit(0);
}
}
}
第二个:
import javax.swing.JFrame;
public class MainTest {
public static void main(String [] args){
MainFrame f = new MainFrame("学生信息管理平台");
f.setSize(400,300);
f.setLocation(350,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第二个:
import java.sql.Connection;
import java.sql.DriverManager;
public class MySQLConnection {
static Connection getCon(){
Connection con = null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","123");
}
catch(Exception e){
System.out.println("建立数据库连接遇到异常!");
}
return con;
}
}
第四个:
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class SelectPanel extends JPanel implements ActionListener{
JButton jb;
JTextField jt;
JTextField jt1,jt2,jt3,jt4;
public SelectPanel(){
JLabel jl = new JLabel("请输入学号:",SwingConstants.CENTER);
jt = new JTextField();
jb = new JButton("确定");
JPanel jp1 = new JPanel(new GridLayout(1,3));
jp1.add(jl);
jp1.add(jt);
jp1.add(jb);
JLabel j1,j2,j3,j4;
j1 = new JLabel("学号:",SwingConstants.CENTER);
j2 = new JLabel("姓名:",SwingConstants.CENTER);
j3 = new JLabel("性别:",SwingConstants.CENTER);
j4 = new JLabel("年龄:",SwingConstants.CENTER);
jt1 = new JTextField(6);
jt1.setEditable(false);
jt2 = new JTextField(6);
jt2.setEditable(false);
jt3 = new JTextField(6);
jt3.setEditable(false);
jt4 = new JTextField(6);
jt4.setEditable(false);
JPanel jp2 = new JPanel(new BorderLayout());
JPanel jp3 = new JPanel(new GridLayout(4,2));
jp2.add(new JLabel(""),BorderLayout.NORTH);
jp3.add(j1);
jp3.add(jt1);
jp3.add(j2);
jp3.add(jt2);
jp3.add(j3);
jp3.add(jt3);
jp3.add(j4);
jp3.add(jt4);
jp2.add(jp3);
this.setLayout(new BorderLayout());
add(jp1,BorderLayout.NORTH);
add(jp2);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jb){
String stuNo = jt.getText().trim();
Student s = new Student();
boolean b = true;
try{
b = s.selectByStuNo(stuNo);
}
catch(Exception ex){
System.out.println("查询学生信息遇到异常!");
}
if(b){
jt1.setText(s.getStuNo());
jt2.setText(s.getName());
jt3.setText(s.getGender());
int a = s.getAge();
Integer i = new Integer(a);
jt4.setText(i.toString());
}
else{
JOptionPane.showMessageDialog(null, "无此学生!");
}
}
}

}
第五个:
import javax.swing.JFrame;
public class SelectTest {
public static void main(String [] args){
JFrame f = new JFrame("查询学生信息");
SelectPanel p = new SelectPanel();
f.add(p);
f.setSize(400,300);
f.setLocation(300,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第六个:
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class Student {
String stuNo;
String name;
String gender;
int age;
public Student(){}
public Student(String stuNo,String name,String gender, int age){
this.stuNo = stuNo;
this.name = name;
this.gender = gender;
this.age = age;
}
public String getStuNo(){
return stuNo;
}
public void setStuNo(String stuNo){
this.stuNo = stuNo;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getGender(){
return gender;
}
public void setGender(String gender){
this.gender = gender;
}
public int getAge(){
return age;
}
public void setAge(int age){
this.age = age;
}
public boolean insertStudent(){
boolean b = true;
try{
Connection con = MySQLConnection.getCon();
Statement statement = con.createStatement();
String sql = "insert into student values('" + stuNo + "','" + name +"','" + gender + "'," + age + ")";
sql = new String(sql.getBytes("gb2312"),"ISO8859_1");
statement.executeUpdate(sql);
con.close();
}
catch(Exception e){
b = false;
System.out.println("插入数据库遇到异常!");
}
return b;
}
public boolean selectByStuNo(String stuNo)throws Exception{
boolean b = true;
Connection con = MySQLConnection.getCon();
Statement statement = con.createStatement();
String sql = "select * from student where stuNo =" + stuNo;
ResultSet rs = statement.executeQuery(sql);
if(rs != null && rs.next()){
String no = rs.getString(1);
this.setStuNo(no);
String n = rs.getString(2);
n = new String(n.getBytes("ISO8859_1"),"gb2312");
this.setName(n);
String g = rs.getString(3);
g = new String (g.getBytes("ISO8859_1"),"gb2312");
this.setGender(g);
this.setAge(rs.getInt(4));
b = true;
}
rs.close();
statement.close();
con.close();
return b;
}
}
数据库你自己弄吧,我没时间弄了!初学得多动手哦

阅读全文

与信息管理网站源码相关的资料

热点内容
收件服务器怎么样 浏览:48
建筑设计规范pdf 浏览:98
如何合并两个pdf 浏览:174
刷机包必须要解压的单词 浏览:483
android课表实现 浏览:864
头条app在哪里能看见有什么活动 浏览:511
冰柜压缩机电容80欧 浏览:609
安卓各个版本图标什么样 浏览:152
无锡哪里有制作手机app 浏览:538
php字符串转json数组 浏览:6
数控网络编程课程有哪些 浏览:482
python30特效程序编码 浏览:392
安卓跟苹果互传照片用什么 浏览:848
原创小说app哪个好看 浏览:97
首台湖南造鲲鹏服务器云服务器 浏览:268
redhatphp 浏览:456
android智能家居蓝牙 浏览:646
pt螺纹编程 浏览:451
手机电音app哪个好 浏览:749
checksum命令 浏览:637