您的位置:首页 > 其它

判断表格某一列是否重复或空

2010-03-09 22:05 288 查看
/**

* 判断分录表中的某一列是否存在空值

* @param kdtEntry

* @param colName

* @throws BOSException

*/

public static void checkTableColumnEmpty(

com.kingdee.bos.ctrl.kdf.table.KDTable kdtEntry, String colName)

throws BOSException {

for (int i = 0, n = kdtEntry.getRowCount(); i < n; i++) {

Object temp = kdtEntry.getRow(i).getCell(colName).getValue();

if (temp == null || temp.toString().equals("")) {

throw new BOSException("第" + (i + 1) + "行的"

+ kdtEntry.getHeadRow(0).getCell(colName).getValue()

+ "不能为空");

}

}

}

/**

* 检查表格某n列是否为空

* @param kdtEntry:表格

* @param colNames:列名数组

* @throws BOSException

*/

public static void checkTableColumnsEmpty(com.kingdee.bos.ctrl.kdf.table.KDTable kdtEntry,

String colNames[]) throws BOSException {

int i = 0;

for (int n = colNames.length; i < n; i++)

checkTableColumnEmpty(kdtEntry, colNames[i]);

}

/**

* 检查某一列是否重复

* @param kdtEntry

* @param colName

* @throws BOSException

*/

public static void checkTableColumnRepeat(com.kingdee.bos.ctrl.kdf.table.KDTable kdtEntry, String colName)

throws BOSException {

int i = 0;

for (int n = kdtEntry.getRowCount(); i < n; i++) {

Object temp = kdtEntry.getRow(i).getCell(colName).getValue();

for (int j = i + 1; j < n; j++)

if (temp.equals(kdtEntry.getRow(j).getCell(colName).getValue()))

throw new BOSException("第" + (i + 1)+ "行和第"+ (j + 1)+

"行的"+ kdtEntry.getHeadRow(0).getCell(colName).getValue() + "重复");

}

}

public static void checkTableColumnsRepeat(com.kingdee.bos.ctrl.kdf.table.KDTable kdtEntry, String colNames[])

throws BOSException {

int i = 0;

for (int n = colNames.length; i < n; i++)

checkTableColumnRepeat(kdtEntry, colNames[i]);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: