/// <summary> /// Thêm mới một số quyền ngoài vai trò của người dùng /// </summary> /// <Modified> /// Author Date Comments /// Cuongdb 15/2/2008 Tạo mới /// </Modified> private void btnQuyenThem_Click(object sender, EventArgs e) { try { _objUserPermission.UserName = _strUserName; string strPermissionIDs = ""; string strPermissionID; string strGrantOptions = ""; DataTable dtPermission = (new Permission()).GetAll(); UserPermission user = new UserPermission(); user.UserName = _strUserName; DataTable dtUserPermission = user.GetUserPermissionFull(); string strPermissionList = ""; string strPermissionIDChon = string.Empty; foreach (DataRow r in dtUserPermission.Rows) { strPermissionList += ',' + r["permission_id"].ToString(); } foreach (DataRowView item in lstQuyenKhongDuocCap.SelectedItems) { DataRow drQuyen = item.Row; strPermissionIDChon = drQuyen["PERMISSION_ID"].ToString().Trim(); strPermissionIDs = strPermissionIDs + strPermissionIDChon + ","; strGrantOptions = strGrantOptions + "0,"; foreach (DataRow drPermission in dtPermission.Rows) { // Add quyền con // debug: sửa đối tượng thông tin đăng nhập = người dùng đang chọn if ((drPermission["PERMISSION_ID"].ToString().IndexOf(strPermissionIDChon) == 0) && (strPermissionIDChon.Length < 6) && (!strPermissionList.Contains(',' + drPermission["PERMISSION_ID"].ToString()))) { strPermissionID = drPermission["PERMISSION_ID"].ToString(); strPermissionIDs += strPermissionID + ','; strGrantOptions = strGrantOptions + "0,"; strPermissionList += ',' + strPermissionID; } //Add quyền cha if (strPermissionIDChon.IndexOf(drPermission["PERMISSION_ID"].ToString()) == 0) { strPermissionIDs += drPermission["PERMISSION_ID"].ToString() + ','; strGrantOptions = strGrantOptions + "0,"; } } } _objUserPermission.PermissionIDs = strPermissionIDs; _objUserPermission.GrantOptions = strGrantOptions; _objUserPermission.InsertUserPermission(); } catch { } LoadPermissionAssignedData(); }
/// <summary> /// Load danh sach cac quyen khac ngoai vai tro ma nguoi dung duoc cap /// </summary> /// <Modified> /// Author Date Comments /// Cuongdb 15/2/2008 Tạo mới /// </Modified> private void LoadPermissionAssignedData() { try { // Add Permission to lstQuyenDuocCap UserPermission objUserPermission = new UserPermission(); objUserPermission.UserName = _strUserName; DataView tabUserPermission = new DataView(objUserPermission.GetUserPermissionFull()); //new DataView(objUserPermission.GetUserPermissionFull());//Thay chỉ lấy quyền gán không lấy quyền trong vai trò! Jira 288 --> Vẫn cho phụ thuộc vai trò lstQuyenDuocCap.DataSource = null; lstQuyenDuocCap.DisplayMember = "PERMISSION_NAME"; lstQuyenDuocCap.ValueMember = "PERMISSION_ID"; lstQuyenDuocCap.DataSource = tabUserPermission; // Load cac quyen khong duoc cap con lai trong he thong objUserPermission.UserName = _strUserName; DataTable tabPermissionNotInUser = objUserPermission.GetPermissionNotInUser(); //Bổ xung thêm các quyền cha DataTable dtPermission = (new Permission()).GetAll(); bool bNotExist; for (int i = dtPermission.Rows.Count - 1; i >= 0; i--) { bNotExist = true; for (int j = 0; j < tabPermissionNotInUser.Rows.Count; j++) { if (tabPermissionNotInUser.Rows[j]["PERMISSION_ID"].ToString().IndexOf( dtPermission.Rows[i]["PERMISSION_ID"].ToString()) == 0) { bNotExist = false; break; } } if (bNotExist) { dtPermission.Rows.RemoveAt(i); } } lstQuyenKhongDuocCap.DataSource = null; lstQuyenKhongDuocCap.DisplayMember = "PERMISSION_NAME"; lstQuyenKhongDuocCap.ValueMember = "PERMISSION_ID"; lstQuyenKhongDuocCap.DataSource = dtPermission; objUserPermission = null; } catch (Exception ex) { LogError.WriteLogError("LoadPermissionAssignedData: ", ex); } }
/// <summary> /// Load danh sach cac quyen khac ngoai vai tro ma nguoi dung duoc cap /// </summary> /// <Modified> /// Author Date Comments /// Cuongdb 15/2/2008 Tạo mới /// </Modified> private void LoadPermissionAssignedData() { // Add Permission to lstQuyenDuocCap UserPermission objUserPermission = new UserPermission(); DataView tabUserPermission; objUserPermission.UserName = strUserName; tabUserPermission = new DataView(objUserPermission.GetUserPermissionFull()); //tabUserPermission.RowFilter = "GRANT_USER_ID = '" + strUserName + "'"; lstQuyenDuocCap.DataSource = null; lstQuyenDuocCap.DisplayMember = "PERMISSION_NAME"; lstQuyenDuocCap.ValueMember = "PERMISSION_ID"; lstQuyenDuocCap.DataSource = tabUserPermission; // Load cac quyen khong duoc cap con lai trong he thong DataTable tabPermissionNotInUser; objUserPermission.UserName = strUserName; tabPermissionNotInUser = objUserPermission.GetPermissionNotInUser(); //Bổ xung thêm các quyền cha DataTable dtPermission = (new Permission()).GetAll(); bool bNotExist; for (int i = dtPermission.Rows.Count - 1; i >= 0; i--) { bNotExist = true; for (int j = 0; j < tabPermissionNotInUser.Rows.Count; j++) { if (tabPermissionNotInUser.Rows[j]["PERMISSION_ID"].ToString().IndexOf( dtPermission.Rows[i]["PERMISSION_ID"].ToString()) == 0) { bNotExist = false; break; } } if (bNotExist) { dtPermission.Rows.RemoveAt(i); } } lstQuyenKhongDuocCap.DataSource = null; lstQuyenKhongDuocCap.DisplayMember = "PERMISSION_NAME"; lstQuyenKhongDuocCap.ValueMember = "PERMISSION_ID"; lstQuyenKhongDuocCap.DataSource = dtPermission; objUserPermission = null; }