Esempio n. 1
0
 /// <summary>
 /// Creates the instance of <see cref="DisposalRequestDetails" /> to be used as a wrapper of <see cref="CustomsWarehouseDisposal" />.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="disposal">The disposal to be wrapped.</param>
 /// <param name="sequenceNumber">The sequence number that will be incremented each time new instance is created.</param>
 internal DisposalRequestDetails(DisposalRequest parent, CustomsWarehouseDisposal disposal, ref int sequenceNumber)
     : this(parent, disposal.CWL_CWDisposal2CustomsWarehouseID, ref sequenceNumber)
 {
     AddedKg                    = disposal.CW_AddedKg.Value;
     CustomsProcedure           = disposal.CustomsProcedure;
     DeclaredNetMass            = disposal.CW_DeclaredNetMass.Value;
     SKUDescription             = disposal.SKUDescription;
     m_Disposal                 = disposal;
     QuantityyToClearSum        = AddedKg + DeclaredNetMass;
     PackagesToDispose          = m_Account.Packages(QuantityyToClearSum);
     QuantityyToClearSumRounded = PackagesToDispose * MassPerPackage;
     TotalStock                 = disposal.CWL_CWDisposal2CustomsWarehouseID.TobaccoNotAllocated.Value + QuantityyToClearSumRounded;
 }
Esempio n. 2
0
        private static DisposalRequest Create
            (List <CustomsWarehouse> listOfAccounts, IGrouping <string, CustomsWarehouseDisposal> disposals, string description, string procedure, Action <DisposalRequest, PropertyChangedEventArgs> notify)
        {
            CustomsWarehouse _firstAccount = listOfAccounts.First <CustomsWarehouse>();
            DisposalRequest  _newRequest   = CreateDisposalRequest(_firstAccount, description, procedure, notify);

            listOfAccounts.Sort(new Comparison <CustomsWarehouse>(CustomsWarehouse.CompareCustomsWarehouse));
            List <DisposalRequestDetails> _newCollection = new List <DisposalRequestDetails>();
            int _sequenceNumber = 0;
            List <CustomsWarehouse> _copylistOfAccounts = new List <CustomsWarehouse>(listOfAccounts);

            if (disposals != null)
            {
                foreach (CustomsWarehouseDisposal _cwdx in disposals)
                {
                    DisposalRequestDetails _newDisposalRequestDetails = new DisposalRequestDetails(_newRequest, _cwdx, ref _sequenceNumber);
                    _copylistOfAccounts.Remove(_cwdx.CWL_CWDisposal2CustomsWarehouseID);
                    _newCollection.Add(_newDisposalRequestDetails);
                    _newRequest.GetDataContext(_newDisposalRequestDetails);
                    if (_cwdx.CustomsStatus.GetValueOrDefault(CustomsStatus.NotStarted) != CustomsStatus.NotStarted)
                    {
                        _newRequest.ReadOnly = true;
                    }
                }
            }
            foreach (CustomsWarehouse _cwx in _copylistOfAccounts)
            {
                if (_cwx.TobaccoNotAllocated == 0)
                {
                    continue;
                }
                DisposalRequestDetails _newDisposalRequestDetails = new DisposalRequestDetails(_newRequest, _cwx, ref _sequenceNumber);
                _newCollection.Add(_newDisposalRequestDetails);
            }
            _newRequest.RemainingOnStock = _newCollection.Sum(x => x.RemainingOnStock);
            _newRequest.UpdateOnInit(_newCollection);
            return(_newRequest);
        }
Esempio n. 3
0
 private void context_GetListCompleted(object siurce, GetListAsyncCompletedEventArgs e)
 {
     try
     {
         DataContext.GetListCompleted -= context_GetListCompleted;
         if (e.Cancelled)
         {
             return;
         }
         if (e.Error != null)
         {
             Parent.OnProgressChanged(new ProgressChangedEventArgs(0, String.Format("Exception {0} at m_DataContext.GetListAsync", e.Error.Message)));
         }
         DisposalRequest _Dr = DisposalRequest.Create(e.Result <CustomsWarehouse>(), m_BatchGroup, (x, y) => Parent.RaisePropertyChanged(y));
         Parent.Add(_Dr);
         _Dr.AutoCalculation = true;
     }
     catch (Exception _ex)
     {
         Parent.OnProgressChanged(new ProgressChangedEventArgs(0, String.Format("Exception {0} at context_GetListCompleted", _ex)));
     }
     DoNext();
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisposalRequestDetails" /> class. Used to add new position of the requests list.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="account">The account without disposal created for the relevant request.</param>
 /// <param name="sequenceNumber">The sequence number that will be incremented each time new instance is created.</param>
 internal DisposalRequestDetails(DisposalRequest parent, CustomsWarehouse account, ref int sequenceNumber)
 {
     m_Parent                   = parent;
     m_Disposal                 = null;
     m_Account                  = account;
     AddedKg                    = 0;
     Batch                      = account.Batch;
     CustomsProcedure           = parent.CustomsProcedure;
     DeclaredNetMass            = 0;
     DocumentNumber             = account.DocumentNo;
     MassPerPackage             = account.CW_MassPerPackage.Value;
     PackagesToDispose          = 0;
     QuantityyToClearSum        = 0;
     QuantityyToClearSumRounded = 0;
     RemainingOnStock           = account.TobaccoNotAllocated.Value;
     SequenceNumber             = sequenceNumber++;
     SKU            = account.SKU;
     SKUDescription = string.Empty;
     TotalStock     = account.TobaccoNotAllocated.Value;
     Units          = account.Units;
     MoveDown       = new SynchronousCommandBase <Nullable <int> >(x => parent.GoDown(SequenceNumber), y => !parent.IsBottomActive(SequenceNumber));
     MoveUp         = new SynchronousCommandBase <Nullable <int> >(x => parent.GoUp(SequenceNumber), y => !parent.IsTopActive(SequenceNumber));
 }