Hi,
Inside a form I have a button called Multivencimientos which when clicked it does the following:
void clicked()
{
CustVendPaymSched custVendPaymSched;
if (! CustPaymSched::exist(salesParmTable.TableId,salesParmTable.RecId))
{
custVendPaymSched = CustVendPaymSched::construct(SysModule::Cust,salesParmTable);
if (specQty.selection() == SalesUpdate::All && CustPaymSched::exist(salesParmTable.salesTable().TableId, salesParmTable.salesTable().RecId))
{
custVendPaymSched.copyCustVendPaymSched(CustPaymSched::find(salesParmTable.salesTable().TableId, salesParmTable.salesTable().RecId));
}
else
{
custVendPaymSched.copyPaymSched(PaymSched::find(salesParmTable.salesTable().PaymentSched));
salesParmTable.createPaymentSched();
}
}
super();
}
Now, I have another button called Ok inside the same form which has the following when clicked:
void clicked()
{
boolean procced = true;
LecVoucherType doc; //LECMMV03.ln
custinvoicejour _custinvoicejour; //LEC081.ln
custinvoicejour _custinvoicejour1; //LEC081.ln
//LEC085.sn
LecVoucherType docType;
OpeningId ID_Establecimiento;
LecInvSecForOpening _LecInvSecForOpening;
LecGuiaRemSecForOpening _LecGuiaRemSecForOpening;
LecRetSecForOpening _LecRetSecForOpening;
LecDebNoteSecForOpening _LecDebNoteSecForOpening;
LecCredNoteSecForOpening _LecCredNoteSecForOpening;
LecInvConfTable _LecInvConfTable;
LecGuiaRemConfTable _LecGuiaRemConfTable;
LecCredDocConfTable _LecCredDocConfTable;
LecDebDocConfTable _LecDebDocConfTable;
SalesParmTable _salesParmTable1; //LEC0041.nl
FormDataObject myField;//PROICE_002.nl
int MaximoDocumento = 0;
int MaximoTalonario = 0;
//LEC085.en
;
if(PrintFormLetter.visible() == true && DocumentStatus==DocumentStatus::Invoice)
{
if (printFormLetter.checked() == false)
{
throw error ("NOV: El check 'Imprimir factura' debe estar marcado para poder continuar");
}
}
if( documentStatus != DocumentStatus::Confirmation &&
documentStatus != DocumentStatus::PackingSlip)
{
_salesParmTable1 = salesParmTable_ds.getFirst();
while (_salesParmTable1)
{
if (!element.validateSalesItemTaxFields(_salesParmTable1.SalesId))
{
procced = false;
}
_salesParmTable1 = salesParmTable_ds.getNext();
}
}
if(DocumentStatus==DocumentStatus::PackingSlip)
{
_salesParmTable1 = salesParmTable_ds.getFirst();
while (_salesParmTable1)
{
if (!element.valida_OV_GuiaRem(_salesParmTable1.SalesId))
{
procced = false;
}
_salesParmTable1 = SalesParmTable_ds.getNext();
}
}
if(DocumentStatus==DocumentStatus::Invoice)
{
_salesParmTable1 = salesParmTable_ds.getFirst();
while (_salesParmTable1)
{
if (!element.valida_OV_Factura(_salesParmTable1.SalesId))
{
procced = false;
}
_salesParmTable1 = SalesParmTable_ds.getNext();
}
element.compensation(LecRegisterCompensation::Register);//LEC0087.nl
}
if(documentStatus == documentStatus::PackingSlip)
{
if(cbGenerateGuia.checked() && updateNow.checked())
{
procced = LecSaleGuiaRemClass::validateAccountOrder(SalesparmUpdate.SumBy,SalesparmUpdate.SumSalesId);
if(procced)
{
procced = LecSaleGuiaRemClass::validateExistGuiaRemTmp(SalesparmUpdate.SumBy,SalesParmTable_ds,SalesParmUpdate.SumSalesId);
//todo probar validación de que se hayan ingresados datos de guias tmp
}
if(procced)
{
procced = LecSaleGuiaRemTmpTable::isMandatoryDataInSaleGuiaRemTmp(SalesParmTable.ParmId);
}
if(procced)
{
procced = LecSaleGuiaRemClass::valMaxNumOflinesPerSalesGuia(SalesParmTable);
}
}
}
if(procced)
{
if(SalesParmTable.salesTable().LecIsDebitNote == NoYesCombo::Yes && SalesParmupdate.SpecQty != SalesUpdate::All)
{
procced = false;
info("@LEC1420");
}
}
if(procced)
{
doc = LecVoucherTypeClass::getDocType(SalesParmTable.DocType);
if(doc.SystemDocType == LecDocTypeEnum::DocInternoReverso)
{
if(SalesParmTable.LecModifiedDocNum_Reverso == '')
throw error('LEC: Usted seleccionó el tipo de documento ' SalesParmTable.DocType ', es necesario seleccionar una ' enum2str(LecDocTypeEnum::CreditDoc) ' o una ' enum2str(LecDocTypeEnum::DebNote));
}
myField = SalesParmUpdate_ds.object(fieldnum(SalesParmUpdate,SpecQty));
myField.modified();
if(DocumentStatus==DocumentStatus::PackingSlip || DocumentStatus==DocumentStatus::Invoice)
{
if(LecEstabPredUserClass::ValidatePostSales(DocumentStatus,SalesParmTable,cbGenerateGuia.checked(),updateNow.checked())==true)
super();
}
else
{
super();
}
}
}The thing is that I need to pass through the code inside the Multivencimientos button even if it wasn't clicked every time. I was thinking of just copying the code inside the button Ok but I think that might cause a problem of duplicates or something like that if a user first clicks the Multivencimientos button and later the Ok button. It also must have a validation to check if the button was already clicked and in that case it wont need to pass through it again.