📄 presentquerydialog.java
字号:
package com.hb.stumanagesys.stutinfomag;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.SpinnerListModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import com.hb.jdbcconnct.JdbcConnct;
import com.hb.stumanagesys.stutinfomag.*;
/**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
* Builder, which is free for non-commercial use. If Jigloo is being used
* commercially (ie, by a corporation, company or business for any purpose
* whatever) then you should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
* ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PresentQueryDialog extends javax.swing.JDialog {
private JPanel presentPanel;
private JSeparator presentSeparator;
private JScrollPane prsentScrollPane;
private JTable presentTable;
private JButton exitButton;
private JComboBox preSelectConditionComboBox;
private JButton querButton;
private JComboBox selectConditionComboBox;
private JPanel studentQueryPanel1;
private JPanel ClassQueryPanel1;
private JButton addButton;
private JButton clearButton;
private JButton queryButtonc;
private JList ClassQueryList;
private JRadioButton orRadioButton;
private JRadioButton addRadioButton;
private JRadioButton nullRadioButton;
private JTextField commentTextField;
private JComboBox conditionComboBox;
private JComboBox ClassQueryComboBox;
private JPanel jPanel1;
private JTable ClassQueryTable;
private JButton addButton1;
private JButton ClearButton;
private JList studentQueryList1;
private JRadioButton orRadioButton1;
private JRadioButton andRadioButton1;
private JRadioButton nullRadioButton1;
private JTextField userInputTextField1;
private JComboBox compareComboBox;
private JComboBox queryConditionComboBox;
private JPanel queryResultPanel1;
private JSeparator jSeparator1;
private JPanel DataViewPanel1;
private JTabbedPane presentTabbedPane;
// 定义出勤查询默认表格模型
protected DefaultTableModel PresentQueryTableModel;
// 定义table表格使用变量,标题column[],数据row[]
private String[][] row;
private String[] column = { "出勤号", "学号", "日期", "出勤状态" };
// 定义ComboBox使用变量 学生查询字段
private String[] combListStu = { "学号", "姓名", "年龄", "班主任名" };
// 定义ComboBox使用变量 班级查询字段
private String[] combListClass = { "班级号", "班级名", "届别" };
// 判断条件
private String[] comCompareList = { ">", "<", "=" };
// 定义table表格使用变量,标题column[],数据row[]
// 班级出勤表字段
private String[] columnClass = { "班级号", "班级名", "届别", "出勤", "迟到", "早退",
"事假", "病假", "出勤率" };
// 学生出勤表字段
private String[] columnStudent = { "学号", "姓名", "出勤", "迟到", "早退", "事假",
"病假", "出勤率" };
// 出勤查询条件
private String[] columnPresentCondition = { "周", "月", "季度", "学期" };
// 定义学号正则表达式7位数字,第一位不能为空
public final static String REG_DIGIT = "[1-9]\\d{0,6}";
// 定义年龄正则表达式2位数字,第一位不能为空
public final static String REG_DIGITAGE = "[1-9]\\d{0,1}";
// 定义班级号正则表达式7位数字,第一位不能为空
public final static String REG_DIGITCLASS = "[1-9]\\d{0,6}";
// 定义届别正则表达式4位数字,第一位不能为空
public final static String REG_DIGITFLAGYEAR = "[1-9]\\d{0,3}";
// 定义nowYear变量,获取当前年
Date nowDate = new Date();
int nowYear = nowDate.getYear() + 1900;
// 定义List显示变量 vecListView
public Vector vecListView = new Vector(20);
private JLabel presentQueryViewLabel;
// 定义List显示变量 vecListViewClass
public Vector vecListViewClass = new Vector(20);
private JSpinner yearSelectjSpinner1;
private JScrollPane jScrollPane1;
private JScrollPane StudentQueryScrollPane1;
private JScrollPane ClassQueryScrollPane1;
private JButton studentQueryButton1;
private ButtonGroup classbuttonGroup;
private ButtonGroup studentQuerybuttonGroup1;
// 定义SQL多条件查询变量
public Vector vecSQL = new Vector(20);
// 定义SQL班级多条件查询变量
public Vector vecSQLClass = new Vector(20);
// 定义学生查询条件数量初始化为1
int ncount = 1;
// 定义班级查询条件数量初始化为1
int ncountClass = 1;
//定义查询显示queryView,用于向用户显示查询信息
String strpreQueryView = "";
// private String[] column1 = { "", "", "", "" };
/**
* Auto-generated main method to display this JDialog
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
PresentQueryDialog inst = new PresentQueryDialog(frame);
inst.setVisible(true);
inst.setLocationRelativeTo(null);
}
public PresentQueryDialog(JFrame frame) {
super(frame);
initGUI();
//查询按钮置为不可见
this.querButton.setVisible(false);
}
private void initGUI() {
try {
{
getContentPane().setBackground(
new java.awt.Color(119, 143, 242));
this.setTitle("\u51fa\u52e4\u67e5\u8be2");
{
{
studentQuerybuttonGroup1 = new ButtonGroup();
}
{
classbuttonGroup = new ButtonGroup();
}
presentPanel = new JPanel();
getContentPane().add(presentPanel, BorderLayout.CENTER);
presentPanel.setLayout(null);
presentPanel
.setBackground(new java.awt.Color(185, 185, 255));
presentPanel.setPreferredSize(new java.awt.Dimension(77,
448));
{
ComboBoxModel weekComboBoxModel = new DefaultComboBoxModel(
);
selectConditionComboBox = new JComboBox();
presentPanel.add(selectConditionComboBox);
selectConditionComboBox.setModel(weekComboBoxModel);
selectConditionComboBox.setBounds(784, 91, 91, 28);
}
{
querButton = new JButton();
presentPanel.add(querButton);
querButton.setText("\u67e5\u8be2");
querButton.setBounds(798, 217, 70, 28);
querButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
querButtonActionPerformed(evt);
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
{
presentSeparator = new JSeparator();
presentPanel.add(presentSeparator);
presentSeparator.setBounds(588, 308, 301, 133);
}
{
exitButton = new JButton();
presentPanel.add(exitButton);
exitButton.setText("\u9000\u51fa");
exitButton.setBounds(798, 336, 70, 28);
exitButton.setSize(70, 21);
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
exitButtonActionPerformed(evt);
}
});
}
{
ComboBoxModel monthComboBoxModel = new DefaultComboBoxModel(
columnPresentCondition);
preSelectConditionComboBox = new JComboBox();
presentPanel.add(preSelectConditionComboBox);
preSelectConditionComboBox.setModel(monthComboBoxModel);
preSelectConditionComboBox.setBounds(700, 91, 77, 28);
preSelectConditionComboBox.setSize(70, 28);
preSelectConditionComboBox
.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
preSelectConditionComboBoxActionPerformed(evt);
}
});
}
{
presentTabbedPane = new JTabbedPane();
presentPanel.add(presentTabbedPane);
presentTabbedPane.setBounds(21, 21, 546, 385);
{
studentQueryPanel1 = new JPanel();
presentTabbedPane.addTab("学生查询", null,
studentQueryPanel1, null);
studentQueryPanel1.setLayout(null);
{
ComboBoxModel queryConditionComboBoxModel = new DefaultComboBoxModel(
combListStu);
queryConditionComboBox = new JComboBox();
studentQueryPanel1.add(queryConditionComboBox);
queryConditionComboBox
.setModel(queryConditionComboBoxModel);
queryConditionComboBox
.setBounds(21, 35, 70, 21);
queryConditionComboBox.setSize(91, 28);
queryConditionComboBox
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
queryConditionComboBoxActionPerformed(evt);
}
});
}
{
ComboBoxModel compareComboBoxModel = new DefaultComboBoxModel(
new String[] { ">", "=", "<" });
compareComboBox = new JComboBox();
studentQueryPanel1.add(compareComboBox);
compareComboBox.setModel(compareComboBoxModel);
compareComboBox.setBounds(133, 35, 91, 28);
}
{
userInputTextField1 = new JTextField();
studentQueryPanel1.add(userInputTextField1);
userInputTextField1
.setText("\u8bf7\u8f93\u5165\u67e5\u8be2\u4fe1\u606f");
userInputTextField1.setBounds(252, 35, 112, 28);
}
{
nullRadioButton1 = new JRadioButton();
studentQueryPanel1.add(nullRadioButton1);
nullRadioButton1.setText("\u65e0");
nullRadioButton1.setBounds(28, 77, 70, 21);
studentQuerybuttonGroup1.add(nullRadioButton1);
nullRadioButton1.setSelected(true);
}
{
andRadioButton1 = new JRadioButton();
studentQueryPanel1.add(andRadioButton1);
andRadioButton1.setText("\u5e76\u4e14");
andRadioButton1.setBounds(98, 77, 70, 21);
studentQuerybuttonGroup1.add(andRadioButton1);
}
{
orRadioButton1 = new JRadioButton();
studentQueryPanel1.add(orRadioButton1);
orRadioButton1.setText("\u6216\u8005");
orRadioButton1.setBounds(168, 77, 70, 21);
studentQuerybuttonGroup1.add(orRadioButton1);
}
{
ClearButton = new JButton();
studentQueryPanel1.add(ClearButton);
ClearButton.setText("\u6e05\u7a7a");
ClearButton.setBounds(105, 301, 70, 21);
ClearButton
.addActionListener(new ActionListener() {
public void actionPerformed(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -