[ExtensionOf(FormControlStr(CustTrans, ShowOpenDateFilter))]
final class DDDCustTransForm_ShowOpenDateFilterControl_Extension
{
public boolean modified()
{
boolean ret;
FormDataSource custTrans_ds = this.formRun().dataSource(1);
element.criteriaOpen = SysQuery::findOrCreateRange(custTrans_ds.query().dataSourceNo(1), fieldnum(CustTrans, Closed));
ret = next modified();
return ret;
}
}
/// <summary>
/// Extension class of custtrans form
/// </summary>
[ExtensionOf(formDataSourceStr(CustTrans,CustTrans))]
final class DDDCustTransForm_Extension
{
/// <summary>
/// Extension of form execute query
/// </summary>
void executeQuery()
{
if (element.args().dataset() == tableNum(CustTable))
{
FormCheckBoxControl myCheckBox = element.design().controlName(formControlStr(CustTrans, DDDViewChildTransactions));
//NoYes viewChildTransactions = myCheckBox.value();
FormDataSource custTrans_ds = this.formRun().dataSource('CustTrans');
CustTrans custTrans = custTrans_ds.cursor();
CustTable custTable = element.args().record();;
CustAccount custAccount = custTable.AccountNum;//custTrans.AccountNum;
FormComboBoxControl showOpenOptions = element.design().controlName(formControlStr(CustTrans, ShowOpenOptions));
EnumId enumId = showOpenOptions.selection();
FormDateControl showOpenDateFilter = element.design().controlName(formControlStr(CustTrans, ShowOpenDateFilter));
date showDate = showOpenDateFilter.dateValue();
if (myCheckBox.checked())
{
DDDCustParentChild parentCustomer;
CustTable custTableLoc;
CustAccount custId;
container custList;
custList = conNull();
// get the all child customers of the parent
while select parentCustomer
join custTableLoc
where custTableLoc.RecId == parentCustomer.ParentAccount
&& custTableLoc.AccountNum == custAccount
{
custList += parentCustomer.ChildAccount;
}
if(custList)
{
this.query().dataSourceTable(tableNum(CustTrans)).clearRanges();
this.query().dataSourceTable(tablenum(CustTrans)).clearDynalinks();
for (int i = 1; i <= conLen(custList); i++) // adding all child ranges to query
{
custId = conPeek(custList, i);
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, AccountNum)).value(queryValue(custId));
}
switch (enumId)
{
case CustVendShowTransaction::All:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(SysQueryRangeUtil::valueUnlimited());
break;
case CustVendShowTransaction::Open:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(strfmt('%1..', dateNull()));
break;
case CustVendShowTransaction::OpenAsOf:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(queryValue(dateNull()));
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(strFmt(' > %1', queryValue(showDate)));
break;
case CustVendShowTransaction::Closed:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(SysQuery::valueNot(queryValue(dateNull())));
break;
}
}
}
if(!myCheckBox.checked() && element.args().dataset() == tableNum(CustTable))
{
if (element.args().dataset() == tableNum(CustTable))
{
custTable = element.args().record();
this.query().dataSourceTable(tableNum(CustTrans)).clearRanges();
this.query().dataSourceTable(tablenum(CustTrans)).clearDynalinks();
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, AccountNum)).value(queryValue(custTable.AccountNum));
switch (enumId)
{
case CustVendShowTransaction::All:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(SysQueryRangeUtil::valueUnlimited());
break;
case CustVendShowTransaction::Open:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(strfmt('%1..', dateNull()));
break;
case CustVendShowTransaction::OpenAsOf:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(queryValue(dateNull()));
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(strFmt(' > %1', queryValue(showDate)));
break;
case CustVendShowTransaction::Closed:
this.query().dataSourceName(custTrans_ds.name()).addRange(fieldnum(CustTrans, Closed)).value(SysQuery::valueNot(queryValue(dateNull())));
break;
}
}
}
}
next executeQuery();
}
}
No comments:
Post a Comment