/*
* Created by JFormDesigner on Tue Dec 21 20:56:25 CST 2021
*/
package shixi.views.administrators;
import shixi.utils.jdbcutil;
import shixi.views.administrators.QI.QIaddUI;
import shixi.views.administrators.QI.QIupdateUI;
import shixi.views.administrators.REI.REIaddUI;
import shixi.views.administrators.REI.REIupdateUI;
import shixi.views.administrators.RI.RIadd;
import shixi.views.administrators.RI.RIupdateUI;
import shixi.views.administrators.RZI.RZIaddUI;
import shixi.views.administrators.RZI.RZIupdateUI;
import shixi.views.administrators.SIUI.SIaddUI;
import shixi.views.administrators.SIUI.SIupdateUI;
import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
/**
* @author Brainrain
*/
public class AdministratorsUI extends JFrame {
jdbcutil jdbcutil;
public AdministratorsUI() {
initComponents();
setVisible(true);
jdbcutil = new jdbcutil();
jdbcutil.connect();
panel1.setOpaque(false);
panel2.setOpaque(false);
panel3.setOpaque(false);
panel4.setOpaque(false);
panel5.setOpaque(false);
panel6.setOpaque(false);
tabbedPane1.setOpaque(false);
this.getLayeredPane().setLayout(null);
textField1.setOpaque(false);
textField2.setOpaque(false);
textField3.setOpaque(false);
textField4.setOpaque(false);
textField5.setOpaque(false);
textField7.setOpaque(false);
button1.setContentAreaFilled(false);
button2.setContentAreaFilled(false);
button3.setContentAreaFilled(false);
button4.setContentAreaFilled(false);
button5.setContentAreaFilled(false);
button6.setContentAreaFilled(false);
button7.setContentAreaFilled(false);
button8.setContentAreaFilled(false);
button9.setContentAreaFilled(false);
button10.setContentAreaFilled(false);
button11.setContentAreaFilled(false);
button12.setContentAreaFilled(false);
button13.setContentAreaFilled(false);
button14.setContentAreaFilled(false);
button15.setContentAreaFilled(false);
button16.setContentAreaFilled(false);
button17.setContentAreaFilled(false);
button18.setContentAreaFilled(false);
button19.setContentAreaFilled(false);
button20.setContentAreaFilled(false);
button21.setContentAreaFilled(false);
button22.setContentAreaFilled(false);
}
private void button1MouseClicked(MouseEvent e) {
// TODO add your code here
new SIaddUI();
}
private void button2MouseClicked(MouseEvent e) {
// TODO add your code here
String name = textField1.getText();
if (name != null) {
String sql1 = "select * from student where name='" + name + "'";
ResultSet rs1 = jdbcutil.getResultSet(sql1);
try {
if (rs1.next()) {
System.out.println("查找到学生信息!");
int n = JOptionPane.showConfirmDialog(null, "已查找到学生,是否删除该学生信息?", "1", JOptionPane.YES_NO_OPTION);
if (n == 0) {
String sql2 = "delete from student where name ='" + name + "'";
int update = jdbcutil.update(sql2);
if (update > 0) {
System.out.println("该学生信息已删除!");
JOptionPane.showMessageDialog(null,"学生信息已全部删除!");
textField1.setText("");
}
}
}
else{
JOptionPane.showMessageDialog(null,"未查找到学生信息!");
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
private void button3MouseClicked(MouseEvent e) {
// TODO add your code here
new SIupdateUI();
}
private void button4MouseClicked(MouseEvent e) {
// TODO add your code here
Vector rowDate, columnNames;
String name = textField1.getText();
columnNames = new Vector();
columnNames.add("姓名");
columnNames.add("院系");
columnNames.add("专业");
columnNames.add("班级");
columnNames.add("老师");
columnNames.add("成绩");
columnNames.add("擅长技能");
rowDate = new Vector();
try {
String sql = "SELECT *FROM student where name ='" + name + "'";
ResultSet rs = jdbcutil.getResultSet(sql);
if (rs.next()) {
Vector hang = new Vector();
hang.add(rs.getString(1));
hang.add(rs.getString(2));
hang.add(rs.getString(3));
hang.add(rs.getString(4));
hang.add(rs.getString(5));
hang.add(rs.getString(6));
hang.add(rs.getString(7));
rowDate.add(hang);
}
} catch (SQLException d) {
d.printStackTrace();
}
DefaultTableModel model = new DefaultTableModel(rowDate,columnNames);
table1.setModel(model);
table1.setRowHeight(80);
}
private void button9MouseClicked(MouseEvent e) {
// TODO add your code here
new QIaddUI();
}
private void button10MouseClicked(MouseEvent e) {
// TODO add your code here
String company = textField2.getText();
if (company != null) {
String sql1 = "select * from enterprise where company='" + company + "'";
ResultSet rs1 = jdbcutil.getResultSet(sql1);
try {
if (rs1.next()) {
System.out.println("查找到企业信息!");
int n = JOptionPane.showConfirmDialog(null, "已查找到企业,是否删除该企业信息?", "1", JOptionPane.YES_NO_OPTION);
if (n == 0) {
String sql2 = "delete from enterprise where company ='" + company + "'";
int update = jdbcutil.update(sql2);
if (update > 0) {
System.out.println("该企业信息已删除!");
JOptionPane.showMessageDialog(null,"企业信息已全部删除!");
textField1.setText("");
}
}
}
else{
JOptionPane.showMessageDialog(null,"未查找到企业信息!");
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
private void button11MouseClicked(MouseEvent e) {
// TODO add your code here
new QIupdateUI();
}
private void button12MouseClicked(MouseEvent e) {
// TODO add your code here
Vector rowDate, columnNames;
String company = textField2.getText();
columnNames = new Vector();
columnNames.add("单位名称");
columnNames.add("地址");
columnNames.add("招聘要求");
columnNames.add("招聘规模");
rowDate = new Vector();
try {
String sql = "SELECT *FROM enterprise where company ='" + company + "'";
ResultSet rs = jdbcutil.getResultSet(sql);
if (rs.next()) {
Vector hang = new Vector();
hang.add(rs.getString(1));
hang.add(rs.getString(2));
hang.add(rs.getString(3));