Ejemplo n.º 1
0
 private void btn_xoaTaiKhoan_Click(object sender, EventArgs e)
 {
     if (dgview_taiKhoan.SelectedRowsCount == 0)
     {
         XtraMessageBox.Show("Chưa chọn đối tượng để xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DialogResult result = XtraMessageBox.Show("Bạn có chắc chắn muốn xóa tài khoản này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (DialogResult.Yes == result)
         {
             int[] selectedRows = dgview_taiKhoan.GetSelectedRows();
             foreach (int rowHandle in selectedRows)
             {
                 if (rowHandle >= 0)
                 {
                     if (this.dgview_taiKhoan.GetRowCellValue(rowHandle, cl_loaiTK).ToString().Trim() == "CV01")
                     {
                         XtraMessageBox.Show("Không thể xóa tài khoản này!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                     else
                     {
                         string manv        = this.dgview_taiKhoan.GetRowCellValue(rowHandle, cl_manv).ToString().Trim();
                         string tenDangNhap = this.dgview_taiKhoan.GetRowCellValue(rowHandle, cl_tenDangNhap).ToString().Trim();
                         tkBUS.DeleteNVDaCoTK(manv);
                         tkBUS.DeleteTK(tenDangNhap);
                         XtraMessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK);
                     }
                 }
                 LoadTK();
             }
         }
     }
 }