private void btnSearchUpdate_Click(object sender, EventArgs e) { try { if (txtSearchMaterialLocationUpdate.Text != string.Empty) { storedShelf = shelfBLL.GetAll(); foreach (var specifiedShelf in storedShelf) { if (specifiedShelf.Location == txtSearchMaterialLocationUpdate.Text) { shelf = specifiedShelf; } } txtMaterialLocationUpdate.Text = shelf.Location; txtShelfQuantityUpdate.Text = shelf.Quantity.ToString(); richLocationDescriptionUpdate.Text = shelf.Description; } else { txtMaterialLocationUpdate.Text = string.Empty; txtShelfQuantityUpdate.Text = string.Empty; richLocationDescriptionUpdate.Text = string.Empty; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BindShelf(Shelf shelf) { try { shelfBLLList = new ShelfBLL(); Shelf sh = new Shelf(); shelfList = shelfBLLList.GetAll(); if (shelfList.Count > 0) { sh = shelfList[0]; shelfList[0] = shelf; shelfList.Add(sh); comboMaterialLocation.DataSource = shelfList; comboMaterialLocation.DisplayMember = "Location"; } } catch (Exception) { shelfList = new List <Shelf>(); shelfList.Add(new Shelf() { ShelfId = 0, Location = "Other" }); comboMaterialLocation.DataSource = shelfList; comboMaterialLocation.DisplayMember = "Location"; } }