private void btnAdd_Click(object sender, EventArgs e) { var frmDetail = new DistrictDetailForm(true); var dialogResult = frmDetail.ShowDialog(); if (dialogResult == DialogResult.OK) { MessageBox.Show(@"Successfully added district", @"Message", MessageBoxButtons.OK, MessageBoxIcon.Information); SearchDistrictInformations(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvDistrictList.SelectedRows.Count > 0) { var districtViewModel = dgvDistrictList.SelectedRows[0].DataBoundItem as DistrictViewModel; if (districtViewModel != null) { var frmDetail = new DistrictDetailForm(false, districtViewModel.DistrictCode); var dialogResult = frmDetail.ShowDialog(); if (dialogResult == DialogResult.OK) { MessageBox.Show(@"Successfully edited the district", @"Message", MessageBoxButtons.OK, MessageBoxIcon.Information); SearchDistrictInformations(); } } } else { MessageBox.Show(@"Please select a district to edit", @"Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }