⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 presentquerydialog.java

📁 学生管理系统。使用java编程
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
													ActionEvent evt) {
												ClearButtonActionPerformed(evt);
											}
										});
							}
							{
								addButton1 = new JButton();
								studentQueryPanel1.add(addButton1);
								addButton1.setText("\u589e\u52a0");
								addButton1.setBounds(189, 301, 70, 21);
								addButton1
										.addActionListener(new ActionListener() {
											public void actionPerformed(
													ActionEvent evt) {
												addButton1ActionPerformed(evt);
											}
										});
							}
							{
								studentQueryButton1 = new JButton();
								studentQueryPanel1.add(studentQueryButton1);
								studentQueryButton1.setText("\u67e5\u8be2");
								studentQueryButton1.setBounds(14, 301, 70, 21);
								studentQueryButton1
										.addActionListener(new ActionListener() {
											public void actionPerformed(
													ActionEvent evt) {
												studentQueryButton1ActionPerformed(evt);
											}
										});
							}
							{
								StudentQueryScrollPane1 = new JScrollPane();
								studentQueryPanel1.add(StudentQueryScrollPane1);
								StudentQueryScrollPane1.setBounds(28, 119, 210,
										154);
								{
									ListModel studentQueryList1Model = new DefaultComboBoxModel();
									studentQueryList1 = new JList();
									StudentQueryScrollPane1
											.setViewportView(studentQueryList1);
									studentQueryList1
											.setModel(studentQueryList1Model);
									studentQueryList1.setBounds(301, 126, 203,
											161);
								}
							}
						}
						{
							ClassQueryPanel1 = new JPanel();
							presentTabbedPane.addTab("班级查询", null, ClassQueryPanel1, null);
							ClassQueryPanel1.setLayout(null);
							{
								jPanel1 = new JPanel();
								ClassQueryPanel1.add(jPanel1);
								// jPanel1.setLayout(jPanel1Layout);
							}
							{
								ComboBoxModel ClassQueryComboBoxModel = new DefaultComboBoxModel(
									new String[] { "班级号", "班级名", "届别" });
								ClassQueryComboBox = new JComboBox();
								ClassQueryPanel1.add(ClassQueryComboBox);
								ClassQueryComboBox
									.setModel(ClassQueryComboBoxModel);
								ClassQueryComboBox.setBounds(28, 14, 84, 28);
								ClassQueryComboBox
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											ClassQueryComboBoxActionPerformed(evt);
										}
									});
							}
							{
								ComboBoxModel conditionComboBoxModel = new DefaultComboBoxModel(
									new String[] { ">", "=", "<" });
								conditionComboBox = new JComboBox();
								ClassQueryPanel1.add(conditionComboBox);
								conditionComboBox
									.setModel(conditionComboBoxModel);
								conditionComboBox.setBounds(126, 14, 84, 28);
							}
							{
								commentTextField = new JTextField();
								ClassQueryPanel1.add(commentTextField);
								commentTextField
									.setText("\u8f93\u5165\u67e5\u8be2\u6761\u4ef6");
								commentTextField.setBounds(224, 14, 112, 28);
							}
							{
								nullRadioButton = new JRadioButton();
								ClassQueryPanel1.add(nullRadioButton);
								nullRadioButton.setText("\u65e0");
								nullRadioButton.setBounds(28, 63, 63, 28);
								classbuttonGroup.add(nullRadioButton);
								nullRadioButton.setSelected(true);
							}
							{
								addRadioButton = new JRadioButton();
								ClassQueryPanel1.add(addRadioButton);
								addRadioButton.setText("\u5e76");
								addRadioButton.setBounds(98, 63, 63, 28);
								classbuttonGroup.add(addRadioButton);
							}
							{
								orRadioButton = new JRadioButton();
								ClassQueryPanel1.add(orRadioButton);
								orRadioButton.setText("\u6216");
								orRadioButton.setBounds(161, 63, 63, 28);
								classbuttonGroup.add(orRadioButton);
							}
							{
								queryButtonc = new JButton();
								ClassQueryPanel1.add(queryButtonc);
								queryButtonc.setText("\u67e5\u8be2");
								queryButtonc.setBounds(28, 308, 63, 28);
								queryButtonc.setSize(70, 21);
								queryButtonc
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											queryButtoncActionPerformed(evt);
										}
									});

							}
							{
								clearButton = new JButton();
								ClassQueryPanel1.add(clearButton);
								clearButton.setText("\u6e05\u7a7a");
								clearButton.setBounds(105, 308, 63, 28);
								clearButton.setSize(70, 21);
								clearButton
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											clearButtonActionPerformed(evt);
										}
									});
							}
							{
								addButton = new JButton();
								ClassQueryPanel1.add(addButton);
								addButton.setText("\u589e\u52a0");
								addButton.setBounds(182, 308, 63, 28);
								addButton.setSize(70, 21);
								addButton
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											addButtonActionPerformed(evt);
										}
									});
							}
							{
								jScrollPane1 = new JScrollPane();
								ClassQueryPanel1.add(jScrollPane1);
								jScrollPane1.setBounds(28, 112, 203, 161);
								{
									ListModel ClassQueryListModel = new DefaultComboBoxModel();
									ClassQueryList = new JList();
									jScrollPane1
										.setViewportView(ClassQueryList);
									ClassQueryList
										.setModel(ClassQueryListModel);
									ClassQueryList.setBounds(273, 98, 189, 168);
									ClassQueryList
										.setPreferredSize(new java.awt.Dimension(
											192,
											264));
								}
							}
						}
						{
							queryResultPanel1 = new JPanel();
							presentTabbedPane.addTab("查询结果", null,
									queryResultPanel1, null);
							queryResultPanel1.setLayout(null);
							{
								ClassQueryScrollPane1 = new JScrollPane();
								queryResultPanel1.add(ClassQueryScrollPane1);
								ClassQueryScrollPane1.setBounds(21, 21, 504,
										308);
								{
									DefaultTableModel ClassQueryTableModel = new DefaultTableModel(row,combListStu);
									
									ClassQueryTable = new JTable();
									ClassQueryScrollPane1
											.setViewportView(ClassQueryTable);
									ClassQueryTable.setLayout(null);
									ClassQueryTable
											.setModel(ClassQueryTableModel);
									ClassQueryTable
											.setBounds(49, 161, 483, 350);
									//设置学生信息表每个单元格的高度
									ClassQueryTable.setRowHeight(24);
									ClassQueryTable.getTableHeader().setBounds(0, 0, 504, 14);
									ClassQueryTable.setPreferredSize(new java.awt.Dimension(483, 644));
								}
								ClassQueryScrollPane1
										.addMouseListener(new MouseAdapter() {
											public void mouseClicked(
													MouseEvent evt) {
												ClassQueryScrollPane1MouseClicked(evt);
											}
										});
							}
						}
						{
							DataViewPanel1 = new JPanel();
							presentTabbedPane.addTab("数据显示", null,
									DataViewPanel1, null);
							{
								prsentScrollPane = new JScrollPane();
								DataViewPanel1.add(prsentScrollPane);
								prsentScrollPane.setBounds(42, 259, 448, 168);
								prsentScrollPane
										.setPreferredSize(new java.awt.Dimension(
												507, 302));
								{
									TableModel presentTableModel = new DefaultTableModel(row,columnStudent);
									presentTable = new JTable();
									presentTable.setLayout(null);
									prsentScrollPane
											.setViewportView(presentTable);
									presentTable.setModel(presentTableModel);
									presentTable.setBounds(42, 21, 448, 210);
									//设置学生信息表每个单元格的高度
									presentTable.setRowHeight(24);
									presentTable.setPreferredSize(new java.awt.Dimension(504, 322));
									presentTable.getTableHeader().setBounds(0, 0, 448, 14);
								}
							}
						}
					}
					{
						jSeparator1 = new JSeparator();
						presentPanel.add(jSeparator1);
						jSeparator1.setBounds(588, 0, 14, 448);
						jSeparator1.setFocusTraversalKeysEnabled(false);
						jSeparator1.setOrientation(SwingConstants.VERTICAL);
					}
					{
						String[] year = new String[20];// 能查询的年份为当前年份的前50年,后30年
						for (int i = nowYear - 10, j = 0; i < nowYear + 10
								&& j < 20; i++, j++) {
							year[j] = i + "";

						}
						SpinnerListModel yearSelectjSpinner1Model = new SpinnerListModel(
								year);
						yearSelectjSpinner1Model.setValue(this.nowYear + "");
						yearSelectjSpinner1 = new JSpinner();
						presentPanel.add(yearSelectjSpinner1);
						yearSelectjSpinner1.setModel(yearSelectjSpinner1Model);
						yearSelectjSpinner1.setBounds(609, 91, 77, 28);
						yearSelectjSpinner1
								.addMouseWheelListener(new MouseWheelListener() {
									public void mouseWheelMoved(
											MouseWheelEvent evt) {
										yearSelectjSpinner1MouseWheelMoved(evt);
									}
								});
					}
					{
						presentQueryViewLabel = new JLabel();
						presentPanel.add(presentQueryViewLabel);
						presentQueryViewLabel
							.setText("\u51fa\u52e4\u67e5\u8be2");
						presentQueryViewLabel.setBounds(609, 28, 266, 28);
						presentQueryViewLabel.setForeground(new java.awt.Color(0,0,255));
						presentQueryViewLabel.setFont(new java.awt.Font("宋体",0,14));
					}
				}
			}
			this.setSize(900, 475);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	DefaultTableModel jTable1Model;

	/**
	 * 退出功能
	 * 
	 * @param evt
	 */
	private void exitButtonActionPerformed(ActionEvent evt) {

		this.dispose();
	}
/**
 * 查询数据并在存放到向量中
 * @param strSQL 查询的sql语句
 * @return 返回向量
 * @throws SQLException
 */

	private Vector getData(String strSQL) throws SQLException {
		// 建立一个JDBC对象
		JdbcConnct jdbcConnection = new JdbcConnct();
		// 建立一个数据库连接对象
		Connection connection = null;
		// 建议一个SQLStatement状态对象
		Statement statement = null;
		// 建立一个ResultSet结果集对象
		ResultSet resultSet = null;
		// 定义一个Vector变量 vecData 存储数据集
		Vector<String[]> vecData = new Vector();

		try {
			connection = jdbcConnection.fetchConnection();
			// System.out.println(connection);
			statement = connection.createStatement();
			String sql1 = strSQL;

			// System.out.println(sql1);
			resultSet = statement.executeQuery(sql1);
			while (resultSet.next()) {
				String presta = resultSet.getString("presentStatus");
				if (presta == null) {
					presta = "无";
				} else if (presta.equals("1")) {
					presta = "出勤";
				} else if (presta.equals("2")) {
					presta = "迟到";
				} else if (presta.equals("3")) {
					presta = "早退";
				} else if (presta.equals("4")) {
					presta = "病假";
				} else if (presta.equals("5")) {
					presta = "事假";
				}
			}
		} catch (SQLException e) {
			JOptionPane.showMessageDialog(this, "表格显示错误!");
			e.printStackTrace();
		} catch (Exception e1) {
			e1.printStackTrace();
		} finally {
			connection.close();
			statement.close();
			resultSet.close();
		}
		return vecData;

	}
    
	/**
	 * 查询并显示出勤信息
	 * @param evt
	 * @throws SQLException
	 */
	private void querButtonActionPerformed(ActionEvent evt) throws SQLException {
		// 查询并显示出勤信息
		// 定义变量bisStudent,判断是否选择学生,初始化为false
		boolean bisStudent = false;
		// 定义变量bisExistStuPresentInfo,判断学生出勤信息是否存在,初始化为false
		boolean bisExistStuPresentInfo = false;
		// 定义变量bisExistClassPresentInfo,判断班级出勤信息是否存在,初始化为false
		boolean bisExistClassPresentInfo = false;


		// 判断是学生出勤查询还是班级出勤查询
		bisStudent = this.getUserSelectType();

		if (bisStudent) {
			// 如果是学生查询
			//判断学生出勤信息是否存在,存在返回true并显示出勤信息,否则返回false
			bisExistStuPresentInfo = this.displayStuPresentInfo();
			if(bisExistStuPresentInfo){
				
			}else{
				JOptionPane.showMessageDialog(this, "您查询的学生出勤记录在数据库中不存在!请换一个查询条件。");				
			}

		} else {
			// 如果是班级查询
			//判断班级出勤信息是否存在,存在显示出勤信息并返回true,否则返回false			
			bisExistClassPresentInfo = this.displayClassPresentInfo();
			if(bisExistClassPresentInfo){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -