📄 teacherlogin.java
字号:
package chuangti;
import javax.swing.*;
import chuangti.studentlogin.change;
import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import login.DBConnection;
import login.UsersDAO;
public class teacherlogin extends JFrame{
JTextField text1=new JTextField(6);
JTextField text2=new JTextField(6);
JTextField text4=new JTextField(6);
JTextField ah1=new JTextField(12);
JTextField ah4=new JTextField(12);
JTextField ah6=new JTextField(12);
JTextField ah7=new JTextField(12);
JTextArea ah2=new JTextArea(1,12);
JTextArea ah3=new JTextArea(1,12);
JTextArea ty=new JTextArea(23,30);
JTextArea bc=new JTextArea(30,30);
String password=new String();
String usersName=new String();
String jiaohao=new String();
//String p=new String();
//String th=new String();
String xuehao=new String();
//String q=new String();
String jk=new String();
String[][] fd=new String[100][2];
// String de=new String();
//String g=new String();
// String mn=new String();
String bianhao=new String();
String aj=new String();
String ad=new String();
String h2=new String();
// String[][] jieguo=new String[100][2];
//JComboBox fh=new JComboBox();
JComboBox jh=new JComboBox();
JButton ah8=new JButton();
JButton ah9=new JButton();
JButton ah5=new JButton();
// JMenuItem[] w2=new JMenuItem[10];
JTextField jp=new JTextField(10);
teachercha s=new teachercha();
int y=0;
public teacherlogin()
{
JPanel username=new JPanel();
JPanel bianhao=new JPanel();
JLabel label1=new JLabel("教师姓名:");
JLabel label3=new JLabel("教师编号:");
JButton button1=new JButton("登录");
setLayout(new GridLayout(4,1));
username.setLayout(new FlowLayout());
username.add(label1);
username.add(text1);
add(username);
bianhao.add(label3);
bianhao.add(text4);
add(bianhao);
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Font l=new Font("SansSerif",Font.BOLD,20);
teacherlogin here=new teacherlogin();
String usersName=text1.getText();
String[] m=new String[4];
String[] w=new String[100];
String[] x=new String[100];
UsersDAO userDao = new UsersDAO();
int j=0;
y=0;
password=text2.getText();
if(userDao.checkUser1(usersName, password,text4.getText())) {
teacherin a=new teacherin();
a.setSize(900,600);
a.setVisible(true);
a.setTitle("登录成功");
a.setExtendedState(MAXIMIZED_BOTH);
m=here.chaxun(usersName);
w=here.chaxun1(text4.getText());
x=here.chaxun2(text4.getText());
(a.c2).setText(m[0]);
a.d2 .setText(m[1]);
a.e2 .setText(m[2]);
a.f2 .setText(m[3]);
ActionListener B=new ActionListener()
{
public void actionPerformed(ActionEvent h)
{
change a=new change();
a.setSize(300,200);
a.setVisible(true);
a.setLocation(300, 250);
a.setTitle("修改密码");
}
};
a.mima.addActionListener(B);
ActionListener a1=new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
teachercha w1=new teachercha();
xianshi1 s1=new xianshi1();
int i=0;
int w=0;
int r=0;
String[] wenben=new String[10];
w1.setVisible(true);
w1.setSize(900,600);
w1.setTitle("选课成绩查询");
w1.a.setText("学生成绩查询("+((JMenuItem)e.getSource()).getText()+")");
jh=w1.b;
jk=((JMenuItem)e.getSource()).getText();
wenben=chaxun3(text4.getText(),jk);
while(wenben[i]!=null)
{jh.addItem(wenben[i]);
i++;
}
jh.addItem("其他");
bc=w1.c;
fd=chaxun6(wenben[0]);
int i1=0;
int j=0;
h2=((JMenuItem)e.getSource()).getText();
String fenshu=new String();
if(fd[i1][j]==null)
{
JOptionPane.showMessageDialog(null, "未找到相关记录,请检查是否记录!","未找到",JOptionPane.INFORMATION_MESSAGE);
}
while(fd[i1][j]!=null)
{
while(j<=1 && fd[i1][j]!=null)
{
bc.append(fd[i1][j]);
bc.append(" ");
if(j==0) fenshu=chaxun13(fd[i1][0],chaxun7(h2));
j++;
}
i1++;
if(fenshu!=null)bc.append(fenshu);
else bc.append("0");
bc.append("\n");
j=0;
}
w1.b.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent h)
{
String r=new String();
String fenshu1=new String();
int i=0;
int j=0;
bc.setText("");
r=(String)((JComboBox)h.getSource()).getSelectedItem();
jp.setText(r);
fd=chaxun6(r);
while(fd[i][j]!=null)
{
while(j<=1 && fd[i][j]!=null)
{
bc.append(fd[i][j]);
bc.append(" ");
if(j==0) fenshu1=chaxun13(fd[i][0],chaxun7(h2));
j++;
}
i++;
bc.append(fenshu1);
bc.append("\n");
j=0;
}
}
});
}
};
ActionListener a2=new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
teachercha w1=new teachercha();
xianshi1 s1=new xianshi1();
int i=0;
int w=0;
int r=0;
int i1=0;
int j=0;
String[] wenben=new String[10];
w1.setVisible(true);
w1.setSize(900,600);
w1.setTitle("选课情况查询");
w1.a.setText("学生选课情况查询("+((JMenuItem)e.getSource()).getText()+")");
jh=w1.b;
jk=((JMenuItem)e.getSource()).getText();
wenben=chaxun3(text4.getText(),jk);
while(wenben[i]!=null)
{jh.addItem(wenben[i]);
i++;
}
jh.addItem("其他");
bc=w1.c;
fd=chaxun6(wenben[0]);
while(fd[i1][j]!=null)
{
while(j<=1 && fd[i1][j]!=null)
{
bc.append(fd[i1][j]);
bc.append(" ");
j++;
}
i1++;
bc.append("\n");
j=0;
}
w1.b.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent h)
{
String r=new String();
int i=0;
int j=0;
bc.setText("");
r=(String)((JComboBox)h.getSource()).getSelectedItem();
jp.setText(r);
fd=chaxun6(r);
while(fd[i][j]!=null)
{
while(j<=1 && fd[i][j]!=null)
{
bc.append(fd[i][j]);
bc.append(" ");
j++;
}
i++;
bc.append("\n");
j=0;
}
}
});
}
};
ActionListener a4=new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
xiugai as=new xiugai();
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.b2;
ah4=as.c2;
ah6=as.d2;
ah7=as.e2;
ah8=as.f;
ah9=as.g;
as.f.setEnabled(false);
as.g.setEnabled(false);
as.b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String[][] ag=new String[1][3];
ah1.setEditable(false);
ah8.setEnabled(true);
ah9.setEnabled(true);
ag=chaxun12(ah1.getText(),ad);
ah4.setText(ag[0][0]);
ah7.setText(ag[0][1]);
ah6.setText(ag[0][2]);
if(ag[0][0]==null || ag[0][1]==null || ag[0][2]==null)
{
JOptionPane.showMessageDialog(null, "您不能操作此学号学生信息!\n请检查此学生是否有本门成绩记录!或您是否有权操作该生信息","提示",JOptionPane.ERROR_MESSAGE);
}
}
});
as.f.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int i=0;
String bianhao=chaxun9(text1.getText());
i=shanchu1(ah1.getText(),ad);
if(i!=0)
{
JOptionPane.showMessageDialog(null, "删除成功!","操作成功",JOptionPane.INFORMATION_MESSAGE);
ah1.setText("");
ah4.setText("");
ah6.setText("");
ah7.setText("");
ah1.setEditable(true);
ah7.setEditable(false);
ah8.setEnabled(false);
ah9.setEnabled(false);
}
else
{
JOptionPane.showMessageDialog(null, "删除失败!","操作失败",JOptionPane.INFORMATION_MESSAGE);
ah1.setEditable(true);
ah6.setEditable(false);
ah8.setEnabled(false);
ah9.setEnabled(false);
}
}
});
as.g .addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ah6.setEditable(true);
}
});
as.d2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int i=0;
String bianhao=chaxun9(text1.getText());
i=xiugai1(ah6.getText(),ah1.getText(),ad);
if(i!=0)
{
JOptionPane.showMessageDialog(null, "修改成功!","成功",JOptionPane.INFORMATION_MESSAGE);
ah1.setEditable(true);
ah6.setEditable(false);
ah8.setEnabled(false);
ah9.setEnabled(false);
ah1.setText("");
ah4.setText("");
ah6.setText("");
ah7.setText("");
}
else
{
JOptionPane.showMessageDialog(null, "修改失败!","失败",JOptionPane.ERROR_MESSAGE);
ah1.setEditable(true);
ah6.setEditable(false);
ah8.setEnabled(false);
ah9.setEnabled(false);
ah1.setText("");
ah4.setText("");
ah6.setText("");
ah7.setText("");
}
}
});
}
};
ActionListener a3=new ActionListener()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -