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

📄 scoaddframe.java

📁 包含了学生管理系统的一些基本操作以及相关窗口页面实现。
💻 JAVA
字号:
package com.hb.studentmanager.ui;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import com.hb.studentmanager.action.ScoAction;
import com.hb.studentmanager.date.StuDTO;
import com.hb.studentmanager.date.TesDTO;


/**
* 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 ScoAddFrame extends javax.swing.JDialog {
	private JPanel AddScoPanel;
	private JComboBox tesComboBox;
	private JComboBox stuidComboBox;
	private JLabel stuLabel;
	private JButton okButton;
	private JTextField scoTextField;
	private JLabel scoLabel;
	private JLabel tesLabel;
	private JTable table;
	private ScoAction sa=new ScoAction();
	private int page;
	
	public ScoAddFrame(JTable table,int page) {
		super();
		this.table=table;
		this.page=page;
		initGUI();
		int width=Toolkit.getDefaultToolkit().getScreenSize().width;
		int height=Toolkit.getDefaultToolkit().getScreenSize().height;
		this.setLocation((width-630)/2, (height-450)/2);
		this.setModal(true);
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				AddScoPanel = new JPanel();
				getContentPane().add(AddScoPanel);
				AddScoPanel.setLayout(null);
				AddScoPanel.setBounds(-3, -2, 392, 266);
				{
					tesLabel = new JLabel();
					AddScoPanel.add(tesLabel);
					tesLabel.setText("\u8003\u8bd5\u7f16\u53f7\uff1a");
					tesLabel.setBounds(63, 42, 77, 28);
				}
				{
					ComboBoxModel subComboBoxModel = new DefaultComboBoxModel();
					tesComboBox = new JComboBox();
					AddScoPanel.add(tesComboBox);
					tesComboBox.setModel(subComboBoxModel);
					tesComboBox.setBounds(140, 42, 189, 28);
                    sa.tesid(tesComboBox);
				}
				{
					scoLabel = new JLabel();
					AddScoPanel.add(scoLabel);
					scoLabel.setText("\u79d1\u76ee\u6210\u7ee9\uff1a");
					scoLabel.setBounds(63, 161, 77, 28);
				}
				{
					scoTextField = new JTextField();
					AddScoPanel.add(scoTextField);
					scoTextField.setBounds(140, 161, 189, 28);
				}
				{
					okButton = new JButton();
					AddScoPanel.add(okButton);
					okButton.setText("\u63d0\u4ea4");
					okButton.setBounds(245, 217, 63, 28);
					okButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							okButtonActionPerformed(evt);
						}
					});
				}
				{
					stuLabel = new JLabel();
					AddScoPanel.add(stuLabel);
					stuLabel.setText("\u5b66\u53f7\uff1a");
					stuLabel.setBounds(63, 98, 77, 28);
				}
				{
					ComboBoxModel stuidComboBoxModel = new DefaultComboBoxModel();
					stuidComboBox = new JComboBox();
					AddScoPanel.add(stuidComboBox);
					stuidComboBox.setModel(stuidComboBoxModel);
					stuidComboBox.setBounds(140, 98, 189, 28);
					sa.stuid(stuidComboBox);
				}
			}
			pack();
			this.setSize(400, 300);
			this.setTitle("\u6dfb\u52a0\u6210\u7ee9");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void okButtonActionPerformed(ActionEvent evt){
		int flag=0;//标志,判断分数是否为空		
		String tes_id=tesComboBox.getSelectedItem().toString();
		String stu_id=stuidComboBox.getSelectedItem().toString();
		String sco_sub=scoTextField.getText();
					
		int score=0;
		if(tes_id.equals("")){
			
			JOptionPane.showMessageDialog(this,"请先选择考试编号!");
		}
		else if(stu_id.equals("")){
			
			JOptionPane.showMessageDialog(this, "请选择学号!");
		}
		else {
			if(sco_sub.equals("")) flag=1 ;
			else {
				if(sco_sub.matches("\\d{1,100}")==false||sco_sub.length()>1&&sco_sub.startsWith("0"))
			      JOptionPane.showMessageDialog(this,"分数输入有误!");
	            else if(Integer.parseInt(sco_sub)>100)
			      JOptionPane.showMessageDialog(this,"分数必须为0-100之间");
	            else
	            	flag=2;
			}
		}
		if(flag==1||flag==2) {
			int control=JOptionPane.showConfirmDialog(this, "真的要添加吗?","警告!",JOptionPane.OK_OPTION);
			if(JOptionPane.OK_OPTION==control){
			    if(flag==2)//不为空		           score=Integer.parseInt(sco_sub);
			    if(flag==1)//为空			    {
				   score=0;
			    }
				if(sa.judgeupdate(tes_id)==false)
					JOptionPane.showMessageDialog(this, "没有科目,不能添加成绩!");
				else{
		        boolean tf=sa.add(tes_id,stu_id,score);
		        if(tf==true){
		            sa.init(table,page,5);
		            this.setVisible(false);
		        }
				}
		     }
	     }
	}
}

⌨️ 快捷键说明

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