分录中常用方法原创
金蝶云社区-月老玩红线
月老玩红线
10人赞赏了该文章 2,137次浏览 未经作者许可,禁止转载编辑于2021年04月20日 18:22:10

//清空分录

kdtFenlu.removeRows();

// 为分录表格中必录项设置颜色

String[] columns = {"F1"};

for(int i = 0; i < columns.length; i++){

kdtEntry.getColumn(columns[i]).getStyleAttributes().setBackground(new Color(255, 255, 220));

}

//获取分录列名

String cellname = kdtEntrys.getHeadRow (0).qetCell (i) .getValue ().toString ();

String key = kdtEntrys.getColumnKey(j);

//设置表

// kdtEntry_detailPanel.setTitle("仓库列表");

// 隐藏分录右上角功能按钮(新增行、插入行、删除行)

KDWorkButton btnAddNew = kdtTest1_detailPanel.getAddNewLineButton();// 新增行

KDWorkButton btnInsert = kdtTest1_detailPanel.getInsertLineButton();// 插入行

KDWorkButton btnRemove = kdtTest1_detailPanel.getRemoveLinesButton();// 删除行

// 设置按钮不可见

btnAddNew.setVisible(false);

btnInsert.setVisible(false);

btnRemove.setVisible(false);

//增加分录行问题

IRow row = null;

int i = 0;

if (kdtEntry.getRowCount() > i) {

row = kdtEntry.getRow(i);

} else {

row = kdtEntry.addRow();

}

//清除分录

kdtEntry.removeRows();

//分录的控制

kdtEntry.getColumn("unit").getStyleAttributes().setHided(true);//隐藏列

kdtEntry.getColumn("unit").getStyleAttributes().setLocked(true);//锁定列使其不可被编辑

kdtEntry.getColumn("unit").getStyleAttributes().setLocked(true);//锁定单元格

//分录判断是否为空

if(this.kdtTest1.getRowCount()<1){

MsgBox.showInfo("请至少添加一条分录!");

return true;

//MsgBox.showWarning("请至少添加一条分录!");  

//SysUtil.abort(); (程序停止)

}else{

for(int i=0;i<kdttest1.getrowcount();i++){< div="" style="">

if(kdtTest1.getCell(i, "testxiangmu").getValue()==null){

MsgBox.showInfo("分录中,第" + (i + 1) + "行中的检验项目必须填写!");

return true;

}

if(kdtTest1.getCell(i, "cankao").getValue()==null){

MsgBox.showInfo("分录中,第" + (i + 1) + "行中的参考标准必须填写!");

return true;

}

if(kdtTest1.getCell(i, "morenzhi").getValue()==null){

MsgBox.showInfo("分录中,第" + (i + 1) + "行中的默认值必须填写!");

return true;

}

}

}

//分录中校验保存数据是否重复(用Map的Key值唯一性,将字段拼接,然后做比较)

Mapmap = new HashMap();

for(int f =0;f<kdtfenlu.getrowcount();f++){< div="" style="">

String str =kdtFenlu.getCell(f, "bianma").getValue()+"_"+kdtFenlu.getCell(f, "name").getValue()+"_"+kdtFenlu.getCell(f, "zubie").getValue();

if(!map.containsKey(str)){

map.put(str, 1);

}else {

MsgBox.showInfo("保存的类型重复");

return true;

}

}

/**

* 设置分录监听(这里应该加到onload方法,在打开时调用)

*/

kdtEntry.addKDTEditListener(new KDTEditAdapter() {

@Override

public void editStopped(KDTEditEvent e) {

try {

onelist(e);

} catch (BOSException e1) {

e1.printStackTrace();

} catch (SQLException e1) {

e1.printStackTrace();

}

}

});

/**

* 分录监听(这个放在外面就好)

*/

public void onelist(KDTEditEvent e) throws BOSException, SQLException {

int rowIndex = e.getRowIndex();

int colIndex = e.getColIndex();

if (colIndex == kdtEntry.getColumnIndex("XXX")) {

if (kdtEntry.getCell(rowIndex, kdtEntry.getColumnIndex("XXX")).getValue() != null

&& !"".equals(kdtEntry.getCell(rowIndex,kdtEntry.getColumnIndex("XXX")).getValue())) {

CostCenterOrgUnitInfo costCenterOrgUnitInfo = (CostCenterOrgUnitInfo) kdtEntry.getCell(rowIndex, "department").getValue();

StorageOrgUnitInfo Storageinfo = (StorageOrgUnitInfo) this.prmtstorageunit.getValue();

String fid = null;

String sql = "XXX";

IRowSet rs = com.kingdee.bos.dao.query.SQLExecutorFactory.getRemoteInstance(sql).executeSQL();

while(rs.next()){

fid = rs.getString(1);

}

}

}

}

/**

* 分录三个小按钮事件(新增分录时,默认赋值)

*/

//新增分录监听器

IDetailPanelListener Entry_detailPanelAddListener=null;

//插入分录监听器

IDetailPanelListener Entry_detailPanelInsertListener=null;

//删除分录监听器

IDetailPanelListener Entry_detailPanelRemoveListener=null;

protected void kdtEntrySetValue(){

//添加新增事件

if(Entry_detailPanelAddListener==null){

Entry_detailPanelAddListener = new IDetailPanelListener(){

//点击事件之前

public void afterEvent(DetailPanelEvent e) throws Exception {

//加需求

}

//点击事件之后

public void beforeEvent(DetailPanelEvent e) throws Exception {

}

};

}

//添加插入事件

if(Entry_detailPanelInsertListener==null){

Entry_detailPanelInsertListener = new IDetailPanelListener(){

public void afterEvent(DetailPanelEvent e) throws Exception {

//加需求

}

public void beforeEvent(DetailPanelEvent e) throws Exception {

//加需求

}

};

}

//添加删除事件

if(Entry_detailPanelRemoveListener==null){

Entry_detailPanelRemoveListener = new IDetailPanelListener(){

public void afterEvent(DetailPanelEvent e) throws Exception {

//加需求

}

public void beforeEvent(DetailPanelEvent e) throws Exception {

//加需求

}

};

}

//添加监听器方法

kdtTest1_detailPanel.addAddListener(Entry_detailPanelAddListener);

kdtTest1_detailPanel.addInsertListener(Entry_detailPanelInsertListener);

kdtTest1_detailPanel.addRemoveListener(Entry_detailPanelRemoveListener);

}

/**

* 获取分录1t列所有行的申请金额汇总

*/

public double getEntryApplyAmountSum(String t){

double amountSum = 0 ;

int count = this.kdtEntry.getRowCount();

for (int i = 0; i < count; i++) {

IRow row = this.kdtEntry.getRow(i);

if(row.getCell(t).getValue()!=null){

amountSum = amountSum +Double.valueOf(row.getCell(t).getValue().toString());

}

}

return amountSum;

}

/**

* 分录的单位和数量转换处理

*/

public double onepanduanidea() {

double amountSum = 0;

int count = this.kdtEntry.getRowCount();

for (int i = 0; i < count; i++) {

IRow row = this.kdtEntry.getRow(i);

if (row.getCell("Qty").getValue() != null && row.getCell("Unit").getValue() != null) {

MeasureUnitInfo t1 = (MeasureUnitInfo) kdtEntry.getCell(i,"Unit").getValue();

String t2 = t1.getCoefficient().toString();

double oneide = Double.valueOf(t2);

amountSum = amountSum + Double.valueOf(row.getCell("Qty").getValue().toString()) * oneide;

}

}

return amountSum;

}

/**

* 合计行

*/

protected void setTableToSumField() {

setTableToSumField(kdtEntry, new String[] { "qty","lossqty" });

IRow footRow = null;

KDTFootManager footManager = kdtEntry.getFootManager();

if (footManager == null) {

footManager = new KDTFootManager(kdtEntry);

footManager.addFootView();

kdtEntry.setFootManager(footManager);

}

// 计算所有指定行的合计值

footRow = footManager.getFootRow(0);

if (footRow == null) {

footRow = footManager.addFootRow(0);

}

footRow.getCell("storage").setValue("合计");

}

//List界面中,点击某一行中的某个单元格,弹出对应单据

@Override

protected void tblMain_tableClicked(KDTMouseEvent e) throws Exception {

super.tblMain_tableClicked(e);

//单击“结果”那一列时

if (e.getColIndex() == 6) {

//取到储存单据ID列的值

String boID = tblMain.getRow(e.getRowIndex()).getCell(9).getValue().toString();

//弹出对应单据

MessageServiceProvider.showWFBill(this, boID.toString());

//com.kingdee.eas.util.client.MsgBox.showInfo(boID);

}

if (e.getColIndex() == 1) {

int[] selectedRows = com.kingdee.bos.ctrl.kdf.table.util.KDTableUtil.getSelectedRows(tblMain);

int rowindex = selectedRows[0];

String bianma = tblMain.getCell(rowindex, 1).getValue().toString();//物料编码

String jieguo = tblMain.getCell(rowindex, 6).getValue().toString();

UIContext map = new com.kingdee.eas.common.client.UIContext(this);

map.put("bianma", bianma);//订单编号

map.put("jieguo", jieguo);

IUIWindow uiWindow = null;

uiWindow = UIFactory.createUIFactory(UIFactoryName.NEWTAB)

.create(RequestFormEditUI.class.getName(), map, null, OprtState.ADDNEW);

uiWindow.show();

}

//隐藏单元格,第9列则取8;true为隐藏,false为显示。

this.tblMain.getColumn(9).getStyleAttributes().setHided(true);


赞 10