diff --git a/src/BreCalClient/EditShipcallControl.xaml.cs b/src/BreCalClient/EditShipcallControl.xaml.cs index 2456bd9..80a033a 100644 --- a/src/BreCalClient/EditShipcallControl.xaml.cs +++ b/src/BreCalClient/EditShipcallControl.xaml.cs @@ -145,8 +145,32 @@ namespace BreCalClient isEnabled &= this.comboBoxShip.SelectedItem != null; isEnabled &= this.comboBoxCategories.SelectedItem != null; - isEnabled &= ((this.comboBoxArrivalBerth.SelectedItem != null) || (this.comboBoxDepartureBerth.SelectedItem != null)); - isEnabled &= (this.datePickerETA.Value.HasValue || this.datePickerETD.Value.HasValue); + + if (comboBoxCategories.SelectedItem == null) + { + isEnabled = false; + } + else + { + TypeEnum callType = (TypeEnum)comboBoxCategories.SelectedItem; + switch (callType) + { + case TypeEnum.Outgoing: + isEnabled &= this.comboBoxDepartureBerth.SelectedItem != null; + isEnabled &= this.datePickerETD.Value.HasValue; + break; + case TypeEnum.Incoming: + isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null; + isEnabled &= this.datePickerETA.Value.HasValue; + break; + case TypeEnum.Shifting: + isEnabled &= ((this.comboBoxDepartureBerth.SelectedItem != null) && (this.comboBoxArrivalBerth.SelectedItem != null)); + isEnabled &= this.datePickerETD.Value.HasValue; + isEnabled &= this.datePickerETA.Value.HasValue; + break; + } + } + isEnabled &= this.comboBoxAgency.SelectedItem != null; this.buttonOK.IsEnabled = isEnabled;