//EVENT HANDLERS private void ButtonUpdateProduct_Click(object sender, EventArgs e) { try { var row = dataGridViewInventory.CurrentRow; if (row == null) { throw new Exception("Please select an entry to update"); } Inventory product = new Inventory() { ProductId = (int)row.Cells[0].Value, ProductName = (string)row.Cells[1].Value, ProductQuantity = (int)row.Cells[2].Value }; AddOrUpdateInventoryProductForm updateInventoryProductForm = new AddOrUpdateInventoryProductForm(product); HandleForm(updateInventoryProductForm); } catch (Exception err) { MessageBox.Show(err.Message); } }
public InventoryForm() { InitializeComponent(); this.TopLevel = false; this.FormBorderStyle = FormBorderStyle.None; this.Visible = true; this.Dock = DockStyle.Fill; this.Load += InventoryForm_Load; InitializeDataGridView <Inventory>(dataGridViewInventory, new string[] { "ProductId", "Services" }); dataGridViewInventory.DataSource = Controller <BeautySalonEntities, Inventory> .SetBindingList(); dataGridViewInventory.Refresh(); AddOrUpdateInventoryProductForm addInventoryProductForm = new AddOrUpdateInventoryProductForm(); buttonNewProduct.Click += ButtonNewProduct_Click; buttonDeleteProduct.Click += ButtonDeleteProduct_Click; buttonUpdateProduct.Click += ButtonUpdateProduct_Click; }
private void ButtonNewProduct_Click(object sender, EventArgs e) { AddOrUpdateInventoryProductForm addInventoryProductForm = new AddOrUpdateInventoryProductForm(); HandleForm(addInventoryProductForm); }