Sales order form changes

Hi!

I added a cancel order button in sales order form, when we click this button sales order will get canceled but here I need to restrict that if any of the lines is delivered it will not allow to cancel the order..

My coding on Clicked method is:

void clicked()
{
    Dialogbutton db1,db2,db3,db4;
    ;
    if(SalesTable.SalesStatus==SalesStatus::Backorder)
    {
        db1 = box::yesNo("Do you want to Cancel PO?", dialogButton::No, "Cancel Order");
        if (db1 == dialogButton::Yes)
        {
            db2 = box::yesNo("This Will Cancel all the PO, no further activities is possible. Do you want to continue?", dialogButton::No, "Cancel Order Confirmation");
            if(db2 == dialogButton::Yes)
            {
                SalesTable.SalesStatus=SalesStatus::Canceled;
                SalesTable.update();
                SalesTable_ds.refresh();
                info(strfmt("%1",SalesTable.SalesId));
             }
          }
    }
    else if( SalesTable.SalesStatus==SalesStatus::Canceled)
    {
        db3=box::yesNo("Do you want to Open PO again?",dialogButton::Yes,"Revoke Cancel");
        if (db3 == dialogButton::Yes)
        {
            db4= box::yesNo("This Will Open all the PO again. Do you want to continue?", dialogButton::Yes, "Open Order Confirmation");
            if(db4 == dialogButton::Yes)
            {
               SalesTable.SalesStatus=SalesStatus::Backorder;
               SalesTable.update();
               SalesTable_ds.refresh();
               info(strfmt("%1",SalesTable.SalesId));
             }
         }
    }
    else
    {
        info( "Process canceled");

    }

}

How could I change my coding there to restrict the button from canceling the order?

Thanks

Related
Recommended