📄 c1_1.java
字号:
catch(IOException E)
{ System.out.println("I/O错误!");}
switch(n)
{
case 1: System.out.println("个人资料");te.show( ); break;
case 2: System.out.println("所教课程");te.course();break;
case 3: System.out.println("成绩查询");te.score();break;
case 4: System.out.println("修改密码");te.changepaw("T" );break;
case 5: System.out.println("登记成绩");te.loadscore();break;
case 6: System.out.println("删除成绩");te.deleteScore();break;
case 7: System.out.println("修改成绩");te.modifscore();break;
case 8: System.out.println("退出");break;
default: System.out.println("\n\n\t\t\t\t对不起!你的输入有误!!!请重新输入!\n");
}
}while(n!=8);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////教务员菜单函数//////////////////////////////////////////////
public static void EA_menu(EAdministrator EA)
{
int n=13;
do
{
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
System.out.println(" *****************************欢迎来到教务员平台**********************");
System.out.println(" *********************************************************************\n\n");
System.out.println(" 1、个人资料 2、学生注册 3、教师注册 ");
System.out.println(" 4、修改密码 5、成绩查询 6、删除学生 ");
System.out.println(" 7、删除教师 8、课程登记 9、删除课程 ");
System.out.println(" 10、修改学生资料 11、修改教师资料 ");
System.out.println(" 12、退出 \n\n");
System.out.println(" *****************************请选择需要的操作************************");
do
{
try
{
n=Integer.parseInt(keyin.readLine());
}
catch(IOException E)
{ System.out.println("I/O错误!");}
if(n>12) System.out.println("输入有误!!! 请重新输入!");
}while(n>12);
switch(n)
{
case 1: System.out.println("个人资料");EA.show( ); break;
case 2: System.out.println("学生注册");EA.stu_register( );break;
case 3: System.out.println("教师注册");EA.te_register( );break;
case 4: System.out.println("修改密码");EA.changepaw("T");break;
case 5: System.out.println("成绩查询");break;
case 6: System.out.println("删除学生");EA.deletest();break;
case 7: System.out.println("删除教师");EA.deletete();break;
case 8: System.out.println("课程登记");EA.c_register( );break;
case 9: System.out.println("删除课程 ");EA.deletecu();break;
case 10: System.out.println("修改学生资料");break;
case 11: System.out.println("修改教师资料");break;
case 12: System.out.println("退出");break;
default: System.out.println("\n\n\t\t\t\t输入有误!!! 请重新输入!!!\n");
}
}while(n!=12);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////学生登陆函数//////////////////////////////////////////////
public static void logstu()
{
boolean c=false;
String num=" ",sex=" ",birthday=" ",name=" ",department=" ",password=" ";
student stu;
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入用户名 :");
try
{num=keyin.readLine();}
catch(IOException E)
{ System.out.println("I/O错误!");}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////连接数据库函数//////////////////////////////////////////////
String conURL="jdbc:odbc:student";
try {
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from S where ID='"+num+"'");
while(rs.next())
{c=true;
name=rs.getString("Name");
System.out.println(name);
sex=rs.getString("Sex");
department=rs.getString("Department");
birthday=rs.getString("Birthday");
password=rs.getString("Password");
num=rs.getString("ID");
}
if(c)
{
stu= new student(name,department,birthday,sex,num,password);
System.out.println("请输入密码: ");
try
{password=keyin.readLine();}
catch(IOException E)
{System.out.println("I/O错误!");}
if(stu.password.equalsIgnoreCase(password)) {System.out.println("\t\t\t"+stu.name+"同学 你好!");st_menu(stu);}
else System.out.println("\n\n\t\t\t\t对不起!你的密码错误!\n\n");
}
else System.out.println("\t\t\t\t对不起!你的用户名不存在!\n");
s.close();
con.close();
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////教师登陆函数//////////////////////////////////////////////
public static void logte()
{
boolean c=false;
String num=" ",sex=" ",birthday=" ",post=" ",name=" ",department=" ",password=" ";
teacher te;
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入用户名 :");
try
{num=keyin.readLine();}
catch(IOException E)
{ System.out.println("I/O错误!");}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////连接数据库函数//////////////////////////////////////////////
String conURL="jdbc:odbc:student";
try {
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from T where ID='"+num+"'");
while(rs.next())
{c=true;
name=rs.getString("Name");
sex=rs.getString("Sex");
post=rs.getString("Post");
num=rs.getString("ID");
birthday=rs.getString("Birthday");
password=rs.getString("Password");
department=rs.getString("Department");
}
if(c)
{
te=new teacher(name,department,birthday,sex,num,password,post);
System.out.println("请输入密码: ");
try
{password=keyin.readLine();}
catch(IOException E)
{System.out.println("I/O错误!");}
if(te.password.equalsIgnoreCase(password)) {System.out.println("\t\t\t"+te.name+" 老师 你好!");te_menu(te);}
else System.out.println("\n\n\t\t\t\t对不起!你的密码错误!\n\n");
}
else System.out.println("\t\t\t\t对不起!你的用户名不存在!\n");
s.close();
con.close();
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////教务员登陆函数//////////////////////////////////////////////
public static void logEA()
{
boolean c=false;
EAdministrator EA;
String num=" ",sex=" ",birthday=" ",post=" ",name=" ",department=" ",password=" ";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入用户名 :");
try
{num=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////连接数据库函数//////////////////////////////////////////////
String conURL="jdbc:odbc:student";
try {
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from T where ID='"+num+"'");
while(rs.next())
{c=true;
name=rs.getString("Name");
sex=rs.getString("Sex");
post=rs.getString("Post");
num=rs.getString("ID");
birthday=rs.getString("Birthday");
password=rs.getString("Password");
department=rs.getString("Department");
}
if(c)
{
EA=new EAdministrator(name,department,birthday,sex,num,password,post);
System.out.println("请输入密码: ");
try
{password=keyin.readLine();}
catch(IOException E)
{System.out.println("I/O错误!");}
if(EA.password.equalsIgnoreCase(password)) {System.out.println("\t\t\t"+EA.name+" 老师 你好!");EA_menu(EA);}
else System.out.println("\n\n\t\t\t\t对不起!你的密码错误!\n\n");
}
else System.out.println("\t\t\t\t对不起!你的用户名不存在!\n");
s.close();
con.close();
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////总菜单函数/////////////////////////////////////////////////
public static void menu( )
{
int n=5;
do
{
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
System.out.println(" *****************************学生成绩管理系统************************");
System.out.println(" *********************************************************************\n\n");
System.out.println(" 1、学生平台 2、教师平台 3、教务员平台 ");
System.out.println(" 4、退出 \n\n");
System.out.println(" *****************************请选择登陆的平台************************");
do
{
try
{
n=Integer.parseInt(keyin.readLine());
}
catch(IOException E)
{ System.out.println("I/O错误!");}
if(n>4) System.out.println("输入有误!!! 请重新输入!");
}while(n>4);
switch(n)
{
case 1: System.out.println("\n\n\n欢迎登陆学生平台");logstu(); break;
case 2: System.out.println("\n\n\n欢迎登陆教师平台"); logte(); break;
case 3: System.out.println("\n\n\n欢迎登陆教务员平台"); logEA( );break;
case 4: System.out.println("\n\n\n\t\t\t\t\t谢谢使用!"); break;
default: System.out.println("\n\n\t\t\t\t输入有误!!! 请重新输入!!!\n");
}
}while(n!=4);
}
public static void main(String args[])
{
String JDriver="sun.jdbc.odbc.JdbcOdbcDriver";
try
{
Class.forName(JDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.out.println("ForName:"+e.getMessage());
}
//对学生类的检验
/* student stu;
System.out.println("My first Java application!");
stu=new student("张海","计算机科学与技术","1986/08/23",'M',"051106214");
stu.show();
stu.c_show();
stu.changepaw();
stu.show();
*/
//对课程类的测试
/*
coures c=new coures("JAVA语言程序设计","邹胜荣",12);
c.show();
*/
//对老师类进行测试
/*
teacher t1=new teacher("邹盛荣","计较","1975/02/24",'m',"05245411","教授");
t1.show();
*/
menu( );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -