/**
* 判断分录表中的某一列是否存在空值
* @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]);
}
判断表格某一列是否重复或空
最新推荐文章于 2021-05-24 22:19:42 发布