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; }
public void InventorySearch(SearchWindow window) { string name = window.TxtSearchItemName.Text; string price = window.TxtSearchItemPrice.Text; string quantity = window.TxtSearchItemQuantity.Text; string skuNumber = window.TxtSearchItemSkuNumber.Text; string itemTypeId = window.CbSearchItemItemTypeId.Text; string locationTypeId = window.CbSearchItemLocationTypeId.Text; List <Item> items = new ItemCRUD().GetAllItems(); if (!String.IsNullOrEmpty(name)) { items.RemoveAll(x => x.Name != name); } if (!String.IsNullOrEmpty(price)) { items.RemoveAll(x => x.Price != Convert.ToDecimal(price)); } if (!String.IsNullOrEmpty(quantity)) { items.RemoveAll(x => x.Quantity != Convert.ToInt32(quantity)); } if (!String.IsNullOrEmpty(skuNumber)) { items.RemoveAll(x => x.SkuNumber != skuNumber); } if (!String.IsNullOrEmpty(itemTypeId)) { items.RemoveAll(x => x.ItemTypeId != Convert.ToInt32(itemTypeId)); } if (!String.IsNullOrEmpty(locationTypeId)) { items.RemoveAll(x => x.LocationTypeId != Convert.ToInt32(locationTypeId)); } if (items.Count > 0) { BindDataGrid(items); window.Close(); } else { MessageBox.Show("There are no results", "Information"); } }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { int result = 0; if (this.IsValidForm()) { result = new ItemCRUD().Update((Item)this.DataContext); } if (result > 0) { this.Close(); MessageBox.Show("The item has been updated.", "Success"); } }
/* -------------------------------------------------------------- *\ * m_SaveMap() * * - Saves the current map to the selected filename / path \* -------------------------------------------------------------- */ private void m_SaveMap() { int idNewWorld = 0; HugoLANDContext context = new HugoLANDContext(); if (m_worldNew) { MondeCRUD.CreerMonde(m_CurrentWorld); List <Monde> lm = MondeCRUD.ListeMonde(); idNewWorld = lm.Last().Id; m_worldNew = false; } else { idNewWorld = m_CurrentWorld.Id; } //Sauvegarde des foreach (var om in m_DObj) { switch (om.Value) { case "ORIGINAL": continue; //Fait rien case "NEW": ObjetMondeCRUD.CreeObjetMonde(om.Key, idNewWorld); break; case "MODIFIED": ObjetMondeCRUD.ChangeDescriptionObjetMonde(om.Key, idNewWorld); break; } } foreach (var item in m_OBJ) { ObjetMondeCRUD.SupprimeObjetMonde(item, idNewWorld); } m_DObj.Clear(); m_OBJ.Clear(); foreach (var monstre in m_DMonstre) { switch (monstre.Value) { case "ORIGINAL": continue; //Fait rien case "NEW": MonstreCRUD.CreerMonstre(monstre.Key, idNewWorld); break; case "MODIFIED": MonstreCRUD.ModifierMonstre(monstre.Key, idNewWorld); break; } } foreach (var item in m_Mons) { MonstreCRUD.SupprimerMonstre(item); } m_Mons.Clear(); m_DMonstre.Clear(); foreach (var i in m_DItem) { switch (i.Value) { case "ORIGINAL": continue; //Fait rien case "NEW": ItemCRUD.CreerItem(i.Key, idNewWorld); break; case "MODIFIED": // ItemCRUD.(i.Key); // Revoir break; } } foreach (var item in m_li) { ItemCRUD.SupprimerItem(item); } m_li.Clear(); m_DItem.Clear(); FillLists(); //m_Map.Save(m_CurrentWorld, m_WorldOpen); //DialogResult result; //dlgSaveMap.Title = "Save Map"; //dlgSaveMap.Filter = "Map File (*.map)|*.map"; //result = dlgSaveMap.ShowDialog(); //if (result == DialogResult.OK) //{ // this.Cursor = Cursors.WaitCursor; // try // { // m_Map.Save(dlgSaveMap.FileName); // } // catch // { // Console.WriteLine("Error Saving..."); // } // this.Cursor = Cursors.Default; //} }