Пример #1
0
        protected override void FieldSelectingImpl(int attributeNumber, PXCache s, PXFieldSelectingEventArgs e, string fieldName)
        {
            var     matrix      = e.Row as EntryMatrix;
            int?    inventoryId = GetValueFromArray(matrix?.InventoryIDs, attributeNumber);
            decimal?qty         = GetValueFromArray(matrix?.Quantities, attributeNumber);
            string  error       = GetValueFromArray(matrix?.Errors, attributeNumber);

            var state = PXDecimalState.CreateInstance(e.ReturnState, _precision.Value, fieldName, false, 0, 0m, null);

            state.Enabled    = inventoryId != null && IsDocumentOpen();
            state.Error      = error;
            state.ErrorLevel = string.IsNullOrEmpty(error) ? PXErrorLevel.Undefined : PXErrorLevel.Warning;
            e.ReturnState    = state;
            e.ReturnValue    = (inventoryId != null || matrix?.IsTotal == true) ? qty : null;

            var firstMatrix = s.Cached.FirstOrDefault_() as EntryMatrix;

            if (attributeNumber < firstMatrix?.ColAttributeValueDescrs?.Length)
            {
                state.DisplayName = firstMatrix.ColAttributeValueDescrs[attributeNumber] ?? firstMatrix.ColAttributeValues[attributeNumber];
                state.Visibility  = PXUIVisibility.Visible;
                state.Visible     = true;
            }
            else
            {
                state.DisplayName = null;
                state.Visibility  = PXUIVisibility.Invisible;
                state.Visible     = false;
            }
        }
Пример #2
0
        protected override void TotalFieldSelecting(PXCache s, PXFieldSelectingEventArgs e, string fieldName)
        {
            var matrix = e.Row as EntryMatrix;

            var state = PXDecimalState.CreateInstance(e.ReturnState, _precision.Value, fieldName, false, 0, 0m, null);

            e.ReturnState = state;
            state.Enabled = false;

            state.DisplayName = PXLocalizer.Localize(Messages.TotalQty);

            var firstMatrix = s.Cached.FirstOrDefault_() as EntryMatrix;

            if (firstMatrix?.ColAttributeValueDescrs?.Length > 0)
            {
                state.Visibility = PXUIVisibility.Visible;
                state.Visible    = true;
            }
            else
            {
                state.Visibility = PXUIVisibility.Invisible;
                state.Visible    = false;
            }

            decimal sum = 0;

            for (int columnIndex = 0; columnIndex < matrix?.Quantities?.Length; columnIndex++)
            {
                sum += (matrix.IsTotal == true || matrix.InventoryIDs[columnIndex] != null) ? (matrix.Quantities[columnIndex] ?? 0m) : 0m;
            }

            e.ReturnValue = sum;
        }
            protected override void TotalFieldSelecting(PXCache s, PXFieldSelectingEventArgs e, string fieldName)
            {
                var matrix = (EntryMatrix)e.Row;

                var state = PXDecimalState.CreateInstance(e.ReturnState, _precision.Value, fieldName, false, 0, 0m, null);

                e.ReturnState = state;
                state.Enabled = false;

                state.DisplayName = PXLocalizer.Localize(Messages.TotalQty);

                var anyMatrixRow = matrix ?? GetFirstMatrixRow();

                if (anyMatrixRow?.ColAttributeValueDescrs?.Length > 0)
                {
                    state.Visibility = PXUIVisibility.Visible;
                    state.Visible    = true;
                }
                else
                {
                    state.Visibility = PXUIVisibility.Invisible;
                    state.Visible    = false;
                }

                decimal sum = 0;

                for (int columnIndex = 0; columnIndex < matrix?.Quantities?.Length; columnIndex++)
                {
                    sum += (matrix.Quantities[columnIndex] ?? 0m);
                }

                e.ReturnValue = sum;
            }
Пример #4
0
 protected override PXFieldState DefaultState(PXCache sender, PXFieldSelectingEventArgs e) => PXDecimalState.CreateInstance(e.ReturnState, Precision, FieldName, null, null, null, null);