fixed CREW/PAS import for variable locode selection
This commit is contained in:
parent
a3019b7a30
commit
d96979a939
@ -25,7 +25,7 @@
|
|||||||
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockType" Grid.Row="0" Grid.Column="1">bla</TextBlock>
|
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockType" Grid.Row="0" Grid.Column="1">bla</TextBlock>
|
||||||
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockValue" Grid.Row="1" Grid.Column="1">bla</TextBlock>
|
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockValue" Grid.Row="1" Grid.Column="1">bla</TextBlock>
|
||||||
<xctk:WatermarkComboBox Grid.Column="1" Grid.Row="2" x:Name="comboBoxValues" IsTextSearchEnabled="True" SelectedValuePath="Key" DisplayMemberPath="Value" Margin="2" IsEditable="True" Watermark="Select an appropriate value" />
|
<xctk:WatermarkComboBox Grid.Column="1" Grid.Row="2" x:Name="comboBoxValues" IsTextSearchEnabled="True" SelectedValuePath="Key" DisplayMemberPath="Value" Margin="2" IsEditable="True" Watermark="Select an appropriate value" />
|
||||||
|
<enictrl:LocodeControl Grid.Column="1" Grid.Row="2" x:Name="locodeControl" Visibility="Hidden" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</enictrl:EditWindowBase>
|
</enictrl:EditWindowBase>
|
||||||
|
|||||||
@ -18,10 +18,21 @@ namespace ENI2.EditControls
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool LocodeMode
|
||||||
|
{
|
||||||
|
get { return this.locodeControl.Visibility == Visibility.Visible; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.locodeControl.Visibility = value ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
this.comboBoxValues.Visibility = value ? Visibility.Hidden : Visibility.Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string SelectedValue
|
public string SelectedValue
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (LocodeMode) return this.locodeControl.LocodeValue;
|
||||||
return this.comboBoxValues.SelectedValue as string;
|
return this.comboBoxValues.SelectedValue as string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2521,47 +2521,61 @@ namespace ENI2.Excel
|
|||||||
|
|
||||||
val = val.ToUpper();
|
val = val.ToUpper();
|
||||||
|
|
||||||
|
if (val.IsNullOrEmpty()) return val;
|
||||||
|
|
||||||
|
// check if this is a legitimate Locode
|
||||||
if (!LocodeDB.LocationNameFromLocode(val).IsNullOrEmpty()) return val;
|
if (!LocodeDB.LocationNameFromLocode(val).IsNullOrEmpty()) return val;
|
||||||
|
|
||||||
string portName = LocodeDB.PortNameFromLocode(val);
|
// check if it is a port that we already know
|
||||||
if (portName.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
// _log.WarnFormat("unknown Locode {0}", val);
|
|
||||||
// reverse search: if this is a name lookup port code
|
|
||||||
List<string> possibleLocodes = LocodeDB.AllLocodesForCityName(val);
|
|
||||||
|
|
||||||
if(possibleLocodes.Count > 1)
|
// _log.WarnFormat("unknown Locode {0}", val);
|
||||||
|
// reverse search: if this is a name lookup port code
|
||||||
|
List<string> possibleLocodes = LocodeDB.AllLocodesForCityName(val);
|
||||||
|
|
||||||
|
if(possibleLocodes.Count > 1)
|
||||||
|
{
|
||||||
|
if (!_locodeImportDict.ContainsKey(val))
|
||||||
{
|
{
|
||||||
if (!_locodeImportDict.ContainsKey(val))
|
FixImportDialog fid = new FixImportDialog();
|
||||||
|
fid.Value = val;
|
||||||
|
fid.ValueType = "Locode";
|
||||||
|
Dictionary<string, string> ld = new Dictionary<string, string>();
|
||||||
|
foreach (string locode in possibleLocodes)
|
||||||
|
ld[locode] = locode;
|
||||||
|
fid.SelectionValues = ld;
|
||||||
|
if (fid.ShowDialog() ?? false)
|
||||||
{
|
{
|
||||||
FixImportDialog fid = new FixImportDialog();
|
_locodeImportDict[val] = fid.SelectedValue;
|
||||||
fid.Value = val;
|
|
||||||
fid.ValueType = "Locode";
|
|
||||||
Dictionary<string, string> ld = new Dictionary<string, string>();
|
|
||||||
foreach (string locode in possibleLocodes)
|
|
||||||
ld[locode] = locode;
|
|
||||||
fid.SelectionValues = ld;
|
|
||||||
if (fid.ShowDialog() ?? false)
|
|
||||||
{
|
|
||||||
_locodeImportDict[val] = fid.SelectedValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(_locodeImportDict.ContainsKey(val))
|
||||||
result = _locodeImportDict[val];
|
result = _locodeImportDict[val];
|
||||||
}
|
}
|
||||||
else if(possibleLocodes.Count == 1)
|
else if(possibleLocodes.Count == 1)
|
||||||
|
{
|
||||||
|
result = possibleLocodes[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!_locodeImportDict.ContainsKey(val))
|
||||||
{
|
{
|
||||||
result = possibleLocodes[0];
|
// nothing found, let the user pick a locode by himself
|
||||||
}
|
FixImportDialog fid = new FixImportDialog();
|
||||||
else
|
fid.Value = val;
|
||||||
{
|
fid.ValueType = "Locode";
|
||||||
// nothing found
|
fid.LocodeMode = true;
|
||||||
|
if (fid.ShowDialog() ?? false)
|
||||||
|
{
|
||||||
|
_locodeImportDict[val] = fid.SelectedValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (_locodeImportDict.ContainsKey(val))
|
||||||
|
result = _locodeImportDict[val];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user