Exemplo n.º 1
0
 /**
  * 删除ds中已经存在的数据行
  *
  * @param ds
  */
 protected void deleteExistRows(Dataset ds) {
   if (ds.getCurrentRowData() == null) {
     return;
   }
   Row[] rows = ds.getCurrentRowData().getRows();
   if (rows == null || rows.length == 0) {
     return;
   }
   Dataset2SuperVOSerializer serializer = new Dataset2SuperVOSerializer();
   SuperVO[] pvos = serializer.serialize(ds, rows);
   try {
     CpbServiceFacility.getCpSuperVOBill().deleteSuperVOs(pvos);
   } catch (CpbBusinessException e) {
     LfwLogger.error(e.getMessage(), e);
     throw new LfwRuntimeException(e.getMessage());
   }
   for (int i = 0; i < rows.length; i++) {
     ds.getCurrentRowData().removeRow(rows[i]);
   }
 }
Exemplo n.º 2
0
  public void execute() {
    ViewContext widgetctx = getLifeCycleContext().getViewContext();

    String dsId = getSlaveDataset(widgetctx);
    Dataset ds = widgetctx.getView().getViewModels().getDataset(dsId);
    Row selRow = ds.getSelectedRow();
    // 未选择行,给出提示
    if (selRow == null) throw new LfwRuntimeException("请选择要删除的行!");
    // 持久化
    Dataset2SuperVOSerializer ser = new Dataset2SuperVOSerializer();
    SuperVO vo = ser.serialize(ds, selRow)[0];
    if (vo.getPrimaryKey() == null) delete = true;
    if (delete) doDeleteVO(vo);
    else doCache(vo, ds, selRow);
    if (selRow != null) {
      int rowIndex = ds.getRowIndex(selRow);
      ds.removeRow(rowIndex);
      if (rowIndex > ds.getCurrentRowCount() - 1) rowIndex = ds.getCurrentRowCount() - 1;
      ds.setRowSelectIndex(rowIndex);
    }
    doAfterDelLine();
  }