学生选课管理系统源代码

合集下载

c语言学生管理系统代码

c语言学生管理系统代码

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

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

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

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

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

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

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

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

学生选课系统代码

学生选课系统代码

数据库设计报告数据库名称:学生选课信息系统学院:信息科学与工程学院班级:控制0807班设计人:王文峰学号:09081413目录第一章前沿1.1 背景 (3)1.2 目的 (3)1.3 数据库基本概念 (3)第二章设计思想2.1需求分析 (4)2.2概要设计 (4)第三章详细设计3.1主窗体的创建 (8)3.2 信息查询模块 (9)3.3 信息添加模块 (12)3.4 信息删除模块 (14)3.5 信息修改模块 (16)3.6 本章小结 (21)第四章心得体会4.1数据库学习心得 (21)附录 (22)前沿1.1背景由于电脑时代的到来以及internet的迅速发展,电脑无出不在,当然各种工作效率也大幅提高,那么对于一个学校来说,开发一个好的学生信息管理系统势在必行。

鉴此,特开发此学生信息管理系统,该系统实现了办公无纸化、网络化、信息化、现代化。

随着学校的规模的不断扩大学生数量急剧增长,需要管理的各种信息也就成倍增加。

同时由于计算机和网络技术的普及,建立一个C/S或者B/S结构的教学管理系统之后,学生可以通过网络来选课并管理自己的信息,使得教学管理工作系统化,规范化,自动化,大大提高了教学管理信息的效率.教学信息管理系统是学校信息管理系统的一个重要组成部分。

1.2目的目的:通过实验熟练掌握MS SQL server 2000软件的使用,包括基本表的设计及定义,数据的输入和单表多表的查询。

并应用数据库知识设计开发小型学生管理系统。

1.3数据库的基本概念数据库技术与其他学科的内容相结合,是新一代数据库技术的一个显著特征。

在结合中涌现出各种新型的数据库,例如:数据库技术与分布处理技术相结合,出现了分布式数据库。

数据库技术与并行处理技术相结合,出现了并行数据库。

数据库技术与人工智能相结合,出现了演绎数据库、知识库和主动数据库。

数据库技术与多媒体处理技术相结合,出现了多媒体数据库。

数据库技术与模糊技术相结合,出现了模糊数据库。

学生选课系统C语言程序代码

学生选课系统C语言程序代码

#include<stdio.h>#include<stdlib.h>struct couse * head1;struct student * head2;struct couse//课程信息结构体{int num1;char name1[20];int score;int nelepeo;//课程已选人数int Melepeo;//课程人数上限struct couse * next;};struct student//学生信息结构体{int num2;char name2[20];int nelenum[50];//已选课程编号int nelen;//已选课程数量struct student * next;};void keyboardc()//录入课程子函数(从键盘录入){struct couse *p1,*p2;N1=0;p1=p2=(struct couse*)malloc(sizeof(struct couse)); printf("\n课程编号\t课程名称\t学分\t课程人数上限\n");scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1 ->Melepeo);p1->nelepeo=0;head1=NULL;while(p1->num1!=0&&p1->num1!='#'){N1=N1+1;if(N1==1)head1=p1;else p2->next=p1;p2=p1;p1=(struct couse * )malloc(sizeof(struct couse));scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1 ->Melepeo);p1->nelepeo=0;}p2->next=NULL;}void inputc()//录入课程主函数{int i;printf("\n录入课程信息\n");printf("\n1.从键盘录入\n"); printf("\n2.返回主菜单\n");printf("\n请选择编号(1~3):\n");scanf("%d",&i);switch(i){case(1):keyboardc();break;case(2):break;}}void insertc(struct couse *incouse)//课程信息增加子函数{struct couse *p0,*p1,*p2;p1=head1;p0=incouse;if(head1==NULL){head1=p0;p0->next=NULL;}else{while((p0->num1>p1->num1)&&(p1->next!=NULL)) {p2=p1;p1=p1->next;}if(p0->num1 <= p1->num1){if(head1==p1) head1=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}N1=N1+1;}void delc(int num1)//课程信息删除子函数{struct couse *p1,*p2;if(head1==NULL){printf("\n没有课程,无法删除!\n"); goto end;}p1=head1;while(num1!=p1->num1 && p1->next!=NULL) {p2=p1;p1=p1->next;}if(num1==p1->num1){if(p1==head1) head1=p1->next;else p2->next=p1->next;printf("\n已删除该编号课程!\n");N1=N1-1;}else printf("\n无该编号的课程!\n");end:;}void managementc()//课程信息管理主函数{struct couse * incouse;int i,num1;printf("\n课程管理\n");printf("\n1.新增课程\n");printf("\n2.删除课程\n");printf("\n3.返回主菜单\n");printf("\n请选择编号(1~3):\n");scanf("%d",&i);switch(i){case(1):{incouse=(struct couse*)malloc(sizeof(struct couse));printf("\n课程编号\t课程名称\t学分\t课程人数上限\n");scanf("%d%s%d%d",&incouse->num1,incouse->name1,&inc ouse->score,&incouse->Melepeo);incouse->nelepeo=0;insertc(incouse);break;}case(2):{printf("\n请输入要删除课程的编号:\n"); scanf("%d",&num1);delc(num1);break;}case(3):break;}}void keyboards()//录入学生信息子函数(从键盘录入){int i;struct student *p1,*p2;N2=0;p1=p2=(struct student *)malloc(sizeof(struct student));printf("\n学生学号\t学生姓名\n");scanf("%d%s",&p1->num2,p1->name2);p1->nelen=0;for(i=0;i<20;i++) p1->nelenum[i]=0;head2=NULL;while(p1->num2!=0){N2=N2+1;if(N2==1)head2=p1;else p2->next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student));scanf("%d%s",&p1->num2,p1->name2);p1->nelen=0;for(i=0;i<20;i++) p1->nelenum[i]=0;}p2->next=NULL;}void inputs()//录入学生信息主函数{int i;printf("\n录入学生信息\n");printf("\n1.从键盘录入\n");printf("\n2.返回主菜单\n");printf("\n请选择编号(1~2):\n");scanf("%d",&i);switch(i){case(1):keyboards();break;case(2):break;}}void inserts(struct student * incouse)//学生信息增加子函数{struct student *p0,*p1,*p2;p1=head2;p0=incouse;if(head2==NULL){head2=p0;p0->next=NULL;}else{while((p0->num2 > p1->num2) && (p1->next!=NULL)){p2=p1;p1=p1->next;}if(p0->num2 <= p1->num2){if(head2==p1) head2=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}N2=N2+1;}void dels(int num2)//学生信息删除子函数{struct student *p1,*p2;if(head2==NULL){printf("\n没有该学生信息,无法删除!\n"); goto end;}p1=head2;while(num2!=p1->num2 && p1->next!=NULL){p2=p1;p1=p1->next;}if(num2==p1->num2){if(p1==head2) head2=p1->next;else p2->next=p1->next;printf("\n已删除该学生信息!\n");N2=N2-1;}else printf("\n无该学号的学生!\n");end:;}void managements()//学生信息管理主函数{struct student * incouse;int i,num2;printf("\n学生信息管理\n");printf("\n1.新增学生信息\n");printf("\n2.删除学生信息\n");printf("\n3.返回主菜单\n");printf("\n请选择编号(1~3):\n");scanf("%d",&i);switch(i){case(1):{incouse=(struct student*)malloc(sizeof(struct student));incouse->nelen=0;incouse->nelenum[0]=0;printf("\n学生学号\t学生姓名\n");scanf("%d%s",&incouse->num2,incouse->name2);inserts(incouse);break;}case(2):{printf("\n请输入要删除学生的学号:\n"); scanf("%d",&num2);dels(num2);break;}case(3):break;}}void elect(struct student * s)//学生选课子函数(进行选课){struct couse * p;int num1,i;printf("\n请输入要选课的编号:\n");scanf("%d",&num1);for(i=0;s->nelenum[i]!=0;i++);s->nelenum[i]=num1;(s->nelen)++;p=head1;while(p->num1!=num1) p=p->next;(p->nelepeo)++;}void cheak()//学生选课子函数(查询可选课程){char e;struct couse * c;struct student * s;int num2,i,j=0,t=0;printf("\n请输入你的学号:\n");scanf("%d",&num2);s=head2;while(s->num2!=num2 && s->next!=NULL) s=s->next; if(s->num2!=num2){printf("\n不存在你的信息,请进入主菜单录入你的信息!\n");goto end;}c=head1;printf("\n你的可选课程编号:\n");while(c!=NULL){for(t=0,i=0;s->nelenum[i]!=0;i++){if(c->num1==s->nelenum[i]) t=1;}if(t==0 && (c->nelepeo!=c->Melepeo)){printf("%d ",c->num1);j++;}c=c->next;}if(j==0){printf("\n你已选完所有课程,无法再多选!\n"); goto end;}printf("\n选课(y/n)?:\n");getchar();e=getchar();i=0;while(e=='y'){elect(s);printf("\n继续选课(y/n)?:\n");getchar();e=getchar();}end:;}void back(struct student * p)//退选课程{struct couse * p1;int num1,i,j;printf("\n请输入你要退掉的课程编号:\n");scanf("%d",&num1);p1=head1;while(p1->num1!=num1) p1=p1->next;for(i=0;p->nelenum[i]!=num1;i++);for(j=i;p->nelenum[j]!=0;j++)p->nelenum[j]=p->nelenum[j+1];p->nelenum[--j]=0;(p1->nelepeo)--;printf("\n退课成功!\n");}void hcheak()//学生选课子函数(查询已选课程){char c;struct couse * p0;struct student * p;int num2,i,f=0;printf("\n请输入学号:\n");scanf("%d",&num2);p=head2;while(p->num2!=num2 && p!=NULL) p=p->next;if(p==NULL){printf("\n不存在你的信息,请回主菜单录入信息:\n");goto end;}printf("\n已选课程编号:\n");if(p->nelenum[0]==0){printf("\n你还没选课!\n");goto end;}for(i=0;p->nelenum[i]!=0;i++){printf("%d\n",p->nelenum[i]);p0=head1;while(p0->num1!=p->nelenum[i]) p0=p0->next; f=f+p0->score;}printf("\n总学分:%d\n",f);printf("\n是否进行退课(y/n)?\n");getchar();c=getchar();while(c=='y'){back(p);printf("\n继续退课(y/n)?"); getchar();c=getchar();(p->nelen)--;}end:;}void elective()//学生选课主函数{int i;printf("\n学生选课\n");printf("\n1.查询可选课程\n");printf("\n2.查询已选课程\n");printf("\n3.返回主菜单\n");printf("\n请输入(1~3):\n");scanf("%d",&i);switch(i){case(1):cheak();break;case(2):hcheak();break;case(3):break;}}void listc()//查看课程信息{struct couse * p;p=head1;printf("\n课程编号课程名称学分课程已选人数课程人数上限\n");while(p!=NULL){printf("%-8d%10s%6d%8d%12d\n",p->num1,p->name1,p->s core,p->nelepeo,p->Melepeo);p=p->next;}}void lists()//查看学生信息{struct student * p;p=head2;printf("\n学生学号学生姓名已选课程数量\n"); while(p!=NULL){printf("%-4d %10s %6d\n",p->num2,p->name2,p->nelen); p=p->next;}}void store()//系统信息查看主函数{int i;printf("\n系统信息查看\n");printf("\n1.查看课程信息\n");printf("\n2.查看学生信息\n");printf("\n3.返回主菜单\n");printf("\n请输入编号(1~3):\n");scanf("%d",&i);switch(i){case(1):listc();break;case(2):lists();break;case(3):break;}}int main()//主函数{system("color f0");int i;start:printf("\n******************************欢迎使用学生选课系统******************************\n");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 6.系统信息查看 \n");printf("\n 7.退出选课系统 \n");printf("\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n"); printf("\n请输入菜单选项编号(1~7):\n");scanf("%d",&i);if(i<1 || i>7){printf("\n输入错误,请重输:\n");goto start;}switch(i){case(1):{system("cls");//清屏函数inputc();goto start;break;}case(2):{system("cls"); managementc(); goto start;break;}case(3):{system("cls"); inputs();goto start;break;}case(4):{system("cls"); managements(); goto start;break;}case(5):{system("cls");elective();goto start;break;}case(6):{system("cls");store();goto start;break;}case(7):{system("cls");printf("\n感谢使用本系统!再见!\n"); }}return(0);}。

C++程序设计源代码 学生选课系统

C++程序设计源代码 学生选课系统
编号的课程,如果存在则提示重新输入,否则将该课程按照顺序插入到相 应位置 5)删除一门课程的基本信息,通过输入课程编号,首先查找是否存在该课程 编号的课程,如果存在则将该课程删除,否则给出提示信息,提示该课程 不存在 6)对课程信息进行修改。 7)选修一门课程,需要给出学号和课程编号,如果课程编号不存在则重新输 入,直到输入正确为止,并将学号和相应的课程编号存入 SelectInfo.txt 文件中 8)查看所选课程。
I
目录
第一章 设计题目的内容、任务及具体要求 ..................................1 第二章 总体设计思路 ....................................................2
2.1 程序功能 ........................................................... 2 2.2 模块关系 ........................................................... 2 2.3 总体框图 ............................................................ 3 第三章 功能模块的具体设计 ..............................................4 3.1 主函数模块的设计 ................................................... 4 3.2 显示课程信息模块的设计 ............................................. 7 3.3 查询模块模块的设计 ................................................. 8 3.4 增加模块的设计 ..................................................... 9 3.5 删除模块模块的设计 ................................................ 13 3.6 修改模块模块的设计 ................................................ 14 3.7 选课模块的设计 .................................................... 15 3.8 显示选课情况模块的设计 ............................................. 17 第四章 功能模块的调试及测试 ...........................................18 4.1 登陆界面和主菜单界面的显示 ........................................ 18 4.2 查询所有课程信息的显示结果 ........................................ 19 4.3 查询单个课程信息的显示结果 ........................................ 19 4.4 添加课程信息的显示结果 ............................................ 20 4.5 删除和修改课程信息的显示结果 ...................................... 20 4.6 选课的显示结果 .................................................... 21 4.7 查询选课情况的显示结果 ............................................ 22 4.8 退出 .............................................................. 22 总结 ..................................................................23 致 谢 ................................................................24 参考资料:............................................................. 25 附程序清单............................................................. 26

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

基于python的学生选课管理系统的设计与实现

基于python的学生选课管理系统的设计与实现

**基于Python的学生选课管理系统的设计与实现****一、引言**随着信息技术的发展和教育信息化的推进,学生选课管理系统已成为现代校园管理的重要组成部分。

本文档将详细介绍一个基于Python的学生选课管理系统的设计与实现,系统主要包含用户登录与注册、课程信息管理、学生信息管理、选课操作管理、选课结果查询、系统设置与维护、数据备份与恢复、系统帮助与文档等核心功能。

**二、系统设计****1. 系统架构**本系统采用客户端-服务器(C/S)架构,服务器端使用Python语言编写,客户端支持多种操作系统,并通过Web浏览器进行访问。

**2. 数据库设计**系统采用关系型数据库管理系统 (RDBMS)存储数据,主要包括用户表、课程表、学生表、选课表等。

**三、功能实现****1. 用户登录与注册**系统提供用户登录与注册功能,用户包括学生、教师和管理员。

学生可以通过注册功能创建账号,并使用账号登录系统。

教师和管理员由系统管理员创建账号,具有更高的权限。

**2. 课程信息管理**系统提供课程信息管理功能,管理员可以添加、修改、删除课程信息,包括课程名称、课程编号、课程学分等。

**3. 学生信息管理**系统提供学生信息管理功能,管理员可以添加、修改、删除学生信息,包括学号、姓名、性别、班级等。

**4. 选课操作管理**学生可以在选课操作管理模块中浏览可选课程,选择自己感兴趣的课程进行选课。

选课过程中,系统会检查学生的选课限制(如学分限制、课程冲突等),确保选课的正确性。

**5. 选课结果查询**系统提供选课结果查询功能,学生和管理员可以查询选课结果,包括学生选课情况、课程选课人数等。

**6. 系统设置与维护**系统管理员可以通过系统设置与维护模块进行系统设置,包括用户权限管理、系统参数设置等。

同时,系统提供日志记录功能,记录用户的操作日志,便于管理员进行系统维护。

**7. 数据备份与恢复**系统提供数据备份与恢复功能,管理员可以定期备份数据库数据,以防止数据丢失。

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

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

系统源代码一、登录界面代码using System;using System.Data;using System。

Configuration;using System。

Collections;using System.Web;using System.Web。

Security;using System。

Web.UI;using System。

Web。

UI。

WebControls;using System.Web。

UI.WebControls。

WebParts;using System。

Web.UI.HtmlControls;using System.Data。

SqlClient;public partial class login :System.Web。

UI。

Page{protected void txtid_Click(object sender,EventArgs e){txtid.Text = ”";txtpassword。

Text = ””;}protected void Button1_Click(object sender, EventArgs e){string strconn = ConfigurationManager。

AppSettings[”connStr”];SqlConnection conn = new SqlConnection(strconn);conn。

Open();DataSet ds=new DataSet ();SqlDataAdapter da = new SqlDataAdapter("select * from users where userid=’" + txtid。

Text + "' and userpwd=’” + txtpassword.Text + ”’", conn);da.Fill(ds);if (ds。

教务管理系统源代码

教务管理系统源代码

教务管理系统源代码开发人:吕双武01083088西安交通大学管理学院信管11 班2004-5-25一、主页登录部分default.asp<% Option Explicit %><% Response.Buffer=True %><%If Trim(request.form("username"))<>"" AND Trim(request.form("pswd"))<>"" Then Dim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim userid,pswd,strsql,rsuserid=Request.Form("username")pswd=Request.Form("pswd")End IfIf request.form("D1")="学生" Thenstrsql="Select * From stu Where sno='"&userid&"'"Set rs=db.Execute(strsql)If pswd=rs("spin") ThenSession("stuid")=useridResponse.Redirect"student.asp"ElseResponse.write"密码错误"End IfElseIf request.form("D1")="教师" Thenstrsql="Select * From tea Where tno='"&userid&"'"Set rs=db.Execute(strsql)If pswd=rs("tpin") ThenSession("teaid")=useridResponse.Redirect"teacher.asp"ElseResponse.write"密码错误"End IfElseIf request.form("D1")="教务管理员" Thenstrsql="Select * From adm Where adm='"&userid&"'"Set rs=db.Execute(strsql)If pswd=rs("apin") ThenSession("admid")=useridResponse.Redirect"adm.asp"ElseResponse.write"密码错误"End IfElseSession("stuid")=""Session("teaid")=""Session("admid")=""End If%>二、学生用户界面(一)实现选课student.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("stuid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseDim stuid,cnoidstuid=Session("stuid")cnoid=Request.form("T1")Dim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Insert Into score(cno,sno) Values('"&cnoid&"','"&stuid&"')"Set rs=db.Execute(strsql)End Ifdb.closeSet db=Nothing%>(二)显示课表cou_list.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("stuid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select Distinct o,ame,cou.tno, cou.room From cou"Set rs=db.Execute(strsql)End if%><div align="center"><table border="1" width="80%" id="table2" cellpadding="0"> <tr> <td align="center">课程编号</td><td align="center">课程名称</td><td align="center">任课教师</td><td align="center">上课地点</td></tr><%Do While Not rs.Eof%><tr> <td align="center"><%=rs("cno")%></td><td align="center"><%=rs("cname")%></td><td align="center"><%=rs("tno")%></td><td align="center"><%=rs("room")%></td></tr><%rs.MoveNextLoop%></table></div>(三)成绩查询mark.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("stuid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim rs,strsqlstrsql="Select * From score Where sno='"&Session("stuid")&"'"Set rs=db.Execute(strsql)End if%><tr><td align="center" height="34">学号</td><td align="center" height="34">课号</td><td align="center" height="34">成绩</td></tr><%Do While Not rs.Eof%><tr><td align="center" ><%=rs("sno")%></td><td align="center" ><%=rs("cno")%></td><td align="center" ><%=rs("mark")%></td></tr><%rs.MoveNextLoop%>三、教师用户界面实现成绩录入功能teacher.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("teaid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseIf Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>""ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,cno,sno,markcno=Request.Form("T1")sno=Request.Form("T2")mark=Request.Form("T3")strsql="Update score Set mark='"&mark&"'Where cno='"&cno&"'And sno='"&sno&"'And tno='"&Session("teaid")&"'"db.Execute(strsql)Response.Write "添加成功"End If%>四、教务管理员登录界面adm.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"End If%>(一)课程信息维护1、显示课程信息adm_cou.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select * From cou"Set rs=db.Execute(strsql)End if%><form method="POST" action=""><table border="0" width="100%" id="table8"><%Do While Not rs.Eof%><tr><td align="center" height="27"><%=rs("cno")%></td><td align="center" height="27"><%=rs("cname")%></td><td align="center" height="27"><%=rs("tno")%></td><td align="center" height="27"><%=rs("room")%></td><td align="center"height="27"><a href="update_cou.asp?cno=<%=rs("cno")%>">修改</a></td> <td align="center" height="27"><a href="dele_cou.asp?cno=<%=rs("cno")%>">删除</a></td> </tr><%rs.MoveNextLoop%></table></form>2、修改课程信息update_cou.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.write"请先登录"Response.Redirect "default.asp"ElseDim cnocno=Request.QueryString("cno")Session("cno")=cnoDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select * From cou Where cno='"&cno&"'"Set rs=db.Execute(strsql)End If%>3、修改课程的执行程序update3.asp<% Option Explicit %><%Dim cnoidcnoid=Session("cno")If Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>""And Request.Form("T5")<>"" ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim cno,cname,tno,stime,room,strsqlcno=Request.Form("T1")cname=Request.Form("T2")tno=Request.Form("T3")room=Request.Form("T5")strsql="Update cou Set cno='"&cno&"',cname='"&cname&"',tno='"&tno&"',room='"&room&"' Where cno='"&cnoid&"'"db.Execute(strsql)Response.Redirect "adm_cou.asp"Response.Write"修改成功"End If%>4、删除课程的执行程序dele_cou.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.write"请先登录"Response.Redirect "default.asp"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,cnocno=Request.QueryString("cno")strsql="Delete From cou Where cno='"&cno&"'"db.Execute(strsql)Response.Redirect"adm_cou.asp"End if%>5、添加课程的执行程序add_cou.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.Redirect "default.asp"End IfIf Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>"" And Request.Form("T5")<>"" ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,cno,cname,tno,stime,roomcno=Request.Form("T1")cname=Request.Form("T2")tno=Request.Form("T3")room=Request.Form("T5")strsql="Insert Into cou(cno,cname,tno,room) Values('"&cno&"','"&cname&"','"&tno&"','"&room&"')"db.Execute(strsql)Response.Redirect"add_cou.asp"Response.write"添加成功"End If%>(二)教师信息维护1、显示教师信息adm_tea.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select tno,tname,ttel From tea"Set rs=db.Execute(strsql)End if%><form method="POST" action=""><table border="0" width="100%" id="table8"><%Do While Not rs.Eof%><tr><td width="20%" align="center"><%=rs("tno")%></td><td width="20%" align="center"><%=rs("tname")%></td><td width="19%" align="center"><%=rs("ttel")%></td><td width="19%" align="center"><a href="update_tea.asp?tno=<%=rs("tno")%>">修改</a></td><td width="19%" align="center"><a href="dele_tea.asp?tno=<%=rs("tno")%>">删除</a></td></tr><%rs.MoveNextLoop%></table></form>2、修改教师信息update_tea<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.write"请先登录"Response.Redirect "default.asp"ElseDim tnotno=Request.QueryString("tno")Session("tno")=tnoDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select * From tea Where tno='"&tno&"'"Set rs=db.Execute(strsql)End If%>3、修改教师信息的执行程序update2.asp<% Option Explicit %><%Dim tnoidtnoid=Session("tno")If Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>""ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim tno,tname,ttel,strsqltno=Request.Form("T1")tname=Request.Form("T2")ttel=Request.Form("T3")strsql="Update tea Set tno='"&tno&"',tname='"&tname&"',ttel='"&ttel&"'Where tno='"&tnoid&"'"db.Execute(strsql)Response.Redirect"adm_tea.asp"ElseResponse.Write"请将所有信息填写完整"Response.Write"<a href='adm_tea.asp'>重新修改</a>"End If%>4、删除教师信息的执行程序dele_tea.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.write"请先登录"Response.Redirect "default.asp"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,tnotno=Request.QueryString("tno")strsql="Delete From tea Where tno='"&tno&"'"db.Execute(strsql)Response.Redirect"adm_tea.asp"End if%>5、添加信息教师信息的执行程序add_tea.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"End IfIf Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>""ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,tno,tname,tteltno=Request.Form("T1")tname=Request.Form("T2")ttel=Request.Form("T3")strsql="Insert Into tea(tno,tname,ttel) Values('"&tno&"','"&tname&"','"&ttel&"')"db.Execute(strsql)Response.Redirect"add_tea.asp"Response.write"添加成功"End If%>(三)学生信息维护1、显示学生信息adm_stu.asp<% Option Explicit %><% Response.Buffer=True%><%If Session("admid")="" ThenResponse.Redirect "default.asp"Response.write"请先登录"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select distinct sno,sname,ssex,class From stu"Set rs=db.Execute(strsql)End if%><form method="POST" action="update_1.asp"><table border="0" width="100%" id="table8"><%Do While Not rs.Eof%><tr><td width="17%" align="center"><%=rs("sno")%></td><td width="16%" align="center"><%=rs("sname")%></td><td width="16%" align="center"><%=rs("ssex")%></td><td width="16%" align="center"><%=rs("class")%></td><td width="16%" align="center"><a href="update_stu.asp?sno=<%=rs("sno")%>">修改</a> </td><td width="16%" align="center"><a href="dele_stu.asp?sno=<%=rs("sno")%>">删除</a></td> </tr><%rs.MoveNextLoop%></table></form>2、修改学生信息update_stu.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.write"请先登录"Response.Redirect "default.asp"ElseDim snosno=Request.QueryString("sno")Session("sno")=snoDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,rsstrsql="Select * From stu Where sno='"&sno&"'"Set rs=db.Execute(strsql)End If%>3、修改学生信息的执行程序update1.asp<% Option Explicit %><%Dim snoidsnoid=Session("sno")If Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>"" And Request.Form("T4")<>"" ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim sno,sname,ssex,sclass,strsqlsno=Request.Form("T1")sname=Request.Form("T2")ssex=Request.Form("T3")sclass=Request.Form("T4")strsql="Update stu Set sno='"&sno&"',sname='"&sname&"',ssex='"&ssex&"',class='"&sclass&"'Wheresno='"&snoid&"'"db.Execute(strsql)Response.Redirect"adm_stu.asp"ElseResponse.Write"请将所有信息填写完整"Response.Write"<a href='adm_stu.asp'>重新修改</a>"End If%>4、删除学生信息的执行程序dele_stu.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.write"请先登录"Response.Redirect "default.asp"ElseDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,snosno=Request.QueryString("sno")strsql="Delete From stu Where sno='"&sno&"'"db.Execute(strsql)Response.Redirect"adm_stu.asp"End if%>5、添加学生信息的执行程序add_stu.asp<% Option Explicit %><% Response.Buffer=True %><%If Session("admid")="" ThenResponse.Redirect "default.asp"End IfIf Request.Form("T1")<>"" And Request.Form("T2")<>"" And Request.Form("T3")<>"" And Request.Form("T4")<>"" ThenDim dbSet db=Server.CreateObject("ADODB.Connection")db.Open "jiaowu"Dim strsql,sno,sname,ssex,sclasssno=Request.Form("T1")sname=Request.Form("T2")ssex=Request.Form("T3")sclass=Request.Form("T4")strsql="Insert Into stu(sno,sname,ssex,class) Values('"&sno&"','"&sname&"','"&ssex&"','"&sclass&"')"db.Execute(strsql)Response.Redirect"add_stu.asp"Response.write"添加成功"End If%>说明部分:1、由于在该教务管理系统中加入了较为复杂的XML 代码,所以在这里只给出了主要的与系统功能相关的ASP文件中的VBScript代码。

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

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

学生信息管理系统完整源代码注:本系统采用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("授课信息重复");。

选课管理系统java代码

选课管理系统java代码

选课管理系统java代码下面是一个简单的选课管理系统的 Java 代码示例,包含了学生选课和教师查看选课信息两个主要功能:```javaimport java.util.ArrayList;import java.util.List;public class CourseManagementSystem {// 学生类static class Student {private String name;private List<Course> courses;public Student(String name) { = name;this.courses = new ArrayList<>();}public void addCourse(Course course) {courses.add(course);}public List<Course> getCourses() {return courses;}}// 课程类static class Course {private String courseName;private int credit;public Course(String courseName, int credit) {this.courseName = courseName;this.credit = credit;}}// 选课管理系统类static class CourseManagementSystem {private List<Student> students;private List<Course> courses;public CourseManagementSystem() {students = new ArrayList<>();courses = new ArrayList<>();}public void addStudent(Student student) {students.add(student);}public void addCourse(Course course) {courses.add(course);}public List<Student> getStudents() {return students;}public List<Course> getCourses() {return courses;}public void viewStudentCourses(Student student) {System.out.println( + " 选修的课程:");for (Course course : student.getCourses()) {System.out.println(course.courseName + "(" + course.credit + " 学分)");}}}public static void main(String[] args) {// 创建选课管理系统对象CourseManagementSystem system = new CourseManagementSystem();// 创建学生对象并选课Student student1 = new Student("Alice");Student student2 = new Student("Bob");Course course1 = new Course("数据结构与算法", 3);Course course2 = new Course("操作系统", 3);student1.addCourse(course1);student1.addCourse(course2);student2.addCourse(course1);// 将学生添加到系统中system.addStudent(student1);system.addStudent(student2);// 创建教师对象并查看学生选课信息Teacher teacher = new Teacher("Mr. Wang");system.viewStudentCourses(student1);system.viewStudentCourses(student2);}}```上述代码实现了一个简单的选课管理系统,包含学生选课和教师查看选课信息两个主要功能。

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

学生管理系统c语言源代码

学生管理系统c语言源代码

学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。

学生选课管理系统(全源代码,Linux环境)

学生选课管理系统(全源代码,Linux环境)

//*************************************************************//*********************************************************//list.h文件#ifndef _LIST_H#define _LIST_H#define _INLINE_ static inlinestruct list_head {struct list_head *next, *prev;};#define LIST_HEAD_INIT(name){&(name), &(name)}#define LIST_HEAD(name) \struct list_head name = LIST_HEAD_INIT(name)#define INIT_LIST_HEAD(ptr)do {\(ptr)->next = (ptr);(ptr)->prev = (ptr);\} while (0)_INLINE_ void __list_add(struct list_head *add,struct list_head *prev,struct list_head *next){next—〉prev = add;add->next = next;add—〉prev = prev;prev—〉next = add;}_INLINE_ void list_add(struct list_head *add, struct list_head *head) {__list_add(add, head,head—〉next);}_INLINE_ void list_add_tail(struct list_head *add, struct list_head *head){__list_add(add, head->prev,head);}_INLINE_ void __list_del(struct list_head *prev, struct list_head *next){next—>prev = prev;prev—>next = next;}_INLINE_ void list_del(struct list_head *entry){__list_del(entry-〉prev,entry—>next);}_INLINE_ void list_del_init(struct list_head *entry){__list_del(entry—〉prev,entry->next);INIT_LIST_HEAD(entry);}_INLINE_ int list_empty(struct list_head *head){return head->next == head;}_INLINE_ void list_splice(struct list_head *list,struct list_head *head){struct list_head *first = list—>next;if (first != list) {struct list_head *last = list->prev;struct list_head *at = head->next;first—〉prev = head;head—〉next = first;last—〉next = at;at-〉prev = last;}}#define list_entry(ptr, type, member)\((type *)((char *)(ptr) - (unsigned long)(&((type *)0)—>member)))#define list_for_each(pos, head)\for (pos = (head)->next; pos != (head);pos = pos—〉next)#define list_for_each_safe(pos,pnext, head) \for (pos = (head)—〉next, pnext = pos—>next;pos != (head);\pos = pnext, pnext = pos—〉next)#undef _INLINE_#endif//** ********************************************************************8//***********************************************************************//****头文件head。

基于Java的选课管理系统的设计与实现

基于Java的选课管理系统的设计与实现

基于Java的选课管理系统的设计与实现选课管理系统是一个非常重要且实用的教务管理系统,旨在解决学校选课流程中的各种问题。

本文将介绍基于Java的选课管理系统的设计与实现。

1.选课管理系统的功能设计本系统的功能主要包括学生选课、课程管理、教师管理、学生管理、成绩管理等。

(1)学生选课:学生可以根据自己的兴趣和需求选择相应的课程进行学习。

(2)课程管理:管理员可以对课程进行增、删、改、查的操作,包括课程名称、授课教师、学时、课程描述等。

(4)学生管理:管理员可以对学生进行管理,包括添加、修改、删除、查询等,同时可以查看某个学生已经选择的课程。

本系统采用MVC结构进行设计,MVC(Model-View-Controller)是一种软件架构模式,在本系统中,Model(模型)负责业务逻辑、数据的存储和读取,View(视图)负责显示数据和用户交互,Controller(控制器)负责处理用户请求。

以下是选课管理系统的部分代码:(1)课程管理:public class Course{private Integer courseId;private String courseName;private String teacherName;private Integer period;private String description;//省略getter和setter方法}public class CourseDao{public List<Course> findAll() throws SQLException {Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;List<Course> courses = new ArrayList<>();try {conn = C3p0Utils.getConnection();String sql = "select * from course";ps = conn.prepareStatement(sql);rs = ps.executeQuery();while (rs.next()) {Course course = new Course();course.setCourseId(rs.getInt("courseId"));course.setCourseName(rs.getString("courseName")); course.setTeacherName(rs.getString("teacherName")); course.setPeriod(rs.getInt("period"));course.setDescription(rs.getString("description")); courses.add(course);}} finally {C3p0Utils.release(conn, ps, rs);}return courses;}}(2)学生选课:(3)管理员查看成绩:以上仅仅是选课管理系统的部分代码,实际上涉及到的技术更加丰富和复杂,包括了Java Web(Servlet、JSP等)、数据库(MySQL、Oracle等)、ORM框架(Hibernate、MyBatis等)、Web容器(Tomcat、Jetty等)等。

选课系统源代码

选课系统源代码
年龄 int check ( 年龄 between 20 and 100),
职称 char(10) not null default '讲师',
工资 smallmoney ,
岗位津贴 smallmoney ,
系别 char(10) not null
--创建授课关系表
use 学生选课管理系统
go
create table 授课关系表
(
教师号 char(10) not null,
课程号 char(10) not null,
constraint Teaching_Prim primary key (教师号,课程号),
where 姓名=@姓名
exec 姓名查找教师信息 '李力'
--drop Procedure 教师号查找教师信息
create Procedure 教师号查找教师信息
(
@教师号 char(10)
)
as
if (@教师号 is null)
begin
--创建选课关系表
use 学生选课管理系统
go
create table 选课关系表
(
学号 char(10) not null ,
课程号 char(10) not null,
成绩 numeric(6,2),
constraint Choice_Prim primary key (学号,课程号),
课程名,
成绩
from 学生信息表,课程信息表,选课关系表
where 学生信息表.学号 =选课关系表.学号 and 选课关系表.课程号 = 课程信息表.课程号

课程设计:学生学籍管理系统源代码

课程设计:学生学籍管理系统源代码

#include”stdio。

h”#include"conio。

h”#include"stdlib。

h”#include”string。

h"#define N 1000 //N为可输入的学生总人数,可根据需要更改#define M 2 //M为宏定义的(在创建密码函数中)可建立的登陆用户个数,可更改struct student //定义学生信息结构体数组{char num[9]; //学号char name[20]; //姓名char depar[15]; //院系char zhuanye[15];//专业char classes[5]; //班级char age[3];//年龄char sex[4]; //性别char nation[5]; //民族char birth[9]; //出生日期char add[10];//籍贯};struct code //定义密码结构体数组{char name[20];char code[7];}co[M],s0;//确认是否新创建密码文件模块int code(){FILE *fp;if((fp=fopen("学生学籍管理系统__code。

txt","rt"))==NULL){printf(”密码文件不存在,请输入新的用户名及密码:\n");//若不存在此密码文件,则提示用户创建密码printf("请输入任意键继续!”);getch();system("cls");return 1; //无密码文件返回1 }elsereturn 0; //已有密码文件返回0 }//新创建初始密码void code_input(){FILE *fp;int i;if((fp=fopen(”学生学籍管理系统__code。

txt”,"wt"))==NULL);//当建立密码文件成功时,进入for循环for(i=0;i〈M;i++) //M为宏定义的可建立的登陆用户个数,可更改{printf("请录入第%d个用户名:",i+1);//创建不同的用户名及密码scanf(”%s",co[i]。

学生学籍管理系统源代码

学生学籍管理系统源代码

学生学籍管理系统源代码源代码:连接数据库的代码:package cn.system.manage.tools; import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class DBAccess {final static private String strDriver="com.mysql.jdbc.Driver";final static private Stringurl="jdbc:mysql://localhost:3306/xjgl?userUnicode=true&characterEnco ding=gb2312";final static private String user="root";final static private String password="admin";private static DBAccess db = null;private Connection con;private Statement stmt;private ResultSet rst;private DBAccess(){try {Class.forName(strDriver);con=DriverManager.getConnection(url, user, password); stmt=con.createStatement();} catch (ClassNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}public static DBAccess getDBAccess(){if(db==null){db= new DBAccess();}return db;}public Connection getConnection(){return con;}public ResultSet query(String sql){try {rst=stmt.executeQuery(sql);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}return rst;}public int update(String sql){int flag=0;try {flag=stmt.executeUpdate(sql);} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();return -1;}return flag;}public void close(){try {rst.close();stmt.close();con.close();} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();}}public ResultSet queryScroll(String sql){try{stmt = con.createStatement(1004, 1007);return stmt.executeQuery(sql);}catch(SQLException sqlexception){return null;}}}转换字符集代码:package cn.system.manage.tools;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException; import javax.servlet.ServletRequest;import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse; public class CharFilter implements Filter {public void destroy() {// TODO Auto-generated method stub}public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {// TODO Auto-generated method stubHttpServletRequest request = (HttpServletRequest)arg0;HttpServletResponse response = (HttpServletResponse)arg1;request.setCharacterEncoding("GBK");response.setCharacterEncoding("GBK");arg2.doFilter(arg0, arg1);}public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub}}分页代码:package cn.system.manage.tools;import java.io.Serializable;import java.util.ArrayList;public class PageBean implements Serializable{ArrayList list;int pageNo;int pageSize;int pageSum;int rowCount;int pagePrev;int pageNext;int hasFirst;int hasPrev;int hasNext;int hasEnd;public PageBean(){list = null;list = new ArrayList();}public ArrayList getList(){return list;}public void setPageInfo(int myRowCount, int myPageSize) {if(myPageSize > 0){setPageSize(myPageSize);setRowCount(myRowCount);if(myRowCount > 0)setPageSum(((myRowCount + myPageSize) - 1) / myPageSize); }}public void setList(ArrayList list){this.list = list;}public int getPageNo(){return pageNo;}public void setPageNo(int pageNo){this.pageNo = pageNo;}public int getPagePrev(){return pageNo - 1;}public int getPageNext(){return pageNo + 1;}public int getPageSum(){return pageSum;}public void setPageSum(int pageSum) {this.pageSum = pageSum;}public int getHasPrev(){if(pageSum > 1)return pageNo >= 2 ? 1 : 0;elsereturn 0;}public int getHasNext(){if(pageSum > 1)return pageNo < pageSum ? 1 : 0; elsereturn 0;}public int getHasFirst(){if(pageSum > 1)return pageNo <= 1 ? 0 : 1;elsereturn 0;}public int getHasEnd(){if(pageSum > 1)return pageNo >= pageSum ? 0 : 1; elsereturn 0;}public int getPageSize(){return pageSize;}public void setPageSize(int pageSize) {this.pageSize = pageSize;}public void setPagePrev(int pagePrev) {this.pagePrev = pagePrev;}public void setHasPrev(int hasPrev) {this.hasPrev = hasPrev;}public void setHasNext(int hasNext) {this.hasNext = hasNext;}public void setHasFirst(int hasFirst) {this.hasFirst = hasFirst;}public void setHasEnd(int hasEnd) {this.hasEnd = hasEnd;}public void setPageNext(int pageNext) {this.pageNext = pageNext;}public int getRowCount(){return rowCount;}public void setRowCount(int rowCount) {this.rowCount = rowCount;}}。

学生管理系统源代码

学生管理系统源代码

#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 3void 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] =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;coutcin>>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;}//.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;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \//deleteRecordvoid 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.// 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;}}}/***************************************************************************** ******************************************************************************/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];}}}void Info_query(){cout<<" : "<<endl; cout<<"1. "<<endl; cout<<"2. "<<endl; cout<<"3. "<<endl; }//queryRecordvoid 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;}}}//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语言程序设计之学生选修课系统设计代码

c语言程序设计之学生选修课系统设计代码

c语言程序设计之学生选修课系统设计代码在学生选修课系统设计中,C语言程序设计是必不可少的一部分。

本文将详细介绍学生选修课系统的设计代码,包括学生信息管理、课程信息管理、选课与退课等功能。

一、学生信息管理在学生选修课系统中,首先需要实现学生信息的管理功能。

以下是学生信息管理的代码示例:#include <stdio.h>#include <stdlib.h>#include <string.h>struct Student {char id[20];char name[20];int age;};void addStudent(struct Student students[], int *count) {printf("请输入学号:");scanf("%s", students[*count].id);printf("请输入姓名:");scanf("%s", students[*count].name);printf("请输入年龄:");scanf("%d", &students[*count].age);(*count)++;printf("添加学生信息成功!\n");}void deleteStudent(struct Student students[], int *count) { char id[20];printf("请输入要删除的学生学号:");scanf("%s", id);for (int i = 0; i < *count; i++) {if (strcmp(students[i].id, id) == 0) {for (int j = i; j < *count - 1; j++) {strcpy(students[j].id, students[j+1].id);strcpy(students[j].name, students[j+1].name); students[j].age = students[j+1].age;}(*count)--;printf("删除学生信息成功!\n");return;}}printf("未找到对应学生信息!\n");}void displayStudents(struct Student students[], int count) {printf("学号\t姓名\t年龄\n");for (int i = 0; i < count; i++) {printf("%s\t%s\t%d\n", students[i].id, students[i].name, students[i].age);}}二、课程信息管理除了学生信息管理外,还需要实现课程信息的管理功能。

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

#include<>
#include<>
#include<>
struct course
{
i nt num;
c har name[20];
c har kind[20];
i nt ttime,mark,term;
}c;
struct student
{
i nt snum;
i nt cnum;
c har cnam[20];
c har snam[20];
}s[500];
int count; 录入课程信息\n\n");
printf(" 2. 浏览课程信息\n\n");
printf(" 3. 查询课程信息\n\n");
printf(" 4. 进入选课操作\n\n");
p rintf(" 5. 统计选课情况\n\n");
p rintf(" 0. 退出选课系统\n\n");
return 0;
}
int f1()
{
p rintf("\n 课程编号课程名称课程性质总学时学分开课学期:\n"); r eturn 0;
}
int luru() 学分查询\n");
p rintf("\n 2.按课程性质查询");
p rintf(" 请选择查询方式 \n\n 输入选项数字:");
s canf("%d",&b);num,s[t].snam,&s[t]um,s[t]am);
i f((fp=fopen("","r"))==NULL)num,s[t].snam,s[t]um,s[t]am);
fclose(fp);num,s[i].snam,&s[i]um,s[i]am);num,s[i].snam,s[i]um,s[i]am); p rintf("\n 选课学生总人数为:%d人",total);
f close(fp);//关闭文件
m enu();
r eturn 0;
}
1。

相关文档
最新文档