private void BtnAdd_Click(object sender, RoutedEventArgs e) { try { if (txtItem.Text != string.Empty) { var item = itemsService.GetItem(txtItem.Text); if (item != null) { _window.txtItem.Text = item.Item; _window.txtUoM.Text = item.BaseUoM; _window.txtDescription.Text = item.Description; _window.txtNCM.Text = ncmService.GetNCM(item.Item); _window.txtStandardCost.Text = itemsService.GetStandardCost(item.Item).ToString(); int?nature = itemsService.GetNatureItem(item.Item); if (nature == 22413314) { _window.cbNature.SelectedIndex = 0; } else if (nature == 22413313) { _window.cbNature.SelectedIndex = 1; } else if (nature == 22413312) { _window.cbNature.SelectedIndex = 2; } _window.EnabledFields(); _window.isEdit = true; this.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }