private async void dgvMunicipality_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgvMunicipality.Columns[e.ColumnIndex].HeaderText == "Edit") { OnEdit = true; MunID = int.Parse(dgvMunicipality.CurrentRow.Cells[2].Value.ToString()); frmAddMunicipality fam = new frmAddMunicipality(); fam.ShowDialog(); } if (dgvMunicipality.Columns[e.ColumnIndex].HeaderText == "Delete") { MunID = int.Parse(dgvMunicipality.CurrentRow.Cells[2].Value.ToString()); DialogResult dr = MessageBox.Show("Are you sure to delete selected Municipality?", "Warning!", MessageBoxButtons.OKCancel); if (dr == DialogResult.OK) { if (GetBarangays.Count(x => x.MunID == MunID) > 0) { MessageBox.Show("Deletion failed, Municipality has barangay...", "Error!"); return; } else { await rep_Municipality.Delete(MunID); await LoadMunicipality(); } } } }
private void btnCreateMunicipality_Click(object sender, EventArgs e) { frmAddMunicipality fam = new frmAddMunicipality(); fam.ShowDialog(); }