private void btnCapNhat_Click(object sender, EventArgs e) { DBEntities model = new DBEntities(); int taikhoan_ID = int.Parse(cboTaiKhoan.SelectedValue.ToString()); string chucVu = cboChucVu.SelectedItem.ToString(); PhanQuyenTaiKhoan pq = model.PhanQuyenTaiKhoans.FirstOrDefault(x => x.TaiKhoan_Id == taikhoan_ID); if (pq != null) { bool flag = bus.CapNhatPhanQuyen(taikhoan_ID, chucVu); if (flag == true) { MessageBox.Show("Cập nhật thành công"); } else { MessageBox.Show("Cập nhật thất bại"); } LoadListPQ(); } else { MessageBox.Show("Tài khoản này đã được phân quyền"); } }
private void lstPhanQuyen_DoubleClick(object sender, EventArgs e) { DBEntities model = new DBEntities(); PhanQuyenTaiKhoan acc = new PhanQuyenTaiKhoan(); if (lstPhanQuyen.SelectedRows.Count == 1) { var row = lstPhanQuyen.SelectedRows[0]; var cell = row.Cells["Id"]; int ID = (int)cell.Value; acc = model.PhanQuyenTaiKhoans.Single(x => x.Id == ID); cboTaiKhoan.SelectedValue = acc.TaiKhoan_Id; cboChucVu.SelectedItem = acc.ChucVu; btnCapNhat.Visible = true; btnPhanQuyen.Visible = false; } }