📄 teacherlogin.java
字号:
public void actionPerformed(ActionEvent e)
{
tianbao as=new tianbao();
String[] af=new String[100];
int i=0;
ad=((JMenuItem)e.getSource()).getText();
as.setTitle("学生成绩填报");
as.setSize(300,360);
as.setVisible(true);
as.setLocation(300,150);
as.a.setText("学生"+ad+"成绩填报");
ah1=as.c;
ah2=as.e;
ah3=as.p;
ah4=as.g;
ah5=as.l;
ah4.setEditable(false);
as.c.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String[][] ag=new String[1][2];
String bianhao=chaxun9(text1.getText());
String kehao=chaxun7(ad);
ah1.setFocusable(false);
aj=ah1.getText();
ah4.setEditable(true);
ag=chaxun11(ah1.getText(),bianhao,kehao);
ah2.append(ag[0][0]);
ah3.append(ag[0][1]);
if(ag[0][0]==null || ag[0][1]==null)
{
JOptionPane.showMessageDialog(null, "您不能为该生添加成绩\n请检查学号是否输入正确或该生是否已有成绩然后点撤销按钮","警告",JOptionPane.ERROR_MESSAGE);
ah4.setEditable(false);
ah5.setEnabled(false);
}
}
});
as.l.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int i=0;
String bianhao=chaxun9(text1.getText());
String kehao=chaxun7(ad);
ah4.setEditable(false);
i=charu1(ah1.getText(),kehao,ah4.getText());
if(i!=0)
{
ah1.setFocusable(true);
ah1.setText("");
ah2.setText("");
ah3.setText("");
ah4.setText("");
}
else if(i==0)
{
JOptionPane.showMessageDialog(null, "操作失败!\n请检查是否漏填或您是否已为该同学添加成绩","操作失败",JOptionPane.ERROR_MESSAGE);
ah4.setEditable(false);
ah5.setEnabled(false);
}
}
}
);
as.m.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ah1.setFocusable(true);
ah1.setText("");
ah2.setText("");
ah3.setText("");
ah4.setText("");
ah4.setEditable(true);
ah5.setEnabled(true);
}
});
}
};
while(w[j]!=null)
{
JLabel b=new JLabel();
JLabel b1=new JLabel(".");
b1.setFont(l);
if(j!=0)a.h5.add(b1);
b.setText(w[j]);
b.setFont(l);
a.h5.add(b);
j++;
}
while(x[y]!=null)
{
JMenuItem c2=new JMenuItem();
JMenuItem c3=new JMenuItem();
JMenuItem c4=new JMenuItem();
JMenuItem c5=new JMenuItem();
JLabel c=new JLabel();
JLabel c1=new JLabel(".");
a.menu1.add(c2);
a.menu2.add(c3);
a.menu3.add(c4);
a.menu4.add(c5);
c2.setText(x[y]);
c2.setFont(l);
c2.setText(x[y]);
c3.setText(x[y]);
c3.setFont(l);
c4.setText(x[y]);
c4.setFont(l);
c5.setText(x[y]);
c5.setFont(l);
c2.addActionListener(a1);
c5.addActionListener(a2);
c3.addActionListener(a3);
c4.addActionListener(a4);
if(y!=0)a.h6.add(c1);
c1.setFont(l);
c.setText(x[y]);
c.setFont(l);
a.h6.add(c);
y++;
}
}
else {
JOptionPane.showMessageDialog(null, "用户名,编号或密码错误","登录失败",JOptionPane.ERROR_MESSAGE);
text1.setText("");
text2.setText("");
text4.setText("");
}
}
});
JPanel password=new JPanel();
JLabel label2=new JLabel("用户密码:");
password.setLayout(new FlowLayout());
password.add(label2);
password.add(text2);
add(password);
JPanel b=new JPanel(new FlowLayout());
b.add(button1);
add(b);
}
public String[] chaxun(String x)
{
ResultSet rs=null,b=null;
String[] a=new String[5];
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("SELECT * FROM jiaoshi WHERE jiaoshiming=?");
checkUser.setString(1,x);
rs = checkUser.executeQuery();
if(rs.next())
{a[0]=rs.getString(1);
a[1]=rs.getString(2);
a[2]=rs.getString(3);
a[3]=rs.getString(5);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
rs=null;
}
}
return a;
}
public String[] chaxun1(String x)
{
ResultSet rs=null,b=null;
String[] a=new String[100];
int n=0;
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("select distinct banji from jiaoban,jiaoshi where jiaoshi.bianhao=? and jiaoshi.bianhao=jiaoban.bianhao");
checkUser.setString(1,x);
rs = checkUser.executeQuery();
while(rs.next())
{
a[n]=rs.getString(1);
n++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
rs=null;
}
}
return a;
}
public String[] chaxun2(String x)
{
ResultSet rs=null,b=null;
String[] a=new String[100];
int n=0;
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("select distinct kecheng from jiaoshi,jiaoban,ke where jiaoshi.bianhao=? and jiaoshi.bianhao=jiaoban.bianhao and jiaoban.kechenghao=ke.kechenghao");
checkUser.setString(1,x);
rs = checkUser.executeQuery();
while(rs.next())
{
a[n]=rs.getString(1);
n++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
rs=null;
}
}
return a;
}
public String[] chaxun3(String x,String y)
{
ResultSet rs=null,b=null;
String[] a=new String[100];
int n=0;
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("select distinct banji from jiaoban,jiaoshi,ke where jiaoshi.bianhao=? and kecheng=? and jiaoban.bianhao=jiaoshi.bianhao and ke.kechenghao=jiaoban.kechenghao");
checkUser.setString(1,x);
checkUser.setString(2,y);
rs = checkUser.executeQuery();
while(rs.next())
{
a[n]=rs.getString(1);
n++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
rs=null;
}
}
return a;
}
public String[][] chaxun4(String x,String y)
{
ResultSet rs=null,b=null;
String[][] a=new String[100][2];
int n=0;
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("select xingming,chengji from fen where kechenghao=? and xuehao=?");
checkUser.setString(1,x);
checkUser.setString(2,y);
rs = checkUser.executeQuery();
while(rs.next())
{
a[n][0]=rs.getString(1);
a[n][1]=rs.getString(2);
n++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
rs=null;
}
}
return a;
}
/*public String chaxun5(String x)
{
ResultSet rs=null,b=null;
String a=new String();
int n=0;
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("select xuehao from jiben where xingming=?");
checkUser.setString(1,x);
rs = checkUser.executeQuery();
if(rs.next()) a=rs.getString(1);
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
rs=null;
}
}
return a;
}*/
public String[][] chaxun6(String x)
{
ResultSet rs=null,b=null;
String[][] a=new String[100][2];
int n=0;
try
{DBConnection dbConn = new DBConnection();
Connection conn = DBConnection.getConncetion();
PreparedStatement checkUser = conn.prepareStatement("select xuehao,xingming from jiben where banji=?");
checkUser.setString(1,x);
rs = checkUser.executeQuery();
while(rs.next())
{
a[n][0]=rs.getString(1);
a[n][1]=rs.getString(2);
n++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{if(rs!=null)
{try
{ rs.close();
}
catch(SQLException e){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -