📄 ydq.java
字号:
public void chaxun() throws SQLException
{
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
for(int i=0;i<num;i++)
{choice.select(i);
String qq="'"+choice.getSelectedItem()+"'";
rs=sql.executeQuery("select * from kecheng where 课程名="+qq);
while(rs.next())
{String q1=rs.getString("教师");
String q2=rs.getString("学时");
String q3=rs.getString("上课地点");
a[i][0]=choice.getSelectedItem();
a[i][1]=q1;
a[i][2]=q2;
a[i][3]=q3;
}
}
con.close();
}
}
}
class chengjichaxun extends Frame implements ActionListener
{Label label1,label2;
TextField text1;
Choice choice;
Button button1,button2;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
int num;
chengjichaxun()
{super("成绩查询页面");
setBackground(color);
setSize(400,400);
setBounds(200,200,600,300);
setVisible(false);
label1=new Label("已选修的课程名");
label2=new Label("成绩");
choice=new Choice();
text1=new TextField(6);
button1=new Button("查询成绩");
button2=new Button("查询全部选修课程的成绩");
button1.addActionListener(this);
button2.addActionListener(this);
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
p1.add(label1,"West");
p1.add(choice,"Center");
p2.add(label2,"West");
p2.add(text1,"Center");
p3.add(button1,"West");
p3.add(button2,"Center");
p5.add(p1,"West");
p5.add(p2,"Center");
p5.add(p3,"East");
p6.add(p5,"South");
add(p6);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose();}
}
);
validate();
try
{ tianjiakecheng();
}
catch(SQLException e8) {}
}
public void tianjiakecheng() throws SQLException
{ try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
rs=sql.executeQuery("select 课程名 from xuanke where 用户名="+xuehao);
while(rs.next())
{String qq=rs.getString("课程名");
choice.add(qq);
}
con.close();
num=choice.getItemCount();
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==button1)
{try
{chaxunchengji();
}
catch(SQLException e4) {}
}
else if(e.getSource()==button2)
{ setVisible(false);
chaxunsuoyouchengji oo=new chaxunsuoyouchengji();
oo.setVisible(true);
}
}
public void chaxunchengji() throws SQLException
{String q1="";
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
String qq="'"+choice.getSelectedItem()+"'";
rs=sql.executeQuery("select 课程号 from kecheng where 课程名="+qq);
while(rs.next())
{ q1=rs.getString("课程号");
}
String s1="'"+q1+"'";
rs=sql.executeQuery("select 成绩 from chengji where 用户名="+xuehao+" and 课程号="+s1);
while(rs.next())
{String tt=rs.getString("成绩");
text1.setText(tt);
con.close();
return;
}
JOptionPane.showMessageDialog(this,"暂时还没有关于你的成绩信息","提示",JOptionPane.WARNING_MESSAGE);
}
class chaxunsuoyouchengji extends JFrame
{Object a[][];
Object columnName[]={"课程名","成绩"};
JTable table;
Container container;
String kechengming,jiaoshi,xueshi,shangkedidian;
Connection con;
Statement sql;
ResultSet rs;
chaxunsuoyouchengji()
{super("查询所有成绩");
a=new Object[num][2];
table=new JTable(a,columnName);
setSize(500,500);
setBounds(200,200,500,300);
setVisible(false);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
container=getContentPane();
container.add(new JScrollPane(table),BorderLayout.CENTER);
container.add(new Label("有些课程的成绩暂时还没公布!"),BorderLayout.SOUTH);
try
{chaxun();
}
catch(SQLException e6) {}
}
public void chaxun() throws SQLException
{ String q1="";
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
for(int i=0;i<num;i++)
{choice.select(i);
String qq="'"+choice.getSelectedItem()+"'";
rs=sql.executeQuery("select 课程号 from kecheng where 课程名="+qq);
while(rs.next())
{ q1=rs.getString("课程号");
}
String s1="'"+q1+"'";
a[i][0]=choice.getSelectedItem();
rs=sql.executeQuery("select 成绩 from chengji where 用户名="+xuehao+" and 课程号="+s1);
while(rs.next())
{String tt=rs.getString("成绩");
a[i][1]=tt;
}
}
con.close();
}
}
}
class pingjiao extends Frame implements ActionListener,ItemListener
{Label label1,label2,label3,label4;
TextField text1,text2;
Choice choice;
TextArea textarea;
Button button1;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
pingjiao()
{super("评教页面");
setBackground(color);
setSize(400,400);
setBounds(200,200,600,300);
setVisible(false);
label1=new Label("课程名");
label2=new Label("教师名");
label3=new Label("分数");
label4=new Label("意见与建议");
choice=new Choice();
text1=new TextField(6);
text2=new TextField(6);
textarea=new TextArea(10,20);
button1=new Button("评教");
button1.addActionListener(this);
choice.addItemListener(this);
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
Panel p7=new Panel();
Panel p8=new Panel();
p1.add(label1,"West");
p1.add(choice,"Center");
p2.add(label2,"West");
p2.add(text1,"Center");
p3.add(label3,"West");
p3.add(text2,"Center");
p4.add(label4,"West");
p4.add(textarea,"Center");
p5.add(button1,"West");
p6.add(p1,"North");
p6.add(p2,"Center");
p6.add(p3,"South");
p7.add(p4,"North");
p7.add(p5,"Center");
p8.add(p6,"North");
p8.add(p7,"Center");
add(p8);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose();}
}
);
validate();
try
{
tianjiakecheng();
}
catch(SQLException e8) {}
}
public void tianjiakecheng() throws SQLException
{try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
rs=sql.executeQuery("select 课程名 from xuanke where 用户名="+xuehao);
while(rs.next())
{String qq=rs.getString("课程名");
choice.add(qq);
}
con.close();
}
public void itemStateChanged(ItemEvent e)
{
try
{qqq();
}
catch(SQLException e7) {}
}
public void qqq() throws SQLException
{ String name="'"+choice.getSelectedItem()+"'";
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
rs=sql.executeQuery("select 教师 from kecheng where 课程名="+name);
while(rs.next())
{String q1=rs.getString("教师");
text1.setText(q1);
con.close();
}
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==button1)
{try
{tianjiapingjiao();
}
catch(SQLException e2) {}
}
}
public void tianjiapingjiao() throws SQLException
{ String s1="'"+choice.getSelectedItem()+"'";
String s2="'"+text1.getText().trim()+"'";
String s3="'"+text2.getText().trim()+"'";
String s4="'"+textarea.getText().trim()+"'";
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
rs=sql.executeQuery("select * from pingjiao where 用户名="+xuehao+" and 课程名="+s1);
while(rs.next())
{JOptionPane.showMessageDialog(this,"你已经给这门课评过了,无法修改!","提示",JOptionPane.WARNING_MESSAGE);
return;
}
sql.executeUpdate("insert into pingjiao values("+xuehao+","+s2+","+s1+","+s3+","+s4+")");
JOptionPane.showMessageDialog(this,"评教成功","提示",JOptionPane.WARNING_MESSAGE);
}
}
class tongyuetongri extends Frame implements ActionListener
{Label label1,label2;
Button button;
Choice choice1,choice2;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
tongyuetongri()
{super("同月同日生查询页面");
setBackground(color);
setSize(200,200);
setBounds(200,200,400,200);
setVisible(false);
label1=new Label("月");
label2=new Label("日");
button=new Button("查询");
button.addActionListener(this);
choice1=new Choice();
choice2=new Choice();
for(int i=1;i<13;i++)
{choice1.add(String.valueOf(i));}
for(int j=1;j<32;j++)
{choice2.add(String.valueOf(j));}
Panel p1=new Panel();
Panel p2=new Panel();
p1.add(label1,"West");
p1.add(choice1,"Center");
p1.add(label2,"East");
p1.add(choice2,"South");
p2.add(p1,"North");
p2.add(button,"Center");
validate();
add(p2);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==button)
{setVisible(false);
tongyuetongrichaxun kk=new tongyuetongrichaxun();
kk.setVisible(true);
}
}
class tongyuetongrichaxun extends JFrame
{Object a[][];
Object columnName[]={"用户名","姓名","性别","出生日期","院系","班级"};
JTable table;
Container container;
String kechengming,jiaoshi,xueshi,shangkedidian;
Connection con;
Statement sql;
ResultSet rs;
int i=0;
tongyuetongrichaxun()
{super("同月同日生同学的信息");
a=new Object[10][6];
table=new JTable(a,columnName);
setSize(500,500);
setBounds(200,200,500,300);
setVisible(false);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
container=getContentPane();
container.add(new JScrollPane(table),BorderLayout.CENTER);
try
{chaxun();
}
catch(SQLException e6) {}
}
public void chaxun() throws SQLException
{
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
String q1=choice1.getSelectedItem();
String q2=choice2.getSelectedItem();
rs=sql.executeQuery("select * from gerenxinxi ");
while(rs.next())
{
String s1=rs.getString("用户名");
String s2=rs.getString("姓名");
String s3=rs.getString("性别");
String s4=rs.getString("出生日期");
String s5=rs.getString("院系");
String s6=rs.getString("班级");
String w1=s4.substring(6,7);
String w4=s4.substring(5,7);
String w2=s4.substring(9,10);
String w3=s4.substring(8,10);
if((w4.equals(q1)||w1.equals(q1))&&(w2.equals(q2)||w3.equals(q2)))
{ a[i][0]=s1;
a[i][1]=s2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -