//check if listings and supplier has been selected and creates new lists item if _isEdit = false and vise versa //created by will fritz 2/11/15 private void btnSubmit_Click(object sender, RoutedEventArgs e) { try { ItemListing itemListing = (ItemListing)lvList.SelectedItems[0]; Supplier supplier = (Supplier)cboSelectSupplier.SelectedItem; Lists newLists = new Lists(); newLists.ItemListID = itemListing.ItemListID; newLists.SupplierID = supplier.SupplierID; newLists.DateListed = new DateTime(); if (_isEdit == false) { _prodMang.AddLists(newLists); } else { _prodMang.EditLists(_oldLists, newLists); } //opens old window and closes this one if (ListsView.Instance == null) { var listsWin = new ListsView(); listsWin.Show(); } else { var listsWin = ListsView.Instance; listsWin.BringIntoView(); listsWin.Show(); listsWin.FillList(); System.Media.SystemSounds.Asterisk.Play(); } this.Close(); } catch (Exception) { lblError.Content = "You Must Select a ItemListing and a Supplier Or there was an error with the database"; } }
//sets instance to this object //created by will fritz 2/9/15 public ListsView() { InitializeComponent(); Instance = this; }
//sets instance to null apon closing //created by will fritz 2/9/15 private void Window_Closed(object sender, EventArgs e) { Instance = null; }