界面上通过按钮批量更新数据很常见,列个更新的例子,方便查阅。
销售订单界面,批量更新行地址:
1.定义继承Runbase的类,使用框架更方便
class UpdateSalesLineAddress extends RunBase { DeliveryAddress deliveryAddress; SalesLine salesLine; DialogField d_deliveryAddress; }
2.Dilog界面设计:
public Object dialog() { Dialog dialog = super(); dialog.caption("标题"); d_deliveryAddress = dialog.addField(extendedTypeStr(DeliveryAddress)); //d_deliveryAddress = dialog.addFieldValue(extendedTypeStr(DeliveryAddress),salesLine.DeliveryAddress); //d_status = dialog.AddField(Enumstr(SalesStatus)); return dialog; }
3.获取Dialog界面中需要更新的值:
public boolean getFromDialog() { boolean ret; ret = super(); deliveryAddress = d_deliveryAddress.value(); return ret; }
4.主方法中进行更新
上次上传时可能部分代码丢失了,这里补段代码,写法类似。
public static void main(Args _args) { FormDataSource formDataSource; SalesSettleTable salesSettleTableloc; CustPackingSlipJour custpackingSlipJour; CustPackingSlipTrans custpackingSlipTrans; ConfirmGenerateSettlement salesSettlement = new ConfirmGenerateSettlement(); if(!_args) { throw Error("@SYS22539"); } formDataSource = _args.caller().dataSource(); ttsbegin; if(formDataSource) { salesSettleTableloc = salesSettlement.insertSettlement(); if(_args.dataset() == tableNum(CustPackingSlipJour)) { for(custpackingSlipJour = formDataSource.getFirst(true) ? formDataSource.getFirst(true) : formDataSource.cursor(); custpackingSlipJour; custpackingSlipJour = formDataSource.getNext()) { while select custpackingSlipTrans where custpackingSlipTrans.PackingSlipId == custpackingSlipJour.PackingSlipId && custpackingSlipTrans.SalesId == custpackingSlipJour.SalesId && custpackingSlipTrans.DeliveryDate == custpackingSlipJour.DeliveryDate { salesSettlement.insertToSalesParmLine(custpackingSlipTrans); } custpackingSlipJour.selectForUpdate(true); custpackingSlipJour.Settled = NoYes::Yes; custpackingSlipJour.doUpdate(); } } } ttscommit; }