private void gridChallan_CellContentClick(object sender, DataGridViewCellEventArgs e) { string Action = this.gridChallan.Columns[e.ColumnIndex].HeaderText; if (Action == "Edit") { frmChildChallan childchallan = new frmChildChallan(); int billid = Convert.ToInt32(gridChallan.Rows[e.RowIndex].Cells[0].Value); childchallan.ChallanData = CommonClass.tblChallanEntryDTO.Where(h => h.SrNo == billid).FirstOrDefault(); childchallan.FormClosed += childchallan_FormClosed; childchallan.ShowInTaskbar = false; } if (Action == "Delete") { try { var messageBoxResult = MessageBox.Show("Are you sure want to delete this record?", "Delete", MessageBoxButtons.YesNo); if (messageBoxResult == DialogResult.Yes) { int billid = Convert.ToInt32(gridChallan.Rows[e.RowIndex].Cells[0].Value); tblChallanEntryDTO billdata = CommonClass.tblChallanEntryDTO.Where(h => h.SrNo == billid).FirstOrDefault(); CommonClass.tblChallanEntryDTO.Remove(billdata); fillGridData(); } } catch (Exception) { MessageBox.Show("Bill already used some where else can't deleted successfully."); } } }
private void AddEntry_Click(object sender, EventArgs e) { frmChildChallan childchallan = new frmChildChallan(); childchallan.FormClosed += childchallan_FormClosed; childchallan.ShowInTaskbar = false; childchallan.ShowDialog(); }