private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == dataGridView1.Columns["Save"].Index) { if (!Access.Instance.CanProceed(Modules.Inventory, Actions.Edit)) { return; } ItemStock record = (ItemStock)dataGridView1.Rows[e.RowIndex].DataBoundItem; record.CompanyId = Session.Instance.AuthUser.CompanyId; ItemStockBS.AddItemStock(record); PopulateInventory(); return; } if (e.ColumnIndex == dataGridView1.Columns["Delete"].Index) { if (!Access.Instance.CanProceed(Modules.Inventory, Actions.Edit)) { return; } ItemStockBS.DeleteItemStock(((ItemStock)dataGridView1.Rows[e.RowIndex].DataBoundItem).ItemStockId); PopulateInventory(); return; } }
private void PopulateInventory() { List <ItemStock> itemstock = null; itemstock = ItemStockBS.GetAllItemStocks().Where(item => item.CompanyId == Session.Instance.AuthUser.CompanyId).ToList(); var itemList = new BindingList <ItemStock>(itemstock); dataGridView1.DataSource = itemList; HideUnwantedColumns(); GenerateCommonColumns(); }