public void BindDataGrid() { List <Item> items = new ItemCRUD().GetAllItems(); List <ItemType> itemTypes = new ItemTypeCRUD().GetItemTypes(); List <LocationType> locationType = new LocationTypeCRUD().GetLocationTypes(); foreach (var item in items) { if (item.ItemTypeId > 0) { item.ItemTypeName = itemTypes.Where(x => x.ItemTypeId == item.ItemTypeId).First().ItemTypeName; } else { item.ItemTypeName = "None"; } if (item.LocationTypeId > 0) { item.LocationTypeName = locationType.Where(x => x.LocationTypeId == item.LocationTypeId).First().LocationTypeName; } else { item.LocationTypeName = "None"; } } this.dgData.ItemsSource = items; }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { int result = 0; result = new LocationTypeCRUD().Create((LocationType)this.DataContext); if (result > 0) { this.Close(); MessageBox.Show("Location type was created", "Success"); } else { MessageBox.Show("Unable to create location type", "Failure"); } }