public void AddItemToGrid(object sender, IdentityEventArgs e) { int count = menuGrid.Rows.Count - 1; menuGrid.Rows.Add(); menuGrid.Rows[count].Cells[0].Value = count + 1; menuGrid.Rows[count].Cells[1].Value = e.item.ItemName; menuGrid.Rows[count].Cells[2].Value = e.item.ItemPrice; }
private void btnSave_Click(object sender, EventArgs e) { decimal price = 0; string itemName = txtItemName.Text; if (decimal.TryParse(txtItemPrice.Text, out price) && !String.IsNullOrWhiteSpace(itemName)) { Item newItem = new Item(); newItem.ItemName = itemName; newItem.ItemPrice = price; IdentityEventArgs args = new IdentityEventArgs(newItem); IdentityUpdate(this, args); this.Close(); } else { MessageBox.Show("You have entered invalid input.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UpdateMenu(object sender, IdentityEventArgs e) { menuGrid.Rows[row].Cells[1].Value = e.item.ItemName; menuGrid.Rows[row].Cells[2].Value = e.item.ItemPrice; }