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

📄 scoreuniversquerydialog.java

📁 学生管理系统。使用java编程
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
									jScrollPane1
										.setViewportView(ClassQueryList);
									ClassQueryList
										.setModel(ClassQueryListModel);
									ClassQueryList
										.setPreferredSize(new java.awt.Dimension(
											185,
											284));
									ClassQueryList.setBounds(273, 98, 189, 168);
								}
							}
							{
								classQueryButton = new JButton();
								classQueryPanel.add(classQueryButton);
								classQueryButton.setText("\u67e5\u8be2");
								classQueryButton.setBounds(28, 308, 63, 21);
								classQueryButton
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											classQueryButtonActionPerformed(evt);
										}
									});
							}
							{
								clearButton = new JButton();
								classQueryPanel.add(clearButton);
								clearButton.setText("\u6e05\u7a7a");
								clearButton.setBounds(105, 308, 63, 21);
								clearButton
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											clearButtonActionPerformed(evt);
										}
									});
							}
							{
								addButton = new JButton();
								classQueryPanel.add(addButton);
								addButton.setText("\u589e\u52a0");
								addButton.setBounds(182, 308, 63, 21);
								addButton
									.addActionListener(new ActionListener() {
										public void actionPerformed(
											ActionEvent evt) {
											addButtonActionPerformed(evt);
										}
									});
							}
						}
						{
							queryResultPanel = new JPanel();
							ScorQueryTabbedPane.addTab("查询结果", null,
									queryResultPanel, null);
							queryResultPanel.setLayout(null);
							queryResultPanel.setFont(new java.awt.Font("Dialog",0,12));
							{
								ClassQueryScrollPane1 = new JScrollPane();
								queryResultPanel.add(ClassQueryScrollPane1);
								ClassQueryScrollPane1.setBounds(21, 21, 504,
										308);

								{
									ClassQueryTableModel = new DefaultTableModel(
											row, combListStu);
									ClassQueryTable = new JTable();
									ClassQueryScrollPane1
											.setViewportView(ClassQueryTable);
									ClassQueryTable
											.setModel(ClassQueryTableModel);
									ClassQueryTable.setRowHeight(24);
									ClassQueryTable.setPreferredSize(new java.awt.Dimension(483, 1771));
									ClassQueryTable
											.setBounds(49, 161, 483, 350);
									ClassQueryTable.getTableHeader().setBounds(
											0, 0, 504, 14);
									ClassQueryTable
										.addMouseListener(new MouseAdapter() {
										public void mouseClicked(MouseEvent evt) {
											ClassQueryTableMouseClicked(evt);
										}
										});
								}
							}
						}
						{
							dataViewPanel = new JPanel();
							ScorQueryTabbedPane.addTab("数据显示", null,
									dataViewPanel, null);
							dataViewPanel.setFont(new java.awt.Font("Dialog",0,12));
							dataViewPanel.setLayout(null);
							dataViewPanel
									.setPreferredSize(new java.awt.Dimension(
											539, 357));
							{
								stuScroeScrollPane = new JScrollPane();
								dataViewPanel.add(stuScroeScrollPane);
								stuScroeScrollPane.setBounds(21, 21, 504, 308);
								{
									stuScoreTableModel = new DefaultTableModel(
											row, columnStudent);
									stuScoreTable = new JTable();
									stuScroeScrollPane
											.setViewportView(stuScoreTable);
									stuScoreTable.setModel(stuScoreTableModel);
									stuScoreTable.setRowHeight(24);
									stuScoreTable.setPreferredSize(new java.awt.Dimension(483, 378));
									stuScoreTable.setBounds(42, 21, 448, 210);
									stuScoreTable.getTableHeader().setBounds(0, 0, 483, 21);
								}
							}
						}
					}
					{
						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 yearSelectSpinnerModel = new SpinnerListModel(year);
						//设置为当前年						yearSelectSpinnerModel.setValue(this.nowYear + "");
						yearSelectSpinner = new JSpinner();
						ScoreQueryPanel.add(yearSelectSpinner);
						yearSelectSpinner.setModel(yearSelectSpinnerModel);
						yearSelectSpinner.setBounds(616, 98, 77, 28);
						yearSelectSpinner
							.addMouseWheelListener(new MouseWheelListener() {
							public void mouseWheelMoved(MouseWheelEvent evt) {
								yearSelectSpinnerMouseWheelMoved(evt);
							}
							});
					}
					{
						ComboBoxModel conditionComboBoxModel = new DefaultComboBoxModel(
								columnScoreQuery);
						conditionComboBox = new JComboBox();
						ScoreQueryPanel.add(conditionComboBox);
						conditionComboBox.setModel(conditionComboBoxModel);
						conditionComboBox.setBounds(707, 98, 70, 28);
					}
					{
						studentQueryButton = new JButton();
						ScoreQueryPanel.add(studentQueryButton);
						studentQueryButton.setText("\u6210\u7ee9\u67e5\u8be2");
						studentQueryButton.setBounds(791, 98, 91, 28);
						studentQueryButton
							.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								studentQueryButtonActionPerformed(evt);
							}
							});
					}
					{
						stuQueryViewLabel = new JLabel();
						ScoreQueryPanel.add(stuQueryViewLabel);
						stuQueryViewLabel
								.setText("\u5b66\u751f\u6210\u7ee9\u67e5\u8be2");
						stuQueryViewLabel.setBounds(616, 21, 259, 28);
						stuQueryViewLabel
								.setFont(new java.awt.Font("宋体", 0, 14));
						stuQueryViewLabel.setForeground(new java.awt.Color(0,
								0, 255));
					}
					{
						fullQueryRadioButton = new JRadioButton();
						ScoreQueryPanel.add(fullQueryRadioButton);
						fullQueryRadioButton
								.setText("\u6240\u6709\u6210\u7ee9");
						fullQueryRadioButton.setBounds(616, 63, 84, 21);
						scoreQuerybuttonGroup.add(fullQueryRadioButton);
						fullQueryRadioButton.setSelected(true);
						fullQueryRadioButton
							.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								fullQueryRadioButtonActionPerformed(evt);
							}
							});
					}
					{
						commonRadioButton = new JRadioButton();
						ScoreQueryPanel.add(commonRadioButton);
						commonRadioButton.setText("\u5e73\u65f6\u6210\u7ee9");
						commonRadioButton.setBounds(714, 63, 84, 21);
						scoreQuerybuttonGroup.add(commonRadioButton);
						commonRadioButton
							.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								commonRadioButtonActionPerformed(evt);
							}
							});
					}
					{
						classIdLabel = new JLabel();
						ScoreQueryPanel.add(classIdLabel);
						classIdLabel.setText("\u73ed\u7ea7\u7f16\u53f7");
						classIdLabel.setBounds(616, 196, 56, 28);
					}
					{
						classIdViewLabel = new JLabel();
						ScoreQueryPanel.add(classIdViewLabel);
						classIdViewLabel.setText("1");
						classIdViewLabel.setBounds(672, 196, 35, 28);
						classIdViewLabel.setForeground(new java.awt.Color(0, 0,
								255));
					}
					{
						classNameLabel = new JLabel();
						ScoreQueryPanel.add(classNameLabel);
						classNameLabel.setText("\u73ed\u7ea7\u540d");
						classNameLabel.setBounds(707, 196, 56, 28);
					}
					{
						classNameViewLabel = new JLabel();
						ScoreQueryPanel.add(classNameViewLabel);
						classNameViewLabel.setText("\u73ed\u7ea7\u540d");
						classNameViewLabel.setBounds(763, 196, 126, 28);
						classNameViewLabel.setForeground(new java.awt.Color(0, 0, 255));
					}
					{
						fullSubjectQueryRadioButton = new JRadioButton();
						ScoreQueryPanel.add(fullSubjectQueryRadioButton);
						fullSubjectQueryRadioButton.setText("\u6240\u6709\u79d1\u76ee\u67e5\u8be2");
						fullSubjectQueryRadioButton.setSelected(true);
						fullSubjectQueryRadioButton.setBounds(616, 231, 105, 21);
						classQuerybuttonGroup.add(fullSubjectQueryRadioButton);
						fullSubjectQueryRadioButton
							.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								fullSubjectQueryRadioButtonActionPerformed(evt);
							}
							});
					}
					{
						subjectQueryRadioButton = new JRadioButton();
						ScoreQueryPanel.add(subjectQueryRadioButton);
						subjectQueryRadioButton.setText("\u5206\u79d1\u76ee\u67e5\u8be2");
						subjectQueryRadioButton.setBounds(735, 231, 105, 21);
						classQuerybuttonGroup.add(subjectQueryRadioButton);
						subjectQueryRadioButton
							.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								subjectQueryRadioButtonActionPerformed(evt);
							}
							});
					}
					{
						ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
								combListSubject);
						subjectConditionComboBox = new JComboBox();
						ScoreQueryPanel.add(subjectConditionComboBox);
						subjectConditionComboBox.setModel(jComboBox1Model);
						subjectConditionComboBox.setBounds(616, 266, 84, 28);
					}
					{
						classScoreQueryButton = new JButton();
						ScoreQueryPanel.add(classScoreQueryButton);
						classScoreQueryButton.setText("\u6210\u7ee9\u67e5\u8be2");
						classScoreQueryButton.setBounds(791, 266, 91, 28);
						classScoreQueryButton
							.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								classScoreQueryButtonActionPerformed(evt);
							}
							});
					}
					{
						VSeparator = new JSeparator();
						ScoreQueryPanel.add(VSeparator);
						VSeparator.setBounds(588, 0, 7, 448);
						VSeparator.setOrientation(SwingConstants.VERTICAL);
					}
					{
						HorSeparator1 = new JSeparator();
						ScoreQueryPanel.add(HorSeparator1);
						HorSeparator1.setBounds(588, 308, 308, 21);
					}
					{
						exitButton = new JButton();
						ScoreQueryPanel.add(exitButton);
						exitButton.setText("\u9000\u51fa");
						exitButton.setBounds(791, 343, 70, 28);
						exitButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								exitButtonActionPerformed(evt);
							}
						});
					}
				}
			}
			setSize(900, 475);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 学生查询清空查询条件	 * 
	 * @param evt
	 */
	private void clearStuQueryButtonActionPerformed(ActionEvent evt) {
		ncount = 1;
		// 清空Vector变量vecSQL vecListView清空List控件中查询条件		this.vecSQL.clear();
		this.vecListView.clear();
		this.studentQueryList1.setListData(vecListView);
		// 清除按钮不可用		this.clearStuQueryButton.setEnabled(false);
	}

	/** 班级查询添加查询条件	 * 
	 * @param evt
	 */
	 	private void addButtonActionPerformed(ActionEvent evt) {
		String strSQL = "";
		// 定义boolean型变量 isRight 用户操作是否正确,初始化false
		boolean bisRight = false;

		// 第一次必须选择”无“条件选项		if (!this.nullRadioButton.isSelected() && ncountClass == 1) {
			bisRight = false;
			JOptionPane.showMessageDialog(this, "选择多条件查询时’无’选项须在第一次操作时选择,\n第一次"
					+ "操作后请不要再选择’无’选项!");
		} else if (this.nullRadioButton.isSelected() && ncountClass > 1) {
			// 第一次以后不能选择”无“条件选项			bisRight = false;
			JOptionPane.showMessageDialog(this, "’无’选项须在第一次操作时选择,\n"
					+ "第一次操作后请不要再选择’无’选项!");
		} else {
			bisRight = true;
			// 用户查询的条件数量加一			ncountClass++;
		}

		if (bisRight) {
			// 获得用户选择,并转化为SQL语句			strSQL = this.getUserSelectClass();
			System.out.println("\t" + strSQL);

			// 向Vector变量vecSQLClass中添加变量			this.vecSQLClass.add(strSQL);
			// 清空按钮可用,范围为本框不可用,查询字段文本框置为空			this.clearButton.setEnabled(true);
			this.commentTextField.setText("");
		}
	}

	/**
	 * 添加学生查询条件	 * 
	 * @param evt
	 */
	private void addStuQueryButtonActionPerformed(ActionEvent evt) {
		// 定义SQL语句		String strSQL = "";
		// 定义boolean型变量 isRight 用户操作是否正确,初始化false
		boolean bisRight = false;

		// 第一次必须选择”无“条件选项		if (!this.nullRadioButton1.isSelected() && ncount == 1) {
			bisRight = false;
			JOptionPane.showMessageDialog(this, "选择多条件查询时’无’选项须在第一次操作时选择,\n第一次"
					+ "操作后请不要再选择’无’选项!");
		} else if (this.nullRadioButton1.isSelected() && ncount > 1) {
			// 第一次以后不能选择”无“条件选项			bisRight = false;
			JOptionPane.showMessageDialog(this, "’无’选项须在第一次操作时选择,\n"
					+ "第一次操作后请不要再选择’无’选项!");
		} else {
			bisRight = true;
			// 用户查询的条件数量加一			ncount++;
		}

		if (bisRight) {
			// 获得用户选择,并转化为SQL语句			strSQL = this.getUserSelect();
			System.out.println("\t" + strSQL);

			// 向Vector变量vecSQL中添加变量			this.vecSQL.add(strSQL);
			// 清空按钮可用,范围为本框不可用,查询字段文本框置为空			this.clearStuQueryButton.setEnabled(true);
			this.userInputTextField1.setText("");
		}
	}

	/**
	 * 根据班级查询条件匹配比较符	 * 
	 * @param evt
	 */
	private void ClassQueryComboBoxActionPerformed(ActionEvent evt) {
		String strUserSelectclass = "";

		// 获取用户选择字段		strUserSelectclass = this.ClassQueryComboBox.getSelectedItem()
				.toString();
		if (strUserSelectclass.equals("班级名")) {
			this.classQueryConditionComboBox.removeAllItems();
			this.classQueryConditionComboBox.addItem("匹配");
			this.classQueryConditionComboBox.addItem("=");
		}
		if (strUserSelectclass.equals("班级号") || strUserSelectclass.equals("届别")) {
			this.classQueryConditionComboBox.removeAllItems();
			this.classQueryConditionComboBox.addItem(">");
			this.classQueryConditionComboBox.addItem("<");
			this.classQueryConditionComboBox.addItem("=");
		}
	}

	/**
	 * 班级查询,显示班级信息	 * 
	 * @param evt
	 *            鼠标响应事件	 */
	private void classQueryButtonActionPerformed(ActionEvent evt) {
		// 查询班级		// 建立一个JDBC对象		JdbcConnct jdbcConnection = new JdbcConnct();
		// 定义Vector变量,存储从数据库查询来的信息		Vector vecData = new Vector();
		// 定义SQL语句组合项		String strSQL = "select classid,classname,flagyear from zlb.classes ";
		String strSQL1 = " where ";
		String strTemp = " order by classid ASC";

		// 组合SQL语句		if (this.vecSQLClass.isEmpty()) {
			strSQL += strTemp;
		} else {
			for (int i = 0; i < this.vecSQLClass.size(); i++) {
				strSQL1 += this.vecSQLClass.get(i).toString();
			}
			strSQL += strSQL1 + strTemp;
		}
		
		// 刷新table中数据		DefaultTableModel StuQueryTableModel = new DefaultTableModel(row,
				combListClass);
		this.ClassQueryTable.setModel(StuQueryTableModel);
		// 获得数据		try {
			vecData = jdbcConnection.getData(strSQL);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		// 依次为各行插入数据		if (vecData.size() > 0) {
			for (int i = 0; i < vecData.size(); i++) {
				StuQueryTableModel.addRow((String[]) vecData.get(i));
			}
			// 显示查询数据			this.ScorQueryTabbedPane
					.setSelectedComponent(this.queryResultPanel);
			//用户点击表格次数置为1
			nclickNum = 1;
		} else {
			JOptionPane.showMessageDialog(this, "您查询的记录在数据库中不存在!请换一个查询条件.");
		}


	}

	/**
	 * 清除班级查询条件	 * 
	 * @param evt
	 */
	private void clearButtonActionPerformed(ActionEvent evt) {

⌨️ 快捷键说明

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