Exemplo n.º 1
0
        private void buttonAddCargoState_Click(object sender, EventArgs e)
        {
            try
            {
                AddStateInfo addState = new AddStateInfo();

                addState.ShowDialog();

                if (addState.ContainersCount < 0 || addState.ContainersCount > _storage.CalculateMaxCapacity())
                {
                    throw new Exception(ErrorConstants.WRONG_STORAGE_STATE);
                }

                StorageStateInfo info = new StorageStateInfo();

                info.TimeChange = addState.ArrivingTime;

                info.StorageFullness = addState.ContainersCount;

                info.StorageCapacity = _storage.CalculateMaxCapacity();

                _storage.AddChangeInfo(info);

                StorageInfoLoader.Save(_storage);

                ReloadInfo();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, ErrorConstants.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }