Exemple #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            using (frmAddEdit fmAE = new frmAddEdit())
            {
                int selectIndex = dgvGiaoVien.SelectedRows[0].Index;

                if (selectIndex < 0)
                {
                    MessageBox.Show("Chọn bản ghi cần sửa!");
                }
                else
                {
                    string id = dgvGiaoVien[0, selectIndex].Value.ToString();
                    fmAE.Id = id;
                    if (fmAE.ShowDialog() == DialogResult.OK)
                    {
                        GiaoVien gv = fmAE.getGiaoVien();
                        if (bsGV.UpdateGiaoVien(gv))
                        {
                            MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Sửa thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }