📄 scomainframe.java
字号:
Label = new JLabel();
selectPanel.add(Label);
Label.setText(" \u81f3");
Label.setBounds(182, 105, 28, 28);
}
{
selectButton = new JButton();
selectPanel.add(selectButton);
selectButton.setText("\u67e5\u8be2");
selectButton.setBounds(406, 112, 77, 28);
selectButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
selectButtonActionPerformed(evt);
}
});
}
{
teLabel = new JLabel();
selectPanel.add(teLabel);
teLabel.setText("\u8003\u8bd5\u7f16\u53f7\uff1a");
teLabel.setBounds(21, 14, 70, 28);
}
{
stLabel = new JLabel();
selectPanel.add(stLabel);
stLabel.setText("\u5b66\u53f7\uff1a");
stLabel.setBounds(210, 14, 70, 28);
}
{
sunameLabel = new JLabel();
selectPanel.add(sunameLabel);
sunameLabel.setText("\u79d1\u76ee\u540d\u79f0\uff1a");
sunameLabel.setBounds(21, 56, 70, 28);
}
{
teTextField = new JTextField();
selectPanel.add(teTextField);
teTextField.setBounds(91, 14, 91, 28);
}
{
stTextField = new JTextField();
selectPanel.add(stTextField);
stTextField.setBounds(281, 14, 98, 28);
}
{
sunameTextField = new JTextField();
selectPanel.add(sunameTextField);
sunameTextField.setBounds(91, 56, 91, 28);
}
{
nameLabel = new JLabel();
selectPanel.add(nameLabel);
nameLabel.setText("\u59d3\u540d\uff1a");
nameLabel.setBounds(406, 14, 63, 28);
}
{
nameTextField = new JTextField();
selectPanel.add(nameTextField);
nameTextField.setBounds(467, 14, 105, 28);
}
{
subscoLabel = new JLabel();
selectPanel.add(subscoLabel);
subscoLabel.setText("\u79d1\u76ee\u5b66\u5206\uff1a");
subscoLabel.setBounds(210, 56, 70, 28);
}
{
subscoTextField = new JTextField();
selectPanel.add(subscoTextField);
subscoTextField.setBounds(280, 56, 98, 28);
}
}
}
}
pack();
this.setSize(630, 450);
} catch (Exception e) {
e.printStackTrace();
}
}
//返回
private void ReturnButtonActionPerformed(ActionEvent evt) {
StudentManagerFrame sco=new StudentManagerFrame();
this.setVisible(false);
sco.setVisible(true);
}
//添加
private void AddButtonActionPerformed(ActionEvent evt) {
ScoAddFrame scoA=new ScoAddFrame(ScoTable,page);
scoA.setVisible(true);
}
//修改
private void UpdateButtonActionPerformed(ActionEvent evt) {
if(row==0||ScoTable.getValueAt(row, 0).equals("")){
JOptionPane.showMessageDialog(this,"请先选择要修改的记录");
}
else{
ScoUpdateFrame scoU=new ScoUpdateFrame(ScoTable,row,page);
scoU.setVisible(true);
}
}
//删除
private void DeleteButtonActionPerformed(ActionEvent evt) {
if(row==0||ScoTable.getValueAt(row, 0).equals("")){
JOptionPane.showMessageDialog(this,"请先选择要删除的记录");
}
else{
int control=JOptionPane.showConfirmDialog(this, "真的要删除吗?","警告!",JOptionPane.OK_OPTION);
if(JOptionPane.OK_OPTION==control){
String tesid=(String)ScoTable.getValueAt(row,0);
String stuid=(String)ScoTable.getValueAt(row,1);
sa.delete(tesid,stuid);
sa.init(ScoTable,1,5);
}
}
}
private void ScoTableMouseClicked(MouseEvent evt) {
row=ScoTable.getSelectedRow();
}
private void ScoTableMouseEntered(MouseEvent evt) {
}
private void ScoTableMouseExited(MouseEvent evt) {
}
private void ScoTableMousePressed(MouseEvent evt) {
}
private void ScoTableMouseReleased(MouseEvent evt) {
}
//首页
private void firstButtonActionPerformed(ActionEvent evt) {
if(this.page==1) JOptionPane.showMessageDialog(this,"本页为首页!");
else {
this.page=1;
if(this.selectflag==false)
sa.init(ScoTable,page,5);
else{
int sco1=Integer.parseInt(sco1ComboBox.getSelectedItem().toString());
int sco2=Integer.parseInt(sco2ComboBox.getSelectedItem().toString());
String tesid=teTextField.getText();
String stuid=stTextField.getText();
String stuname=nameTextField.getText();
String subname=sunameTextField.getText();
String subsco=subscoTextField.getText();
sa.scoSelect(ScoTable,page, tesid, stuid, stuname, subname, subsco, sco1, sco2);
}
}
}
//上一页
private void lastButtonActionPerformed(ActionEvent evt) {
if(this.page==1)
JOptionPane.showMessageDialog(this,"本页为首页,没有上一页!");
else {
if(this.selectflag==false)
sa.init(ScoTable,--this.page,5);
else{
int sco1=Integer.parseInt(sco1ComboBox.getSelectedItem().toString());
int sco2=Integer.parseInt(sco2ComboBox.getSelectedItem().toString());
String tesid=teTextField.getText();
String stuid=stTextField.getText();
String stuname=nameTextField.getText();
String subname=sunameTextField.getText();
String subsco=subscoTextField.getText();
sa.scoSelect(ScoTable,--this.page, tesid, stuid, stuname, subname, subsco, sco1, sco2);
}
}
}
//下一页
private void nextButtonActionPerformed(ActionEvent evt) {
int sco1=Integer.parseInt(sco1ComboBox.getSelectedItem().toString());
int sco2=Integer.parseInt(sco2ComboBox.getSelectedItem().toString());
String tesid=teTextField.getText();
String stuid=stTextField.getText();
String stuname=nameTextField.getText();
String subname=sunameTextField.getText();
String subsco=subscoTextField.getText();
int p;
if(this.selectflag==false)
p=sa.pageCount();
else
p=sa.pageCountSelect(tesid, stuid, stuname, subname, subsco, sco1, sco2);
if(this.page==p)
JOptionPane.showMessageDialog(this,"本页为尾页,没有下一页!");
else {
if(this.selectflag==false)
sa.init(ScoTable,++this.page,5);
else{
sa.scoSelect(ScoTable, ++this.page,tesid,stuid,stuname,subname,subsco, sco1, sco2);
}
}
}
//尾页
private void finalButtonActionPerformed(ActionEvent evt) {
int sco1=Integer.parseInt(sco1ComboBox.getSelectedItem().toString());
int sco2=Integer.parseInt(sco2ComboBox.getSelectedItem().toString());
String tesid=teTextField.getText();
String stuid=stTextField.getText();
String stuname=nameTextField.getText();
String subname=sunameTextField.getText();
String subsco=subscoTextField.getText();
int p;
if(this.selectflag==false)
p=sa.pageCount();
else
p=sa.pageCountSelect(tesid, stuid, stuname, subname, subsco, sco1, sco2);
if(this.page==p)
JOptionPane.showMessageDialog(this,"本页为尾页!");
else {
this.page=p;
if(this.selectflag==false){
this.page=sa.pageCount();
sa.init(ScoTable,page,5);
}
else{
this.page=sa.pageCountSelect(tesid, stuid, stuname, subname, subsco, sco1, sco2);
sa.scoSelect(ScoTable, this.page, tesid, stuid, stuname, subname, subsco, sco1, sco2);
}
}
}
//条件查询
private void selectButtonActionPerformed(ActionEvent evt) {
int sco1=Integer.parseInt(sco1ComboBox.getSelectedItem().toString());
int sco2=Integer.parseInt(sco2ComboBox.getSelectedItem().toString());
String tesid=teTextField.getText();
String stuid=stTextField.getText();
String stuname=nameTextField.getText();
String subname=sunameTextField.getText();
String subsco=subscoTextField.getText();
if(tesid.indexOf("'")!=-1||tesid.indexOf("_")!=-1||tesid.indexOf("?")!=-1||tesid.indexOf("%")!=-1||
stuid.indexOf("'")!=-1||stuid.indexOf("_")!=-1||stuid.indexOf("?")!=-1||stuid.indexOf("%")!=-1||
stuname.indexOf("'")!=-1||stuname.indexOf("_")!=-1||stuname.indexOf("?")!=-1||stuname.indexOf("%")!=-1||
subname.indexOf("'")!=-1||subname.indexOf("_")!=-1||subname.indexOf("?")!=-1||subname.indexOf("%")!=-1||
subsco.indexOf("'")!=-1||subsco.indexOf("_")!=-1||subsco.indexOf("?")!=-1||subsco.indexOf("%")!=-1)
JOptionPane.showMessageDialog(this, "找不到要查询的结果!");
else{
sa.scoSelect(ScoTable,1,tesid,stuid,stuname,subname,subsco,sco1,sco2);
this.selectflag=true;
this.page=1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -