档案开发:增加查询和打卡按钮
和单据开发的不同点
没有单据类型 不是右击–>特性–>单据主表/单据子表,而是右击–>特性–>选择想要的接口 访问器类型是NCVO 不需要映射 不是项目右键–>新建–>其他–>主子表单据结点,而是项目右键–>新建–>其他–>单表档案结点 档案无查询按钮,只有刷新按钮
查询按钮开发
package nc. ui. cjkcmg. cjyxdk. action ;
import nc. bs. framework. common. NCLocator ;
import nc. itf. cjkcmg. ICjyxdkMaintain ;
import nc. ui. pubapp. uif2app. query2. action. DefaultQueryAction ;
import nc. ui. querytemplate. querytree. IQueryScheme ;
import nc. ui. uif2. IShowMsgConstant ;
import nc. ui. uif2. ShowStatusBarMsgUtil ;
import nc. vo. cjkcmg. cjyxdk. Cjyxdk ;
import nc. vo. ml. NCLangRes4VoTransl ;
import nc. vo. pubapp. pattern. exception. ExceptionUtils ;
public class QueryAction extends DefaultQueryAction {
private static final long serialVersionUID = 1310679326706972915L ;
@Override
protected void executeQuery ( IQueryScheme queryScheme) {
try {
Cjyxdk [ ] vos = getService ( ) . query ( queryScheme) ;
if ( vos == null || vos. length == 0 ) {
getModel ( ) . initModel ( null ) ;
ShowStatusBarMsgUtil . showStatusBarMsg ( IShowMsgConstant . getQueryNullInfo ( ) , this . getModel ( ) . getContext ( ) ) ;
} else {
getModel ( ) . initModel ( vos) ;
ShowStatusBarMsgUtil . showStatusBarMsg ( NCLangRes4VoTransl . getNCLangRes ( ) . getStrByID ( "pubapp_0" ,
"0pubapp-0265" , ( String ) null , new String [ ] { "" + vos. length } ) , this . getModel ( ) . getContext ( ) ) ;
}
} catch ( Exception e) {
ExceptionUtils . wrappBusinessException ( "查询异常:" + e. getMessage ( ) ) ;
}
}
private ICjyxdkMaintain service;
private ICjyxdkMaintain getService ( ) {
if ( service == null ) {
service = NCLocator . getInstance ( ) . lookup ( ICjyxdkMaintain . class ) ;
}
return service;
}
}
< bean id = " queryTemplateContainer" class = " nc.ui.uif2.editor.QueryTemplateContainer" >
< property name = " context" ref = " context" > </ property>
< property name = " nodeKey" value = " qt" > </ property>
</ bean>
< bean id = " queryAction" class = " nc.ui.cjkcmg.cjyxdk.action.QueryAction" >
< property name = " model" > < ref bean = " batchModel" /> </ property>
< property name = " templateContainer" > < ref bean = " queryTemplateContainer" /> </ property>
< property name = " nodeKey" value = " qt" />
</ bean>
打卡按钮开发
package nc. ui. cjkcmg. cjyxdk. action ;
import java. awt. event. ActionEvent ;
import nc. bs. framework. common. NCLocator ;
import nc. itf. cjkcmg. ICjyxdkMaintain ;
import nc. ui. pub. beans. MessageDialog ;
import nc. ui. pub. beans. UIRefPane ;
import nc. ui. pubapp. uif2app. model. BatchBillTableModel ;
import nc. ui. pubapp. uif2app. model. BatchModelDataManager ;
import nc. ui. uif2. NCAction ;
import nc. ui. uif2. editor. BatchBillTable ;
import nc. uif2. annoations. MethodType ;
import nc. uif2. annoations. ModelMethod ;
import nc. uif2. annoations. ModelType ;
import nc. vo. bd. meta. BatchOperateVO ;
import nc. vo. cjkcmg. cjyxdk. Cjyxdk ;
import nc. vo. pub. BusinessException ;
import nc. vo. pub. lang. UFDate ;
import nc. vo. wgbfb. utils. NullValueUtils ;
public class DkAction extends NCAction {
private static final long serialVersionUID = 1L ;
private BatchBillTableModel model;
private BatchBillTable editor;
private BatchModelDataManager dataManager ;
public DkAction ( ) {
setCode ( "dkAction" ) ;
setBtnName ( "打卡" ) ;
}
@Override
public void doAction ( ActionEvent e) throws BusinessException {
try {
UIRefPane refPane = new UIRefPane ( "客户档案" ) ;
refPane. showModel ( ) ;
String [ ] unit = ( String [ ] ) refPane. getValueObj ( ) ;
if ( unit == null ) {
return ;
}
String pk_customer = refPane. getRefPK ( ) ;
String userId = getModel ( ) . getContext ( ) . getPk_loginUser ( ) ;
Cjyxdk dkvo = new Cjyxdk ( ) ;
dkvo. setPk_group ( "0001A1100000000003UJ" ) ;
dkvo. setPk_org ( "GLOBLE00000000000000" ) ;
dkvo. setCustomer ( pk_customer) ;
dkvo. setDksj ( new UFDate ( ) ) ;
dkvo. setDkr ( userId) ;
dkvo. setDknd ( NullValueUtils . getNullStringValue ( new UFDate ( ) ) . substring ( 0 , 4 ) ) ;
BatchOperateVO batchVO = new BatchOperateVO ( ) ;
batchVO. setAddObjs ( new Cjyxdk [ ] { dkvo} ) ;
getService ( ) . batchSave ( batchVO) ;
getDataManager ( ) . refresh ( ) ;
MessageDialog . showHintDlg ( null , "提示" , "打卡成功" ) ;
} catch ( Exception e2) {
throw new BusinessException ( "打卡失败:" + e2. getMessage ( ) ) ;
}
}
private ICjyxdkMaintain service;
private ICjyxdkMaintain getService ( ) {
if ( service == null ) {
service = NCLocator . getInstance ( ) . lookup ( ICjyxdkMaintain . class ) ;
}
return service;
}
public BatchBillTableModel getModel ( ) {
return model;
}
@ModelMethod ( modelType= ModelType. AbstractUIAppModel , methodType= MethodType . SETTER )
public void setModel ( BatchBillTableModel model) {
this . model = model;
this . model. addAppEventListener ( this ) ;
}
public BatchBillTable getEditor ( ) {
return editor;
}
public void setEditor ( BatchBillTable editor) {
this . editor = editor;
}
public BatchModelDataManager getDataManager ( ) {
return dataManager;
}
public void setDataManager ( BatchModelDataManager dataManager) {
this . dataManager = dataManager;
}
}
< bean id = " dkAction" class = " nc.ui.cjkcmg.cjyxdk.action.DkAction" >
< property name = " model" ref = " batchModel" />
< property name = " editor" ref = " batchBillTable" />
< property name = " dataManager" ref = " batchModelModelDataManager" />
< property name = " exceptionHandler" > < ref bean = " exceptionHandler" /> </ property>
</ bean>