U8C、NC自制单据:刷新、卡片列表切换
按钮动作中调用其他按钮
//ui-当前单据ui AbstractBtnReg.SYSBTN_REFRESH - 刷新按钮标识
//1 可以获取到当前UI 在其他按钮调用刷新方法
ui.getBtnManager().getCmdByID(AbstractBtnReg.SYSBTN_REFRESH).execute();
//2 无法获取当前UI 调用刷新方法
RefreshSingleAction refreshaction = new RefreshSingleAction();
//this代表实现NCAction的类的对象
refreshaction.setModel(this.getModel());
//点击系统所带的刷新按钮,打断点找到ActionEvent 中的对应参数图下面
ActionEvent e1 = new ActionEvent(refreshaction, 1001, "刷新");
refreshaction.doAction(e1);
卡片切换到列表
//ui.getBillCardPanel().isShowing()--判断当前是不是卡片状态
if (ui.getBillCardPanel().isShowing()) {
TrMainPanel mainPanel = (TrMainPanel) (ui.getMainPanel());// 获取主面板
mainPanel.clearView();
mainPanel.show("LIST_PANEL");
//隐藏卡片
mainPanel.setMainPanelEnabled(false);
//获取进入卡片的时候选择行
int iSelectRowIndex = mainPanel.getMainBillListPanel()
.getHeadSelectedRow();
if (iSelectRowIndex != -1) {
//更改选中行
mainPanel.getMainBillListPanel().setHeadSelectedRow(-1, -1);
mainPanel.getMainBillListPanel().setHeadSelectedRow(
iSelectRowIndex, iSelectRowIndex);
}
//设置单据状态 8 ->行选择状态STATE_LINE_SELECTED 0 初始状态STATE_INIT
getDataModel().setCurrentState(iSelectRowIndex != -1 ? 8 : 0);
//调用刷新动作
getFrameUI().getBtnManager().getCmdByID(AbstractBtnReg.SYSBTN_REFRESH).execute();
}
查询动作拼接自定义条件
- 使用方法
getDataModel().setExtraCondition(" and dr='0'"); // 设置附加查询条件
调用默认的刷新方法也会刷新出符合出附加条件的数据
- 重写ManageDataModel中的方法
//重写完以后,当点击查询的时候会执行该方法
@Override
public SuperVO[] onQuery(Class className, String condition) {
System.out.println(condition);
condition=condition.replace("new.issh = '是'","c2_forecast_main.states in ('审核')").replace("new.issh = '否'","c2_forecast_main.states not in ('审核')").replace("new.issh in ('是','否')","1=1");
try {
String sql = "select count(*) cnt ";
sql =sql+" from sm_user inner join sm_user_role on sm_user.cuserid = sm_user_role.cuserid ";
sql =sql+" inner join sm_role on sm_role.pk_role=sm_user_role.pk_role where role_code in ('604') and sm_user.cuserid='"+ClientEnvironment.getInstance().getUser().getPrimaryKey()+"'";
IUAPQueryBS bsDao = (IUAPQueryBS) NCLocator
.getInstance().lookup(
IUAPQueryBS.class.getName());
int cnt = (int) bsDao.executeQuery(sql,new ColumnProcessor());
//查询出是一般销售工程师,只能查看本人单据
if (cnt>0) {
condition=condition+" and c2_forecast_main.voperatorid='"+ClientEnvironment.getInstance().getUser().getPrimaryKey()+"'";
}
} catch (ComponentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BusinessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return super.onQuery(className, condition);
}
@Override
public SuperVO[] onQuery(Class arg0, Class[] arg1, String arg2) {
// TODO Auto-generated method stub
return super.onQuery(arg0, arg1, arg2);
}