Тема: if (a == true)
Показать сообщение отдельно
Старый 23.05.2012, 14:53   #6  
Napalm is offline
Napalm
Участник
 
80 / 88 (3) ++++
Регистрация: 23.05.2012
Общеизвестно, что для работы разработчиком Dynamics AX не обязательно знать X++ или уметь программировать.

Пример из LedgerJournalEngine\projQtyModified (AX 2012):

X++:
// This switch handles the normal(default) case and 2 other special cases
switch(true)
{
    case _ledgerJournalTrans_Project.Qty == 0:
        _ledgerJournalTrans.AmountCurCredit = 0;
        _ledgerJournalTrans.AmountCurDebit = 0;
        break;

    // If Credit/Debit Amounts are both 0, the Cost Price would be incorrectly set to 0 in the normal case
    // Handle this case separately
    case !_ledgerJournalTrans.AmountCurDebit && !_ledgerJournalTrans.AmountCurCredit && _ledgerJournalTrans_Project.CostPrice:
        this.projRecalcAmountCurDebitCredit(_ledgerJournalTrans, _ledgerJournalTrans_Project);
        break;

    default:
        // this.amount gets the debit amount or the negative credit amount
        offsetFactor = this.projOffsetFactor(_ledgerJournalTrans, _ledgerJournalTrans_Project);
        _ledgerJournalTrans_Project.CostPrice = Currency::price((offsetFactor * _ledgerJournalTrans.amount())/_ledgerJournalTrans_Project.Qty);
        // Cost Price should always be positive
        if (_ledgerJournalTrans_Project.CostPrice < 0)
            _ledgerJournalTrans_Project.CostPrice = - _ledgerJournalTrans_Project.CostPrice;
        // Cost Price have changed, recalc debit and credit amounts to avoid rounding diff
        this.projRecalcAmountCurDebitCredit(_ledgerJournalTrans, _ledgerJournalTrans_Project);
        break;
}
PS: Рекомендовано Microsoft! http://msdn.microsoft.com/en-us/libr...(v=ax.50).aspx
За это сообщение автора поблагодарили: macklakov (1), Zabr (12), db (0).