1.在UI类中的构造方法里调用一个自定义的方法,方法名随便写,本例中是afterinitdlg(parentui);
如下为构造函数:
ReturnArrivalUI parentui = this;
public ReturnArrivalUI() {
super();
afterinit();
afterinitdlg(parentui);
}
2.方法
<span style="color:#FF6666;"><strong>afterinitdlg(parentui);</strong></span>
的实现可以在当前类中,也可以放在UI类的父类,本例放在其父类BillManageUI中
BillManageUI 继承于nc.ui.trade.manage.BillManageUI 是一个自定义的BillManageUI,名字与父类nc.ui.trade.manage.BillManageUI
一样,也可以不一样,这里仅作为例子
/**
*
* 说明:实现双击卡片表体 弹出书的详细信息
*
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-16
* @param parent
*/
public void afterinitdlg ( final Container parent){
getBillCardWrapper().getBillCardPanel().addBodyMouseListener(new BillTableMouseListener() {
public void mouse_doubleclick(BillMouseEnent e) {
try {
SlArrivivalBVO[] bvo = (SlArrivivalBVO[]) getBillCardWrapper().getSelectedBodyVOs();
BookInfoDLG dlg = new BookInfoDLG(parent, "详细信息");
String pk_invbasdoc =bvo[0].getAttributeValue("pk_invbasdoc").toString();//存货基本档案主键
dlg.setConditionData(pk_invbasdoc);
dlg.setVisible(true);
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
}
3. 上面代码块中的弹框类,本例如下:
/**
* 目标: 书本详细信息
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-16
* <p>
*
* @version 1.0
* @since NC5.7
*/
class BookInfoDLG extends UIDialog {
private static BookInfoDLG bookInfoDlg;
private ReturnArrivalUI parent;
private BillListPanel listPanel;
private BillCardPanel cardPanel = new BillCardPanel();
/**
* 构造函数
*
* @param parent
* @param title
* @throws Exception
*/
public BookInfoDLG(Container parent, String title) throws Exception {
super(parent, title);
this.parent = (ReturnArrivalUI) parent;
init();
}
/**
* 说明:初始化
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-15
*
* @throws Exception
*/
private void init() throws Exception {
setSize(660, 500);
setResizable(true);
setLayout(new BorderLayout());
JPanel panel = new JPanel(new BorderLayout());
panel.add(getCardPanel(), BorderLayout.CENTER);
add(panel, BorderLayout.CENTER);
Dimension dsScreen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setLocation((dsScreen.width - getWidth()) / 2 - 100, (dsScreen.height - getHeight()) / 2 - 50);
}
/**
* 说明:加载模板
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-15
*
* @return
*/
private Component getCardPanel() {
cardPanel.loadTemplet("TN1B_BS",
"",
ClientEnvironment.getInstance().getUser().getPrimaryKey(),
ClientEnvironment.getInstance().getCorporation().getPrimaryKey());
return cardPanel;
}
/**
* 说明:
* 返回卡片,包含内容
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-15
*
* @return
*/
private BillCardPanel getBillCardPanel() {
if (cardPanel == null) {
cardPanel = new BillCardPanel();
cardPanel.setName("详细信息");
BillData billdata = geneBillData();
if (null != billdata)
cardPanel.setBillData(billdata);
if (null != billdata)
cardPanel.setBillData(billdata);
}
return cardPanel;
}
/**
* 说明:
* 从数据库查找单据模板信息,放在界面上
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-15
*
* @return
*/
private BillData geneBillData() {
IBKarrivalService service = NCLocator.getInstance().lookup(IBKarrivalService.class);
List<BillTempletBodyVO> billTempletBodyVOList = null;
try {
String sql =
"select * from pub_billtemplet_b where "
+ "pk_billtemplet in (select pk_billtemplet from pub_billtemplet where pk_billtypecode='TN1B_BS' and isnull(dr,0)=0) and isnull(dr,0)=0";
billTempletBodyVOList = service.getBillBillTempletBodyVO(sql);
} catch (Exception e) {
Logger.error(e.getMessage());
}
if (!Toolkit.isEmpty(billTempletBodyVOList)) {
BillItem[] bodyItems = new BillItem[billTempletBodyVOList.size()];
int index = 0;
for (BillTempletBodyVO billTempletBodyVO : billTempletBodyVOList) {
bodyItems[index] = new BillItem(billTempletBodyVO, true);
bodyItems[index].setWidth(100);
index++;
}
BillData billdata = new BillData();
billdata.setHeadItems(bodyItems);
return billdata;
}
return null;
}
/**
* 说明:
* 给界面赋值
* 创建人: 李林君 邮箱:
* 创建日期: 2013-8-15
*
* @param invcode
* @param pk_publishtype
* @param nprice
* @param invname
* @param visbn
*/
public void setConditionData(String pk_invbasdoc) {
IUAPQueryBS service = NCLocator.getInstance().lookup(IUAPQueryBS.class);
// 表头字段赋值
StringBuilder sql = new StringBuilder();
sql.append("select ");
sql.append("pk_publishtype,");
sql.append("pk_btencategory,");
sql.append("pk_invcl,");
sql.append("veditor,");
sql.append("vtranslator,");
sql.append("pk_grade,");
sql.append("dpublishingdate,");
sql.append("vpublishingno,");
sql.append("pk_folio,");
sql.append("pk_binding,");
sql.append("pk_taxitems,");
sql.append("pk_caricategory,");
sql.append("vrecrdtype,");
sql.append("pk_invbasdoc ,");
sql.append("invcode,");// 14
sql.append("pk_publishtype,");
sql.append("nprice,");
sql.append("visbn,");
sql.append("invname ");
sql.append(" from bd_invbasdoc where pk_invbasdoc='"
+ pk_invbasdoc
+ "'");
sql.append(" and isnull(dr,0)=0");
try {
ArrayList<Object[]> invlist =
(ArrayList<Object[]>) service.executeQuery(sql.toString(), new ArrayListProcessor());
if (null != invlist
&& invlist.size() > 0) {
cardPanel.setHeadItem("pk_publishtype", invlist.get(0)[0]);
cardPanel.setHeadItem("pk_btencategory", invlist.get(0)[1]);
cardPanel.setHeadItem("pk_invcl", invlist.get(0)[2]);
cardPanel.setHeadItem("veditor", invlist.get(0)[3]);
cardPanel.setHeadItem("vtranslator", invlist.get(0)[4]);
cardPanel.setHeadItem("pk_grade", invlist.get(0)[5]);
cardPanel.setHeadItem("dpublishingdate", invlist.get(0)[6]);
cardPanel.setHeadItem("vpublishingno", invlist.get(0)[7]);
cardPanel.setHeadItem("pk_folio", invlist.get(0)[8]);
cardPanel.setHeadItem("pk_binding", invlist.get(0)[9]);
cardPanel.setHeadItem("pk_taxitems", invlist.get(0)[10]);
cardPanel.setHeadItem("pk_caricategory", invlist.get(0)[11]);
cardPanel.setHeadItem("vrecrdtype", invlist.get(0)[12]);
cardPanel.setHeadItem("cinventorycode", invlist.get(0)[14]);
cardPanel.setHeadItem("pk_publishtype", invlist.get(0)[15]);
cardPanel.setHeadItem("nprice", invlist.get(0)[16]);
cardPanel.setHeadItem("visbn", invlist.get(0)[17]);
cardPanel.setHeadItem("invname", invlist.get(0)[18]);
String sqlonhand="select nonhandnum from ic_onhandnum where cinvbasid ='"+pk_invbasdoc+"'";
BigDecimal nonhandnum= (BigDecimal) service.executeQuery(sqlonhand, new C