📄 c1_1.java
字号:
int score=0;
String id=" ",id2=" ";
String conURL="jdbc:odbc:student";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
try
{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
Statement s1=con.createStatement();
try
{
System.out.println("请输入你想要察看的课程编号");
id=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
ResultSet rs=s.executeQuery("select Name,SID from SC,S where S.ID=SC.SID and CID='"+id+"'");
while(rs.next())
{
System.out.println("姓名:"+rs.getString("Name"));
id=rs.getString("SID");
s1.executeUpdate("update SC set score="+score+"where SC.SID='"+id2+"' and SC.CID='"+id+"'");
System.out.println("姓名:"+id);
}
s.close();
s1.close();
con.close();
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
public void modifscore() //缺少
{
int score=100;
String id=" ",id2=" ";
String conURL="jdbc:odbc:student";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
try
{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
try
{
System.out.println("请输入你想要察看的课程编号和学生的学号");
id=keyin.readLine();
System.out.println("请输入你想要修改的学生的学号");
id2=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
s.executeUpdate("update SC set score="+score+ "where SC.SID='"+id2+"' and SC.CID='"+id+"'");
System.out.println("姓名:"+id);
s.close();
con.close();
System.out.println("修改成功");
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
public void deleteScore()
{
String id=" ",id2=" ";
String conURL="jdbc:odbc:student";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
try
{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
try
{
System.out.println("请输入你想要察看的课程编号和学生的学号");
id=keyin.readLine();
System.out.println("请输入你想要删除的学生的学号");
id2=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
s.executeUpdate("delete From SC where SID='"+id2+"'and CID='"+id+"'");
System.out.println("姓名:"+id);
s.close();
con.close();
System.out.println("删除成功");
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
}
/**************************************************************************************************************/
/*********************************************教务员类的定义*************************************************/
/*************************************************************************************************************/
class EAdministrator extends teacher
{
EAdministrator(String name,String department,String birthday,String sex,String num,String password,String post)
{
super(name,department,birthday,sex,num,password,post);
}
public static void stu_register( )
{
student su=new student("张海","计算机科学与技术","1986/08/23","男","051106214","051106214");
student S[]={su};
int i=0;
do
{
S[i]= new student( );
i++;
}while(!(S[i-1].num).equalsIgnoreCase("0000"));
}
public static void te_register( )
{
teacher te=new teacher("邹盛荣","计较","1975/02/24","男","051106214","051106214","教授");
teacher T[]={te};
int i=0;
do
{
T[i]= new teacher( );
i++;
}while(!(T[i-1].num).equalsIgnoreCase("0000"));
}
public static void c_register( )
{
coures cr=new coures( );
coures C[]={cr};
int i=0;
do
{
C[i]= new coures( );
i++;
}while(C[i-1].num!=0);
}
public static void deletete()
{
String id=" ";
String conURL="jdbc:odbc:student";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
try
{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
try
{
System.out.println("请输入你想要删除的老师的工号");
id=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
s.executeUpdate("delete From T where ID='"+id+"'");
s.close();
con.close();
System.out.println("删除成功");
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
public static void deletest()
{ String id=" ";
String conURL="jdbc:odbc:student";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
try
{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
try
{
System.out.println("请输入你想要删除的学生的学号");
id=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
s.executeUpdate("delete From S where ID='"+id+"'");
s.close();
con.close();
System.out.println("删除成功");
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
public static void deletecu()
{
String id=" ";
String conURL="jdbc:odbc:student";
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
try
{
Connection con=DriverManager.getConnection(conURL);
Statement s=con.createStatement();
try
{
System.out.println("请输入你想要删除的课程的课程编号");
id=keyin.readLine();
}
catch(IOException E)
{ System.out.println("I/O错误!");}
s.executeUpdate("delete From C where ID='"+id+"'");
s.close();
con.close();
System.out.println("删除成功");
}
catch(SQLException e)
{
System.out.println("SQLException:"+e.getMessage());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////文件操作函数//////////////////////////////////////////////
}
/**************************************************************************************************************/
/*********************************************教务员类的定义*************************************************/
/*************************************************************************************************************/
/**************************************************************************************************************/
/*********************************************系统类的定义***************************************************/
/*************************************************************************************************************/
public class c1_1
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////学生菜单函数//////////////////////////////////////////////
public static void st_menu(student stu )
{
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、修改密码 5、选定课程 6、退出 \n\n");
System.out.println(" *****************************请选择需要的操作************************");
try
{
n=Integer.parseInt(keyin.readLine());
}
catch(IOException E)
{ System.out.println("I/O错误!");}
switch(n)
{
case 1: System.out.println("个人资料");stu.show( ); break;
case 2: System.out.println("选修课程");stu.chose();break;
case 3: System.out.println("成绩查询");stu.c_show();break;
case 4: System.out.println("修改密码");stu.changepaw("S");break;
case 5: System.out.println("选定课程");stu.c_show();break;
case 6: System.out.println("退出");break;
default: System.out.println("\n\n\t\t\t\t输入有错误!!!请重新输入!\n");
}
}while(n!=6);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////教师菜单函数//////////////////////////////////////////////
public static void te_menu(teacher te)
{
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、修改密码 5、登记成绩 6、删除成绩 ");
System.out.println(" 7、修改成绩 8、退出 9、 \n\n");
System.out.println(" *****************************请选择需要的操作************************");
try
{
n=Integer.parseInt(keyin.readLine());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -