package com.kingdee.eas.scm.sm.pur.client;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.kingdee.bos.ctrl.swing.KDWorkButton;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.ui.face.IUIWindow;
import com.kingdee.bos.ui.face.UIFactory;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.eas.common.client.UIContext;
import com.kingdee.eas.common.client.UIFactoryName;
import com.kingdee.eas.scm.common.BillBaseStatusEnum;
import com.kingdee.eas.scm.pur.client.CgPersonUI;
import com.kingdee.eas.scm.sm.pur.PurRequestFactory;
import com.kingdee.eas.scm.sm.pur.PurRequestInfo;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.EASResource;
import com.kingdee.eas.util.client.MsgBox;

public class PurRequestListUIPIEx  extends PurRequestListUI{

	public PurRequestListUIPIEx() throws Exception {
		super();
	}
	public void onLoad() throws Exception {
		// TODO Auto-generated method stub
		super.onLoad();
    	KDWorkButton btnImport = new KDWorkButton("指定采购员");
		btnImport.setIcon(EASResource.getIcon("tbtn_circumscription.gif"));
		this.toolBar.add(btnImport);
		btnImport.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				try {
					checkSelected();
					PurRequestInfo pdinfo =PurRequestFactory.getRemoteInstance().getPurRequestInfo(new ObjectUuidPK(getSelectedKeyValue()));
					if(pdinfo!=null && BillBaseStatusEnum.AUDITED.equals(pdinfo.getBaseStatus())){
						UIContext  context = new UIContext(this);
						context.put("info", pdinfo);
						IUIWindow create = UIFactory.createUIFactory(UIFactoryName.MODEL).create(CgPersonUI.class.getName(),context,null,OprtState.ADDNEW);
						create.show();
						 actionRefresh_actionPerformed(e);
					}else{
	                  MsgBox.showInfo("单据未审核通过");
						SysUtil.abort();
					}
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		});
	}

}
