class DGS_PurchTableFormEventHandler
{
static RecId _curRecId;
static FormDataSource purchTable_ds;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, VendTable_DGS), FormDataSourceEventType::Initialized)]
public static void VendTable_DGS_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
var overrides = DGS_PurchTableFormExtensionOverrides::construct();
sender.registerOverrideMethod(methodStr(FormDataSource, validateWrite),methodStr(DGS_PurchTableFormExtensionOverrides,dgs_vendTable_validateWrite), overrides);
sender.registerOverrideMethod(methodStr(FormDataSource, write),methodStr(DGS_PurchTableFormExtensionOverrides,dgs_vendTable_write), overrides);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, VendTable), FormDataSourceEventType::Initialized)]
public static void VendTable_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
var overrides = DGS_PurchTableFormExtensionOverrides::construct();
sender.registerOverrideMethod(methodStr(FormDataSource, validateWrite),methodStr(DGS_PurchTableFormExtensionOverrides,dgs_vendTable_validateWrite), overrides);
sender.registerOverrideMethod(methodStr(FormDataSource, write),methodStr(DGS_PurchTableFormExtensionOverrides,dgs_vendTable_write), overrides);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchTable), FormDataSourceEventType::QueryExecuted)]
public static void PurchTable_OnQueryExecuted(FormDataSource sender, FormDataSourceEventArgs e)
{
// info("OnQueryExecuted : (1) " + any2str(_curRecId));
if(_curRecId > 0)
{
PurchTable purchTable = PurchTable::findRecId(_curRecId);
purchTable_ds.findRecord(purchTable);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchTable), FormDataSourceEventType::Activated)]
public static void PurchTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
// info("activate : (1) " + any2str(_curRecId));
_curRecId = sender.cursor().RecId;
// info("activate : (2) " +any2str(_curRecId));
purchTable_ds = sender.formRun().dataSource("PurchTable"); //DataSource form DGS_OverallReleaseProductView
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, POSalesInvoice), FormControlEventType::Clicked)]
public static void POSalesInvoice_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
PurchTable _purchTable = sender.formRun().dataSource("PurchTable").cursor();
sender.formRun().args().record(_purchTable);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, DGS_PurchOrderOverallView), FormDataSourceEventType::Initialized)]
public static void DGS_PurchOrderOverallView_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
sender.queryBuildDataSource().addLink(fieldNum(PurchTable, PurchId), fieldNum(DGS_PurchOrderOverallView, PurchId));
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, DGS_POGridRemainPurchPhysicalView), FormDataSourceEventType::Initialized)]
public static void DGS_POGridRemainPurchPhysicalView_OnInitialized(FormDataSource sender, FormDataSourceEventArgs e)
{
sender.queryBuildDataSource().addLink(fieldNum(PurchTable, PurchId), fieldNum(DGS_POGridRemainPurchPhysicalView, PurchId));
}
/// <summary>
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(classStr(PurchTableInteraction), methodStr(PurchTableInteraction, enableHeaderActions))]
public static void PurchTableInteraction_Post_enableHeaderActions(XppPrePostArgs args)
{
DGS_PurchTableFormEventHandler::updateHeaderActions(args);
}
/// <summary>
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(classStr(PurchTableInteraction), methodStr(PurchTableInteraction, purchLine_DS_selectionChanged))]
public static void PurchTableInteraction_Post_purchLine_DS_selectionChanged(XppPrePostArgs args)
{
DGS_PurchTableFormEventHandler::updateHeaderActions(args);
}
/// <summary>
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(classStr(PurchTableInteraction), methodStr(PurchTableInteraction, purchTable_DS_selectionChanged))]
public static void PurchTableInteraction_Post_purchTable_DS_selectionChanged(XppPrePostArgs args)
{
DGS_PurchTableFormEventHandler::updateHeaderActions(args);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchLine), FormDataSourceEventType::SelectionChanged)]
public static void PurchLine_OnSelectionChanged(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun element = sender.formRun(); //form element
FormDataSource purchLine_ds = sender.formRun().dataSource("PurchLine");
// PurchTable _purchTable = sender.formRun().dataSource("PurchTable").cursor();
if(purchLine_ds.allowEdit())
{
//20191105, hide the po line's button
FormControl ButtonLineQuickQuote = element.design(0).controlName("ButtonLineQuickQuote");
FormControl RetailAddItemMenuItem = element.design(0).controlName("RetailAddItemMenuItem");
ButtonLineQuickQuote.enabled(true);
RetailAddItemMenuItem.enabled(true);
}
else
{
//20191105, hide the po line's button
FormControl ButtonLineQuickQuote = element.design(0).controlName("ButtonLineQuickQuote");
FormControl RetailAddItemMenuItem = element.design(0).controlName("RetailAddItemMenuItem");
ButtonLineQuickQuote.enabled(false);
RetailAddItemMenuItem.enabled(false);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchTable), FormDataSourceEventType::SelectionChanged)]
public static void PurchTable_OnSelectionChanged(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun element = sender.formRun(); //form element
PurchTable purchTable = sender.formRun().dataSource("PurchTable").cursor();
if(purchTable.DocumentState > VersioningDocumentState::Approved)
{
// if confrim, cannot edit Vendor invocie no & prepayment %
FormControl PurchTable_THK_Prepayment = element.design(0).controlName("PurchTable_THK_Prepayment");
FormControl PurchTable_THK_VendorInvoiceNo = element.design(0).controlName("PurchTable_THK_VendorInvoiceNo");
PurchTable_THK_Prepayment.enabled(false);
PurchTable_THK_VendorInvoiceNo.enabled(false);
}
else
{
// if confrim, cannot edit Vendor invocie no & prepayment %
FormControl PurchTable_THK_Prepayment = element.design(0).controlName("PurchTable_THK_Prepayment");
FormControl PurchTable_THK_VendorInvoiceNo = element.design(0).controlName("PurchTable_THK_VendorInvoiceNo");
PurchTable_THK_Prepayment.enabled(true);
PurchTable_THK_VendorInvoiceNo.enabled(true);
}
}
public static void updateHeaderActions(XppPrePostArgs args)
{
PurchTableInteraction purchTableInteraction = args.getThis();
FormDataSource purchLine_ds;
FormDataSource _purchTable_ds;
PurchTable purchTable;
Common common_pl = purchTableInteraction.page().activeRecord('PurchLine');
Common common_pt = purchTableInteraction.page().activeRecord('PurchTable');
if(common_pl.isFormDataSource())
{
purchLine_ds = common_pl.dataSource();
}
if(common_pt.isFormDataSource())
{
_purchTable_ds = common_pt.dataSource();
purchTable = _purchTable_ds.cursor();
}
if(purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, buttonRemovePurchPrepayTable))
|| purchTable.DocumentState > VersioningDocumentState::Approved)
{
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, MarkupTrans_HeadingPurchTable),false);
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, AllocateMarkup),false);
purchLine_ds.allowEdit(false);
purchLine_ds.allowCreate(false);
purchLine_ds.allowDelete(false);
purchLine_ds.refresh();
}
else
{
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, MarkupTrans_HeadingPurchTable),true);
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, AllocateMarkup),true);
purchLine_ds.allowEdit(true);
purchLine_ds.allowCreate(true);
purchLine_ds.allowDelete(true);
purchLine_ds.refresh();
}
// 20191106 - always make dim with Prepayment button, will udpate later with premission.
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, PrepayPurchTableHeading),false);
// 20191106 - if Approval Status (Document State) is Confrimed, able for user to click Re-open
if(purchTable.DocumentState == VersioningDocumentState::Confirmed)
{
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, buttonReopen),true);
}
else
{
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, buttonReopen),false);
}
// VoucherTransactions btn
VendInvoiceJour _vendInvoiceJour;
_vendInvoiceJour = VendInvoiceJour::findFromPurchId(purchTable.purchId);
if(_vendInvoiceJour)
{
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, btnVoucherTransactions), true);
}
else
{
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, btnVoucherTransactions), false);
}
WMSJournalTable _wmsJournalTable;
purchTableInteraction.page().actionPaneControlEnabled(formcontrolstr(PurchTable, buttonUpdatePackingSlip), WMSJournalTable::nonRecItemArrivalExist(purchTable.purchId));
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, buttonRemovePurchPrepayTable), FormControlEventType::Clicked)]
public static void buttonRemovePurchPrepayTable_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
FormDataSource _purchTable_ds = sender.formRun().dataSource("PurchTable");
_purchTable_ds.executeQuery();
}
/// <summary>
/// Change PO Document state to Approval
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, buttonReopen), FormControlEventType::Clicked)]
public static void buttonReopen_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
FormDataSource _purchTable_ds = sender.formRun().dataSource("PurchTable");
PurchTable _purchTable = _purchTable_ds.cursor();
if(_purchTable.THK_Prepayment)
{
Args args = new Args();
args.record(_purchTable);
args.caller(element);
new MenuFunction(menuitemActionStr(PurchPrepayRemove), MenuItemType::Action).run(args);
}
else
{
ttsbegin;
_purchTable.selectForUpdate(true);
_purchTable.DocumentState = VersioningDocumentState::Approved;
_purchTable.update();
ttscommit;
}
_purchTable_ds.executeQuery();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, btnVoucherTransactions), FormControlEventType::Clicked)]
public static void btnVoucherTransactions_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun();
PurchTable _purchTable = sender.formRun().dataSource("PurchTable").cursor();
DGS_PurchTableFormEventHandler::openPurchVoucher(_purchTable , element);
}
public static void openPurchVoucher( PurchTable _purchTable, FormRun element)
{
MenuFunction _MenuFunction;
Args _args;
_args = new Args();
_args.parmEnumType(enumnum(AllChosen));
_args.parmEnum(AllChosen::All);
_args.record(_purchTable);
_args.parm(formStr(LedgerTransVoucher));
_MenuFunction = new MenuFunction(menuitemDisplayStr(LedgerTransVoucher), MenuItemType::Display);
_MenuFunction.run(_args);
}
}
留言列表