private void update_Click(object sender, EventArgs e) { var id = int.Parse(listView1.SelectedItems[0].SubItems[0].Text); using (var db = new SunwayCafeContext()) { var stock = db.Stocks.Where(x => x.Id == id).FirstOrDefault(); if (stock != null) { StockCreate sc = new StockCreate(stock, this); sc.Show(); } else { MessageBox.Show("Unable to retrieve item from database", "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } RefreshListView(); }
private void create_Click(object sender, EventArgs e) { StockCreate sc = new StockCreate(null, this); sc.Show(); }