private void Gv_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { DataGridView senderGrid = (DataGridView)sender; int id = Convert.ToInt32(gv.Rows[e.RowIndex].Cells[1].Value); if (senderGrid.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.RowIndex >= 0) { var frm = new Form_MasterClassAddEdit { customerClassId = id }; if (frm.ShowDialog() == DialogResult.OK) { Populate(); } } if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn && e.RowIndex >= 0) { var customers = MasterClassController.GetCustomersByClass(id, "2020-01-24"); var coll = customers.Select(p => new { p.CustomerCode, p.CustomerName }).ToList(); gvCustomer.DataSource = coll; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnAdd_Click(object sender, System.EventArgs e) { try { var frm = new Form_MasterClassAddEdit { customerClassId = 0 }; if (frm.ShowDialog() == DialogResult.OK) { Populate(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }