学籍管理系统(内含源代码)

合集下载

c语言学生管理系统代码

c语言学生管理系统代码

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

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

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

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

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

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

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

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

学生信息管理系统代码

学生信息管理系统代码

主要代码如下:1、登录界面代码:Dim cn As New ADODB.ConnectionDim rst As New ADODB。

RecordsetPrivate Sub Command1_Click()Set cn = New ADODB.ConnectionSet rst = New ADODB。

RecordsetStatic i%cn。

ConnectionString = ”Provider=SQLOLEDB。

1;Persist Security Info=False;User ID=sa;Initial Catalog=students info;Data Source=C1847”cn.Openusna = Trim(Text1.Text)mysql = "select * from 用户表 where 用户名='”& usna &”’”rst。

Open mysql, cnIf rst。

EOF ThenMsgBox ”用户名不存在!”cn。

CloseText1.Text = "”Text2.Text = ""Text1。

SetFocusElseIf Trim(rst(”密码”)) = Trim(Text2。

Text) Then管理界面.ShowElsei = i + 1If i < 3 ThenMsgBox ”用户名或密码错误!”, vbOKOnly + vbExclamation, "警告”cn。

CloseText2。

Text = ””Text1.Text = ””Text1。

SetFocusElseMsgBox "该用户已被锁定!”, vbOKOnly + vbExclamation, "警告"End IfEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Text1。

学籍信息源代码

学籍信息源代码

#include<stdio.h>#include<string.h>#define N 10struct date_type{int year;int month;}date;struct stud_type{char academy[10];char class1[10];int num;char name[10];char sex[4];struct date_type date;char address[10];int score[3];float average;int sum;int jilu;};struct stud_type stu[N];void duru(struct stud_type stu[]); /*数据读入*/void Add(struct stud_type stu[]); /*增加学生*/void Delete(struct stud_type stu[]); /*删除学生*/void Modify(struct stud_type stu[]); /*修改学生*/void Search(struct stud_type stu[]); /*查询学生*/void Print(struct stud_type stu[]); /*输出所有学生信息*/void Stat(struct stud_type stu[]); /*统计*/void Save(struct stud_type stu[]); /*数据存盘*/int r=0;void main(){int x;duru(stu);do{printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※欢迎使用本软件※\n");printf("※~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~※\n");printf("※指导老师:张老师※\n");printf("※※\n");printf("※制作者:黄同学※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~** \n");printf("******************学籍管理系统******************\n");printf("** **\n");printf("** 1.录入学生信息**\n");printf("****\n");printf("********* 2.修改学生信息*********\n");printf("****\n");printf("**** 3.查询学生信息****\n");printf("****\n");printf("************* 4.浏览所有学生信息**********\n");printf("****\n");printf("**** 5.删除学生信息****\n");printf("** **\n");printf("********* 6.综合统计*********\n");printf("** **\n");printf("**0.保存并退出系统**\n");printf("****\n");printf("**********************************************\n");printf("**----------------------------------------------- -----------------***\n");printf("请在0-6中选择: ");scanf("%d",&x);switch(x){case 1:Add(stu); /*录入模块*/break;case 2:Modify(stu); /*修改模块*/break;case 3:Search(stu); /*查询模块*/break;case 4:Print(stu); /*输出模块*/break;case 5:Delete(stu); /*删除模块*/break;case 6:Stat(stu); /*统计模块*/break;case 0:Save(stu);break;}}while(x!=0);}void Add (struct stud_type stu[]) /*录入模块*/{int i;char k;for(i=r;i<N;i++){printf("\n 请输入学院:");scanf("%s",stu[i].academy);printf("\n 请输入班级:");scanf("%s",stu[i].class1);printf("\n 请输入学号:");scanf("%d",&stu[i].num);printf("\n 请输入姓名:");scanf("%s",stu[i].name);printf("\n 请输入性别:");scanf("%s",stu[i].sex);printf("\n请输入出生年月:");scanf("%d%d",&stu[i].date.year,&stu[i].date.month);printf("\n 请输入地址:");scanf("%s",stu[i].address);printf("\n 请输入成绩:");scanf("%d%d%d",&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);r=r+1;stu[i].sum=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];stu[i].average=stu[i].sum/3.0;printf("----------是否继续??(y/n):");scanf("%s",&k);if(k=='y'||k=='Y') continue;elseprintf("**********录入结束!**********\n\n");return;}}void Save(struct stud_type stu[]) /*保存模块*/{FILE *fp1; /*指向文件的指针*/int i;stu[0].jilu=r;if((fp1=fopen("E:\\xj.txt","wb"))==NULL) /*打开文件,并判断打开是否正常*/{printf("**********打开文件失败!**********\n\n");return;printf("开始存盘!\n");for(i=0;i<r;i++)if(fwrite(&stu[i],sizeof(struct stud_type),1,fp1)==0)printf("**********数据存盘失败!**********\n\n");fclose(fp1);printf("**********存盘成功!**********\n"); /*显示保存成功*/}void Search(struct stud_type stu[]) /*查询模块*/{int y=0,i,k;printf("请输入学号:");scanf("%d",&k);for(i=0;i<r;i++){if(k==stu[i].num){printf("学院:%s\n班级:%s\n学号:%d\n姓名:%s\n性别:%s\n出生年月:%d%d\n地址:%s\n 成绩:\nC语言:%d高数:%d英语:%d\n",stu[i].academy,stu[i].class1,stu[i].num,stu[i].name,stu[i].sex,stu[i].date.year,stu[i].date. month,stu[i].address,stu[i].score[0],stu[i].score[1],stu[i].score[2]);y=1;}}if(y==0)printf("**********查无此人!**********\n\n");return;}void Delete(struct stud_type stu[]) /*删除模块*/{int i,j,k,y=0;int m=16899168,n;printf("请输入密码:");scanf("%d",&n);if(n==m);else{printf("**********密码错误!**********\n\n");return;}printf("请输入学号:");scanf("%d",&k);for(i=0;i<r;i++){if(k==stu[i].num)for(j=i;j<r;j++)stu[j]=stu[j+1];r=r-1;printf("**********删除成功!**********\n\n");y=1;}}if(y==0)printf("**********查无此人!**********\n\n");}void Print(struct stud_type stu[]) /*输出模块*/ {int i,j,k,n;struct stud_type t;printf(" 1.按学号排序,2.按总分排序(由高到低)\n");printf("\n请在1和2中选择:");scanf("%d",&n);if(n==1) /*选择排序*/ for(i=0;i<r-1;i++){k=i;for(j=i+1;j<r;j++)if(stu[k].num>stu[j].num)k=j;if(k!=i){t=stu[i];stu[i]=stu[k];stu[k]=t;}}if(n==2)for(i=0;i<r-1;i++){k=i;for(j=i+1;j<r;j++)if(stu[k].sum<stu[j].sum)k=j;if(k!=i){t=stu[i];stu[i]=stu[k];stu[k]=t;}for(i=0;i<r;i++){printf("\n学院\t班级\t学号\t姓名\t性别\t出生年月\t地址\n");printf("%s\t%s\t%d\t%s\t%s\t%d %d\t\t%s\n",stu[i].academy,stu[i].class1,stu[i].num,stu[i].name,s tu[i].sex,stu[i].date.year,stu[i].date.month,stu[i].address);printf("C语言\t高数\t英语\t平均分\t总分\n");printf("%d\t%d\t%d\t%0.1f\t%d\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].average,stu[i ].sum);}}void Stat(struct stud_type stu[]) /*统计模块*/{int i,j,k;printf("0.C语言1.高数2.英语");printf("请在0-2中选择:");scanf("%d",&j);k=j;printf("90-100:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]>=90)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("80-90:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<90&&stu[i].score[k]>=80)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("70-80:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<80&&stu[i].score[k]>=70)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("60-70:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<70&&stu[i].score[k]>=60)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("60分以下:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<60)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}}void Modify(struct stud_type stu[]) /*修改模块*/{int k,i,y=0;int m=16899168,n;printf("请输入密码:");scanf("%d",&n);if(n==m);else{printf("**********密码错误!**********\n\n");return;}printf("************修改学生信息************\n");printf("\n请输入要修改学生的学号: ");scanf("%d",&k);for(i=0;i<r;i++){if(k==stu[i].num){printf("\n请输入新内容:\n");printf("\n 请输入学院:");scanf("%s",stu[i].academy);printf("\n 请输入班级:");scanf("%s",stu[i].class1);printf("\n 请输入学号:");scanf("%d",&stu[i].num);printf("\n 请输入姓名:");scanf("%s",stu[i].name);printf("\n 请输入性别:");scanf("%s",stu[i].sex);printf("\n请输入出生年月:");scanf("%d%d",&stu[i].date.year,&stu[i].date.month);printf("\n 请输入地址:");scanf("%s",stu[i].address);printf("\n 请输入成绩:");scanf("%d%d%d",&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);printf("\n**********修改成功!**********\n\n");y=1;}}if(y==0)printf("**********查无此人!**********\n\n");return;}void duru(struct stud_type stu[]) /*数据读入模块*/{int i;FILE *fp; /*指向文件的指针*/if((fp=fopen("E:\\xj.txt","rb"))==NULL) /*打开文件,并判断打开是否正常*/{printf("打开文件失败!\n");return;}printf("文件开始读取!\n");rewind(fp);for(i=0;i<=r;i++){fread(&stu[i],sizeof(struct stud_type),1,fp);r=stu[0].jilu;}printf("\n文件成功读取!\n");fclose(fp);r=stu[0].jilu;}。

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

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

int main()
{
initLinkTable(&head);//初始化表头
readStu();//读入源文件
while (1)
{
menu();
system("cls");
}
}
void initLinkTable(studentLinkPoint *p)
int sum(studentLinkPoint);//求和
void avg(studentLinkPoint);//求平均分
void disAvgSum(studentLinkPoint);//显示总分和平均分
char *inputNumber();//专门用来输入一个学生的学号,返回该字符串的指针
char name[20];
char number[18];
int i;
if(temp==0)
{
error("input");
return 0;
}
else
{
temp->student=(studentPint)malloc(sizeof(studentNod));
break;
case 0:
del(head,end);
break;
}
if(c==0)
exit(1);
}
void del(studentLinkPoint p,studentLinkPoint End)
{
studentLinkPoint q;
if(end==head)
printf(" %3.1f %3.1f\n",p->student->sum,p->student->avg);

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

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

c语言学籍管理系统源代码学籍管理系统的背景及意义随着社会的不断发展和教育的普及,学籍管理工作日益被重视。

传统的手工管理学籍的方式效率低下,存在着各种弊端,以致无法满足现代学校管理的需求。

因此,开发一款高效、便捷、可靠的学籍管理系统成为普遍需求,为了提高管理效率、减少工作难度,学籍管理系统被越来越广泛地使用。

本文将介绍一款基于C语言开发的学籍管理系统的源代码。

基本功能该学籍管理系统可以实现学生信息的录入、删除、修改和查询,以及学生的成绩录入、修改和查询。

此外,该系统还具备数据存储和文件读写的功能,能够自动保存学生信息和成绩数据,保障数据的安全性和可靠性。

模块设计该系统按照功能模块划分,主要分为三个模块:学生信息管理模块、学生成绩管理模块和数据存储与文件读写模块。

学生信息管理模块该模块主要实现学生信息的录入、删除、修改和查询等基本功能。

以下为该模块的主要源代码:```struct student {char name[20]; // 姓名int id; // 学号char sex[5]; // 性别char major[20]; // 专业};struct student stu[1000]; // 学生信息结构体数组int num_of_stu = 0; // 学生总数void add_student() { // 添加学生信息printf("请输入学生姓名:");scanf("%s", stu[num_of_stu].name);printf("请输入学生学号:");scanf("%d", &stu[num_of_stu].id);printf("请输入学生性别:");scanf("%s", stu[num_of_stu].sex);printf("请输入学生专业:");scanf("%s", stu[num_of_stu].major);num_of_stu++;printf("添加成功!\n");}void delete_student() { // 删除学生信息int delete_id;printf("请输入要删除的学生学号:");scanf("%d", &delete_id);int index = search_student_by_id(delete_id); if (index == -1) {printf("该学号不存在!\n");return;}for (int i = index; i < num_of_stu - 1; i++) { stu[i] = stu[i + 1];}num_of_stu--;printf("删除成功!\n");}void modify_student() { // 修改学生信息int modify_id;printf("请输入要修改的学生学号:");scanf("%d", &modify_id);int index = search_student_by_id(modify_id); if (index == -1) {printf("该学号不存在!\n");return;}printf("请输入学生姓名:");scanf("%s", stu[index].name);printf("请输入学生学号:");scanf("%d", &stu[index].id);printf("请输入学生性别:");scanf("%s", stu[index].sex);printf("请输入学生专业:");scanf("%s", stu[index].major);printf("修改成功!\n");}int search_student_by_id(int id) { // 根据学号查询学生信息for (int i = 0; i < num_of_stu; i++) {if (stu[i].id == id) {return i;}}return -1;}void query_student() { // 查询学生信息int query_id;printf("请输入要查询的学生学号:");scanf("%d", &query_id);int index = search_student_by_id(query_id);if (index == -1) {printf("该学号不存在!\n");return;}printf("姓名\t学号\t性别\t专业\n");printf("%s\t%d\t%s\t%s\n", stu[index].name,stu[index].id, stu[index].sex, stu[index].major);}```学生成绩管理模块该模块主要实现学生成绩信息的录入、修改和查询等功能。

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

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

c语言学生管理系统源代码#include <stdio.h>。

#include <stdlib.h>。

#include <string.h>。

/*定义学生结构体*/。

typedef struct student。

char num[20]; //学号。

char name[20]; //姓名。

int c; //语文成绩。

int math; //数学成绩。

float ave; //平均分。

struct student *next;。

} stu;。

/*函数声明*/。

void menu_select(); //显示菜单。

void add(); //添加学生信息。

void delete(); //删除学生信息。

void modify(); //修改学生信息。

void search(); //查询学生信息。

void get_ave(); //计算学生平均成绩。

void display(); //显示学生信息。

void esc(); //退出系统。

int main()。

menu_select();。

return 0;。

}。

//显示菜单。

void menu_select()。

int select;。

while (1)。

printf("\n学生管理系统\n");。

printf("------菜单------\n");。

printf("1.添加学生信息 2.删除学生信息\n");。

printf("3.修改学生信息 4.查询学生信息\n");。

printf("5.计算学生平均成绩 6.显示学生信息\n");。

printf("7.退出系统\n");。

printf("请输入您的选择:");。

scanf("%d", &select);。

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

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

数据库所用的数据自己导入MYSQL5.5,Navicat8就可以用了。

下面是具体的数据资料/*MySQL Data TransferSource Host: localhostSource Database: simsTarget Host: localhostTarget Database: simsDate: 2013-6-25 9:24:26*/SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for manager-- ----------------------------DROP TABLE IF EXISTS `manager`;CREATE TABLE `manager` (`id` varchar(10) NOT NULL,`name` varchar(30) NOT NULL,`Mima` varchar(20) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Table structure for studentinfo-- ----------------------------DROP TABLE IF EXISTS `studentinfo`;CREATE TABLE `studentinfo` (`Sname` varchar(30) NOT NULL,`Ssex` varchar(10) NOTNULL,`Snumber` varchar(10) NOT NULL,`Sprofession` varchar(30) NOT NULL,`Sclass`varchar(20) NOT NULL,`Sdate` varchar(30) character set utf8 collate utf8_unicode_ciNOT NULL,PRIMARY KEY (`Snumber`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDBfree: 4096 kB';-- ------------------------------ Table structure for userinfo-- ----------------------------DROP TABLE IF EXISTS `userinfo`;CREATE TABLE `userinfo` (`id` varchar(10) NOT NULL,`name` varchar(30) NOT NULL,`Mima` varchar(20) character set utf8 collate utf8_unicode_ci NOT NULL, PRIMARY KEY(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;-- ------------------------------ Records-- ----------------------------INSERT INTO `manager` VALUES ('1', '1', '2');INSERT INTO `manager` VALUES ('2', '恩恩', '123456');INSERT INTO `manager` VALUES ('3', '大大', '123456');INSERT INTO `manager` VALUES ('4', '啊啊', '123456');INSERT INTO `manager` VALUES ('5', '5', '5');INSERT INTO `manager` VALUES ('6', '孙霞', '123456');INSERT INTO `studentinfo` V ALUES ('张三', '男', '2010303755', '数学', '2', '2010-02- 12');INSERT INTO `studentinfo` V ALUES ('李四', '男', '2010303760', '物理', '1', '1995.9.6'); INSERT INTO `studentinfo` V ALUES ('王二', '女', '2010303761', '应数', '2','1990.9.11');INSERT INTO `studentinfo` V ALUES ('麻子', '女', '2010303762', '信计', '1','1999.9.10');INSERT INTO `userinfo` V ALUES ('1', '1', '1');INSERT INTO `userinfo` V ALUES ('13', '13', '1');INSERT INTO `userinfo` V ALUES ('2', '2', '2');INSERT INTO `userinfo` V ALUES ('3', '3', '3');INSERT INTO `userinfo` V ALUES ('6', '6', '6');INSERT INTO `userinfo` V ALUES ('7', '7', '6');下面是相应的程序:package MS;import java.awt.event.ActionEvent;import java.awt.event.ActionListener; import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Add implements ActionListener {JFrame f1;Container ct;JPanel jp,jp1,jp2,jp3;JButton btn1,btn2;JLabel label;JTextField tf1,tf2,tf3,tf4,tf5,tf6;Add(){f1=new JFrame();ct=f1.getContentPane();//初始化面板jp=new JPanel();jp1=new JPanel(new GridLayout(6,1));jp2=new JPanel(new GridLayout(6,1));jp3=new JPanel();btn1=new JButton("确定");btn2=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>添加学生信息</font>",SwingConstants.CENTER);label.setForeground(Color.gray);tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);tf6.setText("例:2000-02-02");//文本框加入提示语tf6.addFocusListener(new FocusListener(){public void focusGained(FocusEvent e) {tf6.setText("");}public void focusLost(FocusEvent e) {}});jp.add(label);ct.add(jp,"North");jp1.add(new JLabel("姓名",SwingConstants.CENTER));jp2.add(tf1);jp1.add(new JLabel("性别",SwingConstants.CENTER));jp2.add(tf2);jp1.add(new JLabel("学号",SwingConstants.CENTER));jp2.add(tf3);jp1.add(new JLabel("专业",SwingConstants.CENTER));jp2.add(tf4);jp1.add(new JLabel("班级",SwingConstants.CENTER));jp2.add(tf5);jp1.add(new JLabel("入学时间",SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);ct.add(jp1,"West");ct.add(jp2,"East");ct.add(jp3,"South");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f1.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f1.setLocation(xcenter, ycenter);f1.setVisible(true);//f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);}public void insert(){if(tf1.getText().equals("")||tf2.getText().equals("")||tf3.getText().equals("")||tf4.getText().equals("")||tf5.getText().equals("")||tf6.getText().equals("")){JOptionPane.showMessageDialog(f1,"请填写完整信息");return;}try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connectioncon=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String s="insert into studentinfo values('"+tf1.getText()+"','"+tf2.getText()+"','"+tf3.getText()+"','"+tf4.getText()+"','"+tf5.getText()+"','"+tf6.getText()+"');";String query="select * from studentinfo where Snumber='"+tf3.getText().trim()+"'";ResultSet res=st.executeQuery(query);if(res.next()){JOptionPane.showMessageDialog(f1,"学号信息已经存在!");con.close();tf3.setText("");}else if(tf6.getText().length()!=10){JOptionPane.showMessageDialog(f1,"入学时间格式有误!");con.close();tf6.setText("");}int insert=st.executeUpdate(s);if(insert==1){JOptionPane.showMessageDialog(f1,"录入信息成功!");tf1.setText("");tf2.setText("");tf3.setText("");tf4.setText("");tf5.setText("");tf6.setText("");}}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){insert();}else if(cmd.equals("取消")){f1.hide();}}public Container getCt(){return ct;}public void setCt(Container ct){this.ct = ct;}}package MS;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Delete implements ActionListener {JFrame f2;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JTextField text;JTable table;//接收数据库中返回的信息JButton btn1,btn2,btn3;Object columnName[]={"姓名","性别","学号","专业","班级","入学时间"};Object ar[][]=new Object[80][6];Delete(){f2=new JFrame();ct=f2.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();label=new JLabel();text=new JTextField();btn1=new JButton("查询");btn2=new JButton("删除");btn3=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>请输入要删除的学生姓名:</font>",SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar,columnName);JScrollPane scroll=new JScrollPane(table);text=new JTextField(20);jp2.add(btn1);jp2.add(btn2);jp2.add(btn3);jp1.add(label);jp1.add(text);ct.add(jp1,"North");jp3.setLayout(new BorderLayout());jp3.add(new JLabel("学生信息如下"));jp3.add(scroll);ct.add(jp2,"South");ct.add(jp3,"Center");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f2.setSize(450, 400);int xcenter=(x-450)/2;int ycenter=(y-400)/2;f2.setLocation(xcenter, ycenter);f2.setVisible(true);//f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);btn3.addActionListener(this);}int i=0;public void show(String s){while(i>=0){ar[i][0]="";ar[i][1]="";ar[i][2]="";ar[i][3]="";ar[i][4]="";ar[i][5]="";i--;}i=0;try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String sql="select * from studentinfo where Sname='"+s+"'";ResultSet res=st.executeQuery(sql);/*if(!(res.next())){JOptionPane.showMessageDialog(f,"所要查询的信息不存在");} */while(res.next()){String sName=res.getString(1);String sSex=res.getString(2);String sNumber=res.getString(3);String sProfession=res.getString(4);String sClass=res.getString(5);String sDate=res.getString(6);ar[i][0]=sName;ar[i][1]=sSex;ar[i][2]=sNumber;ar[i][3]=sProfession;ar[i][4]=sClass;ar[i][5]=sDate;i++;}f2.repaint();con.close();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}public void delete(int line){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String name=(String)(ar[line][2]);String sql="delete from studentinfo where Snumber ='"+name+"'";int del=st.executeUpdate(sql);if(del==1){ar[line][0]="";ar[line][1]="";ar[line][2]="";ar[line][3]="";ar[line][4]="";ar[line][5]="";JOptionPane.showMessageDialog(null,"删除成功!","信息", JOptionPane.YES_NO_OPTION);}con.close();f2.repaint();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("查询")){String qu=text.getText().trim();show(qu);}if(cmd.equals("删除")){int de=table.getSelectedRow();if(de==-1){JOptionPane.showMessageDialog(null,"请选定要删除的行","错误信息", JOptionPane.YES_NO_OPTION);}else{delete(de);}}if(cmd.equals("取消")){f2.hide();}}}package MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.SwingConstants;public class Liulan implements ActionListener {JFrame f4;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JButton btn1,btn2;JTable table;Object[][] ar=new Object[80][6];Object[] columnName={"姓名","性别","学号","专业","班级","入学时间"};Liulan(){f4=new JFrame();ct=f4.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();btn1=new JButton("点击浏览");btn2=new JButton(" 取消");label=new JLabel("<html><font color=#00FF22 size='4'>学生信息浏览<font>",SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar, columnName);JScrollPane scroll=new JScrollPane(table);jp1.add(label);jp2.add(btn1);jp2.add(btn2);jp3.add(scroll);ct.add(jp1,"North");ct.add(jp3,"Center");ct.add(jp2,"South");Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f4.setSize(500,530);int xcen=(x-500)/2;int ycen=(y-530)/2;f4.setLocation(xcen,ycen);f4.setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);}int i=0;public void select(){while(i>=0){ar[i][0]="";ar[i][1]="";ar[i][2]="";ar[i][3]="";ar[i][4]="";ar[i][5]="";i--;}i=0;try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String s="select * from studentinfo";ResultSet res=st.executeQuery(s);while(res.next()){String sName=res.getString(1);String sSex=res.getString(2);String sNumber=res.getString(3);String sProfession=res.getString(4);String sClass=res.getString(5);String sDate=res.getString(6);ar[i][0]=sName;ar[i][1]=sSex;ar[i][2]=sNumber;ar[i][3]=sProfession;ar[i][4]=sClass;ar[i][5]=sDate;i++;}f4.repaint();con.close();}catch(SQLException e){System.out.println("错误代码:"+e.getErrorCode());System.out.println("错误信息:"+e.getMessage());}}@SuppressWarnings("deprecation")public void actionPerformed(ActionEvent e){// TODO Auto-generated method stubString cmd=e.getActionCommand();if(cmd.equals("点击浏览")){select();}else if(cmd.equals(" 取消")){f4.hide();}}}package MS;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.Connection;import java.sql.DriverManager;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.SwingConstants;@SuppressWarnings("serial")public class Login extends JFrame implements ActionListener {Container cp=null;JFrame f=null;JButton button1,button2,button3;JTextField t1;JPasswordField t2;JLabel jlable1,jlable2;JRadioButton rabtn1,rabtn2;Color c;JPanel jp1,jp2,jp3;String table=null;Login(){f=new JFrame("学生信息管理系统");button1=new JButton("确定");button2=new JButton("取消");button3=new JButton("注册");//button3.setOpaque(false);button3.setBorder(null);button3.setBackground(Color.getColor("#292421"));rabtn1=new JRadioButton("普通用户");rabtn1.setBackground(Color.getColor("#292421"));rabtn2=new JRadioButton("管理员");rabtn2.setBackground(Color.getColor("#292421"));ButtonGroup group=new ButtonGroup();group.add(rabtn1);group.add(rabtn2);cp=f.getContentPane();jlable1=new JLabel("输入用户号");jlable2=new JLabel("输入密码");jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();t1=new JTextField(20);t2=new JPasswordField(20);//jp3.add(group);jp1.add(jlable1);jp1.add(t1);jp1.add(jlable2);jp1.add(t2);jp1.add(rabtn1);jp1.add(rabtn2);jp1.add(button3);JLabel JL=new JLabel("<html><font color=#292421 size='7'><i>欢迎登陆" + "</i></font>",SwingConstants.CENTER);cp.add(JL,"North");jp2.add(button1);jp2.add(button2);cp.add(jp1,"Center");cp.add("South",jp2);cp.setBackground(new Color(127, 255, 212 ));jp2.setBackground(new Color(127, 255, 212 ));jp1.setBackground(new Color(127, 255, 212 ));Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f.setSize(250,300);int xcenter=(x-300)/2;int ycenter=(y-300)/2;f.setLocation(xcenter,ycenter);/*显示在窗口中央*/f.setVisible(true);//f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//------------------------------------------------------------///*监听事件*/button1.addActionListener(this);button2.addActionListener(this);button3.addActionListener(this);rabtn1.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e){JRadioButton jop=(JRadioButton) e.getSource();if (jop.isSelected())table="userinfo";}});rabtn2.addItemListener(new ItemListener(){public void itemStateChanged(ItemEvent e){JRadioButton jop=(JRadioButton) e.getSource();if (jop.isSelected())table="manager";}});f.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});}@SuppressWarnings("deprecation")public void confirm(String tableName){try{Class.forName("com.mysql.jdbc.Driver");}catch(ClassNotFoundException e){System.out.print("加载驱动程序失败");}String conURL="jdbc:mysql://localhost:3306/sims";try{Connection con=DriverManager.getConnection(conURL,"root","123456");Statement st=con.createStatement();String id=t1.getText().trim();String Mima=t2.getText().trim();String queryMima="select * from "+tableName+" where id='"+id+"' and mima='"+Mima+"'";ResultSet res=st.executeQuery(queryMima);if(res.next()){if(tableName.equals("manager"))new Mstudent(id);else if(tableName.equals("userinfo"))new Ustudent(id);f.hide();con.close();}else{JOptionPane.showMessageDialog(null,"密码错误请重输!!!","提示!",JOptionPane.YES_NO_OPTION);}t1.setText("");t2.setText("");}catch(SQLException g){System.out.println("错误代码:"+g.getErrorCode());System.out.println("错误内容:"+g.getMessage());}}ItemListener listen=new ItemListener(){public void itemStateChanged(ItemEvent e) {// TODO Auto-generated method stub}};public void actionPerformed(ActionEvent e){String cmd=e.getActionCommand();if(cmd.equals("确定")){if(table==null){JOptionPane.showMessageDialog(f,"请选择用户类型");}confirm(table);}else if(cmd.equals("取消")){f.dispose();}else if(cmd.equals("注册")){new Regist();}}public static void main(String []arg){new Login();}}package MS;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenuBar;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.SwingConstants;import javax.swing.border.TitledBorder;@SuppressWarnings("serial")public class Mstudent extends JFrame implements ActionListener {JButton Query = new JButton("查询信息");JButton add = new JButton("添加信息");JButton delete = new JButton("删除信息");JButton xiugai = new JButton("浏览全部信息");JButton liulan = new JButton("修改密码");JMenuBar mb = new JMenuBar();// 菜单栏JPanel jp = new JPanel();Container cp = getContentPane();String userName;Mstudent(){}Mstudent(String userName){erName = userName;mb.add(Query);mb.add(add);mb.add(delete);mb.add(xiugai);mb.add(liulan);JPanel j=new JPanel();j.add(mb,"Center");cp.add(j, "North");// 设置边框jp.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue, 2), null, TitledBorder.CENTER,TitledBorder.TOP));jp.setLayout(new BorderLayout());JLabel label1 = new JLabel("欢迎使用学生信息管理系统",SwingConstants.CENTER);jp.add(label1);JScrollPane scrollpane = new JScrollPane(jp);cp.add(scrollpane,"Center");setTitle("欢迎登陆" + "--" + "你好:" + userName);Toolkit kit = Toolkit.getDefaultToolkit();Dimension screen = kit.getScreenSize();int x = screen.width; /* 取得显示器窗口的宽度*/int y = screen.height; /* 取得显示器窗口的高度*/setSize(600, 600);int xcenter = (x - 600) / 2;int ycenter = (y - 600) / 2;setLocation(xcenter, ycenter);/* 显示在窗口中央*/setVisible(true);//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 注册临听器Query.addActionListener(this);add.addActionListener(this);delete.addActionListener(this);xiugai.addActionListener(this);liulan.addActionListener(this);}public void actionPerformed(ActionEvent e){String cmd = e.getActionCommand();if (cmd.equals("查询信息")){new QueryWays();}if (cmd.equals("添加信息")){new Add();}if (cmd.equals("删除信息")){new Delete();}if (cmd.equals("浏览全部信息")){new Liulan();}if (cmd.equals("修改密码")){new UpdateCode();}}public static void main(String[] args){new Mstudent("");}}package MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Query implements ActionListener {String sql =null;int a;String info;JFrame f3;// Container cp;JPanel jp1,jp2,jp3,jp4,jp,jpwest;JButton btn1,btn2;//确定,取消JLabel label,label2;//标签,请输入姓名(label)JTextField tf,tf1,tf2,tf3,tf4,tf5,tf6;//文本框Query(int a){this.a=a;f3=new JFrame();Container cp=f3.getContentPane();//初始化面板,按钮,标签,文本框jp=new JPanel();jp1=new JPanel();jp2=new JPanel(new GridLayout(6,1));jp3=new JPanel();jp4=new JPanel(new GridLayout(6,1));jpwest=new JPanel();btn1=new JButton("确定");btn2=new JButton("取消");label=new JLabel("<html><font color=#CC00FF size='4'>请输入姓名:" + "</font>",SwingConstants.CENTER);label2=new JLabel("<html><font color=#CC00FF size='4'>请输入学号:" + "</font>",SwingConstants.CENTER);label.setForeground(Color.gray);tf=new JTextField(20);//------------------------------------------------tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);//布局,添加控件if(a==0){jp.add(label);jp.add(tf);}else if(a==1){jp.add(label2);jp.add(tf);}cp.add(jp,"North");jp4.add(new JLabel("姓名",SwingConstants.CENTER));jp2.add(tf1);jp4.add(new JLabel("性别",SwingConstants.CENTER));jp2.add(tf2);jp4.add(new JLabel("学号",SwingConstants.CENTER));jp2.add(tf3);jp4.add(new JLabel("专业",SwingConstants.CENTER));jp2.add(tf4);jp4.add(new JLabel("班级",SwingConstants.CENTER));jp2.add(tf5);jp4.add(new JLabel("入学时间",SwingConstants.CENTER));jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);cp.add(jp4,"West");cp.add(jp2,"East");cp.add(jp3,"South");cp.add(jp1);Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width; //显示窗口宽度int y=screen.height;//窗口高度f3.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f3.setLocation(xcenter,ycenter);f3.setVisible(true);//f3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);/*f3.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});*/。

C语言学籍管理系统(内含源代码)

C语言学籍管理系统(内含源代码)

学籍管理系统一、系统简介设计一个基于结构体数组的学生学籍管理系统,能实现对学生学籍信息进行录入,修改,删除,查询和输出等基本操作二、需求分析学籍管理系统应该实现以下功能:1、能录入学生的基本信息,包括学号,姓名,专业,年级,性别和出生日期信息,保存到结构体数组中。

2、能根据输入的学号查询学生,进行信息的修改。

3、能根据输入的学号从结构体数组中删除学生的记录。

4、实现查询功能,能根据输入的学号或年级在屏幕上显示相应的学生信息。

5、能在屏幕上以列表的方式输出所有学生的信息。

三、概要设计1、系统功能根据项目的开发要求,本系统划分成六个主要功能模块:录入学生信息模块、修改学生信息模块、删除学生信息模块、查询学生信息模块、输出模块和推出模块。

系统功能机构图如下:2、重要数据的数据结构设计学生学籍的记录项用结构体Stu message表示,包括6个属性,stuno,name、spec、grade、sex、birthday 分另U代表学生的学号、专业、年级、性另U和出生日期,其中birthday 类型为自定义的结构体类型Date.Struct stumessage {Char stuno[11]: // 学号Char name[9]: // 姓名Char spec[2]: // 专业Char grade: // 年级Char sex : // 性别Stuct date birthday: // 出生日期};日期类型date包括三个属性,分别代表年、月、日Struct date{int year : // 年Int month: //Int day: // H};3、函数设计学籍管理系统程序采用了结构化程序设计的思想,由1个.h 头文件和3个C源文件组成。

程序中除了主函数外,共设计了以下14个函数,分别包含在3个.c源文件中。

以下是这些函数原型及功能设计。

(1) void sysinfo(void)函数功能:在屏幕上输入系统及信息并等待用户响应。

学籍管理系统代码

学籍管理系统代码

-----------------------创建课程表-------------------create table C (课程号varchar(5) not null,课程名varchar(10) null,先行课smallint null,学分int null,备注varchar(16) null,constraint PK_C primary key (课程号))go-----------------------创建院系表-------------------create table Department (院系代号varchar(5) not null,院系名varchar(10) null,系主任varchar(8) null,备注varchar(16) null,constraint PK_DEPARTMENT primary key (院系代号))go-----------------------创建专业表-------------------create table Major (专业号varchar(5) not null,院系代号varchar(5) null,专业名称varchar(16) null,备注varchar(16) null,constraint PK_MAJOR primary key (专业号))go-----------------------在专业表上创建索引------------------- create index DM_FK on Major (院系代号ASC)go-----------------------创建学生与课程的成绩表---------------------- create table SC (学号bigint not null,课程号varchar(5) not null,成绩bigint null,constraint PK_SC primary key (学号, 课程号))go-----------------------在SC表上创建索引SC_FK与SC2_FK------------------- create index SC_FK on SC (学号ASC)Gocreate index SC2_FK on SC (课程号ASC)go-----------------------创建学生基本信息表-------------------create table S (班级varchar(16) null,学号bigint not null,院系代号varchar(5) null,专业号varchar(5) null,姓名varchar(6) null,性别varchar(2) null,出生年月datetime null,籍贯varchar(8) null,民族varchar(2) null,家庭住址varchar(20) null,入学时间datetime null,政治面貌varchar(6) null,身份证号char(18) null,联系电话varchar(12) null,备注varchar(14) null,constraint PK_S primary key (学号))go---------------------------创建院系代号索引------------------------------ create index SD_FK on S (院系代号ASC)go--------------------------创建专业号索引------------------------------ create index SM_FK on S (专业号ASC)go---------------------------创建教师与课程关系表------------------------------课程号varchar(5) not null,教师号varchar(5) not null,constraint PK_TC primary key (课程号, 教师号))go---------------------------建立课程号索引------------------------------ create index TC_FK on TC (课程号ASC)go--------------------------建立教师号索引------------------------------ create index TC2_FK on TC (教师号ASC)go---------------------------创建教师表------------------------------ create table Teacher (教师号varchar(5) not null,院系代号varchar(5) null,姓名varchar(6) null,性别char(2) null,年龄int null,工龄int null,备注varchar(16) null,constraint PK_TEACHER primary key (教师号))go---------------------------建立TD_FK 索引------------------------------ create index TD_FK on Teacher (院系代号ASC)goalter table Majoradd constraint FK_MAJOR_DM_DEPARTME foreign key (院系代号) references Department (院系代号)goalter table SCadd constraint FK_SC_SC_STUDENTS foreign key (学号)references S (学号)goadd constraint FK_SC_SC2_C foreign key (课程号)references C (课程号)goalter table Sadd constraint FK_STUDENTS_SD_DEPARTME foreign key (院系代号) references Department (院系代号)goalter table Sadd constraint FK_STUDENTS_SM_MAJOR foreign key (专业号) references Major (专业号)goalter table TCadd constraint FK_TC_TC_C foreign key (课程号)references C (课程号)goalter table TCadd constraint FK_TC_TC2_TEACHER foreign key (教师号)references Teacher (教师号)goalter table Teacheradd constraint FK_TEACHER_TD_DEPARTME foreign key (院系代号) references Department (院系代号)go触发器设计1、CREATE TRIGGER Supdate ON [dbo].[S]FOR UPDA TEASupdate SCset 学号= ( select 学号from inserted)where SC.学号=(select 学号from deleted) ;2、CREATE TRIGGER Sdelete ON [dbo].[StudentsInfo]FOR DELETEASDELETEFROM SCWHERE SC.学号=(select 学号from deleted) ;2. C表上的触发器:其功能是当一个课程的信息改变时,或当一个课程的信息被删除时,相应的在SC和TC表中的相应信息修改或删除。

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

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

系统源代码一、登录界面代码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。

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

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

学生信息管理系统完整源代码注:本系统采用C/S结构,运用Java GUI知识编写,数据库为SQL SERVER 2005,没有采用典型的三级框架结构,所以代码有冗余,仅供参考。

一、数据表及数据源首先创建数据库,包含数据表如下:数据库创建完成后,新建一个名为SIMS的数据源,不会建数据源的同学可以在去搜索创建数据源的详细步骤,这里的数据名称一定要为SIMS,否则在以后程序连接数据库的语句中会出现错误。

二、操作演示三、代码部分创建Java工程,创建名称为SIMS的包,一下Java类均包含在一个包内。

1.登录界面package SIMS;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.text.SimpleDateFormat;import java.util.*;import java.util.Date;public class login extends JFrame implements ActionListener{String userID; //保留用户输入IDString password; //保留用户输入passwordJLabel jlID=new JLabel("用户ID:"); //使用文本创建标签对象 JLabel jlPwd=new JLabel("密码:");JTextField jtID=new JTextField(); //创建ID输入框JPasswordField jpPwd=new JPasswordField(); //创建密码输入框ButtonGroup bg=new ButtonGroup(); //创建ButtonGroup组件对象JPanel jp=new JPanel(); //创建Panel容器JLabel jl=new JLabel();JRadioButton jrb1=new JRadioButton("管理员");JRadioButton jrb2=new JRadioButton("教师");JRadioButton jrb3=new JRadioButton("学生",true);JButton jb1=new JButton("登录");JButton jb2=new JButton("重置");public login(){this.setLayout(null); //设置窗口布局管理器this.setTitle("学生信息管理系统"); //设置窗口标题this.setBounds(200,150,500,300); //设置主窗体位置大小和可见性this.setVisible(true); //设置窗口的可见性this.setResizable(false);jlID.setBounds(150,60,100,20); //设置ID框属性jtID.setBounds(220,60,100,20); //设置ID输入框属性jlPwd.setBounds(150,90,100,20); //设置密码框属性jpPwd.setBounds(220,90,100,20); //设置密码输入框属性jp.setBounds(35,120,400,250); //设置JPanel容器属性jb1.setBounds(160,170,60,20); //设置登录按钮属性jb2.setBounds(250,170,60,20); //设置取消按钮属性jb1.addActionListener(this); //设置登录按钮监听器jb2.addActionListener(this); //设置取消按钮监听器jl.setBounds(340,75,130,20); //设置提示框属性bg.add(jrb1); //将所有空间加入窗体bg.add(jrb2);bg.add(jrb3);this.add(jlID);this.add(jlPwd);this.add(jtID);this.add(jpPwd);this.add(jb1);this.add(jb2);this.add(jl);jp.add(jrb1);jp.add(jrb2);jp.add(jrb3);this.add(jp);centerShell(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(( (screenWidth - shellWidth) / 2),((screenHeight - shellHeight) / 2) );}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(userID);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入IDpassword=jpPwd.getText(); //获取用户输入密码if(e.getSource()==jb1){ //处理登录事件if(userID.equals("") || password.equals("")){jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("请输入用户ID和密码");}else{Connection con=null;try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"","");//获取连接字符串Statement stat=con.createStatement();if(jrb1.isSelected())//如果登录选中的管理员{ResultSet rs=stat.executeQuery("select * from Admin"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectAdmin_Pwd,Admin_Name from Admin where Admin_ID='"+userID+"'");//从表Admin获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new admin(rss.getString(2));//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb2.isSelected()){ResultSet rs=stat.executeQuery("select * from Teacher_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectTea_Pwd,Tea_Names from Teacher_Info where Tea_ID='"+userID+"'");//从表Teacher_Info获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new teacher(rss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb3.isSelected()){ResultSet rs=stat.executeQuery("select * from Student_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rsss=stat.executeQuery("selectStu_Pwd,Stu_Name from Student_Info where Stu_ID='"+userID+"'");//从表Student_Info获取信息while(rsss.next()){String str=rsss.getString(1);if(str.equals(password)){new student(rsss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}}catch(Exception ex){ex.getStackTrace();}finally{try{con.close();}catch(Exception exc){exc.printStackTrace();}}}}else if(e.getSource()==jb2){ //处理登录事件jtID.setText("");jpPwd.setText("");jrb3.setSelected(true);jl.setText("");}}public static void main(String[] args){new login();}}2.添加课程package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_course extends JFrame implements ActionListener{ static add_course ss;String courseID=""; //课程名String coursename=""; //课程名String count=""; //课时JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlcoursename=new JLabel("课程名:");JLabel jlcount=new JLabel("课时:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtcoursename=new JTextField();JTextField jtcount=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_course(){ //添加教师账号信息this.setTitle("添加课程信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(title);this.add(jlcoursename);this.add(jlcount);this.add(jtcourseID);this.add(jtcoursename);this.add(jtcount);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加课程信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlcoursename.setBounds(180,140,100,20);jlcount.setBounds(180,200,100,20);jtcourseID.setBounds(250,80,140,20);jtcoursename.setBounds(250,140,140,20);jtcount.setBounds(250,200,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容coursename=jtcoursename.getText();count=jtcount.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || coursename.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){warning.setText("课程ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!count.equals("")){temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name,Course_Count)values('"+courseID+"','"+coursename+"','"+count+"')");}else{temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name) values('"+courseID+"','"+coursename+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");warning.setText("");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtcourseID.setT ext("");jtcoursename.setText("");jtcount.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}}3.添加学生package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_student extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("学号:"); //创建文本框对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField();JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_student(){this.setTitle("添加学生账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加学生账号信息");title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20);submit.addActionListener(this);reset.addActionListener(this);this.setSize(600,400);centerShell(this);this.setVisible(true);this.setResizable(false); //设置窗体不可变大小this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){ //判断是否已输入必填信息warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否相同warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Stu_ID from Student_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd) values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){ //重置所有控件warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}//public static void main(String args[]){// new add_student();//}}4.添加教师package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_teacher extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("教工号:"); //使用文本框创建标签对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField(); //创建文本框对象JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_teacher(){ //添加教师账号信息this.setTitle("添加教师账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加教师账号信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否一致warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Tea_ID from Teacher_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd)values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}// public static void main(String[] args){// new add_teacher();// }}5.添加授课信息package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_tc extends JFrame implements ActionListener{static add_tc ss;String courseID=""; //课程名String teachername=""; //课程名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlteachername=new JLabel("教师号:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtteachername=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_tc(){ //添加授课信息this.setTitle("添加授课信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(jlteachername);this.add(title);this.add(jtcourseID);this.add(jtteachername);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加授课信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlteachername.setBounds(180,140,100,20);jtcourseID.setBounds(250,80,140,20);jtteachername.setBounds(250,140,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,250,60,20);reset.setBounds(300,250,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容teachername=jtteachername.getText();int temp=0,flag1=0,flag2=0,flag3=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || teachername.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){flag1=1; //判断课程ID存在break;}}ResultSet rss=stat.executeQuery("select Tea_ID fromTeacher_Info");while(rss.next()){if(rss.getString(1).equals(teachername)){flag2=1; //判断教师ID存在break;}}if(flag1!=1){warning.setText("课程ID不存在");}else if(flag2!=1){warning.setText("教师ID不存在");}ResultSet rsss=stat.executeQuery("select Course_ID,T ea_ID from tc");while(rsss.next()){if(rsss.getString(1).equals(courseID) &&rsss.getString(2).equals(teachername)){flag3=1;warning.setText("授课信息重复");。

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

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

学生管理系统c语言源代码学生管理系统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); }。

学生管理系统 C语言代码

学生管理系统 C语言代码

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

学生学籍管理系统源代码

学生学籍管理系统源代码

学生学籍管理系统源代码源代码:连接数据库的代码: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<stdio.h>#define N 50#define M 200int stumax=0,scoremax=0;FILE *fp;struct student{char num[9]; //学号char name[20]; //姓名int sex; //性别int room; //宿舍号码long int tel;//电话号码}stu[N];struct stuscore{char num[9];//学号char coursenum[10];//课程编号char course[15];//课程名称float point;//学分int nscore;//平时成绩int expscore; //实验成绩int examscore;//卷面成绩int comscore; //综合成绩float getpoint;//实得学分}score[M],score1[M];void enter_stu();void input_stu(int j);void enter_score();void input_score(int i);void com_score(int i);void browse_stu();void browse_score();void search();void search_stu();void search_num();void search_name();void search_room();void search_score();void printf_onestu_score(char snum[]);void delete_one();void order();void order_course_num();void order_course();void order_printf(int k);/***********菜单***********/void menu(){int w1;char n;/*变量n保存选择菜单数字,w1判断输入的数字是否在功能菜单对应数字范围内*/system("cls");do{puts(”****************************************************************\n\n”);puts("\t ***************** 总菜单*****************\n\n”);puts("\t***1。

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

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

#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]。

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

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

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

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

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

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

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

学籍管理学生查询代码

学籍管理学生查询代码
System.Console.WriteLine("输入有误,请核对后重新输入!");
else
{
//显示查询的结果
Student s2 = new Student();
s2 = (Student)StudentList[index];
System.Console.WriteLine("学号姓名出生日期");
static void SelectStudentMain()
{
string yandn = "y";
while (yandn == "y")
{
//控制台清屏
System.Console.Clear();
System.Console.WriteLine("===============================================");
System.Console.WriteLine("= 1.按学号查询学生信息=");
System.Console.WriteLine("= 2.按姓名查询学生信息=");
System.Console.WriteLine("= 3.按出生日期查询学生信息=");
System.Console.WriteLine("===============================================");
break;
case 3: SelectStuentByBirthday();
break;
default:
Console.WriteLine("错误的输入信息!请核对后重新输入!");
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

XX学院计算机科学与技术系实验报告课程名称程序设计基础实验(2)实验项目应用系统的面向对象设计与分析实验类型综合性实验完成人所在班级指导教师完成日期2009年11月30日实验报告正文一.实验报告简表二.设计内容与要求设计内容:设计基于文件结构的学籍管理系统设计要求:(1)录入学生基本信息的功能界面(2)修改学生基本信息的功能界面(3)查询学生基本信息的功能界面(4)删除学生基本信息的功能界面三.总体设计,包括需求分析、功能描述、设计工具与运行环境、类及类间关系描述等a、Student.java:程序的入口。

初始化主界面,使主界面位于屏幕中间,且用户不能改变其大小。

b、MainFrame.java:程序的主界面。

由菜单、登陆界面和操作选项所构成。

其中菜单的“文件”中各操作项必须在登陆后方可选择,输入用户名和密码点击“进入”,提示登陆成功之后(用户名和密码在数据库的Admin表中,如果用户填的密码或用户名错误或没填都会产生相应的警告框),登陆界面消失,出现“添加信息”、“修改信息”、“信息查询”和“删除信息”四个按钮,且菜单中的操作项也被激活。

点击要操作的按钮或菜单项,进入要操作的界面(窗口出现在屏幕左上角)。

c、AddInf.java:添加信息界面。

按照要求添入基本信息,如果用户填错或没填,提示错误信息(如不能添加已经注册的学号)。

填写完整后,点击“增加”按钮,将信息加入数据库的BaseInf表中。

d、ChangeInf.java:修改信息界面。

按照提示输入要修改信息的学生学号,点击“下一步”(如果数据库无此学号,则提示“无此对应信息”),从数据库中将该学生的完整信息读出,用户修改之后点击“修改”即可。

注意:为了防止意外,修改学生信息时,程序禁止了对学号的修改。

(为了程序设计方便和代码重用,修改信息的代码是先删此该生所有信息,再将修改后的信息全部添加到数据库,这也是数据库修改的原理)e、SeachInf.java:查询信息界面。

输入要查询的学生的学号或姓名(也可两项都填写),点击“查询”,将提示“查无对应信息”或将查询到的学生完整信息显示出来,如果有多条对应信息,“下一条”按钮可选,单击之后可查看下一满足条件的信息,查找准确的学生信息。

f、DelInf.java:删除信息界面。

输入要删除信息的学生的学号,单击“下一步”,程序给出该生的完整信息,点击“删除”,提示是否确定删除对话框,仔细查看信息确认无误后,单击“确定”完成删除,否则单击“取消”。

四.详细设计,包括类图及代码等Student.java:import javax.swing.UIManager;import java.awt.*;public class Student {boolean packFrame = false;public Student() {MainFrame frame = new MainFrame();if (packFrame) {frame.pack();}else {frame.validate();}Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();Dimension frameSize = frame.getSize();if (frameSize.height > screenSize.height) {frameSize.height = screenSize.height;}if (frameSize.width > screenSize.width) {frameSize.width = screenSize.width;}frame.setLocation( (screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2);frame.setVisible(true);}public static void main(String[] args) {try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch (Exception e) {e.printStackTrace();}new Student();}}MainFrame.java:import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;public class MainFrame extends JFrame {boolean login = false;JPanel contentPane;JMenuBar jMenuBar1 = new JMenuBar();/*菜单条*/JMenu jMenuFile = new JMenu();/*菜单项*/JMenu jMenuHelp = new JMenu();/*菜单项*/JMenuItem jMenuFileExit = new JMenuItem();/*菜单子项*/JMenuItem jMenuHelpAbout = new JMenuItem();/*菜单子项*/JMenuItem jMenuItem1 = new JMenuItem();/*菜单子项*/JMenuItem jMenuItem2 = new JMenuItem();/*菜单子项*/JMenuItem jMenuItem3 = new JMenuItem();/*菜单子项*/JMenuItem jMenuItem4 = new JMenuItem();/*菜单子项*/JMenuItem jMenuItem5 = new JMenuItem();/*菜单子项*/Label label1 = new Label();/*标签*/Label label2 = new Label();/*标签*/Label label3 = new Label();/*标签*/Label label4 = new Label();/*标签*/Button button1 = new Button();/*按钮*/Button button2 = new Button();/*按钮*/Button button3 = new Button();/*按钮*/Button button4 = new Button();/*按钮*/Button button5 = new Button();/*按钮*/TextField textField1 = new TextField();/*文本框*/TextField textField2 = new TextField();/*文本框*/public MainFrame() { /*构造函数*/enableEvents(AWTEvent.WINDOW_EVENT_MASK);try {jbInit();}catch (Exception e) {e.printStackTrace();}}private void jbInit() throws Exception { /*初始化*/contentPane = (JPanel)this.getContentPane();/*初始化一个容器*/contentPane.setLayout(null);contentPane.setEnabled(false);/*设置是否启用该组件FALSE表示不启用*/contentPane.setOpaque(true);/*该组件绘制其边界内的所有像素*/contentPane.setPreferredSize(new Dimension(1, 1));/*设置组建的首选大小*/contentPane.setRequestFocusEnabled(true);/*提供一个关于此JComponent 是否应该获得焦点的提示*/this.setForeground(Color.black);this.setResizable(false);/*设置此窗体为不可由用户调整大小*/this.setSize(new Dimension(400, 300));/*调整窗口大小宽为400高为300*/this.setTitle("学籍管理系统");jMenuBar1.setEnabled(true);jMenuBar1.setBorderPainted(true);/*如果该属性为true 并且按钮有边框,则绘制该边框*/jMenuFile.setVerifyInputWhenFocusTarget(true);/*设置该值指示是否在此组件请求焦点前,为当前的焦点所有者调用输入校验器*/jMenuFile.setActionCommand("文件");jMenuFile.setText("文件");jMenuHelp.setText("帮助");jMenuFileExit.setText("退出");jMenuFileExit.addActionListener(new MainFrame_ActionAdapter(this));jMenuHelpAbout.setText("关于");jMenuHelpAbout.addActionListener(new MainFrame_ActionAdapter(this));label1.setFont(new Font("Dialog", 1, 15));label1.setText("用户:");label1.setBounds(new Rectangle(123, 25, 49, 16));label2.setFont(new Font("Dialog", 1, 15));label2.setText("密码:");label2.setBounds(new Rectangle(123, 62, 49, 16));textField1.setText("");textField1.setBounds(new Rectangle(192, 24, 62, 18));textField2.setEchoChar('*');textField2.setText("");textField2.setBounds(new Rectangle(192, 61, 62, 18));button1.setLabel("进入系统");button1.setFont(new Font("Dialog", 1, 15));button1.setBounds(new Rectangle(150, 104, 101, 22));button1.addActionListener(new MainFrame_ActionAdapter(this));label3.setFont(new Font("Dialog", 1, 15));label3.setForeground(Color.red);label3.setText("请选择操作项");label3.setVisible(false);label3.setBounds(new Rectangle(158, 92, 84, 16));button2.setFont(new Font("Dialog", 1, 15));button2.setLabel("添加信息");button2.setVisible(false);button2.setBounds(new Rectangle(74, 136, 97, 33));button3.setFont(new Font("Dialog", 1, 15));button3.setLabel("修改信息");button3.setVisible(false);button3.setBounds(new Rectangle(226, 136, 97, 33));button4.setFont(new Font("Dialog", 1, 15));button4.setLabel("信息查询");button4.setVisible(false);button4.setBounds(new Rectangle(74, 185, 97, 33));button5.setFont(new Font("Dialog", 1, 15));button5.setLabel("删除信息");button5.setVisible(false);button5.setBounds(new Rectangle(226, 185, 97, 33));jMenuItem1.setText("添加信息");jMenuItem2.setText("信息查询");jMenuItem3.setText("修改信息");jMenuItem4.setText("删除信息");jMenuItem5.setText("帮助");label4.setFont(new Font("Dialog", 1, 30));label4.setText("学籍管理系统");label4.setVisible(false);label4.setBounds(new Rectangle(70, 37, 261, 33));jMenuFile.add(jMenuItem1);jMenuItem1.setEnabled(false);jMenuItem1.addActionListener(new MainFrame_ActionAdapter(this)); jMenuItem2.setEnabled(false);jMenuFile.add(jMenuItem2);jMenuItem2.addActionListener(new MainFrame_ActionAdapter(this)); jMenuItem3.setEnabled(false);jMenuFile.add(jMenuItem3);jMenuItem3.addActionListener(new MainFrame_ActionAdapter(this)); jMenuItem4.setEnabled(false);jMenuFile.add(jMenuItem4);jMenuItem4.addActionListener(new MainFrame_ActionAdapter(this)); jMenuFile.add(jMenuFileExit);jMenuHelp.add(jMenuItem5);jMenuHelp.add(jMenuHelpAbout);jMenuBar1.add(jMenuFile);jMenuBar1.add(jMenuHelp);contentPane.add(label1, null);contentPane.add(label2, null);contentPane.add(textField1, null);contentPane.add(textField2, null);contentPane.add(label3, null);contentPane.add(button2, null);button2.addActionListener(new MainFrame_ActionAdapter(this)); contentPane.add(button4, null);button4.addActionListener(new MainFrame_ActionAdapter(this)); contentPane.add(button3, null);button3.addActionListener(new MainFrame_ActionAdapter(this)); contentPane.add(button5, null);button5.addActionListener(new MainFrame_ActionAdapter(this));contentPane.add(button1, null);contentPane.add(label4, null);this.setJMenuBar(jMenuBar1);}public void jMenuFileExit_actionPerformed(ActionEvent e) {System.exit(0);}public void jMenuHelpAbout_actionPerformed(ActionEvent e) {}protected void processWindowEvent(WindowEvent e) {super.processWindowEvent(e);if (e.getID() == WindowEvent.WINDOW_CLOSING) {jMenuFileExit_actionPerformed(null);}}void button1_actionPerformed(ActionEvent e) {String user = textField1.getText().trim();String pass = textField2.getText().trim();try {String strurl ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=DataBase/student.mdb";Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection conn = DriverManager.getConnection(strurl);Statement stmt = conn.createStatement();if (user.equals("")|| pass.equals(""))JOptionPane.showMessageDialog(null, "用户名或密码不能为空", "警告",JOptionPane.W ARNING_MESSAGE);else {ResultSet rs = stmt.executeQuery("select * from admin where username='" +user + "' AND password='" + pass + "'");if (rs.next()) {JOptionPane.showMessageDialog(null, "登陆成功");login = true;label1.setVisible(false);textField1.setVisible(false);label2.setVisible(false);textField2.setVisible(false);button1.setVisible(false);label3.setVisible(true);label4.setVisible(true);button2.setVisible(true);button3.setVisible(true);button4.setVisible(true);button5.setVisible(true);jMenuItem1.setEnabled(true);jMenuItem2.setEnabled(true);jMenuItem3.setEnabled(true);jMenuItem4.setEnabled(true);}elseJOptionPane.showMessageDialog(null, "登陆失败", "警告",JOptionPane.W ARNING_MESSAGE);}}catch (Exception eg){eg.printStackTrace();}}}class MainFrame_ActionAdapter implements ActionListener {MainFrame adaptee;MainFrame_ActionAdapter(MainFrame adaptee) {this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {if (e.getSource() == adaptee.jMenuFileExit)adaptee.jMenuFileExit_actionPerformed(e);else if (e.getSource() == adaptee.jMenuItem1 ||e.getSource() == adaptee.button2) {AddInf addInf = new AddInf();addInf.setSize(400, 300);addInf.setVisible(true);}else if (e.getSource() == adaptee.jMenuItem3 ||e.getSource() == adaptee.button3) {ChangeInf changeInf = new ChangeInf();changeInf.setSize(400, 300);changeInf.setVisible(true);}else if (e.getSource() == adaptee.jMenuItem2 ||e.getSource() == adaptee.button4) {SearchInf searchInf = new SearchInf();searchInf.setSize(400, 300);searchInf.setVisible(true);}else if (e.getSource() == adaptee.jMenuItem4 ||e.getSource() == adaptee.button5) {DelInf delInf = new DelInf();delInf.setSize(400, 300);delInf.setVisible(true);}else if (e.getSource() == adaptee.jMenuHelpAbout)adaptee.jMenuHelpAbout_actionPerformed(e);else if (e.getSource() == adaptee.button1)adaptee.button1_actionPerformed(e);}}AddInf.javaimport javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class AddInf extends JFrame implements ActionListener { Label label1 = new Label();TextField textField1 = new TextField();Label label2 = new Label();TextField textField2 = new TextField();Label label3 = new Label();Choice choice1 = new Choice();Label label4 = new Label();TextField textField3 = new TextField();Label label5 = new Label();Choice choice2 = new Choice();Label label6 = new Label();TextField textField4 = new TextField();Label label7 = new Label();Choice choice3 = new Choice();Label label8 = new Label();TextField textField5 = new TextField();Label label9 = new Label();TextArea textArea1 = new TextArea();Button button1 = new Button();public AddInf() {try {jbInit();}catch (Exception e) {e.printStackTrace();}}private void jbInit() throws Exception {this.setEnabled(true);this.setResizable(false);this.setTitle("增加学生信息");this.setDefaultCloseOperation(HIDE_ON_CLOSE); label1.setText("学号:");label1.setBounds(new Rectangle(30, 11, 51, 33)); this.getContentPane().setLayout(null);textField1.setText("");textField1.setBounds(new Rectangle(86, 16, 74, 22)); label2.setText("姓名:");label2.setBounds(new Rectangle(162, 11, 28, 33)); textField2.setText("");textField2.setBounds(new Rectangle(192, 16, 44, 22)); label3.setText("性别:");label3.setBounds(new Rectangle(241, 11, 28, 33)); choice1.setEnabled(true);choice1.setFont(new Font("Dialog", 0, 12));choice1.setForeground(Color.black);choice1.setLocale(java.util.Locale.getDefault()); choice1.setVisible(true);choice1.setBounds(new Rectangle(275, 15, 50, 25)); choice1.addItem("男");choice1.addItem("女");label4.setText("出生日期:");label4.setBounds(new Rectangle(31, 53, 49, 33)); textField3.setText("YYYY-MM-DD");textField3.setBounds(new Rectangle(86, 58, 74, 22)); label5.setText("政治面貌:");label5.setBounds(new Rectangle(241, 53, 47, 33)); choice2.setBounds(new Rectangle(296, 57, 72, 25)); choice2.setVisible(true);choice2.setLocale(java.util.Locale.getDefault()); choice2.setForeground(Color.black);choice2.setFont(new Font("Dialog", 0, 12));choice2.setEnabled(true);label6.setText("籍贯:");label6.setBounds(new Rectangle(163, 53, 26, 33)); textField4.setText("");textField4.setBounds(new Rectangle(191, 58, 44, 22)); label7.setText("系别:");label7.setBounds(new Rectangle(30, 94, 50, 33)); choice3.setEnabled(true);choice3.setFont(new Font("Dialog", 0, 12));choice3.setForeground(Color.black);choice3.setLocale(java.util.Locale.getDefault()); choice3.setVisible(true);choice3.setBounds(new Rectangle(86, 98, 75, 25)); label8.setText("专业:");label8.setBounds(new Rectangle(163, 94, 26, 33)); textField5.setText("");textField5.setBounds(new Rectangle(190, 99, 178, 22)); label9.setText("备注:");label9.setBounds(new Rectangle(27, 132, 50, 33)); textArea1.setBounds(new Rectangle(84, 139, 285, 92)); button1.setLabel("增加");button1.setVisible(true);button1.setBounds(new Rectangle(156, 244, 89, 22)); button1.addActionListener(this);this.getContentPane().add(label3, null);this.getContentPane().add(label1, null);this.getContentPane().add(textField1, null);this.getContentPane().add(label2, null);this.getContentPane().add(textField2, null);this.getContentPane().add(choice1, null);this.getContentPane().add(label4, null);this.getContentPane().add(textField3, null);this.getContentPane().add(label6, null);this.getContentPane().add(textField4, null);this.getContentPane().add(label5, null);this.getContentPane().add(choice2, null);this.getContentPane().add(label7, null);this.getContentPane().add(choice3, null);this.getContentPane().add(label8, null);this.getContentPane().add(textField5, null);this.getContentPane().add(label9, null);this.getContentPane().add(textArea1, null);this.getContentPane().add(button1, null);choice2.addItem("团员");choice2.addItem("党员");choice2.addItem("其他");choice3.addItem("计算机");choice3.addItem("电子");choice3.addItem("生化");choice3.addItem("艺术");}public void actionPerformed(ActionEvent e) {try {String strurl ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=DataBase/student.mdb";Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection conn = DriverManager.getConnection(strurl);Statement stmt = conn.createStatement();ResultSet rs = stmt.executeQuery("select 学号from BaseInf where 学号='" +textField1.getText() + "'");if (rs.next()) {JOptionPane.showMessageDialog(null, "此学号已经被注册.", "警告",JOptionPane.W ARNING_MESSAGE);return;}stmt.execute("insert into BaseInf (学号,系别,专业,姓名,性别,出年日期,籍贯,政治面貌,备注) values ('" +textField1.getText() + "','" + choice3.getSelectedItem() + "','" +textField5.getText() + "','" + textField2.getText() + "','" +choice1.getSelectedItem() + "','" + textField3.getText() + "','" +textField4.getText() + "','" + choice2.getSelectedItem() + "','" +textArea1.getText() + "')");textField1.setText("");textField2.setText("");textField3.setText("");textField4.setText("");textField5.setText("");textArea1.setText("");JOptionPane.showMessageDialog(null, "增加信息成功!");}catch (Exception eg) {JOptionPane.showMessageDialog(null, "请认真检查各项(不能为空),\n日期要合法!然后重试.", "异常警告",JOptionPane.WARNING_MESSAGE);eg.printStackTrace();}}}ChangeInf.java:import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class ChangeInf extends JFrame implements ActionListener { String strurl;Connection conn;Statement stmt;ResultSet rs;Label label1 = new Label();TextField textField1 = new TextField();Label label2 = new Label();TextField textField2 = new TextField();Label label3 = new Label();Choice choice1 = new Choice();Label label4 = new Label();TextField textField3 = new TextField();Label label5 = new Label();Choice choice2 = new Choice();Label label6 = new Label();TextField textField4 = new TextField();Label label7 = new Label();Choice choice3 = new Choice();Label label8 = new Label();TextField textField5 = new TextField();Label label9 = new Label();TextArea textArea1 = new TextArea();Button button1 = new Button();TextField textField6 = new TextField();Button button2 = new Button();Label label10 = new Label();public ChangeInf() {try {jbInit();}catch (Exception e) {e.printStackTrace();}}private void jbInit() throws Exception {label1.setText("学号:");label1.setVisible(false);label1.setBounds(new Rectangle(30, 11, 51, 33)); this.getContentPane().setLayout(null);textField1.setText("");textField1.setVisible(false);textField1.setBounds(new Rectangle(86, 16, 74, 22)); label2.setBounds(new Rectangle(162, 11, 28, 33)); label2.setText("姓名:");label2.setVisible(false);textField2.setText("");textField2.setVisible(false);textField2.setBounds(new Rectangle(192, 16, 44, 22)); label3.setText("性别:");label3.setVisible(false);label3.setBounds(new Rectangle(241, 11, 28, 33)); choice1.setEnabled(true);choice1.setFont(new Font("Dialog", 0, 12));choice1.setForeground(Color.black);choice1.setLocale(java.util.Locale.getDefault()); choice1.setVisible(false);choice1.setBounds(new Rectangle(275, 15, 50, 25)); choice1.addItem("男");choice1.addItem("女");this.setDefaultCloseOperation(HIDE_ON_CLOSE); this.setEnabled(true);this.setResizable(false);this.setTitle("修改学生信息");label4.setBounds(new Rectangle(31, 53, 49, 33)); label4.setText("出生日期:");label4.setVisible(false);textField3.setBounds(new Rectangle(86, 58, 74, 22)); textField3.setLocale(java.util.Locale.getDefault()); textField3.setText("");textField3.setVisible(false);label5.setText("政治面貌:");label5.setVisible(false);label5.setBounds(new Rectangle(241, 53, 47, 33)); choice2.setBounds(new Rectangle(296, 57, 72, 25)); choice2.setVisible(false);choice2.setLocale(java.util.Locale.getDefault()); choice2.setForeground(Color.black);choice2.setFont(new Font("Dialog", 0, 12));choice2.setEnabled(true);label6.setText("籍贯:");label6.setVisible(false);label6.setBounds(new Rectangle(163, 53, 26, 33)); textField4.setBounds(new Rectangle(191, 58, 44, 22)); textField4.setText("");textField4.setVisible(false);label7.setBounds(new Rectangle(30, 94, 50, 33));label7.setText("系别:");label7.setVisible(false);choice3.setEnabled(true);choice3.setFont(new Font("Dialog", 0, 12));choice3.setForeground(Color.black);choice3.setLocale(java.util.Locale.getDefault()); choice3.setVisible(false);choice3.setBounds(new Rectangle(86, 98, 75, 25)); label8.setBounds(new Rectangle(163, 94, 26, 33)); label8.setText("专业:");label8.setVisible(false);textField5.setText("");textField5.setVisible(false);textField5.setBounds(new Rectangle(190, 99, 178, 22)); label9.setText("备注:");label9.setVisible(false);label9.setBounds(new Rectangle(27, 132, 50, 33)); textArea1.setVisible(false);textArea1.setBounds(new Rectangle(84, 139, 285, 95)); button1.setLabel("修改");button1.setVisible(false);button1.setBounds(new Rectangle(153, 241, 94, 22)); button1.addActionListener(this);textField6.setText("");textField6.setBounds(new Rectangle(147, 92, 105, 23)); button2.setFont(new Font("Dialog", 1, 15));button2.setLabel("下一步");button2.setVisible(true);button2.setBounds(new Rectangle(156, 148, 89, 23)); button2.addActionListener(this);label10.setFont(new Font("Dialog", 1, 15));label10.setText("请输入要修改的学生学号");label10.setBounds(new Rectangle(110, 49, 178, 24)); this.getContentPane().add(label3, null);this.getContentPane().add(label1, null);this.getContentPane().add(textField1, null);this.getContentPane().add(label2, null);this.getContentPane().add(textField2, null);this.getContentPane().add(choice1, null);this.getContentPane().add(label4, null);this.getContentPane().add(textField3, null);this.getContentPane().add(label6, null);this.getContentPane().add(textField4, null);this.getContentPane().add(label5, null);this.getContentPane().add(choice2, null);this.getContentPane().add(label7, null);this.getContentPane().add(choice3, null);this.getContentPane().add(label8, null);this.getContentPane().add(textField5, null);this.getContentPane().add(label9, null);this.getContentPane().add(textArea1, null);this.getContentPane().add(button2, null);this.getContentPane().add(textField6, null);this.getContentPane().add(label10, null);this.getContentPane().add(button1, null);choice2.addItem("团员");choice2.addItem("党员");choice2.addItem("其他");choice3.addItem("计算机");choice3.addItem("电子");choice3.addItem("生化");choice3.addItem("艺术");strurl ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=DataBase/student.mdb"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");conn = DriverManager.getConnection(strurl);stmt = conn.createStatement();}public void actionPerformed(ActionEvent e) {if (e.getSource() == button2) {try {rs = stmt.executeQuery("SELECT * FROM BaseInf where 学号='" +textField6.getText() + "'");if (rs.next()) {textField6.setVisible(false);button2.setVisible(false);label10.setVisible(false);label1.setVisible(true);label2.setVisible(true);label3.setVisible(true);label4.setVisible(true);label5.setVisible(true);label6.setVisible(true);label7.setVisible(true);label8.setVisible(true);label9.setVisible(true);textArea1.setVisible(true);textArea1.setText(rs.getString("备注"));textField1.setVisible(true);textField1.enable(false);textField1.setText(rs.getString("学号"));textField2.setVisible(true);textField2.setText(rs.getString("姓名"));textField3.setVisible(true);textField3.setText(rs.getString("出年日期"));textField4.setVisible(true);textField4.setText(rs.getString("籍贯"));textField5.setVisible(true);textField5.setText(rs.getString("专业"));choice1.setVisible(true);choice1.select(rs.getString("性别"));choice2.setVisible(true);choice2.select(rs.getString("政治面貌"));choice3.setVisible(true);choice3.select(rs.getString("系别"));button1.setVisible(true);}elseJOptionPane.showMessageDialog(null, "无此学号对应信息", "警告",JOptionPane.W ARNING_MESSAGE);}catch (Exception eg) {eg.printStackTrace();}}else if (e.getSource() == button1) {try {stmt.execute("DELETE * FROM BaseInf where 学号='" + textField1.getText() +"'");stmt.execute("insert into BaseInf (学号,系别,专业,姓名,性别,出年日期,籍贯,政治面貌,备注) values ('" +textField1.getText() + "','" + choice3.getSelectedItem() + "','" +textField5.getText() + "','" + textField2.getText() + "','" +choice1.getSelectedItem() + "','" + textField3.getText() + "','" +textField4.getText() + "','" + choice2.getSelectedItem() + "','" +textArea1.getText() + "')");JOptionPane.showMessageDialog(null, "修改信息成功!");}catch (Exception eg) {JOptionPane.showMessageDialog(null, "请认真检查各项(不能为空),\n日期要合法!然后重试.","异常警告", JOptionPane.W ARNING_MESSAGE);eg.printStackTrace();}}}}SearchInf.java:import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;public class SearchInf extends JFrame implements ActionListener {String strurl;Connection conn;Statement stmt;ResultSet rs;Label label1 = new Label();TextField textField1 = new TextField();Label label2 = new Label();TextField textField2 = new TextField();Label label3 = new Label();Choice choice1 = new Choice();Label label4 = new Label();TextField textField3 = new TextField();Label label5 = new Label();Choice choice2 = new Choice();Label label6 = new Label();TextField textField4 = new TextField();Label label7 = new Label();Choice choice3 = new Choice();Label label8 = new Label();TextField textField5 = new TextField();Label label9 = new Label();TextArea textArea1 = new TextArea();Button button1 = new Button();TextField textField6 = new TextField();Button button2 = new Button();Label label10 = new Label();Label label12 = new Label();Label label13 = new Label();TextField textField7 = new TextField();public SearchInf() {try {jbInit();}catch (Exception e) {e.printStackTrace();}}private void jbInit() throws Exception {label1.setText("学号:");label1.setVisible(false);label1.setBounds(new Rectangle(30, 11, 51, 33)); this.getContentPane().setLayout(null);textField1.setText("");textField1.setVisible(false);textField1.setBounds(new Rectangle(86, 16, 74, 22)); label2.setBounds(new Rectangle(162, 11, 28, 33)); label2.setText("姓名:");label2.setVisible(false);textField2.setText("");textField2.setVisible(false);textField2.setBounds(new Rectangle(192, 16, 44, 22)); label3.setText("性别:");label3.setVisible(false);label3.setBounds(new Rectangle(241, 11, 28, 33)); choice1.setEnabled(true);choice1.setFont(new java.awt.Font("Dialog", 0, 12)); choice1.setForeground(Color.black);choice1.setLocale(java.util.Locale.getDefault()); choice1.setVisible(false);choice1.setBounds(new Rectangle(275, 15, 50, 25)); choice1.addItem("男");choice1.addItem("女");this.setDefaultCloseOperation(HIDE_ON_CLOSE); this.setEnabled(true);this.setResizable(false);this.setTitle("查询学生信息");label4.setBounds(new Rectangle(31, 53, 49, 33)); label4.setText("出生日期:");。

相关文档
最新文档