NC二次開發常用的方法
阿新 • • 發佈:2019-02-11
//這張表存放的是所有單據模板的資訊表 如果不知道單據模板的資訊後可在資料庫中查詢
PUB_BILLTEMPLET
//這張表是列印模板的表改模板可以再此表修改
pub_print_template
//獲取表頭某個欄位的值
getBillCardPanel().getHeadItem("kitarea").getValueObject()
//獲取當前登入人資訊
ClientEnvironment.getInstance().getUser().getUserName()
//獲取當前登入人PK
String userpk = getBillUI()._getOperator();
//獲取當前系統時間
String RefundTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//獲取登入時間
String date = ClientEnvironment.getInstance().getBusinessDate().toString();
//一樣獲取登入時間
UFDate date = getUi()._getDate();
//系統登入時間
String query_actiondate = sf.format(new Date(new Long(InvocationInfoProxy.getInstance().getDate())));
用時間隨機生成數
new SimpleDateFormat("yyyyMMddHHmmssSSS") .format(new Date() );
//給表體某個欄位設值
getBillCardPanelWrapper().getBillCardPanel().getBillModel("pm_cm_material").setValueAt(matervos[i].getInvclass(), i, "invclass");
獲取參照欄位裡面的值
UIRefPane capplydeptref = (UIRefPane) getBillCardPanel().getHeadItem("capplydeptid").getComponent();
capplydeptref.getRefPK();
capplydeptref.getRefName();
capplydeptref.getRefCode();
//給參照欄位賦值
UIRefPane capplyref = (UIRefPane) getBillCardPanel().getHeadItem("capplydeptname").getComponent();
capplyref.setPK(pk_deptdoc);
capplyref.setName(deptname);
//獲取一個VO物件從VO中取出值
SoChangenameNewVO[] customerVO = (SoChangenameNewVO[]) getBillCardPanelWrapper()
.getBillCardPanel().getBillModel("ps_so_changename_new").getBodyValueVOs(SoChangenameNewVO.class.getName());
getBillUI().showHintMessage("") 介面底部出現提示
String strControl = ParamReader.getParamter(_getCorp().getPrimaryKey().toString(), IParamCode.PS_zhgwth).toString();
獲取按鈕引數
IParamCode.PS_zhgwth 在IParamCode.PS_zhgwth 中定義
//UFDouble 型別的取值和通過UFDouble 型別的判斷
UFDouble Num = new UFDouble(String.valueOf(returnVOs[i].getAttributeValue("nsbigmny")));
Double doubleNum=Num.toDouble();
if(doubleNum==0){
ProjectUtil pu = new ProjectUtil();
String house = returnVOs[i].getAttributeValue("pk_house").toString();
// String project = returnVOs[i].getAttributeValue("project").toString();
ArrayList<Object[]> list = pu.getNbroddaccountreceiv(house);
if(list.size()>0){
UFDouble a=new UFDouble(0);
for(int f=0;f<list.size();f++){
String b =String.valueOf(list.get(f)[0]);
if(!b.equals("null")){
a=a.add(new UFDouble(b));
}
}
//讓某個欄位達到是否可編輯效果
getBillCardWrapper().getBillCardPanel().getBillModel("zh_dggcc_sckz_b1").setCellEditable(row, colName, false);
//日期時間相加
String RefundTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
Calendar ca = Calendar.getInstance();
int year = Integer.parseInt(RefundTime.substring(0,4));
ca.set(Calendar.YEAR,year);
int month = Integer.parseInt(RefundTime.substring(5,7));
ca.set(Calendar.MONTH, month-1);
int day = Integer.parseInt(RefundTime.substring(8,10));
ca.set(Calendar.DAY_OF_MONTH, day+91);
SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sp.format(ca.getTime()));
//在介面彈出一個提示框
在ClientEventHandler中
MessageDialog.showOkCancelDlg(getBillUI(),"提示","錯誤提示");
在ClientUI中
MessageDialog.showOkCancelDlg(this,"提示","錯誤提示");
//清空表體參照資料出來的當前行
getBillCardPanel().getBillModel("hfgf_jhsdiscount").clearRowData(e.getRow(), new String[]{"vdbcode", "vdbname", "pk_currtype", "currtype", "ncurrrate", "fdbaccountmode", "fdiscountmode", "ndiscountrate", "bisrefmodify", "dbegindate", "dfinishdate"});
//在UI類中呼叫EventHandler類
((MyEventHandler)getManageEventHandler()).onBoLineDel();
//用SQL獲取時間
select GETDATE() as '當前日期',
DateName(year,GetDate()) as '年',
DateName(month,GetDate()) as '月',
DateName(day,GetDate()) as '日',
DateName(dw,GetDate()) as '星期',
DateName(week,GetDate()) as '週數',
DateName(hour,GetDate()) as '時',
DateName(minute,GetDate()) as '分',
DateName(second,GetDate()) as '秒'
//查詢資料庫以VO的形式返回---在報表中使用放入表體中比較好
ArrayList<SuperVO> listSuperVO = (ArrayList<SuperVO>) query.executeQuery(sql, new BeanListProcessor(Class.forName(CrmDdHouseRptVo.class.getName())));
//編輯儲存警告
this.billForm.getBillCardPanel().getBillModel().cellShowWarning(i, "goodsno");
1.//模擬觸發重新整理按鈕 相當於在介面上點選重新整理按鈕
//new一個按鈕
nc.ui.pubapp.uif2app.actions.RefreshSingleAction refreshaction=new RefreshSingleAction();
//傳資料給這個按鈕
refreshaction.setModel(this.getModel());
//新增一個事件。。。模擬這個按鈕事件
ActionEvent e1=new ActionEvent(refreshaction, 1001, "重新整理");
//執行這個按鈕的doAction方法,把這個模擬事件傳進去
refreshaction.doAction(e1);
// 其他按鈕也應該類似