EAS系统单据上如何加图片原创
金蝶云社区-飞天
飞天
13人赞赏了该文章 462次浏览 未经作者许可,禁止转载编辑于2020年12月03日 14:34:36

1、实体上新增字段类型为byteArray

112106_yN7j_2361451.png

2、对应的数据库表上增加字段数据类型为blob,跟实体上的字段绑定

112219_PdUo_2361451.png

3、UI界面上增加KDLabel112454_BeZ6_2361451.png

112425_tBeO_2361451.png

2、EditUI上增加实现代码

//双击选择图片@Overrideprotected void lbphoto_mouseClicked(MouseEvent e) throws Exception {    	int count = e.getClickCount();    	if (count == 2) {    		selectPhoto();    	}}//选择图片private void selectPhoto() throws Exception{		KDFileChooser fileChooser = new KDFileChooser();		fileChooser.setFileFilter(new PictureFilter());		fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);		int result = fileChooser.showOpenDialog(this);		if(result == 0) {			java.io.File file = fileChooser.getSelectedFile();			byte[] bt = HRUtil.convertFileTOBytes(file);			Image image = ImageIO.read(new ByteArrayInputStream(bt));//			ImageIcon icon =  new ImageIcon(image);			KDImageIcon icon = new KDImageIcon(image);    		lbphoto.setIcon(icon);			editData.setPhoto(bt);		}	}//打开单据加载图片@Overridepublic void onShow() throws Exception {    	super.onShow();    	if (UIRuleUtil.isNotNull(editData.getPhoto())) {    		Image image = ImageIO.read(new ByteArrayInputStream(editData.getPhoto()));    		lbphoto.setIcon(new KDImageIcon(image));		}}//删除图片代码@Overrideprotected void btndelphoto_actionPerformed(ActionEvent e) throws Exception {    	int i = MsgBox.showConfirm2(this, "是否确认删除图片?");    	if (MsgBox.OK == i) {    		lbphoto.setIcon(null);        	editData.setPhoto(null);		}}//选择图片按钮@Overrideprotected void btnupphoto_actionPerformed(ActionEvent e) throws Exception {    	selectPhoto();}

 

赞 13