java问题==========

private class LableListener implements MouseMotionListener {
		@Override
		public void mouseClicked(MouseEvent e) {
			String id = idTextField.getText().trim();
			String name = NameTextField.getText().trim();
			String pw = pwTextField.getText().trim();
			Student student = new Student().setStudent(id, name, pw);
			int idFlag; boolean existflag;
			idFlag = ConnectionStudent.IDCheck(id);
			existflag = ConnectionStudent.IDExist(id);
			String lable = e.getComponent().toString();
			switch (lable) {
			case "insert":
				if(idFlag == -1) {
					JOptionPane.showConfirmDialog(InfoSutdent.this, "用户ID位数不为6位", "插入数据错误", JOptionPane.CLOSED_OPTION,
							JOptionPane.ERROR_MESSAGE);
				}else if(idFlag == -2) {
					JOptionPane.showConfirmDialog(InfoSutdent.this, "ID存在非数字", "插入数据错误", JOptionPane.CLOSED_OPTION,
							JOptionPane.ERROR_MESSAGE);
				}else if(idFlag == 0) {
					JOptionPane.showConfirmDialog(InfoSutdent.this, "请输入学号", "插入数据错误", JOptionPane.CLOSED_OPTION,
							JOptionPane.ERROR_MESSAGE);
				}else if (existflag == true) {
					JOptionPane.showConfirmDialog(InfoSutdent.this, "学号重复", "插入数据错误", JOptionPane.CLOSED_OPTION,
							JOptionPane.ERROR_MESSAGE);
				}else {
					ConnectionStudent.insertAll(id, name, pw);
				}
				break;

			case "delete":
				ConnectionStudent.deleteRecord(id);
				break;

			case "update":
				ConnectionStudent.updateother(id, name, pw);
				break;
			}
			model = new ResultSetTableModel();
			table.setModel(model);
		}
		
		
	}
private class ButtonListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			int id = Integer.parseInt(idField.getText().trim());
			String name = nameField.getText().trim();
			String gender = genderCombo.getSelectedItem().toString().trim();
			String dob = dobField.getText().trim();
			int batch = Integer.parseInt(batchField.getText().trim());

			Student student = new Student(id, name, gender, dob, batch);
			
			JButton button = (JButton)e.getSource();
			String text = button.getText();

			String button = e.getActionCommand();
			switch (button) {
			case "Insert":
				try {
					sqlHelper.insertTable(student);
				} catch (StudentExistException exception) {
					JOptionPane.showConfirmDialog(JTableDemo2.this, "该学号已存在", "插入数据错误", JOptionPane.CLOSED_OPTION,
							JOptionPane.ERROR_MESSAGE);
				}
				break;

			case "Delete":
				sqlHelper.deleteTable(student);
				break;

			case "Update":
				sqlHelper.updateTable(student);
				break;
			}
			model = new ResultSetTableModel();
			table.setModel(model);
		}
		
	}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值