private void EditButton_Click(object sender, EventArgs e) { List <int> blankCertTypeIds = (from DataGridViewRow r in BlankCertTypeDataGridView.Rows where Convert.ToBoolean(r.Cells[1].Value) == true select Convert.ToInt32(r.Cells[0].Value)).ToList(); try { if (blankCertTypeIds.Count == 1) { int blankCertTypeId = blankCertTypeIds.FirstOrDefault(); EditBlankCertTypeForm editBlankCertTypeForm = new EditBlankCertTypeForm(blankCertTypeId); editBlankCertTypeForm.ShowDialog(); } else if (blankCertTypeIds.Count == 0) { //MessageBox.Show("Bạn chưa chọn loại phôi nào", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); NotificationForm notificationForm = new NotificationForm("Bạn chưa chọn loại phôi nào", "Cảnh báo", MessageBoxIcon.Warning); notificationForm.ShowDialog(); } else { //MessageBox.Show("Chỉ chọn 1 loại phôi để sửa", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); NotificationForm notificationForm = new NotificationForm("Bạn chưa chọn loại phôi nào", "Cảnh báo", MessageBoxIcon.Warning); notificationForm.ShowDialog(); } } catch (Exception ex) { //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error); notificationForm.ShowDialog(); } }
private void BlankCertTypeDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == BlankCertTypeDataGridView.Columns["Edit"].Index && e.RowIndex >= 0) { int blankCertTypeId = int.Parse(BlankCertTypeDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString()); EditBlankCertTypeForm editBlankCertTypeForm = new EditBlankCertTypeForm(blankCertTypeId); editBlankCertTypeForm.ShowDialog(); } else if (e.ColumnIndex == BlankCertTypeDataGridView.Columns["Delete"].Index && e.RowIndex >= 0) { DialogResult dialogResult = MessageBox.Show("Đồng ý xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { try { int blankCertTypeId = int.Parse(BlankCertTypeDataGridView.Rows[e.RowIndex].Cells["Id"].Value.ToString()); int result = managingBlankCertTypeService.DeleteBlankCertType(blankCertTypeId); if (result > 0) { //MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); NotificationForm notificationForm = new NotificationForm("Xóa thành công", "Thông báo", MessageBoxIcon.Information); notificationForm.ShowDialog(); LoadBlankCertTypeList(); } else { //MessageBox.Show("Xóa không thành công", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); NotificationForm notificationForm = new NotificationForm("Xóa không thành công", "Cảnh báo", MessageBoxIcon.Error); notificationForm.ShowDialog(); } } catch (Exception ex) { //MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); NotificationForm notificationForm = new NotificationForm(Common.Common.COMMON_ERORR, "Lỗi", MessageBoxIcon.Error); notificationForm.ShowDialog(); } } else if (dialogResult == DialogResult.No) { //no delete } } }