ConsolidatedInventoryHandlers.cs 2.04 KB
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using DirRX.Storage.ConsolidatedInventory;

namespace DirRX.Storage
{
  partial class ConsolidatedInventoryClientHandlers
  {

    public override void Refresh(Sungero.Presentation.FormRefreshEventArgs e)
    {
      _obj.State.IsEnabled = _obj.Status == Status.Active;
    }

    public virtual void FundValueInput(DirRX.Storage.Client.ConsolidatedInventoryFundValueInputEventArgs e)
    {
      // Проверка на уже существующие сводные описи.
      var consInventories = DirRX.Storage.PublicFunctions.Module.Remote.GetConsolidatedInventories(e.NewValue);
      
      foreach (var inventory in consInventories)
      {
        if (_obj.Type == inventory.Type && !inventory.Equals(_obj))
        {
          var consType = ConsolidatedInventories.Info.Properties.Type.GetLocalizedValue(_obj.Type);
          e.AddWarning(_obj.Info.Properties.Fund,
                       DirRX.Storage.ConsolidatedInventories.Resources.ErrorConsolidatedInventoryAlreadyExistsFormat(e.NewValue, consType),
                      _obj.Info.Properties.Fund, _obj.Info.Properties.Type);
        }
      }
    }

    public virtual void TypeValueInput(Sungero.Presentation.EnumerationValueInputEventArgs e)
    {
      // Проверка на уже существующие сводные описи.
      var consInventories = DirRX.Storage.PublicFunctions.Module.Remote.GetConsolidatedInventories(_obj.Fund);
      
      foreach (var inventory in consInventories)
      {
        if (e.NewValue == inventory.Type && !inventory.Equals(_obj))
        {
          var consType = ConsolidatedInventories.Info.Properties.Type.GetLocalizedValue(e.NewValue);
          e.AddWarning(_obj.Info.Properties.Type,
                       DirRX.Storage.ConsolidatedInventories.Resources.ErrorConsolidatedInventoryAlreadyExistsFormat(_obj.Fund, consType),
                      _obj.Info.Properties.Type, _obj.Info.Properties.Fund);
        }
      }
    }

  }
}