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

📄 editcourseinfo.java

📁 针对数据库操作制作的一个学生管理系统
💻 JAVA
字号:
package Cstudent;

import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;

public class EditCourseInfo extends CourseInfo {
	String cNum_str = "";
	public EditCourseInfo() {
		this.setTitle("修改课程信息");
		this.setResizable(false);

		Cno.setEditable(false);
		Cno.setText("请查询课程号");
		Cname.setEditable(false);
		Cpno.setEditable(false);
		Ccredit.setEditable(false);
		//cTime.setEditable(false);
		//cPlace.setEditable(false);

		//设置运行位置,使对话框居中
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation( (int) (screenSize.width - 400) / 2 ,
						(int) (screenSize.height - 300) / 2 +45);
	}

	public void downInit(){
		searchInfo.setText("查询");
		searchInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(searchInfo);
		modifyInfo.setText("修改");
		modifyInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(modifyInfo);
		clearInfo.setText("清空");
		clearInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(clearInfo);
		eixtInfo.setText("退出");
		eixtInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(eixtInfo);

		this.contentPane.add(downPanel,BorderLayout.SOUTH);

		searchInfo.setEnabled(true);
		modifyInfo.setEnabled(false);
		clearInfo.setEnabled(true);
		eixtInfo.setEnabled(true);

		//添加事件侦听
		searchInfo.addActionListener(this);
		modifyInfo.addActionListener(this);
		clearInfo.addActionListener(this);
		eixtInfo.addActionListener(this);
	}

	/**
	 * 事件处理
	 */
	public void actionPerformed(ActionEvent e) {
		Object obj = e.getSource();
		String[] s = new String[5];

		if (obj == eixtInfo) { //退出
			this.dispose();
		}
		else if (obj == modifyInfo) { //修改
			CrsBean modifyCrs = new CrsBean();
			modifyCrs.crsModify(Cno.getText(), Cname.getText(), Cpno.getText(), Ccredit.getText());
			modifyCrs.crsSearch(Cno.getText());
			s = modifyCrs.crsSearch(cNum_str);

			Cname.setText(s[0]);
			Cpno.setText(s[1]);
			Ccredit.setText(s[2]);
			//cType.setText(s[3]);
			//cTime.setText(s[4]);
			
		}
		else if (obj == clearInfo) { //清空
			setNull();
			Cno.setText("请查询课程号");
		}
		else if (obj == searchInfo) { //课程号查询
			//CourseInfoSearchCno cisc = new CourseInfoSearchCno(this);
			//cisc.pack();
			//cisc.setVisible(true);
			//cNum_str = cisc.getCno();
			
			CrsBean searchCrs = new CrsBean();
			s = searchCrs.crsSearch(cNum_str);
			if(s == null){
				JOptionPane.showMessageDialog(null, "记录不存在!");
				Cno.setText("请查询学号");
				Cname.setText("");
				Cpno.setText("");
				Ccredit.setText("");
				//cType.setText("");
				//cTime.setText("");
								
				Cname.setEditable(false);
				Cpno.setEditable(false);
				Ccredit.setEditable(false);
				//cType.setEditable(false);
				//cTime.setEditable(false);
				modifyInfo.setEnabled(false);
				return;
			}
			else{
				Cno.setText(cNum_str);
				Cname.setText(s[0]);
				Cpno.setText(s[1]);
				Ccredit.setText(s[2]);
				//cType.setText(s[3]);
				//cTime.setText(s[4]);
				

				Cname.setEditable(true);
				Cpno.setEditable(true);
				Ccredit.setEditable(true);
				//cType.setEditable(true);
				//cTime.setEditable(true);
				modifyInfo.setEnabled(true);
			}
		}
	}
}

⌨️ 快捷键说明

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