1、删除分录
this.kdtOtherEntrys.removeRows();
this.kdtSettleEntry.removeRow(i);
2、新增行
this.kdtOtherEntrys.addRow();
this.kdtEntrys.getCell(0, "period").setValue("期初");
this.kdtEntrys.getCell(0, "periodNum").setValue(0);
3、获取单元格数据,给单元格赋值
Object custType = this.kdtSettleEntry.getCell(i, "custType").getValue();
this.kdtOtherEntrys.getCell(0, "fa").setValue(prmtfa.getData());
4、锁定行
kdtAssEntrys.getRow(0).getStyleAttributes().setLocked(true);
5、设置字体
kdtAssEntrys.getRow(0).getStyleAttributes().setItalic(true);
6、显示合计行
@Override
protected void setTableToSumField() {
super.setTableToSumField();
setTableToSumField(kdtEntrys, new String[] {"amtLease","amtDepreciation","amtInterest","amtPrincipal"});
}
7、列表显示格式
table.getColumn(colIndex).getStyleAttributes().setNumberFormat(formatString);
table.getCell(rowIndex, colIndex).getStyleAttributes().setNumberFormat(formatString);
####
this.kdtEntrys.getRow(0).getStyleAttributes().setBackground(new Color(167,167,167));
####
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("0.00");
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("0.##");
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("#,##0.00");
####
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("yyyy-m-d");
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("yyyy-MM-dd");
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("yyyy-MM-dd HH:mm:ss");
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("yyyy年MM月dd日");
####
table.getColumn(colIndex).getStyleAttributes().setNumberFormat("0%");
分录按钮隐藏
kdtContractEntry_detailPanel.getAddNewLineButton().setVisible(false);
kdtContractEntry_detailPanel.getInsertLineButton().setVisible(false);
kdtContractEntry_detailPanel.getRemoveLinesButton().setVisible(false);
监听分录按钮(新增、删除、插入行)
class DetailPanelImp implements IDetailPanelListener {
public DetailPanelImp() {}
public void beforeEvent(DetailPanelEvent e) throws Exception {}
public void afterEvent(DetailPanelEvent e) throws Exception {}
}
IDetailPanelListener listener = new DetailPanelImp() {
public void beforeEvent(DetailPanelEvent e) throws Exception {
judgeIsDel(e);
}
private void judgeIsDel(DetailPanelEvent e) {
int[] selectRows = KDTableUtil.getSelectedRows(kdtSettleEntry);
int length = selectRows.length;
String type = "";
if(length >= 1){
for(int i = 0 ; i < length ; i++){
type = kdtSettleEntry.getCell(selectRows[i],"custType").getValue().toString();
if("客户".equals(type)){
MsgBox.showError("客户禁止删除");
SysUtil.abort();
}
}
}
}
};
kdtSettleEntry_detailPanel.addRemoveListener(listener);
监听分录
kdtSettleEntry.addKDTEditListener(new KDTEditAdapter(){
public void editStopped(KDTEditEvent e) {
try {
settleEntryChange(e);
}
catch (Exception exc) {
handUIException(exc);
}
}
});
``
protected void settleEntryChange(KDTEditEvent e) {
int rowIndex = e.getRowIndex();
int colIndex = e.getColIndex();
int count = (kdtSettleEntry.getRowCount());
if(colIndex == 3 || colIndex == 4 || colIndex == 5){
entryQtyChange();
}
if(colIndex == 6){
entryPriceChange();
}
if(colIndex == 7){
entryCalSettleAmt();
}
if(colIndex == 8){
entryCalSettlePrice();
}
private void entryPriceChange() {
BigDecimal price0 = kdtSettleEntry.getCell(0, "price").getValue() == null ? new BigDecimal("0") : new BigDecimal(kdtSettleEntry.getCell(0, "price").getValue() + "");
BigDecimal price1 = kdtSettleEntry.getCell(1, "price").getValue() == null ? new BigDecimal("0") : new BigDecimal(kdtSettleEntry.getCell(1, "price").getValue() + "");
BigDecimal amtHF = getAmtKJ(this.txtamtHF);
BigDecimal amtLF = getAmtKJ(this.txtamtLF);;
BigDecimal amtHFF = getAmtKJ(this.txtamtHFF);;
BigDecimal amtSF = getAmtKJ(this.txtamtSF);;
BigDecimal amtRFYY = getAmtKJ(this.txtamtRFYX);;
BigDecimal amtRFYQD = getAmtKJ(this.txtamtRFYQD);
BigDecimal amtLD25 = getAmtKJ(this.txtamtLD25);
BigDecimal amtLD80 = getAmtKJ(this.txtamtLD80);
BigDecimal amtM10 = getAmtKJ(this.txtamtM10);
BigDecimal amtM25 = getAmtKJ(this.txtamtM25);
BigDecimal priceSettle0 = price0.subtract(amtHF).subtract(amtLF).subtract(amtHFF).subtract(amtSF)
.subtract(amtRFYY).subtract(amtRFYQD).subtract(amtLD25).subtract(amtLD80).subtract(amtM10).subtract(amtM25);
BigDecimal priceSettle1 = price1.subtract(amtHF).subtract(amtLF).subtract(amtHFF).subtract(amtSF)
.subtract(amtRFYY).subtract(amtRFYQD).subtract(amtLD25).subtract(amtLD80).subtract(amtM10).subtract(amtM25);
kdtSettleEntry.getCell(0, "priceSettle").setValue(priceSettle0);
kdtSettleEntry.getCell(1, "priceSettle").setValue(priceSettle1);
entryCalSettleAmt();
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)